diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index a8de4a135..2b93351f8 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -334,6 +334,9 @@ sub _init_menubar { $self->_append_menu_item($helpMenu, L("System Info"), L('Show system information'), sub { wxTheApp->system_info; }); + $self->_append_menu_item($helpMenu, L("Show &Configuration Folder"), L('Show user configuration folder (datadir)'), sub { + Slic3r::GUI::desktop_open_datadir_folder(); + }); $self->_append_menu_item($helpMenu, L("Report an Issue"), L('Report an issue on the Slic3r Prusa Edition'), sub { Wx::LaunchDefaultBrowser('http://github.com/prusa3d/slic3r/issues/new'); }); @@ -352,8 +355,8 @@ sub _init_menubar { $menubar->Append($self->{object_menu}, L("&Object")) if $self->{object_menu}; $menubar->Append($windowMenu, L("&Window")); $menubar->Append($self->{viewMenu}, L("&View")) if $self->{viewMenu}; - # Add a configuration menu. - Slic3r::GUI::add_config_menu($menubar, $self->{preferences_event}, $self->{lang_ch_event}); + # Add additional menus from C++ + Slic3r::GUI::add_menus($menubar, $self->{preferences_event}, $self->{lang_ch_event}); $menubar->Append($helpMenu, L("&Help")); $self->SetMenuBar($menubar); } diff --git a/resources/avrdude/avrdude.conf b/resources/avrdude/avrdude.conf new file mode 100644 index 000000000..7d99c44d3 --- /dev/null +++ b/resources/avrdude/avrdude.conf @@ -0,0 +1,14972 @@ +# $Id: avrdude.conf.in 1371 2016-02-15 20:15:07Z joerg_wunsch $ -*- text -*- +# +# AVRDUDE Configuration File +# +# This file contains configuration data used by AVRDUDE which describes +# the programming hardware pinouts and also provides part definitions. +# AVRDUDE's "-C" command line option specifies the location of the +# configuration file. The "-c" option names the programmer configuration +# which must match one of the entry's "id" parameter. The "-p" option +# identifies which part AVRDUDE is going to be programming and must match +# one of the parts' "id" parameter. +# +# DO NOT MODIFY THIS FILE. Modifications will be overwritten the next +# time a "make install" is run. For user-specific additions, use the +# "-C +filename" commandline option. +# +# Possible entry formats are: +# +# programmer +# parent # optional parent +# id = [, [, ] ...] ; # are quoted strings +# desc = ; # quoted string +# type = ; # programmer type, quoted string +# # supported programmer types can be listed by "-c ?type" +# connection_type = parallel | serial | usb +# baudrate = ; # baudrate for avr910-programmer +# vcc = [, ... ] ; # pin number(s) +# buff = [, ... ] ; # pin number(s) +# reset = ; # pin number +# sck = ; # pin number +# mosi = ; # pin number +# miso = ; # pin number +# errled = ; # pin number +# rdyled = ; # pin number +# pgmled = ; # pin number +# vfyled = ; # pin number +# usbvid = ; # USB VID (Vendor ID) +# usbpid = [, ...] # USB PID (Product ID) (1) +# usbdev = ; # USB interface or other device info +# usbvendor = ; # USB Vendor Name +# usbproduct = ; # USB Product Name +# usbsn = ; # USB Serial Number +# +# To invert a bit, use = ~ , the spaces are important. +# For a pin list all pins must be inverted. +# A single pin can be specified as usual = ~ , for lists +# specify it as follows = ~ ( [, ... ] ) . +# +# (1) Not all programmer types can process a list of PIDs. +# ; +# +# part +# id = ; # quoted string +# desc = ; # quoted string +# has_jtag = ; # part has JTAG i/f +# has_debugwire = ; # part has debugWire i/f +# has_pdi = ; # part has PDI i/f +# has_tpi = ; # part has TPI i/f +# devicecode = ; # deprecated, use stk500_devcode +# stk500_devcode = ; # numeric +# avr910_devcode = ; # numeric +# signature = ; # signature bytes +# usbpid = ; # DFU USB PID +# chip_erase_delay = ; # micro-seconds +# reset = dedicated | io; +# retry_pulse = reset | sck; +# pgm_enable = ; +# chip_erase = ; +# chip_erase_delay = ; # chip erase delay (us) +# # STK500 parameters (parallel programming IO lines) +# pagel = ; # pin name in hex, i.e., 0xD7 +# bs2 = ; # pin name in hex, i.e., 0xA0 +# serial = ; # can use serial downloading +# parallel = ; # can use par. programming +# # STK500v2 parameters, to be taken from Atmel's XML files +# timeout = ; +# stabdelay = ; +# cmdexedelay = ; +# synchloops = ; +# bytedelay = ; +# pollvalue = ; +# pollindex = ; +# predelay = ; +# postdelay = ; +# pollmethod = ; +# mode = ; +# delay = ; +# blocksize = ; +# readsize = ; +# hvspcmdexedelay = ; +# # STK500v2 HV programming parameters, from XML +# pp_controlstack = , , ...; # PP only +# hvsp_controlstack = , , ...; # HVSP only +# hventerstabdelay = ; +# progmodedelay = ; # PP only +# latchcycles = ; +# togglevtg = ; +# poweroffdelay = ; +# resetdelayms = ; +# resetdelayus = ; +# hvleavestabdelay = ; +# resetdelay = ; +# synchcycles = ; # HVSP only +# chiperasepulsewidth = ; # PP only +# chiperasepolltimeout = ; +# chiperasetime = ; # HVSP only +# programfusepulsewidth = ; # PP only +# programfusepolltimeout = ; +# programlockpulsewidth = ; # PP only +# programlockpolltimeout = ; +# # JTAG ICE mkII parameters, also from XML files +# allowfullpagebitstream = ; +# enablepageprogramming = ; +# idr = ; # IO addr of IDR (OCD) reg. +# rampz = ; # IO addr of RAMPZ reg. +# spmcr = ; # mem addr of SPMC[S]R reg. +# eecr = ; # mem addr of EECR reg. +# # (only when != 0x3c) +# is_at90s1200 = ; # AT90S1200 part +# is_avr32 = ; # AVR32 part +# +# memory +# paged = ; # yes / no +# size = ; # bytes +# page_size = ; # bytes +# num_pages = ; # numeric +# min_write_delay = ; # micro-seconds +# max_write_delay = ; # micro-seconds +# readback_p1 = ; # byte value +# readback_p2 = ; # byte value +# pwroff_after_write = ; # yes / no +# read = ; +# write = ; +# read_lo = ; +# read_hi = ; +# write_lo = ; +# write_hi = ; +# loadpage_lo = ; +# loadpage_hi = ; +# writepage = ; +# ; +# ; +# +# If any of the above parameters are not specified, the default value +# of 0 is used for numerics or the empty string ("") for string +# values. If a required parameter is left empty, AVRDUDE will +# complain. +# +# Parts can also inherit parameters from previously defined parts +# using the following syntax. In this case specified integer and +# string values override parameter values from the parent part. New +# memory definitions are added to the definitions inherited from the +# parent. +# +# part parent # quoted string +# id = ; # quoted string +# +# ; +# +# NOTES: +# * 'devicecode' is the device code used by the STK500 (see codes +# listed below) +# * Not all memory types will implement all instructions. +# * AVR Fuse bits and Lock bits are implemented as a type of memory. +# * Example memory types are: +# "flash", "eeprom", "fuse", "lfuse" (low fuse), "hfuse" (high +# fuse), "signature", "calibration", "lock" +# * The memory type specified on the avrdude command line must match +# one of the memory types defined for the specified chip. +# * The pwroff_after_write flag causes avrdude to attempt to +# power the device off and back on after an unsuccessful write to +# the affected memory area if VCC programmer pins are defined. If +# VCC pins are not defined for the programmer, a message +# indicating that the device needs a power-cycle is printed out. +# This flag was added to work around a problem with the +# at90s4433/2333's; see the at90s4433 errata at: +# +# http://www.atmel.com/dyn/resources/prod_documents/doc1280.pdf +# +# INSTRUCTION FORMATS +# +# Instruction formats are specified as a comma seperated list of +# string values containing information (bit specifiers) about each +# of the 32 bits of the instruction. Bit specifiers may be one of +# the following formats: +# +# '1' = the bit is always set on input as well as output +# +# '0' = the bit is always clear on input as well as output +# +# 'x' = the bit is ignored on input and output +# +# 'a' = the bit is an address bit, the bit-number matches this bit +# specifier's position within the current instruction byte +# +# 'aN' = the bit is the Nth address bit, bit-number = N, i.e., a12 +# is address bit 12 on input, a0 is address bit 0. +# +# 'i' = the bit is an input data bit +# +# 'o' = the bit is an output data bit +# +# Each instruction must be composed of 32 bit specifiers. The +# instruction specification closely follows the instruction data +# provided in Atmel's data sheets for their parts. +# +# See below for some examples. +# +# +# The following are STK500 part device codes to use for the +# "devicecode" field of the part. These came from Atmel's software +# section avr061.zip which accompanies the application note +# AVR061 available from: +# +# http://www.atmel.com/dyn/resources/prod_documents/doc2525.pdf +# + +#define ATTINY10 0x10 /* the _old_ one that never existed! */ +#define ATTINY11 0x11 +#define ATTINY12 0x12 +#define ATTINY15 0x13 +#define ATTINY13 0x14 + +#define ATTINY22 0x20 +#define ATTINY26 0x21 +#define ATTINY28 0x22 +#define ATTINY2313 0x23 + +#define AT90S1200 0x33 + +#define AT90S2313 0x40 +#define AT90S2323 0x41 +#define AT90S2333 0x42 +#define AT90S2343 0x43 + +#define AT90S4414 0x50 +#define AT90S4433 0x51 +#define AT90S4434 0x52 +#define ATMEGA48 0x59 + +#define AT90S8515 0x60 +#define AT90S8535 0x61 +#define AT90C8534 0x62 +#define ATMEGA8515 0x63 +#define ATMEGA8535 0x64 + +#define ATMEGA8 0x70 +#define ATMEGA88 0x73 +#define ATMEGA168 0x86 + +#define ATMEGA161 0x80 +#define ATMEGA163 0x81 +#define ATMEGA16 0x82 +#define ATMEGA162 0x83 +#define ATMEGA169 0x84 + +#define ATMEGA323 0x90 +#define ATMEGA32 0x91 + +#define ATMEGA64 0xA0 + +#define ATMEGA103 0xB1 +#define ATMEGA128 0xB2 +#define AT90CAN128 0xB3 +#define AT90CAN64 0xB3 +#define AT90CAN32 0xB3 + +#define AT86RF401 0xD0 + +#define AT89START 0xE0 +#define AT89S51 0xE0 +#define AT89S52 0xE1 + +# The following table lists the devices in the original AVR910 +# appnote: +# |Device |Signature | Code | +# +-------+----------+------+ +# |tiny12 | 1E 90 05 | 0x55 | +# |tiny15 | 1E 90 06 | 0x56 | +# | | | | +# | S1200 | 1E 90 01 | 0x13 | +# | | | | +# | S2313 | 1E 91 01 | 0x20 | +# | S2323 | 1E 91 02 | 0x48 | +# | S2333 | 1E 91 05 | 0x34 | +# | S2343 | 1E 91 03 | 0x4C | +# | | | | +# | S4414 | 1E 92 01 | 0x28 | +# | S4433 | 1E 92 03 | 0x30 | +# | S4434 | 1E 92 02 | 0x6C | +# | | | | +# | S8515 | 1E 93 01 | 0x38 | +# | S8535 | 1E 93 03 | 0x68 | +# | | | | +# |mega32 | 1E 95 01 | 0x72 | +# |mega83 | 1E 93 05 | 0x65 | +# |mega103| 1E 97 01 | 0x41 | +# |mega161| 1E 94 01 | 0x60 | +# |mega163| 1E 94 02 | 0x64 | + +# Appnote AVR109 also has a table of AVR910 device codes, which +# lists: +# dev avr910 signature +# ATmega8 0x77 0x1E 0x93 0x07 +# ATmega8515 0x3B 0x1E 0x93 0x06 +# ATmega8535 0x6A 0x1E 0x93 0x08 +# ATmega16 0x75 0x1E 0x94 0x03 +# ATmega162 0x63 0x1E 0x94 0x04 +# ATmega163 0x66 0x1E 0x94 0x02 +# ATmega169 0x79 0x1E 0x94 0x05 +# ATmega32 0x7F 0x1E 0x95 0x02 +# ATmega323 0x73 0x1E 0x95 0x01 +# ATmega64 0x46 0x1E 0x96 0x02 +# ATmega128 0x44 0x1E 0x97 0x02 +# +# These codes refer to "BOOT" device codes which are apparently +# different than standard device codes, for whatever reasons +# (often one above the standard code). + +# There are several extended versions of AVR910 implementations around +# in the Internet. These add the following codes (only devices that +# actually exist are listed): + +# ATmega8515 0x3A +# ATmega128 0x43 +# ATmega64 0x45 +# ATtiny26 0x5E +# ATmega8535 0x69 +# ATmega32 0x72 +# ATmega16 0x74 +# ATmega8 0x76 +# ATmega169 0x78 + +# +# Overall avrdude defaults; suitable for ~/.avrduderc +# +default_parallel = "/dev/parport0"; +default_serial = "/dev/ttyS0"; +# default_bitclock = 2.5; + +# Turn off safemode by default +#default_safemode = no; + + +# +# PROGRAMMER DEFINITIONS +# + +# http://wiring.org.co/ +# Basically STK500v2 protocol, with some glue to trigger the +# bootloader. +programmer + id = "wiring"; + desc = "Wiring"; + type = "wiring"; + connection_type = serial; +; + +programmer + id = "arduino"; + desc = "Arduino"; + type = "arduino"; + connection_type = serial; +; +# this will interface with the chips on these programmers: +# +# http://real.kiev.ua/old/avreal/en/adapters +# http://www.amontec.com/jtagkey.shtml, jtagkey-tiny.shtml +# http://www.olimex.com/dev/arm-usb-ocd.html, arm-usb-tiny.html +# http://www.ethernut.de/en/hardware/turtelizer/index.html +# http://elk.informatik.fh-augsburg.de/hhweb/doc/openocd/usbjtag/usbjtag.html +# http://dangerousprototypes.com/docs/FT2232_breakout_board +# http://www.ftdichip.com/Products/Modules/DLPModules.htm,DLP-2232*,DLP-USB1232H +# http://flashrom.org/FT2232SPI_Programmer +# +# The drivers will look for a specific device and use the first one found. +# If you have mulitple devices, then look for unique information (like SN) +# And fill that in here. +# +# Note that the pin numbers for the main ISP signals (reset, sck, +# mosi, miso) are fixed and cannot be changed, since they must match +# the way the Multi-Protocol Synchronous Serial Engine (MPSSE) of +# these FTDI ICs has been designed. + +# programmer +# id = "avrftdi"; +# desc = "FT2232D based generic programmer"; +# type = "avrftdi"; +# connection_type = usb; +# usbvid = 0x0403; +# usbpid = 0x6010; +# usbvendor = ""; +# usbproduct = ""; +# usbdev = "A"; +# usbsn = ""; +# #ISP-signals - lower ADBUS-Nibble (default) +# reset = 3; +# sck = 0; +# mosi = 1; +# miso = 2; +# #LED SIGNALs - higher ADBUS-Nibble +# # errled = 4; +# # rdyled = 5; +# # pgmled = 6; +# # vfyled = 7; +# #Buffer Signal - ACBUS - Nibble +# # buff = 8; +# ; +# This is an implementation of the above with a buffer IC (74AC244) and +# 4 LEDs directly attached, all active low. +# programmer +# id = "2232HIO"; +# desc = "FT2232H based generic programmer"; +# type = "avrftdi"; +# connection_type = usb; +# usbvid = 0x0403; +# # Note: This PID is reserved for generic H devices and +# # should be programmed into the EEPROM +# # usbpid = 0x8A48; +# usbpid = 0x6010; +# usbdev = "A"; +# usbvendor = ""; +# usbproduct = ""; +# usbsn = ""; +# #ISP-signals +# reset = 3; +# sck = 0; +# mosi = 1; +# miso = 2; +# buff = ~4; +# #LED SIGNALs +# errled = ~ 11; +# rdyled = ~ 14; +# pgmled = ~ 13; +# vfyled = ~ 12; +# ; + +# #The FT4232H can be treated as FT2232H, but it has a different USB +# #device ID of 0x6011. +# programmer parent "avrftdi" +# id = "4232h"; +# desc = "FT4232H based generic programmer"; +# usbpid = 0x6011; +# ; + +# programmer +# id = "jtagkey"; +# desc = "Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2"; +# type = "avrftdi"; +# connection_type = usb; +# usbvid = 0x0403; +# # Note: This PID is used in all JTAGKey variants +# usbpid = 0xCFF8; +# usbdev = "A"; +# usbvendor = ""; +# usbproduct = ""; +# usbsn = ""; +# #ISP-signals => 20 - Pin connector on JTAGKey +# reset = 3; # TMS 7 violet +# sck = 0; # TCK 9 white +# mosi = 1; # TDI 5 green +# miso = 2; # TDO 13 orange +# buff = ~4; +# # VTG VREF 1 brown with red tip +# # GND GND 20 black +# # The colors are on the 20 pin breakout cable +# # from Amontec +# ; + +# # UM232H module from FTDI and Glyn.com.au. +# # See helix.air.net.au for detailed usage information. +# # J1: Connect pin 2 and 3 for USB power. +# # J2: Connect pin 2 and 3 for USB power. +# # J2: Pin 7 is SCK +# # : Pin 8 is MOSI +# # : Pin 9 is MISO +# # : Pin 11 is RST +# # : Pin 6 is ground +# # Use the -b flag to set the SPI clock rate eg -b 3750000 is the fastest I could get +# # a 16MHz Atmega1280 to program reliably. The 232H is conveniently 5V tolerant. +# programmer +# id = "UM232H"; +# desc = "FT232H based module from FTDI and Glyn.com.au"; +# type = "avrftdi"; +# usbvid = 0x0403; +# # Note: This PID is reserved for generic 232H devices and +# # should be programmed into the EEPROM +# usbpid = 0x6014; +# usbdev = "A"; +# usbvendor = ""; +# usbproduct = ""; +# usbsn = ""; +# #ISP-signals +# sck = 0; +# mosi = 1; +# miso = 2; +# reset = 3; +# ; + +# # C232HM module from FTDI and Glyn.com.au. +# # : Orange is SCK +# # : Yellow is MOSI +# # : Green is MISO +# # : Brown is RST +# # : Black is ground +# # Use the -b flag to set the SPI clock rate eg -b 3750000 is the fastest I could get +# # a 16MHz Atmega1280 to program reliably. The 232H is conveniently 5V tolerant. +# programmer +# id = "C232HM"; +# desc = "FT232H based module from FTDI and Glyn.com.au"; +# type = "avrftdi"; +# usbvid = 0x0403; +# # Note: This PID is reserved for generic 232H devices and +# # should be programmed into the EEPROM +# usbpid = 0x6014; +# usbdev = "A"; +# usbvendor = ""; +# usbproduct = ""; +# usbsn = ""; +# #ISP-signals +# sck = 0; +# mosi = 1; +# miso = 2; +# reset = 3; +# ; + + +# # On the adapter you can read "O-Link". On the PCB is printed "OpenJTAG v3.1" +# # You can find it as "OpenJTAG ARM JTAG USB" in the internet. +# # (But there are also several projects called Open JTAG, eg. +# # http://www.openjtag.org, which are completely different.) +# # http://www.100ask.net/shop/english.html (website seems to be outdated) +# # http://item.taobao.com/item.htm?id=1559277013 +# # http://www.micro4you.com/store/openjtag-arm-jtag-usb.html (schematics!) +# # some other sources which call it O-Link +# # http://www.andahammer.com/olink/ +# # http://www.developmentboard.net/31-o-link-debugger.html +# # http://armwerks.com/catalog/o-link-debugger-copy/ +# # or just have a look at ebay ... +# # It is basically the same entry as jtagkey with different usb ids. +# programmer parent "jtagkey" +# id = "o-link"; +# desc = "O-Link, OpenJTAG from www.100ask.net"; +# usbvid = 0x1457; +# usbpid = 0x5118; +# usbvendor = "www.100ask.net"; +# usbproduct = "USB<=>JTAG&RS232"; +# ; + +# # http://wiki.openmoko.org/wiki/Debug_Board_v3 +# programmer +# id = "openmoko"; +# desc = "Openmoko debug board (v3)"; +# type = "avrftdi"; +# usbvid = 0x1457; +# usbpid = 0x5118; +# usbdev = "A"; +# usbvendor = ""; +# usbproduct = ""; +# usbsn = ""; +# reset = 3; # TMS 7 +# sck = 0; # TCK 9 +# mosi = 1; # TDI 5 +# miso = 2; # TDO 13 +# ; + +# # Only Rev. A boards. +# # Schematic and user manual: http://www.cs.put.poznan.pl/wswitala/download/pdf/811EVBK.pdf +# programmer +# id = "lm3s811"; +# desc = "Luminary Micro LM3S811 Eval Board (Rev. A)"; +# type = "avrftdi"; +# connection_type = usb; +# usbvid = 0x0403; +# usbpid = 0xbcd9; +# usbvendor = "LMI"; +# usbproduct = "LM3S811 Evaluation Board"; +# usbdev = "A"; +# usbsn = ""; +# #ISP-signals - lower ACBUS-Nibble (default) +# reset = 3; +# sck = 0; +# mosi = 1; +# miso = 2; +# # Enable correct buffers +# buff = 7; +# ; + +# # submitted as bug #46020 +# programmer +# id = "tumpa"; +# desc = "TIAO USB Multi-Protocol Adapter"; +# type = "avrftdi"; +# connection_type = usb; +# usbvid = 0x0403; +# usbpid = 0x8A98; +# usbdev = "A"; +# usbvendor = "TIAO"; +# usbproduct = ""; +# usbsn = ""; +# sck = 0; # TCK 9 +# mosi = 1; # TDI 5 +# miso = 2; # TDO 13 +# reset = 3; # TMS 7 +# ; + +programmer + id = "avrisp"; + desc = "Atmel AVR ISP"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "avrispv2"; + desc = "Atmel AVR ISP V2"; + type = "stk500v2"; + connection_type = serial; +; + +# programmer +# id = "avrispmkII"; +# desc = "Atmel AVR ISP mkII"; +# type = "stk500v2"; +# connection_type = usb; +# ; + +# programmer parent "avrispmkII" +# id = "avrisp2"; +# ; + +programmer + id = "buspirate"; + desc = "The Bus Pirate"; + type = "buspirate"; + connection_type = serial; +; + +programmer + id = "buspirate_bb"; + desc = "The Bus Pirate (bitbang interface, supports TPI)"; + type = "buspirate_bb"; + connection_type = serial; + # pins are bits in bitbang byte (numbers are 87654321) + # 1|POWER|PULLUP|AUX|MOSI|CLK|MISO|CS + reset = 1; + sck = 3; + mosi = 4; + miso = 2; + #vcc = 7; This is internally set independent of this setting. +; + +# This is supposed to be the "default" STK500 entry. +# Attempts to select the correct firmware version +# by probing for it. Better use one of the entries +# below instead. +programmer + id = "stk500"; + desc = "Atmel STK500"; + type = "stk500generic"; + connection_type = serial; +; + +programmer + id = "stk500v1"; + desc = "Atmel STK500 Version 1.x firmware"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "mib510"; + desc = "Crossbow MIB510 programming board"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "stk500v2"; + desc = "Atmel STK500 Version 2.x firmware"; + type = "stk500v2"; + connection_type = serial; +; + +programmer + id = "stk500pp"; + desc = "Atmel STK500 V2 in parallel programming mode"; + type = "stk500pp"; + connection_type = serial; +; + +programmer + id = "stk500hvsp"; + desc = "Atmel STK500 V2 in high-voltage serial programming mode"; + type = "stk500hvsp"; + connection_type = serial; +; + +# programmer +# id = "stk600"; +# desc = "Atmel STK600"; +# type = "stk600"; +# connection_type = usb; +# ; + +# programmer +# id = "stk600pp"; +# desc = "Atmel STK600 in parallel programming mode"; +# type = "stk600pp"; +# connection_type = usb; +# ; + +# programmer +# id = "stk600hvsp"; +# desc = "Atmel STK600 in high-voltage serial programming mode"; +# type = "stk600hvsp"; +# connection_type = usb; +# ; + +programmer + id = "avr910"; + desc = "Atmel Low Cost Serial Programmer"; + type = "avr910"; + connection_type = serial; +; + +# programmer +# id = "ft245r"; +# desc = "FT245R Synchronous BitBang"; +# type = "ftdi_syncbb"; +# connection_type = usb; +# miso = 1; # D1 +# sck = 0; # D0 +# mosi = 2; # D2 +# reset = 4; # D4 +# ; + +# programmer +# id = "ft232r"; +# desc = "FT232R Synchronous BitBang"; +# type = "ftdi_syncbb"; +# connection_type = usb; +# miso = 1; # RxD +# sck = 0; # TxD +# mosi = 2; # RTS +# reset = 4; # DTR +# ; + +# # see http://www.bitwizard.nl/wiki/index.php/FTDI_ATmega +# programmer +# id = "bwmega"; +# desc = "BitWizard ftdi_atmega builtin programmer"; +# type = "ftdi_syncbb"; +# connection_type = usb; +# miso = 5; # DSR +# sck = 6; # DCD +# mosi = 3; # CTS +# reset = 7; # RI +# ; + +# # see http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html +# # Note: pins are numbered from 1! +# programmer +# id = "arduino-ft232r"; +# desc = "Arduino: FT232R connected to ISP"; +# type = "ftdi_syncbb"; +# connection_type = usb; +# miso = 3; # CTS X3(1) +# sck = 5; # DSR X3(2) +# mosi = 6; # DCD X3(3) +# reset = 7; # RI X3(4) +# ; + +# # website mentioned above uses this id +# programmer parent "arduino-ft232r" +# id = "diecimila"; +# desc = "alias for arduino-ft232r"; +# ; + +# # There is a ATmega328P kit PCB called "uncompatino". +# # This board allows ISP via its on-board FT232R. +# # This is designed like Arduino Duemilanove but has no standard ICPS header. +# # Its 4 pairs of pins are shorted to enable ftdi_syncbb. +# # http://akizukidenshi.com/catalog/g/gP-07487/ +# # http://akizukidenshi.com/download/ds/akizuki/k6096_manual_20130816.pdf +# programmer +# id = "uncompatino"; +# desc = "uncompatino with all pairs of pins shorted"; +# type = "ftdi_syncbb"; +# connection_type = usb; +# miso = 3; # cts +# sck = 5; # dsr +# mosi = 6; # dcd +# reset = 7; # ri +# ; + +# # FTDI USB to serial cable TTL-232R-5V with a custom adapter for ICSP +# # http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm +# # http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232R_CABLES.pdf +# # For ICSP pinout see for example http://www.atmel.com/images/doc2562.pdf +# # (Figure 1. ISP6PIN header pinout and Table 1. Connections required for ISP ...) +# # TTL-232R GND 1 Black -> ICPS GND (pin 6) +# # TTL-232R CTS 2 Brown -> ICPS MOSI (pin 4) +# # TTL-232R VCC 3 Red -> ICPS VCC (pin 2) +# # TTL-232R TXD 4 Orange -> ICPS RESET (pin 5) +# # TTL-232R RXD 5 Yellow -> ICPS SCK (pin 3) +# # TTL-232R RTS 6 Green -> ICPS MISO (pin 1) +# # Except for VCC and GND, you can connect arbitual pairs as long as +# # the following table is adjusted. +# programmer +# id = "ttl232r"; +# desc = "FTDI TTL232R-5V with ICSP adapter"; +# type = "ftdi_syncbb"; +# connection_type = usb; +# miso = 2; # rts +# sck = 1; # rxd +# mosi = 3; # cts +# reset = 0; # txd +# ; + +# programmer +# id = "usbasp"; +# desc = "USBasp, http://www.fischl.de/usbasp/"; +# type = "usbasp"; +# connection_type = usb; +# usbvid = 0x16C0; # VOTI +# usbpid = 0x05DC; # Obdev's free shared PID +# usbvendor = "www.fischl.de"; +# usbproduct = "USBasp"; + +# # following variants are autodetected for id "usbasp" + +# # original usbasp from fischl.de +# # see above "usbasp" + +# # old usbasp from fischl.de +# #usbvid = 0x03EB; # ATMEL +# #usbpid = 0xC7B4; # (unoffical) USBasp +# #usbvendor = "www.fischl.de"; +# #usbproduct = "USBasp"; + +# # NIBObee (only if -P nibobee is given on command line) +# # see below "nibobee" +# ; + +# programmer +# id = "nibobee"; +# desc = "NIBObee"; +# type = "usbasp"; +# connection_type = usb; +# usbvid = 0x16C0; # VOTI +# usbpid = 0x092F; # NIBObee PID +# usbvendor = "www.nicai-systems.com"; +# usbproduct = "NIBObee"; +# ; + +# programmer +# id = "usbasp-clone"; +# desc = "Any usbasp clone with correct VID/PID"; +# type = "usbasp"; +# connection_type = usb; +# usbvid = 0x16C0; # VOTI +# usbpid = 0x05DC; # Obdev's free shared PID +# #usbvendor = ""; +# #usbproduct = ""; +# ; + +# programmer +# id = "usbtiny"; +# desc = "USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/"; +# type = "usbtiny"; +# connection_type = usb; +# usbvid = 0x1781; +# usbpid = 0x0c9f; +# ; + +programmer + id = "butterfly"; + desc = "Atmel Butterfly Development Board"; + type = "butterfly"; + connection_type = serial; +; + +programmer + id = "avr109"; + desc = "Atmel AppNote AVR109 Boot Loader"; + type = "butterfly"; + connection_type = serial; +; + +programmer + id = "avr911"; + desc = "Atmel AppNote AVR911 AVROSP"; + type = "butterfly"; + connection_type = serial; +; + +# suggested in http://forum.mikrokopter.de/topic-post48317.html +programmer + id = "mkbutterfly"; + desc = "Mikrokopter.de Butterfly"; + type = "butterfly_mk"; + connection_type = serial; +; + +programmer parent "mkbutterfly" + id = "butterfly_mk"; +; + +# programmer +# id = "jtagmkI"; +# desc = "Atmel JTAG ICE (mkI)"; +# baudrate = 115200; # default is 115200 +# type = "jtagmki"; +# connection_type = serial; +# ; + +# # easier to type +# programmer parent "jtagmkI" +# id = "jtag1"; +# ; + +# # easier to type +# programmer parent "jtag1" +# id = "jtag1slow"; +# baudrate = 19200; +# ; + +# # The JTAG ICE mkII has both, serial and USB connectivity. As it is +# # mostly used through USB these days (AVR Studio 5 only supporting it +# # that way), we make connection_type = usb the default. Users are +# # still free to use a serial port with the -P option. + +# programmer +# id = "jtagmkII"; +# desc = "Atmel JTAG ICE mkII"; +# baudrate = 19200; # default is 19200 +# type = "jtagmkii"; +# connection_type = usb; +# ; + +# # easier to type +# programmer parent "jtagmkII" +# id = "jtag2slow"; +# ; + +# # JTAG ICE mkII @ 115200 Bd +# programmer parent "jtag2slow" +# id = "jtag2fast"; +# baudrate = 115200; +# ; + +# # make the fast one the default, people will love that +# programmer parent "jtag2fast" +# id = "jtag2"; +# ; + +# # JTAG ICE mkII in ISP mode +# programmer +# id = "jtag2isp"; +# desc = "Atmel JTAG ICE mkII in ISP mode"; +# baudrate = 115200; +# type = "jtagmkii_isp"; +# connection_type = usb; +# ; + +# # JTAG ICE mkII in debugWire mode +# programmer +# id = "jtag2dw"; +# desc = "Atmel JTAG ICE mkII in debugWire mode"; +# baudrate = 115200; +# type = "jtagmkii_dw"; +# connection_type = usb; +# ; + +# # JTAG ICE mkII in AVR32 mode +# programmer +# id = "jtagmkII_avr32"; +# desc = "Atmel JTAG ICE mkII im AVR32 mode"; +# baudrate = 115200; +# type = "jtagmkii_avr32"; +# connection_type = usb; +# ; + +# # JTAG ICE mkII in AVR32 mode +# programmer +# id = "jtag2avr32"; +# desc = "Atmel JTAG ICE mkII im AVR32 mode"; +# baudrate = 115200; +# type = "jtagmkii_avr32"; +# connection_type = usb; +# ; + +# # JTAG ICE mkII in PDI mode +# programmer +# id = "jtag2pdi"; +# desc = "Atmel JTAG ICE mkII PDI mode"; +# baudrate = 115200; +# type = "jtagmkii_pdi"; +# connection_type = usb; +# ; + +# # AVR Dragon in JTAG mode +# programmer +# id = "dragon_jtag"; +# desc = "Atmel AVR Dragon in JTAG mode"; +# baudrate = 115200; +# type = "dragon_jtag"; +# connection_type = usb; +# ; + +# # AVR Dragon in ISP mode +# programmer +# id = "dragon_isp"; +# desc = "Atmel AVR Dragon in ISP mode"; +# baudrate = 115200; +# type = "dragon_isp"; +# connection_type = usb; +# ; + +# # AVR Dragon in PP mode +# programmer +# id = "dragon_pp"; +# desc = "Atmel AVR Dragon in PP mode"; +# baudrate = 115200; +# type = "dragon_pp"; +# connection_type = usb; +# ; + +# # AVR Dragon in HVSP mode +# programmer +# id = "dragon_hvsp"; +# desc = "Atmel AVR Dragon in HVSP mode"; +# baudrate = 115200; +# type = "dragon_hvsp"; +# connection_type = usb; +# ; + +# # AVR Dragon in debugWire mode +# programmer +# id = "dragon_dw"; +# desc = "Atmel AVR Dragon in debugWire mode"; +# baudrate = 115200; +# type = "dragon_dw"; +# connection_type = usb; +# ; + +# # AVR Dragon in PDI mode +# programmer +# id = "dragon_pdi"; +# desc = "Atmel AVR Dragon in PDI mode"; +# baudrate = 115200; +# type = "dragon_pdi"; +# connection_type = usb; +# ; + +# programmer +# id = "jtag3"; +# desc = "Atmel AVR JTAGICE3 in JTAG mode"; +# type = "jtagice3"; +# connection_type = usb; +# usbpid = 0x2110, 0x2140; +# ; + +# programmer +# id = "jtag3pdi"; +# desc = "Atmel AVR JTAGICE3 in PDI mode"; +# type = "jtagice3_pdi"; +# connection_type = usb; +# usbpid = 0x2110, 0x2140; +# ; + +# programmer +# id = "jtag3dw"; +# desc = "Atmel AVR JTAGICE3 in debugWIRE mode"; +# type = "jtagice3_dw"; +# connection_type = usb; +# usbpid = 0x2110, 0x2140; +# ; + +# programmer +# id = "jtag3isp"; +# desc = "Atmel AVR JTAGICE3 in ISP mode"; +# type = "jtagice3_isp"; +# connection_type = usb; +# usbpid = 0x2110, 0x2140; +# ; + +# programmer +# id = "xplainedpro"; +# desc = "Atmel AVR XplainedPro in JTAG mode"; +# type = "jtagice3"; +# connection_type = usb; +# usbpid = 0x2111; +# ; + +# programmer +# id = "xplainedmini"; +# desc = "Atmel AVR XplainedMini in ISP mode"; +# type = "jtagice3_isp"; +# connection_type = usb; +# usbpid = 0x2145; +# ; + +# programmer +# id = "xplainedmini_dw"; +# desc = "Atmel AVR XplainedMini in debugWIRE mode"; +# type = "jtagice3_dw"; +# connection_type = usb; +# usbpid = 0x2145; +# ; + +# programmer +# id = "atmelice"; +# desc = "Atmel-ICE (ARM/AVR) in JTAG mode"; +# type = "jtagice3"; +# connection_type = usb; +# usbpid = 0x2141; +# ; + +# programmer +# id = "atmelice_pdi"; +# desc = "Atmel-ICE (ARM/AVR) in PDI mode"; +# type = "jtagice3_pdi"; +# connection_type = usb; +# usbpid = 0x2141; +# ; + +# programmer +# id = "atmelice_dw"; +# desc = "Atmel-ICE (ARM/AVR) in debugWIRE mode"; +# type = "jtagice3_dw"; +# connection_type = usb; +# usbpid = 0x2141; +# ; + +# programmer +# id = "atmelice_isp"; +# desc = "Atmel-ICE (ARM/AVR) in ISP mode"; +# type = "jtagice3_isp"; +# connection_type = usb; +# usbpid = 0x2141; +# ; + + +programmer + id = "pavr"; + desc = "Jason Kyle's pAVR Serial Programmer"; + type = "avr910"; + connection_type = serial; +; + +# programmer +# id = "pickit2"; +# desc = "MicroChip's PICkit2 Programmer"; +# type = "pickit2"; +# connection_type = usb; +# ; + +# programmer +# id = "flip1"; +# desc = "FLIP USB DFU protocol version 1 (doc7618)"; +# type = "flip1"; +# connection_type = usb; +# ; + +# programmer +# id = "flip2"; +# desc = "FLIP USB DFU protocol version 2 (AVR4023)"; +# type = "flip2"; +# connection_type = usb; +# ; + +# Parallel port programmers. + +# programmer +# id = "bsd"; +# desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/"; +# type = "par"; +# connection_type = parallel; +# vcc = 2, 3, 4, 5; +# reset = 7; +# sck = 8; +# mosi = 9; +# miso = 10; +# ; + +# programmer +# id = "stk200"; +# desc = "STK200"; +# type = "par"; +# connection_type = parallel; +# buff = 4, 5; +# sck = 6; +# mosi = 7; +# reset = 9; +# miso = 10; +# ; + +# The programming dongle used by the popular Ponyprog +# utility. It is almost similar to the STK200 one, +# except that there is a LED indicating that the +# programming is currently in progress. + +# programmer parent "stk200" +# id = "pony-stk200"; +# desc = "Pony Prog STK200"; +# pgmled = 8; +# ; + +# programmer +# id = "dt006"; +# desc = "Dontronics DT006"; +# type = "par"; +# connection_type = parallel; +# reset = 4; +# sck = 5; +# mosi = 2; +# miso = 11; +# ; + +# programmer parent "dt006" +# id = "bascom"; +# desc = "Bascom SAMPLE programming cable"; +# ; + +# programmer +# id = "alf"; +# desc = "Nightshade ALF-PgmAVR, http://nightshade.homeip.net/"; +# type = "par"; +# connection_type = parallel; +# vcc = 2, 3, 4, 5; +# buff = 6; +# reset = 7; +# sck = 8; +# mosi = 9; +# miso = 10; +# errled = 1; +# rdyled = 14; +# pgmled = 16; +# vfyled = 17; +# ; + +# programmer +# id = "sp12"; +# desc = "Steve Bolt's Programmer"; +# type = "par"; +# connection_type = parallel; +# vcc = 4,5,6,7,8; +# reset = 3; +# sck = 2; +# mosi = 9; +# miso = 11; +# ; + +# programmer +# id = "picoweb"; +# desc = "Picoweb Programming Cable, http://www.picoweb.net/"; +# type = "par"; +# connection_type = parallel; +# reset = 2; +# sck = 3; +# mosi = 4; +# miso = 13; +# ; + +# programmer +# id = "abcmini"; +# desc = "ABCmini Board, aka Dick Smith HOTCHIP"; +# type = "par"; +# connection_type = parallel; +# reset = 4; +# sck = 3; +# mosi = 2; +# miso = 10; +# ; + +# programmer +# id = "futurlec"; +# desc = "Futurlec.com programming cable."; +# type = "par"; +# connection_type = parallel; +# reset = 3; +# sck = 2; +# mosi = 1; +# miso = 10; +# ; + + +# From the contributor of the "xil" jtag cable: +# The "vcc" definition isn't really vcc (the cable gets its power from +# the programming circuit) but is necessary to switch one of the +# buffer lines (trying to add it to the "buff" lines doesn't work in +# avrdude versions before 5.5j). +# With this, TMS connects to RESET, TDI to MOSI, TDO to MISO and TCK +# to SCK (plus vcc/gnd of course) +# programmer +# id = "xil"; +# desc = "Xilinx JTAG cable"; +# type = "par"; +# connection_type = parallel; +# mosi = 2; +# sck = 3; +# reset = 4; +# buff = 5; +# miso = 13; +# vcc = 6; +# ; + + +# programmer +# id = "dapa"; +# desc = "Direct AVR Parallel Access cable"; +# type = "par"; +# connection_type = parallel; +# vcc = 3; +# reset = 16; +# sck = 1; +# mosi = 2; +# miso = 11; +# ; + +# programmer +# id = "atisp"; +# desc = "AT-ISP V1.1 programming cable for AVR-SDK1 from micro-research.co.th"; +# type = "par"; +# connection_type = parallel; +# reset = ~6; +# sck = ~8; +# mosi = ~7; +# miso = ~10; +# ; + +# programmer +# id = "ere-isp-avr"; +# desc = "ERE ISP-AVR "; +# type = "par"; +# connection_type = parallel; +# reset = ~4; +# sck = 3; +# mosi = 2; +# miso = 10; +# ; + +# programmer +# id = "blaster"; +# desc = "Altera ByteBlaster"; +# type = "par"; +# connection_type = parallel; +# sck = 2; +# miso = 11; +# reset = 3; +# mosi = 8; +# buff = 14; +# ; + +# It is almost same as pony-stk200, except vcc on pin 5 to auto +# disconnect port (download on http://electropol.free.fr/spip/spip.php?article27) +# programmer parent "pony-stk200" +# id = "frank-stk200"; +# desc = "Frank STK200"; +# buff = ; # delete buff pin assignment +# vcc = 5; +# ; + +# The AT98ISP Cable is a simple parallel dongle for AT89 family. +# http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2877 +# programmer +# id = "89isp"; +# desc = "Atmel at89isp cable"; +# type = "par"; +# connection_type = parallel; +# reset = 17; +# sck = 1; +# mosi = 2; +# miso = 10; +# ; + + +#This programmer bitbangs GPIO lines using the Linux sysfs GPIO interface +# +#To enable it set the configuration below to match the GPIO lines connected to the +#relevant ISP header pins and uncomment the entry definition. In case you don't +#have the required permissions to edit this system wide config file put the +#entry in a separate .conf file and use it with -C+.conf +#on the command line. +# +#To check if your avrdude build has support for the linuxgpio programmer compiled in, +#use -c?type on the command line and look for linuxgpio in the list. If it's not available +#you need pass the --enable-linuxgpio=yes option to configure and recompile avrdude. +# +#programmer +# id = "linuxgpio"; +# desc = "Use the Linux sysfs interface to bitbang GPIO lines"; +# type = "linuxgpio"; +# reset = ?; +# sck = ?; +# mosi = ?; +# miso = ?; +#; + +# some ultra cheap programmers use bitbanging on the +# serialport. +# +# PC - DB9 - Pins for RS232: +# +# GND 5 -- |O +# | O| <- 9 RI +# DTR 4 <- |O | +# | O| <- 8 CTS +# TXD 3 <- |O | +# | O| -> 7 RTS +# RXD 2 -> |O | +# | O| <- 6 DSR +# DCD 1 -> |O +# +# Using RXD is currently not supported. +# Using RI is not supported under Win32 but is supported under Posix. + +# serial ponyprog design (dasa2 in uisp) +# reset=!txd sck=rts mosi=dtr miso=cts + +programmer + id = "ponyser"; + desc = "design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts"; + type = "serbb"; + connection_type = serial; + reset = ~3; + sck = 7; + mosi = 4; + miso = 8; +; + +# Same as above, different name +# reset=!txd sck=rts mosi=dtr miso=cts + +programmer parent "ponyser" + id = "siprog"; + desc = "Lancos SI-Prog "; +; + +# unknown (dasa in uisp) +# reset=rts sck=dtr mosi=txd miso=cts + +programmer + id = "dasa"; + desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts"; + type = "serbb"; + connection_type = serial; + reset = 7; + sck = 4; + mosi = 3; + miso = 8; +; + +# unknown (dasa3 in uisp) +# reset=!dtr sck=rts mosi=txd miso=cts + +programmer + id = "dasa3"; + desc = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts"; + type = "serbb"; + connection_type = serial; + reset = ~4; + sck = 7; + mosi = 3; + miso = 8; +; + +# C2N232i (jumper configuration "auto") +# reset=dtr sck=!rts mosi=!txd miso=!cts + +programmer + id = "c2n232i"; + desc = "serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts"; + type = "serbb"; + connection_type = serial; + reset = 4; + sck = ~7; + mosi = ~3; + miso = ~8; +; + +# +# PART DEFINITIONS +# + +#------------------------------------------------------------ +# ATtiny11 +#------------------------------------------------------------ + +# This is an HVSP-only device. + +part + id = "t11"; + desc = "ATtiny11"; + stk500_devcode = 0x11; + signature = 0x1e 0x90 0x04; + chip_erase_delay = 20000; + + timeout = 200; + 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; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + blocksize = 64; + readsize = 256; + delay = 5; + ; + + memory "flash" + size = 1024; + blocksize = 128; + readsize = 256; + delay = 3; + ; + + memory "signature" + size = 3; + ; + + memory "lock" + size = 1; + ; + + memory "calibration" + size = 1; + ; + + memory "fuse" + size = 1; + ; +; + +#------------------------------------------------------------ +# ATtiny12 +#------------------------------------------------------------ + +part + id = "t12"; + desc = "ATtiny12"; + stk500_devcode = 0x12; + avr910_devcode = 0x55; + signature = 0x1e 0x90 0x05; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 8; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + size = 1024; + min_write_delay = 4500; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; +; + +#------------------------------------------------------------ +# ATtiny13 +#------------------------------------------------------------ + +part + id = "t13"; + desc = "ATtiny13"; + has_debugwire = yes; + flash_instr = 0xB4, 0x0E, 0x1E; + eeprom_instr = 0xBB, 0xFE, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, + 0xBC, 0x0E, 0xB4, 0x0E, 0xBA, 0x0D, 0xBB, 0xBC, + 0x99, 0xE1, 0xBB, 0xAC; + stk500_devcode = 0x14; + signature = 0x1e 0x90 0x07; + chip_erase_delay = 4000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 90; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 0; + + memory "eeprom" + size = 64; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 1024; + page_size = 32; + num_pages = 32; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny15 +#------------------------------------------------------------ + +part + id = "t15"; + desc = "ATtiny15"; + stk500_devcode = 0x13; + avr910_devcode = 0x56; + signature = 0x1e 0x90 0x06; + chip_erase_delay = 8200; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 5; + synchcycles = 6; + latchcycles = 16; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + min_write_delay = 8200; + max_write_delay = 8200; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + size = 1024; + min_write_delay = 4100; + max_write_delay = 4100; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x o o o o x x o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x i i i i 1 1 i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; +; + +#------------------------------------------------------------ +# AT90s1200 +#------------------------------------------------------------ + +part + id = "1200"; + desc = "AT90S1200"; + is_at90s1200 = yes; + stk500_devcode = 0x33; + avr910_devcode = 0x13; + signature = 0x1e 0x90 0x01; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 1; + bytedelay = 0; + pollindex = 0; + pollvalue = 0xFF; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 64; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 32; + readsize = 256; + ; + memory "flash" + size = 1024; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x02; + delay = 15; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s4414 +#------------------------------------------------------------ + +part + id = "4414"; + desc = "AT90S4414"; + stk500_devcode = 0x50; + avr910_devcode = 0x28; + signature = 0x1e 0x92 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s2313 +#------------------------------------------------------------ + +part + id = "2313"; + desc = "AT90S2313"; + stk500_devcode = 0x40; + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 128; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 2048; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x i i x", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s2333 +#------------------------------------------------------------ + +part + id = "2333"; +##### WARNING: No XML file for device 'AT90S2333'! ##### + desc = "AT90S2333"; + stk500_devcode = 0x42; + avr910_devcode = 0x34; + signature = 0x1e 0x91 0x05; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + pwroff_after_write = yes; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + + +#------------------------------------------------------------ +# AT90s2343 (also AT90s2323 and ATtiny22) +#------------------------------------------------------------ + +part + id = "2343"; + desc = "AT90S2343"; + stk500_devcode = 0x43; + avr910_devcode = 0x4c; + signature = 0x1e 0x91 0x03; + chip_erase_delay = 18000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 0; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 128; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + 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 o o o x x x x o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 o o o x x x x o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + + +#------------------------------------------------------------ +# AT90s4433 +#------------------------------------------------------------ + +part + id = "4433"; + desc = "AT90S4433"; + stk500_devcode = 0x51; + avr910_devcode = 0x30; + signature = 0x1e 0x92 0x03; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + pwroff_after_write = yes; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s4434 +#------------------------------------------------------------ + +part + id = "4434"; +##### WARNING: No XML file for device 'AT90S4434'! ##### + desc = "AT90S4434"; + stk500_devcode = 0x52; + avr910_devcode = 0x6c; + signature = 0x1e 0x92 0x02; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s8515 +#------------------------------------------------------------ + +part + id = "8515"; + desc = "AT90S8515"; + stk500_devcode = 0x60; + avr910_devcode = 0x38; + signature = 0x1e 0x93 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 512; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 8192; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s8535 +#------------------------------------------------------------ + +part + id = "8535"; + desc = "AT90S8535"; + stk500_devcode = 0x61; + avr910_devcode = 0x68; + signature = 0x1e 0x93 0x03; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 8192; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + 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 x x x x x x x o"; + write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + memory "lock" + size = 1; + 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 o o x x x x x x"; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# ATmega103 +#------------------------------------------------------------ + +part + id = "m103"; + desc = "ATmega103"; + stk500_devcode = 0xB1; + avr910_devcode = 0x41; + signature = 0x1e 0x97 0x01; + chip_erase_delay = 112000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + pp_controlstack = + 0x0E, 0x1E, 0x8E, 0x9E, 0x2E, 0x3E, 0xAE, 0xBE, + 0x4E, 0x5E, 0xCE, 0xDE, 0x6E, 0x7E, 0xEE, 0xDE, + 0x66, 0x76, 0xE6, 0xF6, 0x6A, 0x7A, 0xEA, 0x7A, + 0x7F, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 10; + + memory "eeprom" + size = 4096; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 22000; + max_write_delay = 56000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x11; + delay = 70; + blocksize = 256; + readsize = 256; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o x o 1 o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 1 i 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega64 +#------------------------------------------------------------ + +part + id = "m64"; + desc = "ATmega64"; + has_jtag = yes; + stk500_devcode = 0xA0; + avr910_devcode = 0x45; + signature = 0x1e 0x96 0x02; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x22; + spmcr = 0x68; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + + +#------------------------------------------------------------ +# ATmega128 +#------------------------------------------------------------ + +part + id = "m128"; + desc = "ATmega128"; + has_jtag = yes; + stk500_devcode = 0xB2; + avr910_devcode = 0x43; + signature = 0x1e 0x97 0x02; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x22; + spmcr = 0x68; + rampz = 0x3b; + allowfullpagebitstream = yes; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN128 +#------------------------------------------------------------ + +part + id = "c128"; + desc = "AT90CAN128"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x97 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN64 +#------------------------------------------------------------ + +part + id = "c64"; + desc = "AT90CAN64"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x96 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN32 +#------------------------------------------------------------ + +part + id = "c32"; + desc = "AT90CAN32"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x95 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 256; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega16 +#------------------------------------------------------------ + +part + id = "m16"; + desc = "ATmega16"; + has_jtag = yes; + stk500_devcode = 0x82; + avr910_devcode = 0x74; + signature = 0x1e 0x94 0x03; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 100; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x04; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "calibration" + size = 4; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega164P +#------------------------------------------------------------ + +# close to ATmega16 + +part parent "m16" + id = "m164p"; + desc = "ATmega164P"; + signature = 0x1e 0x94 0x0a; + + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + allowfullpagebitstream = no; + chip_erase_delay = 55000; + + ocdrev = 3; + ; + + +#------------------------------------------------------------ +# ATmega324P +#------------------------------------------------------------ + +# similar to ATmega164P + +part + id = "m324p"; + desc = "ATmega324P"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x95 0x08; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega324PA +#------------------------------------------------------------ + +# similar to ATmega324P + +part parent "m324p" + id = "m324pa"; + desc = "ATmega324PA"; + signature = 0x1e 0x95 0x11; + + ocdrev = 3; + ; + + +#------------------------------------------------------------ +# ATmega644 +#------------------------------------------------------------ + +# similar to ATmega164 + +part + id = "m644"; + desc = "ATmega644"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x96 0x09; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega644P +#------------------------------------------------------------ + +# similar to ATmega164p + +part parent "m644" + id = "m644p"; + desc = "ATmega644P"; + signature = 0x1e 0x96 0x0a; + + ocdrev = 3; + ; + + + +#------------------------------------------------------------ +# ATmega1284 +#------------------------------------------------------------ + +# similar to ATmega164 + +part + id = "m1284"; + desc = "ATmega1284"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x97 0x06; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega1284P +#------------------------------------------------------------ + +# similar to ATmega164p + +part + id = "m1284p"; + desc = "ATmega1284P"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x97 0x05; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega162 +#------------------------------------------------------------ + +part + id = "m162"; + desc = "ATmega162"; + has_jtag = yes; + stk500_devcode = 0x83; + avr910_devcode = 0x63; + signature = 0x1e 0x94 0x04; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + + idr = 0x04; + spmcr = 0x57; + allowfullpagebitstream = yes; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + ocdrev = 2; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + + ; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + + read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; +; + + + +#------------------------------------------------------------ +# ATmega163 +#------------------------------------------------------------ + +part + id = "m163"; + desc = "ATmega163"; + stk500_devcode = 0x81; + avr910_devcode = 0x64; + signature = 0x1e 0x94 0x02; + chip_erase_delay = 32000; + pagel = 0xd7; + bs2 = 0xa0; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 30; + programfusepulsewidth = 0; + programfusepolltimeout = 2; + programlockpulsewidth = 0; + programlockpolltimeout = 2; + + + memory "eeprom" + size = 512; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 16000; + max_write_delay = 16000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x11; + delay = 20; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o x x o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i 1 1 i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x x x x x 1 o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x 0 x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega169 +#------------------------------------------------------------ + +part + id = "m169"; + desc = "ATmega169"; + has_jtag = yes; + stk500_devcode = 0x85; + avr910_devcode = 0x78; + signature = 0x1e 0x94 0x05; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega329 +#------------------------------------------------------------ + +part + id = "m329"; + desc = "ATmega329"; + has_jtag = yes; +# stk500_devcode = 0x85; # no STK500 support, only STK500v2 +# avr910_devcode = 0x?; # try the ATmega169 one: + avr910_devcode = 0x75; + signature = 0x1e 0x95 0x03; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega329P +#------------------------------------------------------------ +# Identical to ATmega329 except of the signature + +part parent "m329" + id = "m329p"; + desc = "ATmega329P"; + signature = 0x1e 0x95 0x0b; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega3290 +#------------------------------------------------------------ + +# identical to ATmega329 + +part parent "m329" + id = "m3290"; + desc = "ATmega3290"; + signature = 0x1e 0x95 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega3290P +#------------------------------------------------------------ + +# identical to ATmega3290 except of the signature + +part parent "m3290" + id = "m3290p"; + desc = "ATmega3290P"; + signature = 0x1e 0x95 0x0c; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega649 +#------------------------------------------------------------ + +part + id = "m649"; + desc = "ATmega649"; + has_jtag = yes; +# stk500_devcode = 0x85; # no STK500 support, only STK500v2 +# avr910_devcode = 0x?; # try the ATmega169 one: + avr910_devcode = 0x75; + signature = 0x1e 0x96 0x03; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega6490 +#------------------------------------------------------------ + +# identical to ATmega649 + +part parent "m649" + id = "m6490"; + desc = "ATmega6490"; + signature = 0x1e 0x96 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega32 +#------------------------------------------------------------ + +part + id = "m32"; + desc = "ATmega32"; + has_jtag = yes; + stk500_devcode = 0x91; + avr910_devcode = 0x72; + signature = 0x1e 0x95 0x02; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega161 +#------------------------------------------------------------ + +part + id = "m161"; + desc = "ATmega161"; + stk500_devcode = 0x80; + avr910_devcode = 0x60; + signature = 0x1e 0x94 0x01; + chip_erase_delay = 28000; + pagel = 0xd7; + bs2 = 0xa0; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 30; + programfusepulsewidth = 0; + programfusepolltimeout = 2; + programlockpulsewidth = 0; + programlockpolltimeout = 2; + + memory "eeprom" + size = 512; + min_write_delay = 3400; + max_write_delay = 3400; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 14000; + max_write_delay = 14000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 16; + blocksize = 128; + readsize = 256; + ; + + memory "fuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x o x o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x 1 i 1 i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega8 +#------------------------------------------------------------ + +part + id = "m8"; + desc = "ATmega8"; + stk500_devcode = 0x70; + avr910_devcode = 0x76; + signature = 0x1e 0x93 0x07; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 10000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega8515 +#------------------------------------------------------------ + +part + id = "m8515"; + desc = "ATmega8515"; + stk500_devcode = 0x63; + avr910_devcode = 0x3A; + signature = 0x1e 0x93 0x06; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + + +#------------------------------------------------------------ +# ATmega8535 +#------------------------------------------------------------ + +part + id = "m8535"; + desc = "ATmega8535"; + stk500_devcode = 0x64; + avr910_devcode = 0x69; + signature = 0x1e 0x93 0x08; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATtiny26 +#------------------------------------------------------------ + +part + id = "t26"; + desc = "ATtiny26"; + stk500_devcode = 0x21; + avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x09; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 16; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x x x x i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny261 +#------------------------------------------------------------ +# Close to ATtiny26 + +part + id = "t261"; + desc = "ATtiny261"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x0c; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 128; + page_size = 4; + num_pages = 32; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny461 +#------------------------------------------------------------ +# Close to ATtiny261 + +part + id = "t461"; + desc = "ATtiny461"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x92 0x08; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 256; + page_size = 4; + num_pages = 64; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny861 +#------------------------------------------------------------ +# Close to ATtiny461 + +part + id = "t861"; + desc = "ATtiny861"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x93 0x0d; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 512; + num_pages = 128; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny28 +#------------------------------------------------------------ + +# This is an HVPP-only device. + +part + id = "t28"; + desc = "ATtiny28"; + stk500_devcode = 0x22; + avr910_devcode = 0x5c; + signature = 0x1e 0x91 0x07; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "flash" + size = 2048; + page_size = 2; + readsize = 256; + delay = 5; + ; + + memory "signature" + size = 3; + ; + + memory "lock" + size = 1; + ; + + memory "calibration" + size = 1; + ; + + memory "fuse" + size = 1; + ; +; + + + +#------------------------------------------------------------ +# ATmega48 +#------------------------------------------------------------ + +part + id = "m48"; + desc = "ATmega48"; + has_debugwire = yes; + 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; + stk500_devcode = 0x59; +# avr910_devcode = 0x; + signature = 0x1e 0x92 0x05; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 45000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 256; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x x", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega48P +#------------------------------------------------------------ + +part parent "m48" + id = "m48p"; + desc = "ATmega48P"; + signature = 0x1e 0x92 0x0a; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega48PB +#------------------------------------------------------------ + +part parent "m48" + id = "m48pb"; + desc = "ATmega48PB"; + signature = 0x1e 0x92 0x10; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega88 +#------------------------------------------------------------ + +part + id = "m88"; + desc = "ATmega88"; + has_debugwire = yes; + 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; + stk500_devcode = 0x73; +# avr910_devcode = 0x; + signature = 0x1e 0x93 0x0a; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 512; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega88P +#------------------------------------------------------------ + +part parent "m88" + id = "m88p"; + desc = "ATmega88P"; + signature = 0x1e 0x93 0x0f; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega88PB +#------------------------------------------------------------ + +part parent "m88" + id = "m88pb"; + desc = "ATmega88PB"; + signature = 0x1e 0x93 0x16; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega168 +#------------------------------------------------------------ + +part + id = "m168"; + desc = "ATmega168"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x94 0x06; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 512; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# ATmega168P +#------------------------------------------------------------ + +part parent "m168" + id = "m168p"; + desc = "ATmega168P"; + signature = 0x1e 0x94 0x0b; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATmega168PB +#------------------------------------------------------------ + +part parent "m168" + id = "m168pb"; + desc = "ATmega168PB"; + signature = 0x1e 0x94 0x15; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATtiny88 +#------------------------------------------------------------ + +part + id = "t88"; + desc = "ATtiny88"; + has_debugwire = yes; + 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; + stk500_devcode = 0x73; +# avr910_devcode = 0x; + signature = 0x1e 0x93 0x11; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 64; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 64; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega328 +#------------------------------------------------------------ + +part + id = "m328"; + desc = "ATmega328"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x95 0x14; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 1024; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +part parent "m328" + id = "m328p"; + desc = "ATmega328P"; + signature = 0x1e 0x95 0x0F; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATmega32m1 +#------------------------------------------------------------ + +part parent "m328" + id = "m32m1"; + desc = "ATmega32M1"; + # stk500_devcode = 0x; + # avr910_devcode = 0x; + signature = 0x1e 0x95 0x84; + bs2 = 0xe2; + + memory "efuse" + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x i i i i i i"; + ; +; + +#------------------------------------------------------------ +# ATtiny2313 +#------------------------------------------------------------ + +part + id = "t2313"; + desc = "ATtiny2313"; + has_debugwire = yes; + 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; + stk500_devcode = 0x23; +## Use the ATtiny26 devcode: + avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x0a; + pagel = 0xD4; + bs2 = 0xD6; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 0; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + +# The information in the data sheet of April/2004 is wrong, this works: + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + +# The information in the data sheet of April/2004 is wrong, this works: + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + +# The information in the data sheet of April/2004 is wrong, this works: + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny2313 has Signature Bytes: 0x1E 0x91 0x0A. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + 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 = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny4313 +#------------------------------------------------------------ + +part + id = "t4313"; + desc = "ATtiny4313"; + has_debugwire = yes; + 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; + stk500_devcode = 0x23; +## Use the ATtiny26 devcode: + avr910_devcode = 0x5e; + signature = 0x1e 0x92 0x0d; + pagel = 0xD4; + bs2 = 0xD6; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 0; + + memory "eeprom" + size = 256; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny4313 has Signature Bytes: 0x1E 0x92 0x0D. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90PWM2 +#------------------------------------------------------------ + +part + id = "pwm2"; + desc = "AT90PWM2"; + has_debugwire = yes; + 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; + stk500_devcode = 0x65; +## avr910_devcode = ?; + signature = 0x1e 0x93 0x81; + pagel = 0xD8; + bs2 = 0xE2; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; +# AT90PWM2 has Signature Bytes: 0x1E 0x93 0x81. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90PWM3 +#------------------------------------------------------------ + +# Completely identical to AT90PWM2 (including the signature!) + +part parent "pwm2" + id = "pwm3"; + desc = "AT90PWM3"; + ; + +#------------------------------------------------------------ +# AT90PWM2B +#------------------------------------------------------------ +# Same as AT90PWM2 but different signature. + +part parent "pwm2" + id = "pwm2b"; + desc = "AT90PWM2B"; + signature = 0x1e 0x93 0x83; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# AT90PWM3B +#------------------------------------------------------------ + +# Completely identical to AT90PWM2B (including the signature!) + +part parent "pwm2b" + id = "pwm3b"; + desc = "AT90PWM3B"; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# AT90PWM316 +#------------------------------------------------------------ + +# Similar to AT90PWM3B, but with 16 kiB flash, 512 B EEPROM, and 1024 B SRAM. + +part parent "pwm3b" + id = "pwm316"; + desc = "AT90PWM316"; + signature = 0x1e 0x94 0x83; + + ocdrev = 1; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + ; + +#------------------------------------------------------------ +# AT90PWM216 +#------------------------------------------------------------ +# Completely identical to AT90PWM316 (including the signature!) + +part parent "pwm316" + id = "pwm216"; + desc = "AT90PWM216"; + ; + +#------------------------------------------------------------ +# ATtiny25 +#------------------------------------------------------------ + +part + id = "t25"; + desc = "ATtiny25"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x08; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny25 has Signature Bytes: 0x1E 0x91 0x08. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny45 +#------------------------------------------------------------ + +part + id = "t45"; + desc = "ATtiny45"; + has_debugwire = yes; + 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; + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x06; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 256; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny45 has Signature Bytes: 0x1E 0x92 0x08. (Data sheet 2586C-AVR-06/05 (doc2586.pdf) indicates otherwise!) + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny85 +#------------------------------------------------------------ + +part + id = "t85"; + desc = "ATtiny85"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x93 0x0b; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny85 has Signature Bytes: 0x1E 0x93 0x08. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega640 +#------------------------------------------------------------ +# Almost same as ATmega1280, except for different memory sizes + +part + id = "m640"; + desc = "ATmega640"; + signature = 0x1e 0x96 0x08; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega1280 +#------------------------------------------------------------ + +part + id = "m1280"; + desc = "ATmega1280"; + signature = 0x1e 0x97 0x03; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega1281 +#------------------------------------------------------------ +# Identical to ATmega1280 + +part parent "m1280" + id = "m1281"; + desc = "ATmega1281"; + signature = 0x1e 0x97 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega2560 +#------------------------------------------------------------ + +part + id = "m2560"; + desc = "ATmega2560"; + signature = 0x1e 0x98 0x01; + has_jtag = yes; + stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 4; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 262144; + page_size = 256; + num_pages = 1024; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + load_ext_addr = " 0 1 0 0 1 1 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 a16", + " 0 0 0 0 0 0 0 0"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega2561 +#------------------------------------------------------------ + +part parent "m2560" + id = "m2561"; + desc = "ATmega2561"; + signature = 0x1e 0x98 0x02; + + ocdrev = 4; + ; + +#------------------------------------------------------------ +# ATmega128RFA1 +#------------------------------------------------------------ +# Identical to ATmega2561 but half the ROM + +part parent "m2561" + id = "m128rfa1"; + desc = "ATmega128RFA1"; + signature = 0x1e 0xa7 0x01; + chip_erase_delay = 55000; + bs2 = 0xE2; + + ocdrev = 3; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 50000; + max_write_delay = 50000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 256; + readsize = 256; + ; + ; + +#------------------------------------------------------------ +# ATmega256RFR2 +#------------------------------------------------------------ + +part parent "m2561" + id = "m256rfr2"; + desc = "ATmega256RFR2"; + signature = 0x1e 0xa8 0x02; + chip_erase_delay = 18500; + bs2 = 0xE2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 8192; + min_write_delay = 13000; + max_write_delay = 13000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + + ocdrev = 4; + ; + +#------------------------------------------------------------ +# ATmega128RFR2 +#------------------------------------------------------------ + +part parent "m128rfa1" + id = "m128rfr2"; + desc = "ATmega128RFR2"; + signature = 0x1e 0xa7 0x02; + + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega64RFR2 +#------------------------------------------------------------ + +part parent "m128rfa1" + id = "m64rfr2"; + desc = "ATmega64RFR2"; + signature = 0x1e 0xa6 0x02; + + + ocdrev = 3; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 50000; + max_write_delay = 50000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 256; + readsize = 256; + ; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 13000; + max_write_delay = 13000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + + ; + +#------------------------------------------------------------ +# ATmega2564RFR2 +#------------------------------------------------------------ + +part parent "m256rfr2" + id = "m2564rfr2"; + desc = "ATmega2564RFR2"; + signature = 0x1e 0xa8 0x03; + ; + +#------------------------------------------------------------ +# ATmega1284RFR2 +#------------------------------------------------------------ + +part parent "m128rfr2" + id = "m1284rfr2"; + desc = "ATmega1284RFR2"; + signature = 0x1e 0xa7 0x03; + ; + +#------------------------------------------------------------ +# ATmega644RFR2 +#------------------------------------------------------------ + +part parent "m64rfr2" + id = "m644rfr2"; + desc = "ATmega644RFR2"; + signature = 0x1e 0xa6 0x03; + ; + +#------------------------------------------------------------ +# ATtiny24 +#------------------------------------------------------------ + +part + id = "t24"; + desc = "ATtiny24"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x0b; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny24 has Signature Bytes: 0x1E 0x91 0x0B. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny44 +#------------------------------------------------------------ + +part + id = "t44"; + desc = "ATtiny44"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x07; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 256; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny44 has Signature Bytes: 0x1E 0x92 0x07. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny84 +#------------------------------------------------------------ + +part + id = "t84"; + desc = "ATtiny84"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x93 0x0c; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny84 has Signature Bytes: 0x1E 0x93 0x0C. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny43U +#------------------------------------------------------------ + +part + id = "t43u"; + desc = "ATtiny43u"; + has_debugwire = yes; + 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; + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x0C; + reset = io; + chip_erase_delay = 1000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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, 0x06, 0x16, 0x46, 0x56, + 0x0A, 0x1A, 0x4A, 0x5A, 0x1E, 0x7C, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 20; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + memory "eeprom" + size = 64; + paged = yes; + page_size = 4; + num_pages = 16; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "0 0 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "0 0 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " 0 0 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# ATmega32u4 +#------------------------------------------------------------ + +part + id = "m32u4"; + desc = "ATmega32U4"; + signature = 0x1e 0x95 0x87; + usbpid = 0x2ff4; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB646 +#------------------------------------------------------------ + +part + id = "usb646"; + desc = "AT90USB646"; + signature = 0x1e 0x96 0x82; + usbpid = 0x2ff9; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB647 +#------------------------------------------------------------ +# identical to AT90USB646 + +part parent "usb646" + id = "usb647"; + desc = "AT90USB647"; + signature = 0x1e 0x96 0x82; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AT90USB1286 +#------------------------------------------------------------ + +part + id = "usb1286"; + desc = "AT90USB1286"; + signature = 0x1e 0x97 0x82; + usbpid = 0x2ffb; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB1287 +#------------------------------------------------------------ +# identical to AT90USB1286 + +part parent "usb1286" + id = "usb1287"; + desc = "AT90USB1287"; + signature = 0x1e 0x97 0x82; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AT90USB162 +#------------------------------------------------------------ + +part + id = "usb162"; + desc = "AT90USB162"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x94 0x82; + usbpid = 0x2ffa; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB82 +#------------------------------------------------------------ +# Changes against AT90USB162 (beside IDs) +# memory "flash" +# size = 8192; +# num_pages = 64; + +part + id = "usb82"; + desc = "AT90USB82"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x93 0x82; + usbpid = 0x2ff7; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega32U2 +#------------------------------------------------------------ +# Changes against AT90USB162 (beside IDs) +# memory "flash" +# size = 32768; +# num_pages = 256; +# memory "eeprom" +# size = 1024; +# num_pages = 256; +part + id = "m32u2"; + desc = "ATmega32U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x95 0x8a; + usbpid = 0x2ff0; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + num_pages = 256; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; +#------------------------------------------------------------ +# ATmega16U2 +#------------------------------------------------------------ +# Changes against ATmega32U2 (beside IDs) +# memory "flash" +# size = 16384; +# num_pages = 128; +# memory "eeprom" +# size = 512; +# num_pages = 128; +part + id = "m16u2"; + desc = "ATmega16U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x94 0x89; + usbpid = 0x2fef; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega8U2 +#------------------------------------------------------------ +# Changes against ATmega16U2 (beside IDs) +# memory "flash" +# size = 8192; +# page_size = 64; +# blocksize = 64; + +part + id = "m8u2"; + desc = "ATmega8U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x93 0x89; + usbpid = 0x2fee; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; +#------------------------------------------------------------ +# ATmega325 +#------------------------------------------------------------ + +part + id = "m325"; + desc = "ATmega325"; + signature = 0x1e 0x95 0x05; + has_jtag = yes; +# stk500_devcode = 0x??; # No STK500v1 support? +# avr910_devcode = 0x??; # Try the ATmega16 one + avr910_devcode = 0x74; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega645 +#------------------------------------------------------------ + +part + id = "m645"; + desc = "ATmega645"; + signature = 0x1E 0x96 0x05; + has_jtag = yes; +# stk500_devcode = 0x??; # No STK500v1 support? +# avr910_devcode = 0x??; # Try the ATmega16 one + avr910_devcode = 0x74; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " 0 0 0 0 0 0 0 0"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega3250 +#------------------------------------------------------------ + +part parent "m325" + id = "m3250"; + desc = "ATmega3250"; + signature = 0x1E 0x95 0x06; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega6450 +#------------------------------------------------------------ + +part parent "m645" + id = "m6450"; + desc = "ATmega6450"; + signature = 0x1E 0x96 0x06; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AVR XMEGA family common values +#------------------------------------------------------------ + +part + id = ".xmega"; + desc = "AVR XMEGA family common values"; + has_pdi = yes; + nvm_base = 0x01c0; + mcu_base = 0x0090; + + memory "signature" + size = 3; + offset = 0x1000090; + ; + + memory "prodsig" + size = 0x32; + offset = 0x8e0200; + page_size = 0x32; + readsize = 0x32; + ; + + memory "fuse1" + size = 1; + offset = 0x8f0021; + ; + + memory "fuse2" + size = 1; + offset = 0x8f0022; + ; + + memory "fuse4" + size = 1; + offset = 0x8f0024; + ; + + memory "fuse5" + size = 1; + offset = 0x8f0025; + ; + + memory "lock" + size = 1; + offset = 0x8f0027; + ; + + memory "data" + # SRAM, only used to supply the offset + offset = 0x1000000; + ; +; + +#------------------------------------------------------------ +# ATxmega16A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x16a4u"; + desc = "ATxmega16A4U"; + signature = 0x1e 0x94 0x41; + usbpid = 0x2fe3; + + memory "eeprom" + size = 0x400; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x4000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x803000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x804000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x5000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega16C4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16c4"; + desc = "ATxmega16C4"; + signature = 0x1e 0x95 0x44; +; + +#------------------------------------------------------------ +# ATxmega16D4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16d4"; + desc = "ATxmega16D4"; + signature = 0x1e 0x94 0x42; +; + +#------------------------------------------------------------ +# ATxmega16A4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16a4"; + desc = "ATxmega16A4"; + signature = 0x1e 0x94 0x41; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega32A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x32a4u"; + desc = "ATxmega32A4U"; + signature = 0x1e 0x95 0x41; + usbpid = 0x2fe4; + + memory "eeprom" + size = 0x400; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x8000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x807000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x808000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x9000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega32C4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32c4"; + desc = "ATxmega32C4"; + signature = 0x1e 0x94 0x43; +; + +#------------------------------------------------------------ +# ATxmega32D4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32d4"; + desc = "ATxmega32D4"; + signature = 0x1e 0x95 0x42; +; + +#------------------------------------------------------------ +# ATxmega32A4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32a4"; + desc = "ATxmega32A4"; + signature = 0x1e 0x95 0x41; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega64A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x64a4u"; + desc = "ATxmega64A4U"; + signature = 0x1e 0x96 0x46; + usbpid = 0x2fe5; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x10000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x80f000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x810000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x11000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega64C3 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64c3"; + desc = "ATxmega64C3"; + signature = 0x1e 0x96 0x49; + usbpid = 0x2fd6; +; + +#------------------------------------------------------------ +# ATxmega64D3 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64d3"; + desc = "ATxmega64D3"; + signature = 0x1e 0x96 0x4a; +; + +#------------------------------------------------------------ +# ATxmega64D4 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64d4"; + desc = "ATxmega64D4"; + signature = 0x1e 0x96 0x47; +; + +#------------------------------------------------------------ +# ATxmega64A1 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64a1"; + desc = "ATxmega64A1"; + signature = 0x1e 0x96 0x4e; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega64A1U +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a1u"; + desc = "ATxmega64A1U"; + signature = 0x1e 0x96 0x4e; + usbpid = 0x2fe8; +; + +#------------------------------------------------------------ +# ATxmega64A3 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a3"; + desc = "ATxmega64A3"; + signature = 0x1e 0x96 0x42; +; + +#------------------------------------------------------------ +# ATxmega64A3U +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a3u"; + desc = "ATxmega64A3U"; + signature = 0x1e 0x96 0x42; + usbpid = 0x2fe5; +; + +#------------------------------------------------------------ +# ATxmega64A4 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a4"; + desc = "ATxmega64A4"; + signature = 0x1e 0x96 0x46; +; + +#------------------------------------------------------------ +# ATxmega64B1 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64b1"; + desc = "ATxmega64B1"; + signature = 0x1e 0x96 0x52; + usbpid = 0x2fe1; +; + +#------------------------------------------------------------ +# ATxmega64B3 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64b3"; + desc = "ATxmega64B3"; + signature = 0x1e 0x96 0x51; + usbpid = 0x2fdf; +; + +#------------------------------------------------------------ +# ATxmega128C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128c3"; + desc = "ATxmega128C3"; + signature = 0x1e 0x97 0x52; + usbpid = 0x2fd7; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x81e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega128D3 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128d3"; + desc = "ATxmega128D3"; + signature = 0x1e 0x97 0x48; +; + +#------------------------------------------------------------ +# ATxmega128D4 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128d4"; + desc = "ATxmega128D4"; + signature = 0x1e 0x97 0x47; +; + +#------------------------------------------------------------ +# ATxmega128A1 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128a1"; + desc = "ATxmega128A1"; + signature = 0x1e 0x97 0x4c; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128A1 revision D +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a1d"; + desc = "ATxmega128A1revD"; + signature = 0x1e 0x97 0x41; +; + +#------------------------------------------------------------ +# ATxmega128A1U +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a1u"; + desc = "ATxmega128A1U"; + signature = 0x1e 0x97 0x4c; + usbpid = 0x2fed; +; + +#------------------------------------------------------------ +# ATxmega128A3 +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a3"; + desc = "ATxmega128A3"; + signature = 0x1e 0x97 0x42; +; + +#------------------------------------------------------------ +# ATxmega128A3U +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a3u"; + desc = "ATxmega128A3U"; + signature = 0x1e 0x97 0x42; + usbpid = 0x2fe6; +; + +#------------------------------------------------------------ +# ATxmega128A4 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128a4"; + desc = "ATxmega128A4"; + signature = 0x1e 0x97 0x46; + has_jtag = yes; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x81f000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128a4u"; + desc = "ATxmega128A4U"; + signature = 0x1e 0x97 0x46; + usbpid = 0x2fde; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x81f000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega128B1 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128b1"; + desc = "ATxmega128B1"; + signature = 0x1e 0x97 0x4d; + usbpid = 0x2fea; + has_jtag = yes; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x81e000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128B3 +#------------------------------------------------------------ + +part parent "x128b1" + id = "x128b3"; + desc = "ATxmega128B3"; + signature = 0x1e 0x97 0x4b; + usbpid = 0x2fe0; +; + +#------------------------------------------------------------ +# ATxmega192C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x192c3"; + desc = "ATxmega192C3"; + signature = 0x1e 0x97 0x51; + # usbpid = 0x2f??; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x30000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x82e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x830000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x32000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega192D3 +#------------------------------------------------------------ + +part parent "x192c3" + id = "x192d3"; + desc = "ATxmega192D3"; + signature = 0x1e 0x97 0x49; +; + +#------------------------------------------------------------ +# ATxmega192A1 +#------------------------------------------------------------ + +part parent "x192c3" + id = "x192a1"; + desc = "ATxmega192A1"; + signature = 0x1e 0x97 0x4e; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega192A3 +#------------------------------------------------------------ + +part parent "x192a1" + id = "x192a3"; + desc = "ATxmega192A3"; + signature = 0x1e 0x97 0x44; +; + +#------------------------------------------------------------ +# ATxmega192A3U +#------------------------------------------------------------ + +part parent "x192a1" + id = "x192a3u"; + desc = "ATxmega192A3U"; + signature = 0x1e 0x97 0x44; + usbpid = 0x2fe7; +; + +#------------------------------------------------------------ +# ATxmega256C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x256c3"; + desc = "ATxmega256C3"; + signature = 0x1e 0x98 0x46; + usbpid = 0x2fda; + + memory "eeprom" + size = 0x1000; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x40000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x83e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x840000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x42000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega256D3 +#------------------------------------------------------------ + +part parent "x256c3" + id = "x256d3"; + desc = "ATxmega256D3"; + signature = 0x1e 0x98 0x44; +; + +#------------------------------------------------------------ +# ATxmega256A1 +#------------------------------------------------------------ + +part parent "x256c3" + id = "x256a1"; + desc = "ATxmega256A1"; + signature = 0x1e 0x98 0x46; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega256A3 +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3"; + desc = "ATxmega256A3"; + signature = 0x1e 0x98 0x42; +; + +#------------------------------------------------------------ +# ATxmega256A3U +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3u"; + desc = "ATxmega256A3U"; + signature = 0x1e 0x98 0x42; + usbpid = 0x2fec; +; + +#------------------------------------------------------------ +# ATxmega256A3B +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3b"; + desc = "ATxmega256A3B"; + signature = 0x1e 0x98 0x43; +; + +#------------------------------------------------------------ +# ATxmega256A3BU +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3bu"; + desc = "ATxmega256A3BU"; + signature = 0x1e 0x98 0x43; + usbpid = 0x2fe2; +; + +#------------------------------------------------------------ +# ATxmega384C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x384c3"; + desc = "ATxmega384C3"; + signature = 0x1e 0x98 0x45; + usbpid = 0x2fdb; + + memory "eeprom" + size = 0x1000; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x60000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x85e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x860000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x62000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega384D3 +#------------------------------------------------------------ + +part parent "x384c3" + id = "x384d3"; + desc = "ATxmega384D3"; + signature = 0x1e 0x98 0x47; +; + +#------------------------------------------------------------ +# ATxmega8E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x8e5"; + desc = "ATxmega8E5"; + signature = 0x1e 0x93 0x41; + + memory "eeprom" + size = 0x0200; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x2000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x800; + offset = 0x00801800; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x800; + offset = 0x00802000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x2800; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega16E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x16e5"; + desc = "ATxmega16E5"; + signature = 0x1e 0x94 0x45; + + memory "eeprom" + size = 0x0200; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x4000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x00803000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x00804000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x5000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega32E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x32e5"; + desc = "ATxmega32E5"; + signature = 0x1e 0x95 0x4c; + + memory "eeprom" + size = 0x0400; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x8000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x00807000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x00808000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x9000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# AVR32UC3A0512 +#------------------------------------------------------------ + +part + id = "uc3a0512"; + desc = "AT32UC3A0512"; + signature = 0xED 0xC0 0x3F; + has_jtag = yes; + is_avr32 = yes; + + memory "flash" + paged = yes; + page_size = 512; # bytes + readsize = 512; # bytes + num_pages = 1024; # could be set dynamicly + size = 0x00080000; # could be set dynamicly + offset = 0x80000000; + ; +; + +part parent "uc3a0512" + id = "ucr2"; + desc = "deprecated, use 'uc3a0512'"; +; + +#------------------------------------------------------------ +# ATtiny1634. +#------------------------------------------------------------ + +part + id = "t1634"; + desc = "ATtiny1634"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x94 0x12; + pagel = 0xB3; + bs2 = 0xB1; + reset = io; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + paged = no; + page_size = 4; + size = 256; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 32; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 1 1 1 1 i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# Common values for reduced core tinys (4/5/9/10/20/40) +#------------------------------------------------------------ + +part + id = ".reduced_core_tiny"; + desc = "Common values for reduced core tinys"; + has_tpi = yes; + + memory "signature" + size = 3; + offset = 0x3fc0; + page_size = 16; + ; + + memory "fuse" + size = 1; + offset = 0x3f40; + page_size = 16; + blocksize = 4; + ; + + memory "calibration" + size = 1; + offset = 0x3f80; + page_size = 16; + ; + + memory "lockbits" + size = 1; + offset = 0x3f00; + page_size = 16; + ; +; + +#------------------------------------------------------------ +# ATtiny4 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t4"; + desc = "ATtiny4"; + signature = 0x1e 0x8f 0x0a; + + memory "flash" + size = 512; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny5 +#------------------------------------------------------------ + +part parent "t4" + id = "t5"; + desc = "ATtiny5"; + signature = 0x1e 0x8f 0x09; +; + +#------------------------------------------------------------ +# ATtiny9 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t9"; + desc = "ATtiny9"; + signature = 0x1e 0x90 0x08; + + memory "flash" + size = 1024; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny10 +#------------------------------------------------------------ + +part parent "t9" + id = "t10"; + desc = "ATtiny10"; + signature = 0x1e 0x90 0x03; +; + +#------------------------------------------------------------ +# ATtiny20 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t20"; + desc = "ATtiny20"; + signature = 0x1e 0x91 0x0F; + + memory "flash" + size = 2048; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny40 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t40"; + desc = "ATtiny40"; + signature = 0x1e 0x92 0x0E; + + memory "flash" + size = 4096; + offset = 0x4000; + page_size = 64; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATmega406 +#------------------------------------------------------------ + +part + id = "m406"; + desc = "ATMEGA406"; + has_jtag = yes; + signature = 0x1e 0x95 0x07; + + # STK500 parameters (parallel programming IO lines) + pagel = 0xa7; + bs2 = 0xa0; + serial = no; + parallel = yes; + + # 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; + + # JTAG ICE mkII parameters, also from XML files + allowfullpagebitstream = no; + enablepageprogramming = yes; + idr = 0x51; + rampz = 0x00; + spmcr = 0x57; + eecr = 0x3f; + + memory "eeprom" + paged = no; + size = 512; + page_size = 4; + blocksize = 4; + readsize = 4; + num_pages = 128; + ; + + memory "flash" + paged = yes; + size = 40960; + page_size = 128; + blocksize = 128; + readsize = 128; + num_pages = 320; + ; + + memory "hfuse" + size = 1; + ; + + memory "lfuse" + size = 1; + ; + + memory "lockbits" + size = 1; + ; + + memory "signature" + size = 3; + ; +; + + diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 4f44fc7bf..77747cd07 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -7,12 +7,12 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") # Workaround for an old CMake, which does not understand CMAKE_CXX_STANDARD. - add_compile_options(-std=c++11 -Wall) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall" ) endif() if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX) # Adding -fext-numeric-literals to enable GCC extensions on definitions of quad float literals, which are required by Boost. - add_compile_options(-fext-numeric-literals) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals" ) endif() # Where all the bundled libraries reside? @@ -220,12 +220,16 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/Config/Version.hpp ${LIBDIR}/slic3r/Utils/ASCIIFolding.cpp ${LIBDIR}/slic3r/Utils/ASCIIFolding.hpp + ${LIBDIR}/slic3r/Utils/Serial.cpp + ${LIBDIR}/slic3r/Utils/Serial.hpp ${LIBDIR}/slic3r/GUI/ConfigWizard.cpp ${LIBDIR}/slic3r/GUI/ConfigWizard.hpp ${LIBDIR}/slic3r/GUI/MsgDialog.cpp ${LIBDIR}/slic3r/GUI/MsgDialog.hpp ${LIBDIR}/slic3r/GUI/UpdateDialogs.cpp ${LIBDIR}/slic3r/GUI/UpdateDialogs.hpp + ${LIBDIR}/slic3r/GUI/FirmwareDialog.cpp + ${LIBDIR}/slic3r/GUI/FirmwareDialog.hpp ${LIBDIR}/slic3r/Utils/Http.cpp ${LIBDIR}/slic3r/Utils/Http.hpp ${LIBDIR}/slic3r/Utils/OctoPrint.cpp @@ -331,6 +335,9 @@ add_library(semver STATIC ${LIBDIR}/semver/semver.c ) + +add_subdirectory(src/avrdude) + # Generate the Slic3r Perl module (XS) typemap file. set(MyTypemap ${CMAKE_CURRENT_BINARY_DIR}/typemap) add_custom_command( @@ -427,7 +434,7 @@ if(APPLE) # Ignore undefined symbols of the perl interpreter, they will be found in the caller image. target_link_libraries(XS "-undefined dynamic_lookup") endif() -target_link_libraries(XS libslic3r libslic3r_gui admesh miniz clipper nowide polypartition poly2tri semver) +target_link_libraries(XS libslic3r libslic3r_gui admesh miniz clipper nowide polypartition poly2tri semver avrdude) if(SLIC3R_PROFILE) target_link_libraries(XS Shiny) endif() @@ -435,7 +442,7 @@ endif() # Add the OpenGL and GLU libraries. if (SLIC3R_GUI) if (MSVC) - target_link_libraries(XS OpenGL32.Lib GlU32.Lib) + target_link_libraries(XS user32.lib Setupapi.lib OpenGL32.Lib GlU32.Lib) elseif (MINGW) target_link_libraries(XS -lopengl32) elseif (APPLE) diff --git a/xs/src/avrdude/AUTHORS b/xs/src/avrdude/AUTHORS new file mode 100644 index 000000000..6abbec066 --- /dev/null +++ b/xs/src/avrdude/AUTHORS @@ -0,0 +1,28 @@ +AVRDUDE was written by: + + Brian S. Dean + +Contributors: + + Joerg Wunsch + Eric Weddington + Jan-Hinnerk Reichert + Alex Shepherd + Martin Thomas + Theodore A. Roth + Michael Holzt + Colin O'Flynn + Thomas Fischl + David Hoerl + Michal Ludvig + Darell Tan + Wolfgang Moser + Ville Voipio + Hannes Weisbach + Doug Springer + Brett Hagman + Rene Liebscher + Jim Paris + +For minor contributions, please see the ChangeLog files. + diff --git a/xs/src/avrdude/BUILD-FROM-SVN b/xs/src/avrdude/BUILD-FROM-SVN new file mode 100644 index 000000000..3a218f2d1 --- /dev/null +++ b/xs/src/avrdude/BUILD-FROM-SVN @@ -0,0 +1,13 @@ +$Id$ + +How to build avrdude from SVN: + +1. svn co svn://svn.savannah.nongnu.org/avrdude/trunk + +2. cd trunk/avrdude + +3. ./bootstrap + +4. ./configure + +5. make diff --git a/xs/src/avrdude/CMakeLists.txt b/xs/src/avrdude/CMakeLists.txt new file mode 100644 index 000000000..043f8fb7b --- /dev/null +++ b/xs/src/avrdude/CMakeLists.txt @@ -0,0 +1,79 @@ + + +add_definitions(-D_BSD_SOURCE -D_DEFAULT_SOURCE) # To enable various useful macros and functions on Unices +remove_definitions(-D_UNICODE -DUNICODE) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # Workaround for an old CMake, which does not understand CMAKE_C_STANDARD. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall") +endif() + + +set(AVRDUDE_SOURCES + ${LIBDIR}/avrdude/arduino.c + ${LIBDIR}/avrdude/avr.c + # ${LIBDIR}/avrdude/avrftdi.c + # ${LIBDIR}/avrdude/avrftdi_tpi.c + ${LIBDIR}/avrdude/avrpart.c + ${LIBDIR}/avrdude/avr910.c + ${LIBDIR}/avrdude/bitbang.c + ${LIBDIR}/avrdude/buspirate.c + ${LIBDIR}/avrdude/butterfly.c + ${LIBDIR}/avrdude/config.c + ${LIBDIR}/avrdude/config_gram.c + # ${LIBDIR}/avrdude/confwin.c + ${LIBDIR}/avrdude/crc16.c + # ${LIBDIR}/avrdude/dfu.c + ${LIBDIR}/avrdude/fileio.c + # ${LIBDIR}/avrdude/flip1.c + # ${LIBDIR}/avrdude/flip2.c + # ${LIBDIR}/avrdude/ft245r.c + # ${LIBDIR}/avrdude/jtagmkI.c + # ${LIBDIR}/avrdude/jtagmkII.c + # ${LIBDIR}/avrdude/jtag3.c + ${LIBDIR}/avrdude/lexer.c + ${LIBDIR}/avrdude/linuxgpio.c + ${LIBDIR}/avrdude/lists.c + # ${LIBDIR}/avrdude/par.c + ${LIBDIR}/avrdude/pgm.c + ${LIBDIR}/avrdude/pgm_type.c + ${LIBDIR}/avrdude/pickit2.c + ${LIBDIR}/avrdude/pindefs.c + # ${LIBDIR}/avrdude/ppi.c + # ${LIBDIR}/avrdude/ppiwin.c + ${LIBDIR}/avrdude/safemode.c + ${LIBDIR}/avrdude/ser_avrdoper.c + ${LIBDIR}/avrdude/serbb_posix.c + ${LIBDIR}/avrdude/serbb_win32.c + ${LIBDIR}/avrdude/ser_posix.c + ${LIBDIR}/avrdude/ser_win32.c + ${LIBDIR}/avrdude/stk500.c + ${LIBDIR}/avrdude/stk500generic.c + ${LIBDIR}/avrdude/stk500v2.c + ${LIBDIR}/avrdude/term.c + ${LIBDIR}/avrdude/update.c + # ${LIBDIR}/avrdude/usbasp.c + # ${LIBDIR}/avrdude/usb_hidapi.c + # ${LIBDIR}/avrdude/usb_libusb.c + # ${LIBDIR}/avrdude/usbtiny.c + ${LIBDIR}/avrdude/wiring.c + + ${LIBDIR}/avrdude/main.c + ${LIBDIR}/avrdude/avrdude-slic3r.hpp + ${LIBDIR}/avrdude/avrdude-slic3r.cpp +) +if (WIN32) + set(AVRDUDE_SOURCES ${AVRDUDE_SOURCES} + ${LIBDIR}/avrdude/windows/unistd.cpp + ${LIBDIR}/avrdude/windows/getopt.c + ) +endif() +add_library(avrdude STATIC ${AVRDUDE_SOURCES}) + +if (WIN32) + target_compile_definitions(avrdude PRIVATE WIN32NATIVE=1) + target_include_directories(avrdude SYSTEM PRIVATE ${LIBDIR}/avrdude/windows) # So that sources find the getopt.h windows drop-in +endif() diff --git a/xs/src/avrdude/COPYING b/xs/src/avrdude/COPYING new file mode 100644 index 000000000..e69cf7e6c --- /dev/null +++ b/xs/src/avrdude/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/xs/src/avrdude/ChangeLog b/xs/src/avrdude/ChangeLog new file mode 100644 index 000000000..975f52317 --- /dev/null +++ b/xs/src/avrdude/ChangeLog @@ -0,0 +1,90 @@ +2016-05-10 Joerg Wunsch + + Submitted by Hannes Jochriem: + * avrdude.conf.in (ehajo-isp): New programmer. + +2016-04-20 Joerg Wunsch + + * configure.ac (libftdi1): Rather than hardcoding the library + providing the libusb-1.0 API, use the result from the previous + probe. This helps detecting libftdi1 on FreeBSD where the + libusb-1.0 API is provided by the system's libusb. + +2016-04-18 Joerg Wunsch + + * usb_hidapi.c (usbhid_open): Correctly calculate the + offset for serial number matching + +2016-03-28 Joerg Wunsch + + bug #47550: Linux GPIO broken + * linuxgpio.c: Replace %ud by %u in snprintf calls. + +2016-03-02 Joerg Wunsch + + * usb_hidapi.c (usbhid_recv): Bump read timeout to 300 ms. + +2016-02-20 Joerg Wunsch + + * jtag3.c: add support for libhidapi as (optional) transport for + CMSIS-DAP compliant debuggers (JTAGICE3 with firmware 3+, + AtmelICE, EDBG, mEDBG) + * usb_hidapi.c: (New file) + * libavrdude.h: Mention usbhid_serdev + * configure.ac: Bump version date + +2016-02-18 Joerg Wunsch + + (Obtained from patch #8717: pattch for mcprog and libhidapi support) + * configure.ac: Probe for libhidapi + * Makefile.am: Add @LIBHIDAPI@ + +2016-02-16 Joerg Wunsch + + * doc/avrdude.texi: Bump copyright year. + +2016-02-16 Joerg Wunsch + + * configure.ac: Bump for post-release 6.3. + +2016-02-16 Joerg Wunsch + + * configure.ac: Released version 6.3. + +2016-02-15 Joerg Wunsch + + patch #8894: Spelling in 6.2 doc + * doc/avrdude.texi: Various spelling fixes. + +2016-02-15 Joerg Wunsch + + patch #8895: Spelling in 6.2 code + * avrftdi.c (avrftdi_open): Spell fix. + +2016-02-15 Joerg Wunsch + + patch #8896: Silence cppcheck warnings in 6.2 code + * linuxgpio.c: Use %ud to print GPIO values. + +2016-02-15 Joerg Wunsch + + patch #8735: ATtiny28 support in avrdude.conf + * avrdude.conf.in (ATtiny28): New device. + +2016-02-15 Joerg Wunsch + + * avrdude.conf.in (ATmega48PB, ATmega88PB, ATmega168PB): New + devices. + +2016-02-15 Joerg Wunsch + + patch #8435: Implementing mEDBG CMSIS-DAP protocol + * usb_libusb.c: Add endpoint IDs for Xplained Mini, correctly + transfer trailing ZLP when needed + * avrdude.conf.in (xplainedmini, xplainedmini_dw): New entries. + * jtag3.c (jtag3_edbg_send, jtag3_edbg_recv_frame): Implement + fragmentation needed for the 64-byte EP size of the Xplained Mini + * avrdude.1: Document the change + * doc/avrdude.texi: (Dito.) + + diff --git a/xs/src/avrdude/ChangeLog-2001 b/xs/src/avrdude/ChangeLog-2001 new file mode 100644 index 000000000..048dcf1c2 --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2001 @@ -0,0 +1,598 @@ +2001-12-30 Brian S. Dean + + * main.c: Update version. + + * avrdude.conf.sample: Clarify a comment. + + * avrdude.conf.sample: fix address bits + + * avrdude.1: Bring up to date. + +2001-12-29 Brian S. Dean + + * avrdude.conf.sample: Add the AVR3 progammer. + + * avr.c, avrdude.conf.sample, config_gram.y, main.c, pindefs.h: + Fix VCC assertion. + + Make the BUFF pin a mask like VCC to allow multiple pins to be + asserted at the same time (STK200 has two buffer enable lines). + + Add the STK200 programmer. + + Fix EEPROM address line selection for several parts. + +2001-12-15 Brian S. Dean + + * avrdude.conf.sample: fix spelling error + +2001-11-24 Brian S. Dean + + * Makefile: + Change "WARNING" to "NOTE" when overwriting the avrprog.conf file. + + * avrdude.1: Add my e-mail address. + + * avrdude.conf.sample: + Add comments about instruction formats. Correct an instruction + specification (cut&paste error). + +2001-11-21 Brian S. Dean + + * avr.c, config_gram.y, lexer.l, term.c: + In interactive mode, reset the address and length if we start dumping + a memory type different than the previous one. + + * avr.c, avrdude.conf.sample, config_gram.y: + Allow instruction data to be specified more flexibly, which can be + used to make the instruction input more readable in the config file. + + * main.c: Bump version number. + + * Makefile, avr.c, avr.h, avrdude.conf.sample, config.c, config.h: + * config_gram.y, fileio.c, fileio.h, lexer.l, main.c, term.c: + This is a major re-write of the programming algorithms. The Atmel + serial programming instructions are not very orthoganal, i.e., the + "read fuse bits" instruction on an ATMega103 is an entirely different + opcode and data format from the _same_ instruction for an ATMega163! + Thus, it becomes impossible to have a single instruction encoding + (varying the data) across the chip lines. + + This set of changes allows and requires instruction encodings to be + defined on a per-part basis within the configuration file. Hopefully + I've defined the encoding scheme in a general enough way so it is + useful in describing the instruction formats for yet-to-be invented + Atmel chips. I've tried hard to make it match very closely with the + specification in Atmel's data sheets for their parts. It's a little + more verbose than what I initially hoped for, but I've tried to keep + it as concise as I could, while still remaining reasonably flexible. + +2001-11-19 Brian S. Dean + + * avr.c, avr.h, avrdude.conf.sample, main.c, ppi.c, term.c: + Add support for ATMega163. + + Add support for reading/writing ATMega163 lock and fuse bits. + Unfortunately, in looking at the specs for other ATMega parts, they + use entirely different instruction formats for these commands. Thus, + these routines won't work for the ATMega103, for example. + + Add support for sending raw command bytes via the interactive terminal + interface. This allows one to execute any programming instruction on + the target device, whether or not avrprog supports it explicitly or + not. Thus, one can use this feature to program fuse / lock bits, or + access any other feature of a current or future device that avrprog + does not know how to do. + + Add in comments, an experimental instruction format in the + configuration file. If this works out, it would allow supporting new + parts and non-orthoganal instructions across existing parts without + making avrprog code changes. + +2001-11-17 Brian S. Dean + + * avrdude.conf.sample: Add ATMEGA163 part. + +2001-11-11 Brian S. Dean + + * main.c: output formatting + +2001-11-05 Brian S. Dean + + * ppi.c: Get ppi.h from /usr/include, not /sys. + +2001-10-31 Brian S. Dean + + * avr.c, avrdude.conf.sample, main.c: Correct version string. + Update read/write status more frequently. + Prefix ATMega parts with an 'm'. + +2001-10-16 Brian S. Dean + + * avr.c: Change ording for memory display. + + * config_gram.y: comment + + * avr.c, avr.h, avrdude.conf.sample, config_gram.y, lexer.l, term.c: + Fix (again, hopefully) page addressing for the ATMega parts. + + Rename the poorly chosen name "bank" to "page" for page addressing. + Atmel calls it "page" in their documentation. + + * config_gram.y, main.c: Fix an (non)exit. + Silence a couple of compiler warnings. + + * avr.c, avr.h, avrdude.conf.sample, config_gram.y, main.c: + Fix ATMega flash addressing. Add an ATMEGA16 part. Perform sanity + checking on the memory parameters for parts that do bank addressing. + +2001-10-15 Brian S. Dean + + * config.c, config.h, lists.h: Add copyright. + + * config_gram.y, lexer.l, lists.c: Add copyrights. + + * Makefile: Attempt to install avrprog.conf. + + * avrdude.conf.sample: Correct dt006 pinout. + + * Makefile, lexer.l: + Try and detect an old-style config file and print an appropriate error + message and a suggestion for correcting it. + + * Makefile, avr.c, avrdude.1, avrdude.conf.sample: Update the man page. + + Miscellaneous minor cleanups. + +2001-10-14 Brian S. Dean + + * Makefile, Makefile.inc, avr.c, avr.h, avrdude.conf.sample: + * config.c, config.h, config_gram.y, lexer.l, lists.c, lists.h: + * main.c, pindefs.h, term.c: + Use lex/yacc for parsing the config file. Re-work the config file + format using a more human-readable format. + + Read part descriptions from the config file now instead of hard-coding + them. + + Update usage(). + + Cleanup unused code. + + * Makefile, avr.c, avr.h, fileio.c, term.c: + First cut at supporting the ATmega 103 which uses bank addressing and + has a 128K flash. + + Due to the bank addressing required, interactive update of the flash + is not supported, though the eeprom can be updated interactively. + Both memories can be programmed via non-interactive mode. + + Intel Hex Record type '04' is now generated as required for outputing + memory contents that go beyond 64K. + +2001-10-13 Brian S. Dean + + * avr.c, avr.h, fileio.c, fileio.h, main.c, ppi.c, ppi.h, term.c: + * term.h: + Style fixes. + + * avr.c, avr.h, fileio.c, fileio.h, main.c, term.c: + Commit changes in preparation for support the ATMega line. + +2001-10-01 Brian S. Dean + + * Makefile: Don't override CFLAGS. + + * avrdude.1: Correct default pin assignment. + + * avr.c, fileio.c, main.c, ppi.c, term.c: + Remove debugging code - it served its purpose. + + Update copyrights. + +2001-09-21 Brian S. Dean + + * main.c: + Be sure to read the exit specs after the pin configuration has been + assigned, otherwise, we may apply the exit specs to the wrong pins. + + * main.c: debugging + +2001-09-20 Brian S. Dean + + * avrdude.1, avrdude.conf.sample, main.c: + Prefix pin config entries in the config file with a "c:". Later, I + might make part descriptions read in this way and we can use a + different letter for those (p). This will make the parsing easier to + distinguish between the entry types. + + * main.c: Initialize pin configuration description. + +2001-09-19 Brian S. Dean + + * AVRprog.pdf, Makefile, avr.c, avrdude.1, avrdude.conf.sample: + * avrdude.pdf, fileio.c, fileio.h, main.c, pindefs.h, term.c: + Make the pin definitions configurable based on entries in a config + file. This makes supporting other programmers much easier. + + Rename AVRprog.pdf to avrprog.pdf. + +2001-04-29 Brian S. Dean + + * avrprog-programmer.jpg: Remove this image file from the repository. + +2001-04-26 Brian S. Dean + + * avrprog-schematic.jpg: + Remove this image, use AVRprog.pdf as the preferred schematic for the + programmer. + +2001-04-25 Brian S. Dean + + * AVRprog.pdf, Makefile, avrdude.1: + Add a schematic provided by Joerg Wunch and also update the manual + page (also updated by Joerg) to reference the schematic. + +2001-02-25 Brian S. Dean + + * Makefile, Makefile.inc: Automate dependency generation. + +2001-02-08 Brian S. Dean + + * main.c: Turn off ready led when finished programming. + + * main.c: update version + + * avr.c, main.c: Correct a few comments. + + * Makefile, avr.c, term.c: Makefile : update dependencies + + avr.c : correct status led updates + + term.c : update status leds on write, make the address and length + arguments for dump optional. + +2001-01-26 Brian S. Dean + + * main.c: Version 1.1 + + * main.c: + Hmmm ... cvs co -D does not work. Change the revision + timestamp to a full date/time value. + + * avr.c, fileio.c, main.c, ppi.c, term.c: + Add a -V option to display the version information about each + component module. This is intended for support purposes, so that I + can tell unambiguously what version a binary out in the field is. + + Additionally, display a revision timestamp along with the version + number. This also is intended for aiding in support and is the Unix + time of the latest component module. Having this, should allow me to + do a "cvs co -D timestamp avrprog" and get exactly the source of the + version that is being reported. + + * fileio.c: + Return the maximum address (+1) written as opposed to the actual + number of bytes written. The presence of an Intel Hex address + record can cause these two number to be different; but the callers + of this routine need the former. + + * main.c: + Fix a place where we were exiting without applying the exit-specs. + + Wrap a long line. + + * avr.c, fileio.c: avr.c: Update a comment. + + fileio.c: Properly handle all the Intel Hex record types that I can + find information about. + +2001-01-25 Brian S. Dean + + * Usage, avr.h: Get rid of the Usage file. + +2001-01-24 Brian S. Dean + + * Makefile, avr.c, avr.h, main.c, pindefs.h, ppi.c: + Move pin definitions to their own file. + + First pass at providing feedback via the optionally connected leds. I + don't actually have any of these attached to my programmer, so I can + only guess as whether this is toggling them on and off correctly. + + Also, enable and disable the optional 74367 buffer. + + * avr.h, main.c, ppi.c, ppi.h, avr.c: + Rearrange the pinout for the programmer to be a little more logical. + Provide hooks to support a buffered programmer, pin 6 is now used to + enable a buffer that can be used to isolate the target system from the + parallel port pins. This is important when programming the target + in-system. + + Totally change the way the pin definitions are defined. Actually + set/clear pins based on the way more intuitive pin number, instead of + PPI data register, bit number combination. A table of pin data is + used so that any hardware inversion done by the parallel port is + accounted for, what you set is actually what appears at the pin. + Retain the old method for handling Vcc, however, because the hold + method is much easier to use when setting / retrieving multiple pins + simultaneously. + +2001-01-22 Brian S. Dean + + * Makefile: Don't gzip the man page. + + * avrdude.1: .Nm macro fix. Submitted by Joerg. + + * main.c: Cosmetic, don't output a preceding linefeed for usage(). + + * Makefile, avr.c, avr.h, fileio.c, term.c: + Makefile : use gzip -f for man page installation so that we don't get + prompted. + + avr.c avr.h fileio.c term.c : + + Change the avrpart data structure so that the typedef AVRMEM is + used as an index into an array for the sizes of the memory types + and also for pointers to buffers that represent the chip data for + that memory type. This removes a lot of conditional code of the + form: + + switch (memtype) { + case AVR_FLASH : + ... + } + + Also, re-code avr_read_byte() and avr_write_byte() to properly + handle the flash memory type without having to tell them whether + they should program the high byte or the low byte - figure that + out from the address itself. For flash memory type, these + routines now take the actual byte address instead of the word + address. This _greatly_ simplifies many otherwise simple + operations, such a reading or writing a range of memory, by not + having to worry about whether the address starts on an odd byte + or an even byte. + +2001-01-20 Brian S. Dean + + * avr.c, avr.h, fileio.c, fileio.h, main.c: + Return error codes instead of exiting, thus making sure that we exit + only via main() so that the exitspecs are properly applied. + + When reading input data from a file, remember how many bytes were read + and write and verify only that many bytes. + + Don't complain when an input file size is smaller than the memory size + we are programming. This is normal. + + * fileio.c: + Correct checksum calculation; failure to account for the value of the + record type was causing non-zero record types to be calculated + incorrectly. + + * Makefile, main.c: Makefile : install the man page + + main.c : drop the giant usage text now that we have a man page. + + * avrdude.1: + Add initial man page graciously contributed by Joerg Wunsch. Thanks + Joerg! + +2001-01-19 Brian S. Dean + + * term.c: + Accept abbreviations for eeprom and flash for the dump and write + commands. + + Fix small bug keeping 1 character command lines from being added to + the history. + + * term.c: + Implement enough state in cmd_dump so that if it is called with no + arguments, it successively dumps the next chunk of data of the same + previously specified length. + + * term.c, term.h, fileio.c, fileio.h, main.c, ppi.c, ppi.h: + * Makefile, avr.c, avr.h, avrprog.c: + The program was getting too large for a single file. Split it up into + more modular pieces. + + Also, accept command abbreviations as long as they are not ambiguous. + + * avrprog.c: + Add ability to specify the state of the power and reset pins on + program exit. Default to leaving the pins in the state they were when + we found them. + + Contributed by: Joerg Wunsch + +2001-01-18 Brian S. Dean + + * Makefile, avrprog.c: + Switch to using readline() for getting terminal input. I can't seem + to get the history capabilities working yet, but even so, it does + better handling of the prompt and strips newlines for us, so it's + still a win. + + Add a few new commands for terminal mode: help, sig, part, erase. + Display rudimentory help using the help command. + + Add some function prototypes. + + * Usage, avrprog.c: + Change -c (interactive command mode) to the more intuitive -t + (terminal mode). + + Make binary format the default for output. + + Update the parts table with corrections for old values and add some + new values. + +2001-01-15 Brian S. Dean + + * avrprog.c: + Automatically verify on-chip data with what we just programmed. + + * avrprog.c, Makefile: + Prepare the Makefile for integration into the FreeBSD ports tree. + + Fix a few "may be used uninitialized" bugs found by -Wall. + +2001-01-14 Brian S. Dean + + * avrprog.c: Free a buffer. + + * avrprog.c: + Use a smarter programming algorithm - read the existing data byte + first and only write the new one if it is different. + + Add -n option which is a test mode in which the chip is not actually + updated. This option does not affect writes in interactive mode. + + * avrprog.c: Add the "dump" and "write" interactive commands. + + * avrprog.c: + Correctly produce and handle "end of record" for intel hex files. + +2001-01-13 Brian S. Dean + + * avrprog.c: + Re-enable writing to the chip. I should probably should make this a + command-line selectable option so that I don't keep forgetting and + committing it with it disabled. + + * avrprog.c: + Add a newline before exiting due to command line errors. Perform a + bit more option compatibility testing between -c, -i, and -o. + + * avrprog.c: Add input file format auto-detection support. + + * Usage, avrprog.c: Say what the defaults are. + + * avrprog-programmer.jpg, Usage, avrprog-schematic.jpg: New files. + + * avrprog.c: Correct usage text. + + * avrprog.c: + Parameterize a few additional items per chip. Print out all per-chip + parameters on startup. Use the per-chip parameters in the code + instead of hard-coded values for the 2313. + + * avrprog.c: Fix filename assignment error. + + Clean up debugging code a little, utilize fileio() instead of making + direct calls to b2ihex(). + + * avrprog.c: A lot of general code cleanup. + + Re-work command line options to be more intuitive. + + Support Intel Hex input and output file formats. Provide hooks to + support Motorola S-Record as well. + + Add a few more part-specific parameters to the avrpart structure. + + Only write the flash or eeprom if the data to be written is not 0xff. + +2000-12-31 Brian S. Dean + + * avrprog.c: Update a comment. + + * avrprog.c: + Provide the ability to tie additionally tie pins 6-9 of the parallel + port to Vcc in order to supply more current. + + Fix a typo on the size of the S1200's Flash. + + Bring RESET low when programming is completed. + + * avrprog.c: + Correct pin connection comments. Elaborate a bit on Vcc connection. + + * avrprog.c: + Update after receiving some good feedback from Joerg Wunsch. We + should now be able to program AT90S1200's. + +2000-12-30 Brian S. Dean + + * avrprog.c: Don't limit eeprom addresses. + +2000-12-20 Brian S. Dean + + * Makefile, avrprog.c: + Add support for the 8515. Make the addition for other devices easier. + +2000-08-27 Brian S. Dean + + * avrprog.c: + Clear all bits except AVR_RESET when finished reading or programming + the Atmel device. + +2000-08-07 Brian S. Dean + + * avrprog.c: update announcement message + + * avrprog.c: Update announcement message. + + * avrprog.c: Return the correct return code from 'main()'. + + * avrprog.c: + Add ppi_pulse() function and fix ppi_toggle() to actully toggle + instead of pulse. + + Make all abnormal returns after the parallel port has been opened go + through a single exit point at the bottom of 'main()'. + +2000-08-06 Brian S. Dean + + * Makefile, avrprog.c: Makefile: add --pedantic compiler option + + avrprog.c: + + Add lots of comments, move getop() variable declarations to + the top of the program. + + Add a typedef name to the AVR memory type and use it for + function declarations. + + Add a usleep() delay in the sense loop to avoid becoming a cpu + hog. + + Print out a version string so that folks know what version of + the software they are running. + + Be sure and close the parallel device and the i/o file when + terminating abnormally. + + * avrprog.c: Print out version information when invoked. + + * Makefile, avrprog.c: Makefile: Add an install target. + + avrprog.c: + + Add license. + + Document the header a bit better. + + Add capability to read out and display the device signature bytes. + + Add capability to power the device from the parallel port. + + Eliminate debug print facility. + + Provide 'avr_cmd()' function. + + When memory locations don't program, generate a newline so that the + information is not overwritten and lost. + + Don't print out the message about needing to specify a file if the + user is not requesting an operation that requires the file. + +2000-08-05 Brian S. Dean + + * avrprog.c: Pring usage when no arguments are supplied. + + * Makefile, avrprog.c: Initial check-in + + * Makefile, avrprog.c: New file. + diff --git a/xs/src/avrdude/ChangeLog-2002 b/xs/src/avrdude/ChangeLog-2002 new file mode 100644 index 000000000..9bfa030a9 --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2002 @@ -0,0 +1,237 @@ +2002-12-12 Brian S. Dean + + * main.c: minor cleanup + +2002-12-07 Brian S. Dean + + * avrdude.1, main.c: + If the stk500 is being used, default to using the first serial port. + +2002-12-03 Brian S. Dean + + * avrdude.1: Mention STK500 support. + +2002-12-01 Brian S. Dean + + * stk500.c: Remove unused code. + + * CHANGELOG, stk500.c: + Document changes since the previous version in the CHANGELOG. + + Cleanup stk500.c a bit. + + * stk500.c: Fix cut and paste braino. + + * avr.c, avrdude.conf.sample, main.c, pgm.h, stk500.c: + The STK500 can perform paged read/write operations even on standard + "non-paged" parts. Take advantage of that and use the faster internal + routines of the STK500 for those parts as well. + + * avr.c, avr.h, avrpart.h, main.c, pgm.c, pgm.h, stk500.c: + Optimize reading and writing for the STK500 programmer if the part + supports paged reads and writes. This greatly decreases the + program/verify time from about 4.5 minutes down to about 10 seconds in + a 12K program size test case. + + Print out the hardware and firmware version for the STK500 if verbose + is enabled. + + * avrdude.conf.sample, avrpart.h, config_gram.y, lexer.l, pgm.h: + * ppi.c, ppi.h, stk500.c, stk500.h, stk500_private.h: + Add basic support for STK500. + +2002-11-30 Brian S. Dean + + * avrdude.conf.sample, config.c, config.h, config_gram.y, lexer.l: + * main.c, pgm.c, pgm.h, ppi.c, ppi.h, term.c, term.h, Makefile: + * avr.c, avr.h: + Seperate programmer operations out into a driver-like interface so + that programmers other than the direct parallel port connection can be + supported. + +2002-11-23 Brian S. Dean + + * CHANGELOG, main.c, term.c: + term.c - when in interactive terminal mode and dumping memory using + the 'dump ' command without any address information, + and the end of memory is reached, wrap back around to zero on + the next invocation. + + CHANGELOG - describe changes + + main.c - update version number + + * main.c: + When getting ready to initiate communications with the AVR device, + first pull /RESET low for a short period of time before enabling the + buffer chip. This sequence allows the AVR to be reset before the + buffer is enabled to avoid a short period of time where the AVR may be + driving the programming lines at the same time the programmer tries + to. Of course, if a buffer is being used, then the /RESET line from + the programmer needs to be directly connected to the AVR /RESET line + and not via the buffer chip. + +2002-11-06 Brian S. Dean + + * CHANGELOG: Update changelog. + + * avr.c, avr.h, main.c: Fix -Y option. Reported by Joerg Wunsch. + +2002-11-01 Brian S. Dean + + * CHANGELOG, main.c: Version update and CHANGELOG entry. + + * avr.c: + Be backward compatible with the 2-byte rewrite cycle counter which + appeared in version 2.1.0, but was changed to a 4 byte counter in + version 2.1.1. Reminded by Joerg Wunsch. + +2002-10-29 Brian S. Dean + + * CHANGELOG, avrdude.1, main.c: + Add '-V' (no verify) flag requested by Joerg Wunsch. Update the man + page. + +2002-10-13 Brian S. Dean + + * CHANGELOG, avrdude.1: Update man page and changelog. + + * main.c: Update version number. + +2002-10-12 Brian S. Dean + + * Makefile: Remove --pedantic and -g from the compiler options. + +2002-10-11 Brian S. Dean + + * avr.c, term.c: + Use a four byte value instead of a two byte value for the programming + cycle count stored at the end of EEPROM. It seems as though Atmel was + greatly conservative in claiming a 1000 count reliability for the + FLASH. I current have a part that has been reprogrammed 173330 times, + and counting. + + Fix a compiler warning. + + * avrdude.conf.sample: + Fix ATMega128 instruction encoding for reading the low and high fuse + bits. Thanks to Joerg Wunsch for tripping over this. + +2002-08-01 Brian S. Dean + + * avr.c, avrdude.1, main.c: + Move erase-rewrite cycle increment to within the chip erase routine so + that it is tracked no matter where the erase was initiated: command + line mode or interactive mode, without code duplicaiton. + + * CHANGELOG: Recent updates. + + * avr.c: Eliminate unused variables. + + * avr.c, avr.h, avrdude.1, fileio.c, main.c: + Implement a way of tracking how many erase-rewrite cycles a part has + undergone. This utilizes the last two bytes of EEPROM to maintain a + counter that is incremented each time the part is erased. + +2002-07-27 Brian S. Dean + + * avr.c, main.c: + Fix a typo in a comment. Display the size of memory being written. + Display the correct memory name in an error message (previously + hardcoded). + +2002-06-22 Brian S. Dean + + * CHANGELOG, avrdude.conf.sample: + Add support for ATtiny15 - contributed by Asher Hoskins + + +2002-04-23 Brian S. Dean + + * CHANGELOG: Say what changed. + +2002-04-07 Brian S. Dean + + * Makefile, avrdude.conf.sample: + Backup the config file to a timestamped name to keep from possibly + overwriting user-modified configs. + + Add read/write instructions for all memory types for ATMEGA103, + ATMEGA128, ATMEGA16, and ATMEGA8. + +2002-04-05 Brian S. Dean + + * avrdude.conf.sample: + Add support for ATMEGA128; untested; requested by Jeff Gardner + . + +2002-02-15 Brian S. Dean + + * avrdude.conf.sample: Minor ordering. + + * CHANGELOG, main.c: Update version numbers. + +2002-02-14 Brian S. Dean + + * CHANGELOG: Summarize latest updates. + + * avrdude.conf.sample, config_gram.y: + Make pwroff_after_write a yes/no field instead of a numeric. + + * avrdude.conf.sample: Document the pwroff_after_write flag. + + * avr.c: Enable the extra part verbosity when verbosity >= 3. + + * avr.c, avr.h, avrdude.conf.sample, config_gram.y, lexer.l: + * main.c, term.c: + Fix error reporting by avr_write_byte(). + + Fix setting of status LEDs under various write-fail conditions. + + Add a flag to indicate that a memory type requires the device to + possibly be powered off and back on after a write to it. This is due + to a hardware problem on some Atmel devices, see: + + http://www.atmel.com/atmel/acrobat/doc1280.pdf + + Add greater verbosity to the part-display code when verbose>1 to + display avrprog's encoding of the defined programming instructions. + This is primarily for debugging purposes. + + + Part updates: + + * add the AT90S4414 part + + * add fuse and lock bit access instructions for the AT90S1200, + AT90S4434, and AT90S8515. + + * add the pwroff_after_write flag to the fuse bits for the AT90S2333 + and AT90S4433 parts + +2002-02-09 Brian S. Dean + + * avrdude.conf.sample: + Updates to the 2333 and 4433 parts, contributed by Joerg Wunsh. + +2002-01-18 Brian S. Dean + + * CHANGELOG: Add changelog. + +2002-01-12 Brian S. Dean + + * main.c: Add (c) to copyright. + + * fileio.c, fileio.h, lexer.l, lists.c, lists.h, main.c: + * pindefs.h, ppi.c, ppi.h, term.c, term.h, avr.c, avr.h: + * config.c, config.h, config_gram.y: + Update version number. Update copyright. + + * avrdude.1: Update copyright and add description of "default". + + Submitted by: Joerg Wunsch + + * avr.c, term.c: + Fix programming of write-only memories (such as lock bits on the + 2313). + diff --git a/xs/src/avrdude/ChangeLog-2003 b/xs/src/avrdude/ChangeLog-2003 new file mode 100644 index 000000000..1115bdfbc --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2003 @@ -0,0 +1,1095 @@ +2003-12-01 Eric B. Weddington + + * doc/avrdude.texi: Update devices and programmers supported. + +2003-12-01 Eric B. Weddington + + * doc/avrdude.texi: Add missing -D option to user manual. + [This fixes bug #6804] + +2003-11-30 Jan-Hinnerk Reichert + + * avrpart.c,main.c: Moved list_parts() and locate_part() + from main.c to avrpart.c. + * avrpart.h: Added prototypes for list_parts() and + locate_part(). + +2003-11-30 Jan-Hinnerk Reichert + + * avrpart.c, avr.c: Moved elementary functions on types + OPCODE, AVRMEM and AVRPART from avr.c to new file avrpart.c. + * avr.h: Removed prototypes for moved functions. + * avrpart.h: Added prototypes for functions in avrpart.c. + * Makefile.am: Added new file avrpart.c. + +2003-11-28 Michael Mayer + + * lexer.l: New programmer type "butterfly". + * config_gram.y: New token K_BUTTERFLY. + * avrdude.conf.in: Added programmer definition. + * butterfly.c, butterfly.h: Cloned from avr910.?, changed to work + with the Atmel Butterfly device. + * Makefile.am: Added butterfly.[ch] to avrdude_SOURCES. + +2003-11-26 Joerg Wunsch + + * main.c: Make the -U parser tolerate colons in filenames. + * avrdude.1, doc/avrdude.texi: Document the -U changes. + +2003-11-21 Jan-Hinnerk Reichert + + * ppi.c: Major speed tuning. Since ioctl() is expensive read from + shadowregisters where possible. + +2003-11-19 Eric B. Weddington + + * NEWS: Update news from items in ChangeLog. + +2003-11-19 Theodore A. Roth +[Contributed by Jan-Hinnerk Reichert ] + + * avr.c (avr_write_byte_default): Improve polling algorithm to speed up + programming of byte oriented parallel programmers. + +2003-11-14 Brian S. Dean +[Contributed by Erik Christiansen ] + + * avrdude.conf.in: + Add ATmega64 part. + +2003-11-08 Joerg Wunsch + + * avrdude.conf.in: + Add "fuse" and "lock" definitions for the AT90S8535. Actually, + this is stolen from the AT90S8515 since the datasheet says it's + the same there. + +2003-10-13 Bill Somerville + + * stk500.c (stk500_paged_write): Limit blocks written to no bigger + than memory device size. + (stk500_paged_write): Send whole block at once. + (stk500_paged_load): Limit blocks read to no bigger than memory + device size. + [This fixes bug #5713.] + +2003-10-13 Eric B. Weddington + + * avrdude.conf.in: Fix for unterminated character error. + +2003-10-13 Eric B. Weddington + + * avrdude.conf.in: Add ATmega8515 definition. + Contributed by: Matthias Weißer + * NEWS: Add note about ATmega8515 definition. + +2003-09-24 Eric B. Weddington + + * doc/TODO: Updated TODO list. + +2003-09-22 Eric B. Weddington + + * windows/Makefile.am: Correct makefile so loaddrv does not link + to Cygwin DLL. + +2003-09-18 Eric B. Weddington + + * doc/avrdude.texi: Minor corrections. Change description of -P + to reference platform dependencies. + +2003-09-16 Eric B. Weddington + + * stk500.c: If writing flash, skip empty pages in paged write. + +2003-09-06 Theodore A. Roth + + * NEWS: Add 'Current:' header. + * configure.ac (AC_INIT): Add cvs back to version since we're + back in dev cycle (post release). + +2003-09-06 Theodore A. Roth + + * AVRDUDE 4.2.0 has been released (cvs release tag is "release_4_2_0"). + +2003-09-06 Theodore A. Roth + + * NEWS: Update for 4.2.0 release. Add note about read/write of fuses + support for avr910. + * configure.ac (AC_INIT): Set version to 4.2.0. + +2003-09-05 Theodore A. Roth +[Contributed by Jan-Hinnerk Reichert ] + + * avr.c (avr_read_byte): If pgm->read_byte method fails, retry with + avr_read_byte_default. + * avr.c (avr_write_byte): If pgm->write_byte method fails, retry with + avr_write_byte_default. + * avr910.c (avr910_cmd): Implement using universal command. + +2003-09-04 Theodore A. Roth + + * Makefile.am: Change AM_CPPFLAGS to avrdude_CPPFLAGS. + Define avrdude_CFLAGS. + * configure.ac: Set ENABLE_WARNINGS to "-Wall" if using gcc. + +2003-09-02 Eric B. Weddington + + * doc/avrdude.texi: Add note about privileges needed to load + the giveio driver for Windows. + +2003-08-29 Brian S. Dean + + * avrdude.1: + * main.c: + Perform an auto erase before programming if the flash memory is + anywhere specified to be written by any of the -U requests. + + To remain backward compatible with previous versions, disable this + feature if any of the old-style memory specification operations are + specified (-i, -o). + + Implement the -D option to explicitly disable the auto erase default. + + Deprecate the old-style memory specification options (-f, -i, -I, -m, + and -o) in favor of the new -U option which allows one to operate on + multiple memories on a single command line. + +2003-08-28 Eric B. Weddington + + * avr910.c: + * fileio.c: + * main.c: + * stk500.c: + More code cleanup to remove warnings. + +2003-08-27 Theodore A. Roth + + * main.c (update_progress_no_tty): Properly terminate progress. Also + fixes stk500 problem where number of bytes written is less than a page. + +2003-08-27 Theodore A. Roth + + * avrdude.spec.in: Fix broken rpmbuild on RedHat-9. + +2003-08-25 Eric B. Weddington + + * fileio.c: + * main.c: + * ppiwin.c: + * ser_posix.c: + * stk500.c: + Minor code cleanup to remove warnings. + +2003-08-21 Brian S. Dean + + * avrdude.1: + * main.c: + + Introduce a new option, -U, for performing memory operions. + Its argument is a 4 field string (fields seperated by colons) + which indicate what memory type to operate on, what operation + to perform is (read, write, or verify), the filename to read + from, write to, or verify against, and an optional file format + field. Multple -U options can be specified to operate on more + than one memory at a time with a single invocation. For + example, to update both the flash and the eeprom at the same + time one can now specify the following: + + avrdude -p -e -U flash:w:main.hex:i -U eeprom:w:eeprom.hex:i + +2003-08-20 Brian S. Dean + + * ppiwin.c: + Timing related fixes for the Windows platform. Several folks have + reported that this patch fixes verify errors on the Windows platform + that are apparently timing related. Submitted by: Alex Shepherd + , who indicates that this patch was based on + code from the UISP project. + +2003-08-01 Theodore A. Roth + + * avrdude.1: Document the -q option. + * doc/avrdude.texi: Document the -q option. + Fix some typos left over from pasting in man output. + +2003-07-30 Brian S. Dean + + * main.c: Add elapsed time information to the new progress bar. + +2003-07-29 Theodore A. Roth + + * avr.c: + * avr.h: + * avr910.c: + * main.c: + * stk500.c: + New progress reporting implementation. + +2003-07-24 Joerg Wunsch + + * avrdude.1: + * doc/avrdude.texi: + * pgm.c: + * pgm.h: + * stk500.c: + * stk500_private.h: + * term.c: Add support for displaying and setting the various + operational parameters of the STK500 (Vtarget, Varef, clock). + +2003/07/22 Brian S. Dean + + * avrdude.conf.in: + Add 'picoweb' programming cable programmer. + Contributed by Rune Christensen . + +2003-06-18 Brian S. Dean + + * avrdude.conf.in: + Add the 'sp12' (Steve Bolt's) programmer. + Submitted by Larry Barello . + +2003-06-17 Brian S. Dean + + * avrdude.conf.in: + Properly identify the "ALF" programmer. + + Extend ATmega8 calibration memory to support all 4 calibration bytes. + Savannah bug #3835. Submitted by Francisco T. A. Silva + . + + Add a few AVR910 programmer device codes. Savannah bug #3569 - sorry + I can't tell who submitted this to give proper credit. + + Add support for the ATtiny12. Submitted by Pontifex + +2003-05-22 Brian S. Dean + + * avr.c: + * avr.h: + * fileio.c: + Optimize flash memory handling a little bit by ignoring 0xff data that + resides above the last non-0xff data value in the address space. Only + do this for flash memory since writing a 0xff to flash is a no-op. + This has the affect of creating smaller output files when dumping + memory contents from flash if the program in flash does not consume + the whole memory space. It also results in shorter programming times + when avrdude is asked to load a file into flash that has lots of 0xff + filled data past the last non-0xff data value. + +2003-05-13 Theodore A. Roth + + * avr910.c (avr910_paged_write_flash): Add code to send the 'm' + command ("issue page write" cmd) for each page. + +2003-05-13 Theodore A. Roth + + * avrdude.conf.in: Add pagel and bs2 entries for at90s1200 device. + +2003-05-13 Theodore A. Roth + + * doc/TODO: Add note about avr910 device codes. + +2003-05-04 Theodore A. Roth + + * configure.ac: Check for ncurses library (since it can be a + replacement for termcap). + +2003-05-02 Theodore A. Roth + + * avrdude.conf.in: Add avr decodes for devices known in avr910 + firmware version 2.3. + Add missing stk500 devocde for 2343. + +2003-04-23 Eric B. Weddington + + * fileio.c: Fix for bug #3293. Set correct open mode for raw format + for Windows. + +2003-04-19 Brian S. Dean + + * avrdude.1: + * fileio.c: + * fileio.h: + * main.c: + Implement and "immediate mode" for file input - this allows + one to specify byte values on the command line instead of via + a file. This can be good for specifying fuse bytes and + eliminates the need to create single-byte files or using + interactive terminal mode for these single-byte memories. + Requested by several folks on the mailing list. + +2003-04-18 Theodore A. Roth + + * configure.ac: Add cvs suffix back to version. + * doc/TODO: Add a few items. + +2003-04-18 Theodore A. Roth + + * AVRDUDE 4.1.0 has been released (cvs release tag is "release_4_1_0"). + +2003-04-17 Theodore A. Roth + + * configure.ac: Set version to 4.1.0. + * doc/avrdude.texi: Add note about avr910 programmer type. + +2003-04-17 Eric B. Weddington + + * NEWS: Replace TBD with new release version. + +2003-04-17 Eric B. Weddington + + * avrdude.conf.in: Change name of pony programmer to pony-stk200 + to better describe the hardware (PonyProg is software that works + with various hardware). + +2003-04-16 Eric B. Weddington + + * avrdude.conf.in: Add support for ATtiny26 + Submitted by Artur Lipowski + * NEWS: List new devices supported: ATtiny26 + +2003-04-16 Eric B. Weddington + + * avrdude.conf.in: Add support for ATmega8535 + Submitted by Alexander Peter + * NEWS: List new devices supported: ATmega8535 + +2003-04-09 Theodore A. Roth + + * avr910.c: Reading a 16 bit word in paged load needs to swap the + bytes since the 'R' command returns MSB first and the internal buffer + stores LSB first. + +2003-04-07 Theodore A. Roth + + * stk500.c: Don't print out read/write byte progress unless the verbose + option is given. + +2003-04-05 Theodore A. Roth + + * avr910.c: Re-add the avr910 byte read/write methods which were + removed in my previous patch. Terminal mode read/writes are broken + without those methods. D'oh! + +2003-04-05 Theodore A. Roth + + * avr910.c: Refactor to allow probing for auto addr increment. If auto + incr supported by programmer hw, don't send addr for every byte. + +2003-04-03 Eric B. Weddington + + * confwin.c: Fix bug that allows garbage for non-existent user + config filename on Windows. + +2003-03-29 Brian S. Dean + + * avrdude.conf.in: + Add the ATmega32 part. This part definition was contributed by: + Daniel Williamson and + Ruwan Jayanetti + The resulting part definition used was actually somewhat of a merge of + the two submitted definitions. + +2003-03-24 Theodore A. Roth + + * NEWS: Add note about avr910 support. + +2003-03-23 Theodore A. Roth + + * avr.c (avr_write): Add call to pgm->write_setup() before the write + loop. + * avr910.c: Change all show_func_info() calls to no_show_func_info(). + Add read/write to/from flash/eeprom memory functionality. + * pgm.c: Initialize pgm->write_setup. + * pgm.h: Add write_setup field to PROGRAMMER structure. + * ser_posix.c: Remove unneeded cast in verbosity code. + +2003-03-23 Theodore A. Roth + + * ser_posix.c: Limit verbose output to 2 chars. + +2003-03-23 Theodore A. Roth + + * ser_posix.c: Add verbose level > 3 output for send and recv functions. + +2003-03-23 Theodore A. Roth + + * avr.c: Add avr_read_byte_default(). + Have avr_read_byte() call pgm->read_byte() or avr_read_byte_default(). + Add avr_write_byte_default(). + Have avr_write_byte() call pgm->write_byte or avr_write_byte_default(). + * pgm.c: Initialize pgm->write_byte and pgm->read_byte. + * pgm.h: Add write_byte and read_byte fields to struct programmer_t. + +2003-03-17 Theodore A. Roth + + * avrdude.conf.in: Fix typo for devicecode deprecation comment. + +2003-03-17 Eric B. Weddington + + * avrdude.conf.in: Add Bascom SAMPLE programmer. + Submitted by Larry Barello + +2003-03-16 Theodore A. Roth + + * avr.c (avr_read): Use pgm->read_sig_bytes to read signature bytes if + available. + * avr910.c (avr910_vfy_cmd_sent): New function. + (avr910_chip_erase): Add support for chip erase. + (avr910_enter_prog_mode): New function. + (avr910_leave_prog_mode): New function. + (avr910_initialize): Add code to select device type and enter prog mode. + (avr910_close): Leave programming mode before closing serial port. + (avr910_read_sig_bytes): New function. + (avr910_initpgm): Add avr910_read_sig_bytes method to pgm initializer. + * avrdude.conf.in: Add note about deprecating devicecode. + Change all occurences of devicecode to stk500_devcode. + Add avr910_devcode to a few parts for testing. + * avrpart.h (struct avrpart): Change devicecode field to stk500_devcode. + (struct avrpart): Add avr910_devcode field. + * config_gram.y: Add K_STK500_DEVCODE and K_AVR910_DEVCODE tokens. + Generate an error if devicecode is found in the config file. + Handle parsing of avr910_devcode and stk500_devcode. + * lexer.l: Handle parsing of avr910_devcode and stk500_devcode. + * pgm.c: Initialize pgm->read_sig_bytes field. + * pgm.h: Add pgm->read_sig_bytes field. + * stk500.c: Use stk500_devcode instead of devicecode. + +2003-03-16 Theodore A. Roth + + * avrdude.conf.in: Add avr910 and pavr programmers. + * config_gram.y: Add parsing of avr910 programmer. + * lexer.l: Add avr910 token. + * avr910.c: [this is still work in progress] + Add some debug output. + Add probe for programmer presense. + * main.c: Set port to default_serial if programmer type is avr910. + +2003-03-13 Theodore A. Roth + + * ser_posix.c, ser_win32.c, serial.h: + Change baud from int to long to avoid a 16-bit int overflow. + +2003-03-12 Theodore A. Roth + + * Makefile.am (avrdude_SOURCES): Add avr910.[ch], serial.h and + ser_posix.c files. + * avr910.c: New file (stubs for avr910 serial programmer). + * avr910.h: New file. + * ser_posix.c: New file. + * ser_win32.c: New file (just stubs for now). + * serial.h: New file. + * stk500.c: Move all the code for accessing the posix serial ports + into ser_posix. This will make a native win32 port easier and allows + the avr910 programmer to share the serial code. + +2003-03-12 Theodore A. Roth + + * configure.ac (AC_INIT): Set version to 4.0.0cvs since we're done + with 4.0.0 release. + +2003-03-12 + + * AVRDUDE 4.0.0 has been released (cvs release tag is "release_4_0_0"). + +2003-03-11 Theodore A. Roth + + * Makefile.am: Add CLEANFILES to remove all files from a make. + * doc/Makefile.am: Ditto + +2003-03-11 Theodore A. Roth + + * windows/Makefile.am: Fix uninstall-local rule (forget the $$file + part of the rm command). + +2003-03-11 Theodore A. Roth + + * AUTHORS: Updated. + * CHANGELOG: Move contents to NEWS and remove file. + * ChangeLog: All of the changes for this year. + * ChangeLog-2001: All 2001 changes. + * ChangeLog-2002: All 2002 changes. + * Makefile.am (EXTRA_DIST): Remove CHANGELOG and and Change-200[12]. + * NEWS: Moved contents of CHANGELOG file here. + * README: Add note pointing to savannah site. + +2003-03-11 Eric Weddington + + * doc/avrdude.texi: + Add Install and Documentation sections for Windows. Fix typo. + +2003-03-10 Theodore A. Roth + + * Makefile.am: * Makefile.am (EXTRA_DIST): Add CHANGELOG. + +2003-03-10 Brian S. Dean + + * stk500.c: Disable debugging printf. + + * configure.ac: Update version number in preparation for release. + +2003-03-10 Theodore A. Roth + + * doc/avrdude.texi: + Add comment before each node to make them stand out better. + Use @option{} command for options instead of @code{}. + Merge FreeBSD and Linux platform dependent information. + +2003-03-10 Brian S. Dean + + * avrdude.1: Minor man page updates to better reflect reality. + +2003-03-10 Joerg Wunsch + + * bootstrap: + Export all the AUTO* variables. Hopefully, that way the generated + Makefile might get them correctly. + + * bootstrap: + Export ${AUTOCONF} so automake will find it by whatever name it will be + called today. + +2003-03-06 Eric Weddington + + * doc/avrdude.texi: + Add notes about ability to list parts and list programmers in the + config file in -p and -c descriptions. Change info about where to + find Windows search method in -C description. + + * main.c: + Change software version from hardcoded value to getting it from + the configuration. + +2003-03-06 Theodore A. Roth + + * avrdude.spec.in: * avrdude.spec.in: Add docs sub-package. + Add %post and %preun scriptlets for handling info files. + + * configure.ac, doc/Makefile.am: + * configure.ac: Add --enable-versioned-doc option and set DOC_INST_DIR. + * doc/Makefile.am: Add rules to install docs in DOC_INST_DIR. + + * doc/Makefile.am: + Delete the lines which where commented out in previous commit. + + * configure.ac, doc/Makefile.am: + * configure.ac: Remove hack to make work with automake-1.5. + * doc/Makefile.am: Remove extra rules that were needed to work with + automake-1.5. + + * bootstrap: + * bootstrap: Force use of autoconf-2.57 and automake-1.7.x. + +2003-03-05 Joerg Wunsch + + * avrdude.conf.in: Add a definition for the popular Ponyprog dongle. + + Submitted by: Daniel Williamson + +2003-03-05 Brian S. Dean + + * main.c: + Check the programmer type against 'STK500' instead of the programmer + name when checking to see if we should default to the default_serial + port instead of the default_parallel port. This has us do the right + thing for the new 'avrisp' programmer. + + * stk500.c: + Make the page size used for non-paged parts for the 'paged_write' + command be 128 bytes. This cuts 6 seconds off the programming time + for uploading a 6K file into an AT90S8515 vs the time loading the same + file using a 16 byte buffer, and the response feedback is still good. + + * avr.c, stk500.c: + Fix stk500 page write (Program Page command). This is supported after + all on non-paged-memory parts. The problem was that the page size was + defaulting to 256 (maximum for the stk500), but the timeout for a + response from the stk500 before declaring it dead was only 0.5 + seconds. But it takes much longer than 0.5 seconds to program 256 + bytes, so we just weren't waiting long enough. + + Fix this in two ways - increase the timeout to 5 seconds, and decrease + the page size to 16 bytes for non-paged parts. The programming time + for 16 bytes is short enough to provide the user with some feedback + that something is happening. + + * avr.c, stk500.c: + Don't call the programmer's 'paged_write' routine unless the memory + itself is paged as it doesn't appear to work otherwise. + + * avrdude.conf.in: Fix device codes for at90s8515 and at90s8535. + + * avrdude.conf.in: + Add PAGEL and BS2 parms for parts I have datasheets for. + + * config_gram.y: + Do that last commit slightly differently - this way results in no + shift-reduce conflicts. + + * config_gram.y: + It shouldn't be an error to have an empty configuration file. This + causes some shift-reduce conflicts, but I think they are OK. + + * main.c: + Print out a list of valid parts for '-p ?' and a list of valid + programmers for '-c ?'. + +2003-03-04 Eric Weddington + + * doc/avrdude.texi: Minor Windows doc corrections. + + * doc/TODO: Add TODO file. + + * avrdude.conf.in: Add AVR ISP programmer. + +2003-03-04 Brian S. Dean + + * stk500.c: + Don't try to set extended device programming parameters if they + haven't been specified in the config file for the part. + + * stk500.c: Set extended device parameters for all firmware versions. + + * stk500.c: + First attempt at supporting STK500 firmware past 1.10. Thanks to + Jason Kyle for the needed protocol information. + +2003-03-03 Theodore A. Roth + + * doc/Makefile.am: + * doc/Makefile.am: Add ps and pdf rules since they aren't supplied by + automake versions prior to 1.7. + + * doc/avrdude.texi: + * doc/avrdude.texi: Add node and menu information for the info system. + + * Makefile.am, configure.ac, doc/Makefile.am, doc/avrdude.texi: + * Makefile.am (SUBDIRS): Add doc dir. + * configure.ac (AC_CONFIG_FILES): Add doc/Makefile. + * doc/Makefile.am: New file. + * doc/avrdude.texi: Use automatically generated version.texi. + +2003-03-02 Brian S. Dean + + * doc/avrdude.texi: Initial manual. + +2003-02-27 Theodore A. Roth + + * term.c: * term.c: Use fgets() if readline() is not available. + +2003-02-27 Joerg Wunsch + + * bootstrap: + Oops, accidentally spammed the repository with my private version of + "bootstrap". Back out that change. + + * bootstrap, lexer.l: + Ignore \r as white space, to make the Windows people happy. + +2003-02-27 Theodore A. Roth + + * Makefile.am (EXTRA_DIST): Add avrdude.spec and make entries one + per line so future patches are obvious as to what changed. + * avrdude.spec.in: New file to support creation of binaries in rpm + format. + * configure.ac (AC_OUTPUT): Add avrdude.spec. Reorder so that + Makefile is the last entry. + +2003-02-26 Theodore A. Roth + + * Makefile.am (SUBDIRS): Add windows dir. + * configure.ac: If $target is a windows system, build whats in + windows sub dir. + * windows/Makefile.am: New file. + +2003-02-25 Theodore A. Roth + + * ChangeLog: Point reader to the CHANGELOG file. + * Makefile.am (EXTRA_DIST): Rename avrdude.conf.sample to + avrdude.conf.in. + Remove avrdude.conf and distclean-local rules. + Add install-exec-local and backup-avrdude-conf rules. + * avrdude.conf.in: + Set default_parallel to "@DEFAULT_PAR_PORT@" for autoconf expansion. + Set default_serial to "@DEFAULT_SER_PORT@" for autoconf expansion. + * configure.ac: Add call to AC_CANONICAL_{BUILD,HOST,TARGET} macros. + Set DEFAULT_PAR_PORT and DEFAULT_SER_PORT based on $host. + Add copyright header. + Define avrdude_version so AC_INIT and AM_INIT_AUTOMAKE are sure + to get the same version. + + * avrdude.conf.in, avrdude.conf.sample: + Renamed avrdude.conf.sample to avrdude.conf.in. + +2003-02-25 Eric Weddington + + * ppiwin.c: CRs again. + + * confwin.c, confwin.h: Get rid of CRs. + + * main.c, Makefile.am: Get rid of CRs again. + +2003-02-24 Joerg Wunsch + + * avrdude.1: Atmel has rearranged their web site, so now the AVR + docs have been moved to a more logically sounding URL. + +2003-02-24 Eric Weddington + + * Makefile.am, main.c: Integrate Windows search of config files. + + * confwin.c, confwin.h: config file search on Windows. + + * ppiwin.c: Change port value from lpt1alt to lpt3. Other + formatting changes. + + * windows/giveio.c: + Add giveio device driver source. Requires MS DDK to build. + + * windows/giveio.sys: Add giveio device driver binary. + + * giveio.sys, install_giveio.bat, remove_giveio.bat, status_giveio.bat: + Move Windows specific files. + + * windows/loaddrv.c, windows/loaddrv.h, windows/remove_giveio.bat: + * windows/status_giveio.bat, windows/install_giveio.bat: + Add Windows specific files. + + * main.c: Usage back to stderr. + +2003-02-22 Brian S. Dean + + * CHANGELOG: Add note about .avrduderc. + + * avr.c, avrdude.conf.sample, avrpart.h, config_gram.y, main.c, + * par.c, pgm.c, pgm.h: + Add the ability to read a per-user config file located at + $HOME/.avrduderc. Entries from .avrduderc take precedence over those + from the system wide config file in ${PREFIX}/etc/avrdude.conf. + + Track and display the config file name and line number when we print + out the available parts and programmers. This is useful in case + someone has overridden a definition in their .avrduderc file and is + wondering why the definition in the system wide config file is not + being used. + + Remove the default programmer 'stk500' from the distributed config + file. + + * CHANGELOG: Spelling. + +2003-02-21 Brian S. Dean + + * CHANGELOG: + Put some stuff in the CHANGELOG for this upcoming new version before I + forget. + + * main.c: + Update comment due to removal of the default parallel port pin config. + + * config.c, config.h, config_gram.y, lexer.l, main.c: + * avrdude.conf.sample: + Introduce 'default_programmer' to the config file instead of requiring + one of the programmers to be tagged "default" within its definition. + + Also, axe the notion of a compiled-in default programmer. It is + kind've pointless now that nearly all configuration comes from the + config file, thus, avrdude is not very useful without the config file, + and thus, having a programmer compiled-in offers little or no benefit. + +2003-02-21 Eric Weddington + + * main.c: Change usage text to be verbose. + + * giveio.sys: Add Windows parallel port device driver (binary). + + * install_giveio.bat, remove_giveio.bat, status_giveio.bat: + Windows batch files to work with giveio.sys. + +2003-02-21 Brian S. Dean + + * avrdude.conf.sample, config.c, config.h, config_gram.y, lexer.l: + * main.c: + Add port name defaults to the config file instead of hard-coding. + This adds 'default_parallel' and 'default_serial' keywords to the + grammar, which take quoted string arguments. + + * avrdude.conf.sample: + Document the recent additions to the config file. + + * stk500.c, avr.c, avrpart.h, config_gram.y, lexer.l, par.c: + Add the ability to specify which pin to pulse when retrying entry into + programming mode. Use 'retry_pulse' in the per-part specification + that can currently take values of 'reset' or 'sck', the default being + 'sck' which preserves the previous behaviour. Some newer parts + indicate that /RESET should be pulsed, while older parts say to pulse + SCK. + +2003-02-20 Eric Weddington + + * main.c, par.c: + Make verbose global. Make debug code in par_cmd() based on verbose=2. + +2003-02-20 Brian S. Dean + + * stk500.c: Fix pseudo/full parallel mode selection logic. + + * avrdude.conf.sample: + Woops, didn't really mean to commit those changes that slipped in with + the last commit. Those were just there for testing. + + * avr.c, avrdude.conf.sample, avrpart.h, config_gram.y, lexer.l: + * stk500.c: + Add 'serial' and 'parallel' keywords to the grammar so that one can + say whether parts support these programming modes or not. Possible + values for 'serial' are 'yes' or 'no'. Possible values for 'parallel' + are 'yes', 'no', or 'pseudo'. Add a bit mask of flags to the AVRPART + structure to capture these settings. Use these within + stk500_initialize() to set the device parameters correctly. + + Defaults for 'serial' and 'parallel' are 'yes' unless specified + otherwise. + +2003-02-20 Eric Weddington + + * Makefile.am, ppiwin.c: Get rid of CRs. + + * Makefile.am: Add ppiwin.c to avrdude_SOURCES. + + * ppiwin.c: Added ppiwin.c: Windows parallel port driver. + + * stk500.c: + Add error message for fail to enter programming mode. Fix typos. + +2003-02-20 Brian S. Dean + + * avr.c, avrdude.conf.sample, avrpart.h, config_gram.y, lexer.l: + Add a few parameters needed for parallel programming: assignment of + PAGEL and BS2 signals and the disposition of the reset pin + ('dedicated' or 'io'). + +2003-02-20 Theodore A. Roth + + * avrdude.1: Fix spacing for m169 entry. (tabs not spaces ;-) + +2003-02-20 Brian S. Dean + + * avrdude.1, fileio.c, main.c: Add Motorola S-record support. + + Submitted by: "Alexey V.Levdikov" + +2003-02-19 Theodore A. Roth + + * avrdude.1: Add m169 to list of supported targets. + +2003-02-19 Joerg Wunsch + + * avrdude.conf.sample, avrdude.1: + My colleague contributed a part definition for the AT90S2343. + + Submitted by: Mirko Kaffka + +2003-02-18 Theodore A. Roth + + * avrdude.conf.sample: + Add support for mega169. (tested with stk500 with 1.7 firmware) + + * avrdude.conf.sample: + Add commments to separate parts (makes it easier for the eye to parse). + +2003-02-15 Theodore A. Roth + + * Makefile.am: Add $srcdir to sample config filename so that + building in a separate dir works. + +2003-02-15 Joerg Wunsch + + * Makefile.am: + Only GNU make sets $< in non-inference rules, so rather explicitly + spell the source file(s) to remain compatible. + +2003-02-14 Theodore A. Roth + + * Makefile.am: Add distclean rule and EXTRA_DIST list to get 'make + distcheck' to succeed. + + These changes add basic support for a autoconf/automake based + build system. + + * .cvsignore: Ignore autoconf files. + * AUTHORS: New file. + * ChangeLog: New file. + * Makefile: Removed file. + * Makefile.am: New file. + * NEWS: New file. + * README: New file. + * bootstrap: New file. + * configure.ac: New file. + * avr.c: Include ac_cfg.h (generated by autoconf). + * config.c: Include ac_cfg.h. + Include config_gram.h instead of y.tab.h. + * config.h: If HAS_YYSTYPE is not defined, define YYSTYPE. + * config_gram.y: Include ac_cfg.h. + * fileio.c: Include ac_cfg.h. + * lexer.l: Include config_gram.h instead of y.tab.h. + * lists.c: Include ac_cfg.h. + * main.c: Include ac_cfg.h. + * par.c: Include ac_cfg.h. + * pgm.c: Include ac_cfg.h. + * ppi.c: Include ac_cfg.h. + * stk500.c: Include ac_cfg.h. + * term.c: Include ac_cfg.h. + +2003-02-14 Brian S. Dean + + * stk500.c: Fix typos. Fix error messages. + +2003-02-13 Brian S. Dean + + * Makefile, avrdude.conf.sample, config_gram.y, lexer.l, main.c: + * par.c, par.h, ppi.c, ppi.h, stk500.c: + Split higher level parallel port programmer code off from ppi.c into + its own file par.c, leaving low level parallel port accessor routines + in ppi.c to help with portability. Change the programmer type to + 'PAR' now instead of 'PPI' - 'PAR' represents the parallel port + programmer type. + + Be more liberal with 'static' function declarations within the + programmer implimentation files - these functions should never be + called directly - always use the programmer function references. + + There are still a few places in 'main.c' that directly reference the + parallel programmer explicitly (par_getpinmask). These should be + fixed somehow. + + Axe a few unused functions. + +2003-02-12 Theodore A. Roth + + * .cvsignore: New file. + + * stk500.c: Remove need for inttypes.h. + + * lexer.l: Define YY_NO_UNPUT to quell a compiler warning. + + * Makefile: Remove YACC assignment. + Add '-b y' options to YACC invocation. + Remove leading '-' from 'include .depend'. + +2003-02-12 Joerg Wunsch + + * config_gram.y: + Declare the internally used static functions on top, to get rid of the + compiler warnings. + + Reported by: bison-generated parsers + +2003-02-11 Theodore A. Roth + + * linux_ppdev.h: New file. + * ppi.c: Include system dependant parallel port interface file. + (ppi_open): Add call to ppi_claim(). + (ppi_close): Add call to ppi_release(). + * ppi.h: Define ppi_claim() and ppi_release() as NOPs if not previously + defined. + * stk500.c: Include inttypes header to quell compiler warning. + +2003-02-11 Joerg Wunsch + + * pgm.c, ppi.c, stk500.c: Fix some implicit declaration warnings. + + * config_gram.y: + Move the C declarations to the top of the file. While [b]yacc doesn't + care, bison does, and this is normally the way it's meant to be + anyway. + +2003-02-11 Theodore A. Roth + + * Makefile: Generate dependencies specific to the target system. + Explicitly use byacc. + + * Makefile: + Remove reference to avr-gcc in depend rule (cut & paste error). + +2003-02-09 Brian S. Dean + + * main.c, pgm.c, pgm.h, pindefs.h, ppi.c, ppi.h, stk500.c: + * stk500.h, stk500_private.h, term.c, term.h, CHANGELOG, COPYING: + * Makefile, avr.c, avr.h, avrdude.1, avrdude.conf.sample: + * avrdude.pdf, avrpart.h, config.c, config.h, config_gram.y: + * fileio.c, fileio.h, lexer.l, lists.c, lists.h: + Test commit in new public repository. Before this time this repo + existed on a private system. Commits made by 'bsd' on the old system + were made by Brian Dean (bdean on the current system). + +2003-02-08 Brian S. Dean + + * Makefile, avr.c, avr.h, avrdude.1, avrpart.h, config.c, + * config.h, config_gram.y, fileio.c, fileio.h, lexer.l, lists.c: + * lists.h, main.c, pgm.c, pgm.h, pindefs.h, ppi.c, ppi.h: + * stk500.c, stk500.h, term.c, term.h: + The last part of that last commit message should read: + + All others - modify program description. + + * Makefile, avr.c, avr.h, avrdude.1, avrpart.h, config.c: + * config.h, config_gram.y, fileio.c, fileio.h, lexer.l, lists.c: + * lists.h, main.c, pgm.c, pgm.h, pindefs.h, ppi.c, ppi.h: + * stk500.c, stk500.h, term.c, term.h: + Makefile: include a target to automatically generate the dependency + list. + + All others + +2003-02-06 Brian S. Dean + + * avrdude.1: Update license to GPL, permission by Joerg Wunsch. + + * lexer.l: Add GPL. + + * Makefile, config_gram.y: Add GPL to the Makefile and config_gram.y. + + * Makefile, stk500.h: + Add stk500.h as a dependency for stk500.c. Remove carraige returns + from stk500.h - don't know how those got in there (pointed out by Ted + Roth). + + * COPYING, avr.c, avr.h, avrpart.h, config.c, config.h, fileio.c: + * fileio.h, lists.c, lists.h, main.c, pgm.c, pgm.h, pindefs.h: + * ppi.c, ppi.h, stk500.c, stk500.h, term.c, term.h: + Re-license using the GNU GPL. Thanks to Ted Roth for the patch. + + * avr.c, avr.h, config.c, config.h, config_gram.y, fileio.c: + * fileio.h, lexer.l, lists.c, lists.h, main.c, pgm.c, pgm.h: + * pindefs.h, ppi.c, ppi.h, stk500.c, stk500.h, term.c, term.h: + Get rid of the verbose printing of individual file CVS version ids. + This was intended to be used for identifying code in the field for + incoming bug reports, but I've never really found it all that useful. + + * CHANGELOG, Makefile, Makefile.inc, avr.c, avrdude.1: + * avrdude.conf.sample, config_gram.y, lexer.l, main.c, stk500.c: + * term.c: + Change the name from AVRPROG to AVRDUDE. + + This change represents a name change only. There is currently an + effort to port AVRPROG to other platforms including Linux and Windows. + Since Atmel's programmer binary that's included within their AVR + Studio software is named AVRPROG.EXE on the Windows OS, there is the + chance for confusion if we keep calling this program AVRPROG as well. + Up until now the name hasn't really been a problem since there was no + chance to confuse 'avrprog' on Unix with Atmel's AVRPROG because + Atmel's tools only run on Windows. But with the Unix 'avrprog' + possibly being ported to Windows, I felt a name change was the best + way to avoid problems. + + So - from this point forward, my FreeBSD Unix program formerly + known as AVRPROG will subsequently be known as AVRDUDE (AVR + Downloader/UploaDEr). + + This change also represents a time when the AVRDUDE sources move from + my own private repository to a public repository. This will give + other developers a chance to port AVRDUDE to other platforms and + extend its functionality to support additional programming hardware, + etc. + + So goodbye AVRPROG, welcome AVRDUDE! diff --git a/xs/src/avrdude/ChangeLog-2004-2006 b/xs/src/avrdude/ChangeLog-2004-2006 new file mode 100644 index 000000000..20e5b2e8b --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2004-2006 @@ -0,0 +1,1644 @@ +2006-12-23 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version to 5.3cvs (again). + +2006-12-22 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version to 5.3.1. + * avrdude.conf.in (frank-stk200): Fix syntax error. + * ser_avrdoper.c: Make #ifdef for Win32/libhid + consistent with the initial check: use the HID driver + only iff found, otherwise use libusb. + +2006-12-21 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version to 5.3cvs. + +2006-12-21 Joerg Wunsch + + Released AVRDUDE 5.3. + +2006-12-21 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version to 5.3. + +2006-12-21 Joerg Wunsch + + Submitted by Vince VG: + * avrdude.conf.in (frank-stk200): New programmer added. + * doc/avrdude.texi: Mention frank-stk200. + Closes patch #5502: one other programmer + +2006-12-21 Joerg Wunsch + + Submitted by Christian Starkjohann: + * ser_avrdoper.c (usbOpenDevice): clear the error code when + returning successfully. + +2006-12-21 Joerg Wunsch + + Submitted by Christian Starkjohann: + patch #5507: Support for AVR-Doper USB programmer in HID mode + * configure.ac: Add hooks to detect the Win32 HID library, + as well as the existence of . + * Makefile.am: Add new files. + * my_ddk_hidsdi.h: (New file.) + * ser_avrdoper.c: (New file.) + * serial.h: Add declaration for avrdoper_serdev. + * stk500v2.c: Add hook to divert to the AVR Doper code. + * avrdude.1: Document the AVR Doper support. + * doc/avrdude.texi: (Ditto.) + +2006-12-15 Joerg Wunsch + + Submitted by ivanv at netman.ru + * jtagmkI.c: fix length for single-byte write operations. + Closes bug #18527 JTAG ICE: fuse bits have been writen incorrectly + +2006-12-11 Joerg Wunsch + + * jtagmkII.c (jtagmkII_paged_write): Remove a debugging + usleep(1000000) that accidentally crept in in rev 1.19. + +2006-12-11 Joerg Wunsch + + * ser_posix.c (ser_open): Do fill in fdp->ifd before already + using it in ser_setspeed(). + +2006-12-11 Joerg Wunsch + + * jtagmkI.c (jtagmkI_close): revert baud rate to the initial + value in case we had changed it. + Fixes bug #18262: JTAGMKI/JTAG1 Reset Bug + +2006-12-11 Colin O'Flynn + + * safemode.c: Stop ignoring return values! + Closes bug #18339 + +2006-12-11 Joerg Wunsch + + Submitted by Nick Lott: + * avrdude.conf.in: Fix signature for ATmega8515. + Closes bug #18348: ATMEGA8515 Signature is wrong in avrdude.conf + +2006-12-11 Joerg Wunsch + + * avr.c: Fix a bug introduced in rev. 1.69, when implementing the + fallback from each programmer's paged_load() or paged_write() + method, respectively. The return value needs to be checked for + being greater or equal than 0 rather equal to 0 in order to + assume the operation has been successful. + Fixes bug #18489: avrdude is too slow (20 byte/s) + +2006-12-11 Joerg Wunsch + + * avr910.c: Make the code compile warning-free: + - declare a dummy "struct timezone" for some Win32 systems (MinGW) + - fix a few printf() argument types + - get rid off the prevailing "all filedescriptors are of type int" + attitude + The last item required a large sweep across the code, in order to + replace all "int fd"s by "struct filedescriptor *fd"s, and pass + pointers (as we cannot pass a union directly). In return, the + code is now supposed to be fully 64-bit safe, rather than relying + on a 64-bit pointer being converted to a (32-bit) int and back + to a pointer as we did previously. + * butterfly.c: (Ditto.) + * jtagmkI.c: (Ditto.) + * jtagmkII.c: (Ditto.) + * lists.c: (Ditto.) + * par.c: (Ditto.) + * pgm.h: (Ditto.) + * ppi.c: (Ditto.) + * ppi.h: (Ditto.) + * ppiwin.c: (Ditto.) + * ser_posix.c: (Ditto.) + * ser_win32.c: (Ditto.) + * serbb_posix.c: (Ditto.) + * serbb_win32.c: (Ditto.) + * serial.h: (Ditto.) + * stk500.c: (Ditto.) + * stk500v2.c: (Ditto.) + * usb_libusb.c: (Ditto.) + +2006-11-23 Joerg Wunsch + + Implement EEPROM access through debugWire. + * jtagmkII.c: Extend the jtagmkII_read_byte() and + jtagmkII_write_byte() methods to handle EEPROM through + debugWire. + * avrpart.h: Implement the "flash instruction" parameter. + * config_gram.y: (Ditto.) + * lexer.l: (Ditto.) + * avrdude.conf.in: (Ditto.) + * avrdude.1: Document the EEPROM access through dW. + * doc/avrdude.texi: (Ditto.) + * tools/get-dw-params.xsl: Extend to extract the flash + instruction field. + +2006-11-23 Joerg Wunsch + + * avr.c (avr_read, avr_write): if the paged access returns a + failure, fall back to byte access. + +2006-11-21 Joerg Wunsch + + * jtagmkII.c: In jtagmkII_read_byte() and jtagmkII_write_byte(), + return an error upon failure now that the upper layers won't fall + back to the cmd() method anymore in that case. + +2006-11-21 Joerg Wunsch + + Implement debugWire programming support. + * avrpart.h: Implement debugWire support. + * config_gram.y: (Ditto.) + * jtagmkII.c: (Ditto.) + * jtagmkII.h: (Ditto.) + * lexer.l: (Ditto.) + * avrdude.conf.in: Add the new dW programmers. + * avrdude.1: Document the dW support. + * doc/avrdude.texi: (Ditto.) + * tools/get-dw-params.xsl: XSL stylesheet to extract the dW + parameters from the XML files. + +2006-11-20 Joerg Wunsch + + * jtagmkI.c (jtagmkI_close): remove two unused variables. + +2006-11-20 Joerg Wunsch + + * avr.c: Replace the fallback of avr_read_byte() and avr_write_byte() to + avr_read_byte_default() and avr_write_byte_default (resp.) by directly + calling the latter functions from within all programmers that don't + implement their own read_byte()/write_byte() methods. In turn, make the + read_byte() and write_byte() methods mandatory, and the cmd() method + (direct ISP command) optional instead (it's effectively mandatory for + any programmer using avr_read_byte_default()/avr_write_byte_default() + though). Remove all the pointless cmd() method stubs from those programmers + that don't need it. + Eliminate avr_read_byte() as it was now completely identical to + pgm->read_byte(). + * avr.h: (Ditto.) + * bitbang.c: (Ditto.) + * butterfly.c: (Ditto.) + * jtagmkI.c: (Ditto.) + * jtagmkII.c: (Ditto.) + * par.c: (Ditto.) + * pgm.c: (Ditto.) + * safemode.c: (Ditto.) + * serbb_posix.c: (Ditto.) + * serbb_win32.c: (Ditto.) + * stk500.c: (Ditto.) + * stk500v2.c: (Ditto.) + * term.c: (Ditto.) + * usbasp.c: (Ditto.) + +2006-11-13 Joerg Wunsch + + * jtagmkI.c: Avoid sending a CMD_RESET when leaving programming + mode, and CMD_GO when closing the connection. They cause the + activity LED on the ICE to continue to flicker, and are not + necessary anyway (the target starts to run by itself when leaving + programmng mode). + This is a partial fix for bug #18262: JTAGMKI/JTAG1 Reset Bug + +2006-11-12 Colin O'Flunn + + * avrdude.conf.in: Add read command for lockbits for Tiny2313. + Applies patch #5538 + +2006-11-10 Joerg Wunsch + + * avrdude.conf.in: Add signatures for ATmega325/3250/645/6450. + +2006-11-08 Joerg Wunsch + + * configure.ac: Preserve ${LDFLAGS} inherited from environment + for Win32 environments. + +2006-11-07 Joerg Wunsch + + * configure.ac: Don't pretend --enable-doc were the default. + +2006-11-02 Joerg Wunsch + + * avrdude.conf.in: Fix the width of the efuse memory area for a + number of AVRs. + Closes bug #18182: Wrong setting of eFuse configuration for + mega640/1280/1281/2560/2561 in avrdude 5.2 + +2006-11-01 Joerg Wunsch + + * avrdude.conf.in: Implement HVSP and PP modes for the AVR Dragon. + * config_gram.y: (Ditto.) + * jtagmkII.c: (Ditto.) + * jtagmkII_private.h: (Ditto.) + * lexer.l: (Ditto.) + * stk500v2.c: (Ditto.) + * stk500v2.h: (Ditto.) + * avrdude.1: Document the HVSP and PP support for the Dragon. + * doc/avrdude.texi: (Ditto.) + +2006-10-27 Joerg Wunsch + + * jtagmkI.c: Implement a flags field in struct serdev, and populate it + with a flag that indicates whether the underlying communication can + dynamically change its speed or not. This flag is set for true serial + communication but clear for USB communication. Don't try to adjust + the speed when talking over a communication channel that doesn't + support it. (The Dragon does not even support the respective parameter.) + * jtagmkII.c: (Ditto.) + * ser_posix.c: (Ditto.) + * ser_win32.c: (Ditto.) + * serial.h: (Ditto.) + * usb_libusb.c: (Ditto.) + +2006-10-26 Joerg Wunsch + + * avrdude.conf.in: Add support for the AVR Dragon (JTAG and ISP mode). + * config_gram.y: (Ditto.) + * jtagmkII.c: (Ditto.) + * jtagmkII.h: (Ditto.) + * lexer.l: (Ditto.) + * stk500v2.c: (Ditto.) + * stk500v2.h: (Ditto.) + * usbdevs.h: (Ditto.) + * avrdude.1: Document the AVR Dragon support. + * doc/avrdude.texi: (Ditto.) + +2006-10-09 Joerg Wunsch + + Released AVRDUDE 5.2. + +2006-10-09 Joerg Wunsch + + * configure.ac: Bump version to 5.2 + +2006-10-09 Joerg Wunsch + + Submitted by John Voltz: add AVR053 oscillator calibration. + * main.c: Add the -O option. + * pgm.c: Add the hook for the perform_osccal() method. + * pgm.h: (Ditto.) + * stk500v2.c: Implement perform_osccal(). + * avrdude.1: Document the -O option. + * doc/avrdude.texi: (Ditto.) + Partially closes bug #17487: AVR RC oscillator calibration + routine not supported (feature request) + +2006-10-09 Joerg Wunsch + + Submitted by freckle@sf.net: + * stk500.c (stk500_paged_write): Send the command and the data + payload within a single write(). + patch #5025: Improve stk500.c robustness + + Submitted by Matthias Ringwald: + * stk500.c (stk500_open): do not flush the serial line after + getting in sync with the programmer. + patch #5293: stk500.c: no drain after sync (-> allow BTnode + Bootloader to work on cygwin) + +2006-09-29 Joerg Wunsch + + * pgm.h: Fix prototype for gettimeofday(). + Closes bug #17884: another gettimeofday conflict under win32/cygwin + +2006-09-24 Joerg Wunsch + + Submitted by Thomas Fischl (initially): + * configure.ac: Add the CoreFoundation and IOKit framework + linker flags on MacOS X when configuring for USB support. + patch #4685: Libusb on MacOS X: detection and additional includes + +2006-09-20 Joerg Wunsch + + * avr910.c: As there is a lot of ambiguity about the AVR910 + device codes, allow the user to override the device code + verification with the -F option. + * main.c: Make ovsigck a global variable. + +2006-09-20 Joerg Wunsch + + Add the "stk500generic" programmer that auto-probes for STK500 + either firmware version 1 or 2. + * Makefile.am (avrdude_SOURCES): add the new files + stk500generic.c and stk500generic.h. + * avrdude.conf.in: Add the stk500generic programmer type, and + change the "stk500" entry to point to this programmer. + * config_gram.y: Add the stk500generic keyword. + * lexer.l: (Ditto.) + * stk500.c: Change the stk500v1 code to not call exit() + prematurely when failing to open the programmer, but instead + return an error status. + * stk500generic.c: (New file.) Stub programmer implementation. + Probe for either stk500v1 or stk500v2, and adjust the current pgm + appropriately. + * stk500generic.h: (New file.) Declare the public interface(s) + of stk500generic.c. + * doc/avrdude.texi: Document the changed behaviour of stk500. + +2006-09-18 Joerg Wunsch + + * avrdude.conf.in: Various fixes for ancient processors and their + capabilities. For the AT90S1200 and the AT90S8515, fuse bit + handling via ISP, and lock bit reading via ISP are not supported + at all. For the AT90S4414 (small brother of the AT90S8515), add + the ability to write the lock bits, and add a definition for the + fuse bits (usable for HV programming). For the AT90S2313, add the + "fuse" memory range, so it's available for HV programming. + + Resolves bug #17796: avrdude will not program or verify lockbits + with Atmel STK protocol programmers + +2006-09-17 Joerg Wunsch + + Submitted by Thomas Fischl: + * usbasp.c: Check for USBasp with new as well as old VID/PID + pair, warn the user about upgrading the firmware in case an + old one has been found. + * usbasp.h: Add new VID/PID. + +2006-09-15 Joerg Wunsch + + * avrdude.conf.in: Fix some mistakes for the ATtinyX61 family: + . high fuse has 8 bits + . there is an extended fuse (just one bit) + . the calibration area is only 1 byte + +2006-09-12 Joerg Wunsch + + * doc/avrdude.texi: Convert some of the tables to multitables + in order to beautify the result. + +2006-09-10 Joerg Wunsch + + Contributed by Thomas Fischl: add support for USBasp. + patch #4686: Add support for USBasp, a simple USB programmer + * usbasp.c: New file, implement the USBasp driver. + * usbasp.h: New file, interface declarations for USBasp. + * Makefile.am: Wire the new files into the build. + * avrdude.conf.in: Add the usbasp programmer entry. + * config_gram.y: Add the usbasp token. + * lexer.l: (Ditto.) + * avrdude.1: Document the USBasp programmer. + * doc/avrdude.texi: (Ditto.) + +2006-09-08 Joerg Wunsch + + * main.c: Implement -U filename as a shorthand for + -U flash:w:filename:a. + * avrdude.1: Document this. + * doc/avrdude.texi: (Ditto.) + +2006-09-08 Joerg Wunsch + + Implement numerical output formats for decimal, hexadecimal, + octal, and binary numbers. + Closes bug #16129: more output formats for fuse bits + (avrdude enhancement request) + * fileio.c: Implement fileio_num() and the itoa_simple() + helper function. + * fileio.h: Add new file formats to FILEFMT. + * main.c: Parse the new file formats. + * avrdude.1: Document all this. + * doc/avrdude.texi: (Ditto.) + +2006-09-08 Joerg Wunsch + + * fileio.c: CPP statements start in column #1. + * stk500v2.c: Hide two debug/trace statements behind "verbose". + +2006-09-07 Joerg Wunsch + + * avrdude.1: Describe how to disable the DWEN fuse. + * doc/avrdude.texi: (Ditto.) + +2006-09-07 Joerg Wunsch + + * jtagmkII.c: Translate numerical response codes to strings. + +2006-09-07 Joerg Wunsch + + * avrdude.1: The avr109 programmer type no longer chokes on + a wrong avr910 device ID, so remove that description. + * doc/avrdude.texi: (Ditto.) + +2006-09-07 Joerg Wunsch + + * jtagmkII.c: When failing to start in ISP mode, try + debugWire instead. This requires the user to eventually + restart AVRDUE from scratch then. + +2006-09-06 Joerg Wunsch + + Add support for the JTAG ICE mkII in ISP mode. + * avrdude.conf.in (jtag2isp): New programmer entry. + * config_gram.y: Add K_JTAG_MKII_ISP. + * jtagmkII.c: Restructure and export some more functions. + * jtagmkII.h: Declare exported functions. + * jtagmkII_private.h: Prepare file to be included in stk500v2.c. + * lexer.l: Add jtagmkii_isp token. + * stk500v2.c: Implement glue to jtagmkII.c. + * stk500v2.h: Declare stk500v2_jtagmkII_initpgm(). + * avrdude.1: Document the new programmer support. + * doc/avrdude.texi: (Ditto.) + +2006-09-01 Joerg Wunsch + + * main.c: Add date and time of compilation to the verbose + greeting message. + Idea taken from patch #3172: Adds date and time of compile + to usage message + +2006-09-01 Joerg Wunsch + + Contributed by as + patch #4372: Better synchronization for stk500 + * stk500.c: Sync three times, and drop any noise inbetween. + +2006-09-01 Joerg Wunsch + + * avrdude.conf.in (ATtiny261, ATtiny461, ATtiny861): new + entries. + +2006-09-01 Joerg Wunsch + + * butterfly.c: Remove the device support decision based on + the old AVR910 device codes; we've got signature verification + now so better rely on that. + * avr910.c: Revert the signature bytes returned, as it already + happened in butterfly.c. This closes bug #14998: Signature Bytes + read in wrong order (avr910 mode) + +2006-09-01 Joerg Wunsch + + Submitted by Wim Lewis. + * serbb_posix.c: Improve error handling. + patch #4923: Better error reporting for serial-bitbang programmers + +2006-08-31 Joerg Wunsch + + * avrdude.conf.in: Introduce a "stk500v1" entry, so we + can switch the default "stk500" to "stk500v2" some day. + +2006-08-31 Joerg Wunsch + + The major part of this change has been contributed by + . + Implements patch #4635: Add support for terminal/console + servers for serial programmers + * ser_posix.c: Add net_open(), and divert to it for net:host:port. + * ser_win32.c: Recognize net:host:port, and bail out. + * avrdude.1: Document the net:host:port connection option. + * doc/avrdude.texi: (Ditto.) + +2006-08-31 Joerg Wunsch + + Fix for bug #16627: Butterfly programmer does not reset after + programming + * butterfly.c: Wait for the device's response after sending + an "E" command. + +2006-08-31 Joerg Wunsch + + Tentative fix for bug #16156: Problem with Si-Prog + * serbb_posix.c: Disable reset before closing. + * serbb_win32.c: (Ditto.) + +2006-08-30 Joerg Wunsch + + Rewrite the serbb code so the pin numbering matches the + DB9 connector, and fix some related bugs in serbb_posix.c. + Closes bug #16265: dasa2 does not work under posix + * avrdude.conf.in: New serbb pin numbering; added "siprog" + as an alias for "ponyser". + * serbb_posix.c: New pin numbering, fix some confusion. + * serbb_win32.c: New pin numbering. + The generic and Posix-related parts of these changes have + been contributed by Hanns-Konrad Unger + +2006-08-30 Joerg Wunsch + + Contributed by the anonymous developer of patch #5096: + * avrdude.conf.in (blaster): Add an entry for the Altera + byteblaster. + +2006-08-30 Joerg Wunsch + + Rework the exit specs so they actually work again. It should be + possible to extend them for other programmers than PPI now (serbb, + stk500*). + * pgm.h: Keep the exit specs in an abstract form inside struct + programmer_t. (Should be moved out into some programmer-specific + structure.) Rename the getexitspecs() method into + parseexitspecs(). + * main.c: Move the exit specs stuff out to the programmer + implementation. + * par.c: Implement the new exit spec handling. Everything is now + done using the generic abstraction layer. + Closes bug #16443: No disable Resetsignal at the end of + Programming Session + Obviates need for patch #5057: quick and dirty Hack to unset Reset + after Programming + +2006-08-29 Joerg Wunsch + + This patch has been contributed by an anonymous developer + via the patch tracking system. + patch #5096: Allow VCC and BUFF to be any pin in parallel mode + * config_gram.y: Release the restriction to PPIDATA pins. + * par.c: Rework the code to introduce a function par_setmany() + that builds on top of par_setpin(), and use that function for the + PPI_AVR_VCC and PPI_AVR_BUFF pin collections. This also abstracts + the polarity of these signals appropriately. + +2006-08-28 Joerg Wunsch + + Contributed by Ned Konz: + * ser_posix.c: Open the serial port with O_NONBLOCK, and + save and restore the port state before exiting. + patch #5008: Patch for (5.1) ser_posix.c for O_NONBLOCK open + and restoring serial port state on close + Closes bug #12622: avrdude hangs on macosx/darwin with PL-2303 + usb-to-serial and Butterfly + +2006-08-22 Joerg Wunsch + + * bitbang.c: Move the bitbang prerequisite checks out from + main() into their own bitbang_check_prerequisites(). + * bitbang.h: (Ditto.) + * main.c: (Ditto.) + * par.c: (Ditto.) + * serbb_posix.c: (Ditto.) + * serbb_win32.c: (Ditto.) + +2006-08-22 Joerg Wunsch + + * avrdude.conf.in: Add page mode parameters for all "eeprom" + memory definitions that are organized in pages. + * avr.c (avr_write_byte_default): Consider using the loadpage + instructions only if the respective memory is marked "paged". + Closes bug #17199: EEPROM fails verification on ATmega645 with + pony-stk200 hardware + Closes bug #16849: EEPROM write fails for AT90USB1287 with + mode 0x41 + Closes bug #15146: stk500v2_paged_write: loadpage instruction + not defined for part + +2006-08-22 Joerg Wunsch + + * doc/avrdude.info (-c): Change "avrispmk2" into "avrisp2" as that + is the programmer actually supported by avrdude.conf.in. + Closes bug #15677: documentation mentions wrong programmer-id + "avrispmk2" + +2006-08-21 Joerg Wunsch + + * avrdude.conf.in: Fix various AVR910 device codes. Add the code + tables from both, AVR910 and AVR109. Change avr910_devcode of + the ATtiny2313 to 0x5e (ATtiny26). + Closes bug #16671: Tiny2313 avr910_devcode is bad + Closes bug #15826: avr910 device type for ATmega8 wrong + +2006-08-21 Joerg Wunsch + + * avrdude.conf.in: Add (rather conservative) write delay timing + values to the *fuse and lock memory spaces of all devices where + they have been missing. Add the lock memory space to the ATmega48 + section. + Closes bug #14920: tiny2313 fuses and AVRDUDE 5.0 + Closes bug #15751: atmega48: no lock bits defined + +2006-08-21 Joerg Wunsch + + * avrdude.conf.in: Fix the size of the calibration memory space + for ATtiny13, ATmega64, ATmega16, ATmega32, ATmega8535, ATtiny25, + ATtiny45, ATtiny85. + Closes bug #17383: Wrong calibration section in avrdude.conf... + +2006-08-21 Joerg Wunsch + + * avrdude.conf.in (ATmega324): Correct the pagesize from 256 to + 128. + This closes bug #16410: ATMega164/324/644 cannot be programmed + +2006-08-20 Joerg Wunsch + + * configure.ac: Check for gettimeofday(). + * ppiwin.c (gettimeofday): Define gettimeofday() replacement + only if !defined(HAVE_GETTIMEOFDAY); use correct protype. + +2006-08-18 Joerg Wunsch + + * stk500v2: Minor cosmetic changes: STK500 firmware version + numbers are M.NN, so always display the minor number as two + digits. Examine the response to the sign-on command to see which + programmer hardware we are talking to, and then restrict the + STK500 topcard display to devices detected as STK500. + +2006-08-18 Joerg Wunsch + + * Makefile.am: Add a dist-hook, and make it remove lexer.c, + config_gram.c, and config_gram.h from the source distribution + archive. These files are supposed to be generated on the target + system. + Closes bug #15536: avrdude-5.1 compilation fails on Gentoo/amd64 + +2006-08-17 Joerg Wunsch + + * stk500v2.c: unreverse the argument order for + CMD_CHIP_ERASE_HVSP; Atmel says AVR068 is right, and + stk500.exe is wrong. + * configure.ac (AC_CHECK_LIB[usb]): Fix the generation + of HAVE_LIBUSB in ac_cfg.h. + +2006-08-17 Joerg Wunsch + + Submitted by Neil Davey: + patch #4539: Ability to control the bit clock (usleep) delay + for ppi interface + * bitbang.c: Implement bitbang_delay() and its calibration. + * bitbang.h: Declare bitbang_delay(). + * main.c: Add the ispdelay option (-i). + * pgm.h (struct programmer_t): Add the ispdelay parameter. + * par.c: Add calls to bitbang_delay() when requested. + * serbb_posix.c: (Ditto.) + * serbb_win32.c: (Ditto.) + * avrdude.1: Document the new -i option. + * doc/avrdude.texi: (Ditto.) + +2006-08-14 Joerg Wunsch + + Submitted by : + * avrdude.conf.in (ATmega48, ATmega88, ATmega168): patch #5100: + mega88 EEPROM support (extended for ATmega48 and ATmega168 - jw). + +2006-08-14 Joerg Wunsch + + Submitted by : + * stk500v2.c (stk500v2_open): patch #5273: Emit error message + if user requests usb and no libusb support + +2006-08-14 Joerg Wunsch + + * avrdude.conf.in: Add HVSP/PP mode parameters for all AVRs. + +2006-08-13 Joerg Wunsch + + * tools: New directory. + * tools/get-hv-params.xsl: New file, extract high-voltage + programming parameters from Atmel XML files, and produce + an avrdude.conf[.in] snippet. + +2006-08-11 Joerg Wunsch + + * configure.ac (AC_CHECK_LIB([usb]): implement a private LIBUSB + macro to add this library to, to prevent it from being + automatically linked to all binaries. This should fix the Win32 + build of loaddrv. + * Makefile.am (avrdude_LDADD): add LIBUSB here. + +2006-08-10 Eric B. Weddington + + Contributed by Bob Paddock + * avrdude.conf.in: Patch #4780. Provide support for mega325, + mega3250, mega645, mega6450. + +2006-08-10 Joerg Wunsch + + * avrdude.conf.in (ATtiny11): fix the HVSP control stack, + add delay values required for flash and EEPROM. + * stk500v2.c: reverse the argument order for + CMD_CHIP_ERASE_HVSP; AVR068 and stk500.exe differ here. + +2006-08-09 Joerg Wunsch + + * stk500v2.c (stk500v2_program_enable): Fix a typo + (synchloops vs. synchcycles). + +2006-08-04 Joerg Wunsch + + * avrdude.conf.in: Add parallel programming definitions for + the ATmega8/48/88/168. + +2006-07-22 Joerg Wunsch + + * avrdude.conf.in: Add the ATtiny11, an HVSP-only device. + +2006-07-21 Joerg Wunsch + + Implement STK500 (v2) HVSP mode. + * stk500v2.c: Add new functions for HVSP support. + * stk500v2.h: Add prototype for the stk500hvsp programmer. + * avrpart.h: Add fields to struct avrpart for new features. + * config_gram.y: Extend the configuration syntax for new + features required for HVSP support. + * lexer.l: (Ditto.) + * avrdude.conf.in: Add HVSP support for ATtiny13 and + ATtiny45 as an example. + * avrdude.1: Document stk500hvsp. + * doc/avrdude.texi: (Ditto.) + +2006-07-21 Joerg Wunsch + + * avrpart.c: Print the very verbose memory details only + in debug level > 4. + +2006-07-19 Joerg Wunsch + + * stk500v2.c: Add more parameters for PP mode. Fix the + non-paged write operations for old AVRs. + * lexer.l: Add more parameters for PP mode. + * config_gram.y: (Ditto.) + * avrpart.h: (Ditto.) + * avrdude.conf.in: Use the new PP mode parameters; add PP mode + definitions for AT90S8515. + * avrdude.1: Document the stk500pp support. + * doc/avrdude.texi: (Ditto.) + +2006-07-19 Joerg Wunsch + + * stk500v2.c: Hide stk500v2_set_sck_period_mk2() behind an #if + defined(HAVE_LIBUSB) as it is only used there (for the AVRISP + mkII). + +2006-07-17 Joerg Wunsch + + * stk500v2.c: Fix all bugs in stk500pp. Eliminate pagebuf, and + use a stack-allocated buffer instead, as the pagesize can be at + most 256 for all current AVRs anyway. + +2006-07-17 Joerg Wunsch + + * main.c: Use mem->desc in place of upd->memtype in more places to + give the full name of the respective memory area, instead of + the (possibly abbreviated) name the user typed in the -U option. + +2006-07-16 Joerg Wunsch + + First stab at an implementation of the STK500 parallel programming + feature (v2 firmware only), named "stk500pp". Still not yet + complete: EEPROM writes not working, documentation missing, only + ATmega16 parameters available in avrdude.conf.in, some parameters + not yet implemented. + * avrdude.conf.in: Add sample parameters for PP mode to ATmega16. + * avrpart.h: Add the parallel programming control parameters. + * avrpart.c: (Ditto.) + * config_gram.y: Add stk500pp configuration grammar. + * lexer.l: Add stk500pp token recognition. + * stk500v2.h: Add declaration for stk500pp_initpgm(). + * stk500v2.c: Add stk500pp implementation. + +2006-07-11 Joerg Wunsch + + * avrdude.conf.in: Fix the signatures for the + ATmega164/324 devices. + +2006-07-10 Joerg Wunsch + + * avrdude.conf.in: Enter the signatures for the + ATmega164/324/644 devices. + +2006-05-25 Joerg Wunsch + + * stk500v2.c: Implement extended addressing needed + for the ATmega256x devices. + * avrdude.1: Document ATmega256x support. + * doc/avrdude.texi: Document ATmega256x support. + Also document Solaris port defaults. + +2006-05-24 Joerg Wunsch + + * avr.c: Start implementing support for ATmega256x; + jtag2 and bitbang programmers are working, stk500v2 + still needs to be done. + * avrdude.conf.in: (Ditto.) + * avrpart.c: (Ditto.) + * avrpart.h: (Ditto.) + * config_gram.y: (Ditto.) + * lexer.l: (Ditto.) + +2006-04-18 Joerg Wunsch + + Contributed by Julius Luukko : + * avrdude.conf.in: Add the "ere-isp-avr" programmer. + +2006-04-13 Joerg Wunsch + + * par.c: Add logic to negate parallel-port signals in + avrdude.conf using a tilde. + + Contributed by Bram Daams: + * avrdude.conf.in: Add the "atisp" programmer entry that + makes use of negated signals. + +2006-03-28 Joerg Wunsch + + * avrdude.conf.in: Add entries for AT90USB{64,128}{6,7} + +2006-03-23 Colin O'Flynn + + Contributed by Wim Lewis, fix a few typos (patch #4987) + * avrdude.1: Typo fix + +2006-02-27 Colin O'Flynn + + Contributed by Wim Lewis, add support for checking device + signatures in detail (patch #4924 and #4925) + * avrdude.conf.in: Add signatures + * avrpart.c: Set default signature + * avrpart.h: Variable for signature + * config_gram.y: More signature reading + * lexer.l: Define that signatures exist + * main.c: Read signatures and check them against hardware + +2006-02-21 Joerg Wunsch + + * avrdude.conf.in: Fix paged flash write for AT90PWMx + (error in datasheet). + +2006-01-23 Joerg Wunsch + + * configure.in: Bump version. + +2006-01-17 Colin O'Flynn + + * main.c: Fixed a typo in safemode variable names, fixed bug 15113 + * avrdude.conf.in : Added BS2 and pagel to M162, Patch 4766 + * main.c, stk500v2.c: Added patch 4804 from eolson@mit.edu + Which stops sck from being writtend needlessly + +2006-01-13 Joerg Wunsch + + Contributed by David Moore: add support for the + AVRISP mkII device. (Savannah patch #4789.) + * serial.h: Declare usb_serdev_frame device descriptor. + * stk500v2.c: Implementation of the AVRISP mkII handling. + * usb_libusb.c: Add USB handling for short-frame delimited + AVRISP mkII USB protocol; add distinction of different + devices in usbdev_open(). + * jtagmkII.c: Tell usbdev_open() to search for the JTAG ICE mkII. + * usbdevs.h: (New file.) + * Makefile.am: Add usbdevs.h, as well as some other forgotten + files "make distcheck" complained about. + * avrdude.conf.in: Add more aliases for the AVRISP mkII. + * avrdude.1: Document how to use the AVRISP mkII. + * doc/avrdude.texi: (Ditto.) + +2006-01-12 Joerg Wunsch + + * avrdude.conf.in: Add EEPROM page instructions for the + ATmega169 so it will work for STK500v2. + +2005-12-16 Joerg Wunsch + + * avrdude.conf.in: Added support for ATtiny24/44/84. + +2005-12-05 Colin O'Flynn + + * avrdude.conf.in: Added m162 support for stk500v2 + +2005-12-01 Joerg Wunsch + + * avrdude.conf.in: fix the number of significant bits for + the efuse memory in ATmega48/88/168; the datasheet is a bit + off here as well. + +2005-11-29 Joerg Wunsch + + * avrdude.1: update for JTAG ICE mkI support. + * doc/avrdude.texi: (Ditto.) + +2005-11-29 Joerg Wunsch + + Submitted by Galen Seitz: + patch #4459: Fix for rpm package builds + * avrdude.spec.in: update the RPM spec file: + - Default to enable-doc=yes during configure. + - Move info file to docs package. + - Make building of docs package conditional. Basic + idea copied from avr-gcc. + +2005-11-29 Joerg Wunsch + + Submitted by someone who thinks he's called "Daper": + Fix bug #15013: Wrong use of PPICLAIM (kernel: ppdev0: claim the + port first) + * par.c: don't claim/release here (thus win_ppdev.h not needed + anymore) + * ppi.c: claim/release here. + * freebsd_ppi.h: ppi_claim/ppi_release now take an fd as parameter. + * solaris_ecpp.h: (Ditto.) + * linux_ppdev.h: (Ditto.) (Also add copyright.) + * win_ppdev.h: Not needed anymore, remove. + +2005-11-28 Joerg Wunsch + + * jtagmkI.c: Improve the communication startup with the ICE. + +2005-11-28 Joerg Wunsch + + * configure.ac: enable parport access on x86_64 Linux and + FreeBSD systems. + +2005-11-27 Joerg Wunsch + + * avrdude.conf.in: add the "calibration" space to ATmega16. + +2005-11-25 Colin O'Flynn + + Fixed bug 15051, building for Windows breaks. + * par.c: ppi_claim and ppi_release definitions now in a Windows header file + * ppi.c: Only included if you are building for Windows + * win_ppdev.h: Initial Commit, see par.c + +2005-11-24 Joerg Wunsch + + Add basic support for the Atmel JTAG ICE mkI: + * config_gram.y: add mkI support to config sytax. + * lexer.l: (Ditto.) + * avrdude.conf.in: add sample programmer entries. + * jtagmkI.c: New file + * jtagmkI.h: New file + * jtagmkI_private.h: New file + * Makefile.am: include new files in build. + +2005-11-24 Colin O'Flynn + + Fix bug 14681 - Serial Communication Fails on -vvvv with Windows + * ser_win32.c: Patched with Brian Dean's patch + +2005-11-05 Colin O'Flynn + + Patch #4532 by Manfred Bartz + * avrdude.conf.in: added support for ATMega168 (also added support + for the stk500v2 protocol which was not in the patch). + +2005-11-03 Joerg Wunsch + + Add ecpp(7D) (parallel port) for Solaris. + * configure.ac: add Solaris' default parallel port. + * linux_ppdev.h: change parallel port access to the new style. + * freebsd_ppi.h: New file, abstract FreeBSD's ppi(4). + * solaris_ecpp.h: New file, abstract Solaris' ecpp(7D). + * par.c: change header inclusion sequence. + * pgm.h: remove obsolete ppi_claim() and ppi_release() dummies. + * ppi.c: change header inclusion sequence, use new parport + abstraction, drop obsolete dummy implementation. + +2005-11-02 Joerg Wunsch + + * config.h: change YYSTYPE to be a single word, to work around + a bug in Solaris' yacc. + * lexer.l: remove incompatibilities with Solaris' default lex, + bump resource limits for lex. + +2005-11-01 Joerg Wunsch + + Make avrdude Solaris-compatible. + * Makefile.am: distclean avrdude.conf. + * avrdude.conf.in: make the parallel-port programmers optional. + * bitbang.c: move the bitbang features out into PROGRAMMER. + * configure.ac: introduce --enable-parport, add Solaris. + * lexer.l: replace str by strng to work around problems in some + versions of flex. + * main.c: move getexitspecs into the respective programmer's + domain; replace rindex by the C-standard strrchr. + * par.c: make parallel port optional. + * par.h: everything but par_initpgm() is private now. + * pgm.h: add setping/getping/highpulsepin/getexitspecs. + * serbb_posix.c: generalize bitbang interface; replace + cfmakeraw() by explicit code. + * serbb_win32.c: generalize bitbang interface. + +2005-10-20 Joerg Wunsch + + * butterfly.c: fix yet another sign extension bug. + +2005-10-14 Joerg Wunsch + + * avrdude.conf.in (ATmega8515): fix size of calibration + memory. + +2005-10-09 Joerg Wunsch + + * avrdude.conf.in: add support for ATmega640/1280/1281. + * avrdude.1: document the above. + * doc/avrdude.texi: (Ditto.) + +2005-09-27 Joerg Wunsch + + * doc/avrdude.texi: Polish up the docs a bit. Use smallexample + instead of example for wide tty output. Document a trick to + find out about the serial numbers of all JTAG ICEs attached + to USB. + +2005-09-26 Joerg Wunsch + + * jtagmkII.c (jtagmkII_paged_write): default the page size early so the + buffer will be allocated correctly. + * usb_libusb.c: fix libusb handling; now it works with libusb-win32 as + well. + +2005-09-21 Joerg Wunsch + + * main.c(do_op): use mem->desc in place of upd->memtype to + give the full name of the respective memory area, instead of + the (possibly abbreviated) name the user typed in the -U option. + +2005-09-21 Joerg Wunsch + + * main.c: Add the forgotten -B option to the option string in + getopt(); sort the -s option into order. + +2005/09/21 Brian S. Dean + + * avr.c: + * main.c: + * safemode.c: + * safemode.h: + * term.h: + This is Colin O'Flynn's mega patch for updating safemode support: + + * add support for parts with just 'fuse' memory + + * if any fuse memories are altered, reflect those changes in the + post-programming safemode check so that safemode no longer + complains about fuses which were intentionally altered; this + eliminates the need to completely disable safemode using -u in + order to program fuses. + + * provide -s option which will not ask to restore fuses, it will + just do it + +2005-09-19 Joerg Wunsch + + * butterfly.c (butterfly_initialize): make the device code unsigned so + it wouldn't sign-extend when >= 0x80. + +2005-09-18 Joerg Wunsch + + Add the serial bit-bang driver, contributed by Michael Holzt. + * bitbang.h: New file. + * bitbang.c: New file. + * serbb.h: New file. + * serbb_posix.c: New file. + * serbb_win32.c: New file. + * Makefile.am: Include new files. + * config_gram.y: Add serbb to configuration language. + * lexer.l: (Ditto.) + * par.c: Centralize bit-bang code in bitbang.c. + * par.h: Declare newly published functions. + * pgm.h (struct programmer_t): Add a flag field for private use + by the programmer. + * pindefs.h: Add definitions for negated serbb pins. + * avrdude.conf.in: Add serbb programmers ponyser, dasa, and dasa3. + * avrdude.1: Document serbb code. + * doc/avrdude.texi: (Ditto.) + +2005/09/18 Brian S. Dean + + * avrdude.conf.in: Patch #4078: add VCC pin definition for DAPA + programmer. + +2005/09/18 Brian S. Dean + + * avr910.c: This is patch #3277 which appears to fix a number of + issues with the avr910 programmer. + + Fixes the following problems with paged writes in avr910.c: + - failure to re-set address after page writes; + - no polling or delay after page writes; + - no page writes when not using auto-increment; + - an extraneous page write when data ends on page boundary. + +2005-09-17 Joerg Wunsch + + * avrdude.conf.in: Fix the poll values for the ATmega103's EEPROM + so they eventually match the XML file. + This fixes bug #7492: EEPROM writing fail on atmega103 with + atavrisp + +2005-09-17 Joerg Wunsch + + * avrdude.conf.in: The ATmega128 has four oscillator calibration + bytes, not only a single one. + This closes bug #11496: Memory bank calibration on atmega128 + should have 4 bytes + +2005/09/17 Brian S. Dean + + * avrdude.1: + Document -q -q. Expand a little on the description of the 'part' + command. + +2005/09/16 Brian S. Dean + + * fileio.c: + * main.c: + Implement -q -q to be very very quiet. + +2005/09/16 Brian S. Dean + + * avrdude.conf.in: + Add DAPA programmer. + +2005/09/16 Brian S. Dean + + * avrdude.conf.in: + * stk500v2.c: + This fixes EEPROM access using the STK500V2 programmer, partially + undoing part of a previous general fixup commit. Choose the correct + read/write operations with the stk500v2 program function - the correct + one depends on the memory type. EEPROM is byte addressable so uses + read/write. FLASH is word addressable and so uses read_lo/write_lo. + +2005-09-16 Joerg Wunsch + + * avrdude.1: document the memtypes for -U + * doc/avrdude.texi: (Ditto.) + Closes bug #13501: should be listed in the man page + +2005-09-16 Joerg Wunsch + + * doc/Makefile.am: add logic to detect the misf^H^H^H^H + gratitous API change in recent versions of texi2html where + the output directory has changed names. + Fix for: + bug #13026: The build fails with texi2html 1.76 + bug #12715: make issues during install + patch #3091: commandline fix for latest version of texi2html + +2005-09-16 Joerg Wunsch + + * usb_libusb.c (usbdev_drain): actually implement draining to aid + synchronizing against a JTAG ICE in weird state. + +2005-09-16 Joerg Wunsch + + * butterfly.c: improve the butterfly initialization so it is more likely + to synchonize; [bug #9787: avrdude 4.4.0 correct butterfly interface] + +2005-09-14 Joerg Wunsch + + * jtagmkII.c (jtagmkII_paged_load): return the number of bytes read. + This makes EEPROM block reads work again. + +2005-09-14 Joerg Wunsch + + * avrdude.conf.in: add a jtag2slow programmer alias, and make + "jtag2" default to 115200 Bd. + * doc/avrdude.texi: document the above changes. + +2005/09/14 Brian S. Dean + + * avrdude.conf.in: + Change bit 0 of the ATmega169 efuse 'write' opcode from 'x' (ignore) + to 'i' (input). Even though this bit should be ignored, it should not + be changed. The 'x' setting sets the bit to zero which programs it + and could cause undefined behaviour. Setting to 'i' enables it to be + rewritten to its old value. + + A better solution might be to read the fuse byte, apply the new value + while leaving the 'x' bit alone, then writing the value back. The + current fix is a workaround which allows the developer to change the + bit as desired. + +2005-08-30 Joerg Wunsch + + * usb_libusb.c: Consistently use unsigned char for buffers. + +2005-08-29 Brian S. Dean + + * avr910.c: Eliminate compiler warnings. GCC 4.x elicits many + signedness warnings when passing unsigned char * when char * is in + the prototype and vice versa. Clean these up along with a few + others. + * butterfly.c: (Ditto.) + * jtagmkII.c: (Ditto.) + * safemode.c: (Ditto.) + * safemode.h: (Ditto.) + * ser_posix.c: (Ditto.) + * serial.h: (Ditto.) + * stk500.c: (Ditto.) + * stk500v2.c: (Ditto.) + +2005-08-28 Joerg Wunsch + + * avrdude.conf.in: Add support for the ATtiny25/45/85. Note that + only the ATtiny45 appears to have a complete XML description right + now. + * avrdude.1: Mention all the recently added device support: AT90PWM2/3, + ATmega164/324/644, ATmega329x/649x, ATtiny25/45/85. + * doc/avrdude.texi: (Ditto.) + +2005/08/28 Brian S. Dean + + * avrdude.conf.in: + * stk500v2.c: + This is patch # 4338, obsoletes patch #4327, provides fixes for bugs + #13693, #13871, and #14212. + + This provides bug fixes to the STK500V2 programmer type. + + - incorrect token used from avrdude.conf.in + - wrong command sent to programmer, hence no write to eeprom. + - programmer was said to start writing at 0x0000 and continue + page by page and was not repositionned when a gap was found + in the hex file, or when the hex file start address was not + 0x0000. Hence the verify procedure was correct, not the + write procedure. + - speed up of flash write to skip empty pages (full of 0xFF) + by re-enabling a dedicated function for that task. + - stk500v2_paged_load() was not returning the number of byte + read, so empty hex files were generated when reading memory. + +2005-08-17 Joerg Wunsch + + * avrdude.conf.in: fix the EEPROM size for ATmega329x/649x. + +2005-08-16 Joerg Wunsch + + * avrdude.conf.in: Add support for the AT90PWM2/3. + +2005-07-27 Joerg Wunsch + + (This work has been done as part of a contract with Atmel, Dresden.) + * butterfly.c: Implement full support for AVR109 boot loaders. + * avrdude.conf.in: add avr109 and avr911 as alias for butterfly. + * avrdude.1: Document the AVR109 addition. + * doc/avrdude.texi: (Ditto.) + +2005-07-26 Brian S. Dean + + * main.c: + Don't call exit() directly here - set the exit value and jump to the + main_exit: label to ensure the programmer is released correctly. + + * stk500v2.c: + The stk500v2_getsync() function was improperly checking for success, + thus it was falsely reporting that it failed when it was actually + working correctly. Fixed. + +2005-07-25 Joerg Wunsch + + * usb_libusb.c: Catch benign errors when reading the serial #. + +2005-06-19 Joerg Wunsch + + * Makefile.am: Implement libusb-base USB transport for the + JTAG ICE mkII. + * configure.ac: ditto. + * jtagmkII.c: ditto. + * ser_posix.c: ditto. + * ser_win32.c: ditto. + * serial.h: ditto. + * usb_libusb.c: ditto (New file). + * avrdude.1: document the USB transport. + * doc/avrdude.texi: ditto. + +2005-06-15 Joerg Wunsch + + * avrdude.conf.in: The AT90CAN128 has AllowFullPageBitstream = no. + +2005-06-14 Joerg Wunsch + + * avrdude.conf.in: Add support for the ATmega164/324/644. + * jtagmkII.c: If enter_progmode fails with RSP_ILLEGAL_JTAG_ID, give + the user a hint that the JTAGEN fuse might be unset. + +2005-06-11 Joerg Wunsch + + * avrdude.conf.in: Add support for the ATmega329x/649x. + +2005-05-27 Joerg Wunsch + + * jtagmkII.c: fix a signedness bug when shifting bits; when + discarding a packet for being overly long, restart the state + machine instead of attempting to drop a preposterous amount + of data. + +2005-05-19 Joerg Wunsch + + * avrdude.1: + * doc/avrdude.texi: Document that the JTAG ICE mkII code currently + cannot write to flash one byte at a time. Also mention the bug + tracker interface on savannah. + +2005/05/14 Brian S. Dean + + * configure.ac: + * main.c: + Update version for beta release and copyright message. + Change the default port to 'serial' for the newly added serial + programmers stk500v2 and jtagmkii. + +2005-05-10 Joerg Wunsch + + * Makefile.am: + * avr910.c: + * avrdude.1: + * avrdude.conf.in: + * avrpart.c: + * avrpart.h: + * butterfly.c: + * config_gram.y: + * crc16.c: + * crc16.h: + * jtagmkII.c: + * jtagmkII.h: + * jtagmkII_private.h: + * lexer.l: + * main.c: + * pgm.h: + * serial.h: + * ser_posix.c: + * ser_win32.c: + * stk500.c: + * stk500v2.c: + * stk500v2.h: + * stk500v2_private.h: + * doc/avrdude.texi: + + Mega-commit to bring in both, the STK500v2 support from Erik + Walthinsen, as well as JTAG ICE mkII support (by me). + + Note that for the JTAG ICE, I did change a few things in the + internal API. Notably I made the serial receive timeout + configurable by the backends via an exported variable (done in + both the Posix and the Win32 implementation), and I made the + serial_recv() function return a -1 instead of bailing out with + exit(1) upon encountering a receive timeout (currently only done + in the Posix implementation). Both measures together allow me to + receive a datastreem from the ICE at 115 kbps on a somewhat lossy + PCI multi-UART card that occasionally drops a character. The JTAG + ICE mkII protocol has enough of safety layers to allow recovering + from these events, but the previous code wasn't prepared for any + kind of recovery. The Win32 change for this still has to be done. + +2005/02/11 Brian S. Dean + + * main.c: + Exit non-zero if safe-mode reverts fuse bits that were requested on + the command-line. + + Variable declarations must only appear at the beginning of a block. + +2005/02/10 Brian S. Dean + + * avrdude.1: + Document -u option to disable safe mode. + +2005/02/10 Brian S. Dean + + * configure.ac: + doc/Makefile is now dependent on whether or not doc is enabled. + +2005/02/10 Brian S. Dean + + * Makefile.am: + * configure.ac: + Disable the doc build by default; the tools needed to build + doc are either not available on all systems or are at best + inconvenient to build and install. The doc can still be built, one + just needs to specify --enable-doc at configure time. + +2005-01-24 Colin O'Flynn + + * main.c: Add "safe mode". Fuse settings will be restored at the end + of a programming session unless the -u switch is specified. + * safemode.c: New file. Safe mode support. + * safemode.h: New file. Safe mode support. + * Makefile.am: Add new files. + * doc/avrdude.texi: Document new Safe Mode feature and switch. + +2004/12/22 Brian S. Dean + + * avrdude.conf.in: + Add support for "Xilinx JTAG cable". Contributed by: + Tymm + + Add support for the AT90CAN128. Not sure if all the instruction + encoding is correct, specifically the address bits don't exactly match + those of the preliminary datasheet that I have, but I don't see how + they could be right. Tested with STK500 and it works there. + Instruction encodings have not been tested due to lack of a parallel + port on my Mac development box. + +2004-07-19 Theodore A. Roth + + * avrdude.1: Remove reference to ppi programmer schematic. + * configure.ac (AC_INIT): Set version to "4.4.0cvs". + +2004-07-18 Theodore A. Roth + + * AVRDUDE 4.4.0 has been released (cvs release tag is "release_4_4_0"). + +2004-07-18 Theodore A. Roth + + * Makefile.am (EXTRA_DIST): Remove avrdude.pdf since it is no longer + supplied. + * NEWS: Fix typo. + * bootstrap: Delete the autom4te.cache dir before running the + autotools. + * configure.ac (AC_INIT): Set version to 4.4.0. + +2004-07-17 Jan-Hinnerk Reichert + + * avrdude.1: Fixed obvious copy and paste error + (Patch #3199 contributed by Galen Seitz) + +2004-07-15 Theodore A. Roth + + * main.c (main): Don't indent CPP directives. + When showing update progress in a no tty situation, use unbuffered IO + for all systems, not just win32 native. + Update copyright year when printing version. + Remove warning about native win32 being experimental. + Split a line string. + * ppiwin.c: Update copyright year. + Add cvs Id keyword. + (usleep): Cleanup debug CPP directives to improve readability. + * ser_win32.c: Include to fix failing build. + +2004-07-08 Theodore A. Roth + + * AUTHORS: Add names of recent major contributors. + * ser_win32.c: Assign copyright to Martin J. Thomas since he did all + real work on this file. + +2004-07-07 Jan-Hinnerk Reichert + + * NEWS, doc/TODO: Updated NEWS and TODO + +2004-07-07 Jan-Hinnerk Reichert + + * stk500.c, term.c, doc/avrdude.texi, avrdude.1: + added "sck"-command to the terminal mode. + This command allows slowing down of the SCK of + STK500-programmers. + +2004-07-05 Jan-Hinnerk Reichert + + * *.c, *.h: Removed unnecessary includes of + config.h + +2004-07-04 Jan-Hinnerk Reichert + + * avr.h: Removed some unused prototypes + +2004-07-04 Jan-Hinnerk Reichert + + * stk500.c: Fixed fosc behaviour for values exceeding + maximum frequency (contributed by Galen Seitz) + +2004-07-04 Jan-Hinnerk Reichert + * avrdude.conf.in: Added support for + ATtiny2313 (contributed by Bob Paddock) + +2004-06-25 Joerg Wunsch + + * avrdude.conf.in: Fix efuse bits for ATmega169. + +2004-06-24 Alex Shepherd + + Merged in Win32 Native changes contributed by Martin Thomas + Changed all instances of __CYGWIN__ conditional compilation to + WIN32NATIVE + + * ser_win32.c: fleshed out all the previous stubs + * ser_posix.c: added WIN32NATIVE conditional compilation to skip + all function to allow ser_win32.c functions to operate + * ppi.h: removed commented code + * pgh.h: added usleep macros + * main.c: stdout,stderr tweaks for Win32 + * configure.ac: added CFLAGS and LDFLAGS for Win32Native + * config_gram.y: added strtok_r macro + * buterfly.c: added various stub functions and EXIT processing + * avr910.c: added return 0 to avr910_open() and included time headers + * term.c: added warning about libreadline not supported in WIN32NATIVE + +2004-06-17 Jan-Hinnerk Reichert + + * avrdude.conf.in: Added support for + - tiny13 (contributed by Pawel Moll) + - mega48 and mega88 (contributed by Galen Seitz) + However, the STK500-code for mega8 remains unchanged. + +2004-05-19 Brian S. Dean + + * main.c: + * stk500.c: Allow the baud rate to be specified on the command + line with a new -b switch. The specified baud rate will + override the default serial port baud rate for a particular + programmer. + +2004-05-19 Brian S. Dean + + * ppi.c: Stub-out the ppi_* functions in ppi.c with empty + wrappers that simply return an error code in order to build + successfully on MacOS X. This allows avrdude to work on MacOS + X and was tested using a USB<->RS232 cable adapter, + specifically Keyspan model USA-19HS. + +2004-04-23 Joerg Wunsch + + * lists.h, lists.c: Drop LISTSZ and the check for + it in lcreat(). + +2004-04-17 Jan-Hinnerk Reichert + + * avr910.c: Hopefully fixed that weird "first byte not + programmed"-error in a good way (previous fix was not + working with all firmwares) + +2004-02-10 Jan-Hinnerk Reichert + + * avrdude.1, doc/avrdude.texi, doc/TODO: + Removed the deprecated options from documentation + +2004-02-10 Jan-Hinnerk Reichert + + * main.c: Removed deprecated options. + +2004-01-28 Jan-Hinnerk Reichert + + * pgm.c, main.c, avr910.c, butterfly.c, stk500.c: + Changed default for powerup, powerdown and LED-commands + to do nothing and return OK. Then removed these commands + from avr910, butterfly and stk500. + * pgm.c: Fixed wrong type for default_open introduced by + the cleanup yesterday. + +2004-01-29 Jan-Hinnerk Reichert + + * par.c: changed order of port-read/writes in par_txrx(). + This change should increase immunity to delays in the + programmer-hardware. + Also did some unrelated cleanup in par_txrx(). + +2004-01-28 Jan-Hinnerk Reichert + + * pgm.[ch], main.c, par.c, avr910.c, butterfly.c, stk500.c: + Move save/restore-functionality into open/close. + * par.c: open/close now saves/restores PPICTRL, too. + * TODO: exitspecs don't work if RESET is in PPICTRL. + +2004-01-26 Theodore A. Roth + + * configure.ac (AC_INIT): Post release version update. + +2004-01-26 Theodore A. Roth + + * AVRDUDE 4.3.0 has been released (cvs release tag is "release_4_3_0"). + +2004-01-26 Theodore A. Roth + + * configure.ac: Update copyright year. + (AC_INIT): Set version to 4.3.0. + +2004-01-25 Theodore A. Roth + + * ChangeLog: Minor formatting cleanups. + Move to all 2003 entries to ChangeLog-2003. + * ChangeLog-2003: New file. + * Makefile.am: Update copyright year. + (EXTRA_DIST): Add ChangeLog-2003. + +2004-01-17 Jan-Hinnerk Reichert + + * doc/avrdude.texi: Get rid of those black boxes marking "overfull + hbox". + +2004-01-17 Jan-Hinnerk Reichert + + * doc/avrdude.texi: New appendix "Troubleshooting". + +2004-01-12 Jan-Hinnerk Reichert + + * avr910.c, avrpart.c, avrpart.h, doc/TODO: + Look up devicecode and report device. + +2004-01-03 Jan-Hinnerk Reichert + + * avr910.c, pgm.c, pgm.h, config_gram.y, lexer.l: Add new configuration + parameter baudrate to support avr910-programmers with non-standard + baudrates. + * avrdude.conf.in, doc/avrdude.texi: Added "baudrate" to documentation. + +2004-01-03 Jan-Hinnerk Reichert + + * avr910.c: Removed debugging stuff that is no longer needed. + +2004-01-03 Jan-Hinnerk Reichert + + * doc/TODO: Removed two items. + +2004-01-03 Jan-Hinnerk Reichert + + * main.c, avr.c, avr.h, par.c, stk500.c: Add function + avr_chip_erase() to unify handling of cycle-count. + Makes cycle-count work for avr910-programmers. + diff --git a/xs/src/avrdude/ChangeLog-2007 b/xs/src/avrdude/ChangeLog-2007 new file mode 100644 index 000000000..3514da7e0 --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2007 @@ -0,0 +1,364 @@ +2007-11-08 Joerg Wunsch + + * main.c: Partially revert the line buffered output change, + and turn stderr into unbuffered output while producing the + progress report. + +2007-11-07 Joerg Wunsch + + * main.c: Add setup and teardown hooks to the programmer + definition. If present, call the setup hook immediately after + finding the respective programmer object, and schedule the + teardown hook to be called upon exit. This allows the + programmer implementation to dynamically allocate private + programmer data. + * pgm.c: (Ditto.) + * pgm.h: (Ditto.) + * avr910.c: Convert static programmer data into dynamically + allocated data. + * butterfly.c: (Ditto.) + * jtagmkI.c: (Ditto.) + * jtagmkII.c: (Ditto.) + * stk500v2.c: (Ditto.) + * usbasp.c: (Ditto.) + * usbtiny.c: (Ditto.) + +2007-11-06 Joerg Wunsch + + * butterfly.c: Remove the no_show_func_info() calls, as Brian + promised some 4 years ago. + +2007-11-06 Joerg Wunsch + + * main.c: Add the -x option to pass extended parameters to + the programmer backend. + * pgm.c: (Ditto.) + * pgm.h: (Ditto.) + * jtagmkII.c: Implement the extended parameter jtagchain= + to support JTAG daisy-chains. + * avrdude.1: Document all of the above. + * doc/avrdude.texi: (Ditto.) + +2007-10-30 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version for post-release. + +2007-10-29 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version, releasing avrdude-5.5. + +2007-10-29 Joerg Wunsch + + Submitted by : + patch #5007: Patch for line-buffering of stdout and stderr + * main.c: call setvbuf() for stdout and stderr. + +2007-10-29 Joerg Wunsch + + Submitted by : + patch #5953: Add AT90CAN64 and AT90CAN32 to avrdude.conf + * avrdude.conf.in: Add entry for AT90CAN64 and AT90CAN32. + +2007-10-29 Joerg Wunsch + + Submitted by Wolfgang Moser: + patch #6121: ISP support for the C2N232I device (serial port + bitbanging) + * avrdude.conf.in: Add entry for c2n232i. + +2007-10-29 Joerg Wunsch + + Submitted by : + patch #6141: accept binary format immediate values + * fileio.c: Detect a 0b prefix, and call strtoul() differently + in that case. + +2007-10-29 Joerg Wunsch + + bug #21076: -vvvv serial receive prints are empty in Win32 build + * ser_win32.c (ser_recv): Drop the essentially unused variable + "len", and use the variable "read" in order to track how many + bytes have just been read in. + +2007-10-29 Joerg Wunsch + + bug #21145: atmega329p not recognized + * avrdude.conf.in: Add definitions for the ATmega329P/3290P. + Same as ATmega329/3290 except of the different signature. + +2007-10-29 Joerg Wunsch + + bug #21152: Unable to program atmega324p with avrdude 5.4 and AVRISP + using default configuration file. + * avrdude.conf.in: Uncomment the (bogus) stk500_devcode lines for + the ATmega164P, ATmega324P, ATmega644, and ATmega644P definitions. + This only affects users of STK500v1 firmware. + +2007-10-29 Joerg Wunsch + + Submitted by : + Patch #6233: Add support for USBtinyISP programmer + * usbtiny.c: New file. + * usbtiny.h: (Ditto.) + * Makefile.am: Include usbtiny into the build. + * avrdude.conf.in: (Ditto.) + * config_gram.y: (Ditto.) + * lexer.l: (Ditto.) + * avrdude.1: Document the usbtiny support. + * doc/avrdude.texi: (Ditto.) + +2007-10-29 Joerg Wunsch + + * doc/avrdude.texi: Sort list of supported programmers into + alphabetical order, add all missing programmers. + +2007-07-24 Thomas Fischl + + * usbasp.c: Added long addresses to support devices with more + than 64kB flash. Closes bug #20558: Long address problem with + USBasp. + +2007-06-27 Joerg Wunsch + + * Makefile.am (EXTRA_DIST): Add ChangeLog-2004-2006. + +2007-05-16 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version for post-release. + +2007-05-16 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version, releasing avrdude-5.4. + +2007-05-16 Joerg Wunsch + + * avrdude.conf.in: Fix AVR910 devcodes. It seems that the AVR109 + listing refers to "BOOT"-type code, while the standard codes are + different (usually one below). + +2007-05-16 Joerg Wunsch + + * avr.c (avr_read, avr_write): only use the paged_load and + paged_write backend functions iff the memory area in question has + a page_size != 0. + This is supposed to fix bug #19234: avrdude-5.3.1 segfaults when + stk500v1 tries to program an ATtiny15 + +2007-05-15 Joerg Wunsch + + * avr910.c: Fall back to avr_{read,write}_byte_default(). Fixes + bug #18803: Fuse reading regression in avrdude 5.3.1 with avr910 + programmer + +2007-05-15 Colin O'Flynn + + * avrdude.conf.in: Rename the ATmega164 and ATmega324 into + ATmega164P and ATmega324P, resp. Add an entry for the ATmega644P. + Fixes bug #19769: ATmega164p not recognized + +2007-05-15 Joerg Wunsch + + * ser_posix.c (ser_send): Don't select() on the output fd before + trying to write something to the serial line. That kind of + polling isn't very useful anyway, and it seems it breaks for the + Linux CP210x USB<->RS-232 bridge driver which is certainly a bug + in the driver, but we can just avoid that bug alltogether. + +2007-05-15 Joerg Wunsch + + * avrdude.conf.in: Fix the STK500v2 ISP delay parameter for + ATmega640/1280/1281/2560/2561. Atmel has changed the XML + files after the initial release. + +2007-05-01 Colin O'Flynn + + * safemode.c: -Oops - bug in verbose output. Fixed. + -Fixed handling of cases where programmer cannot read fuses (AVR910) + * main.c: -Also fixing handling of cases where programmer cannot + read fuses + This should close one or more bugs (18803, 19570) + +2007-05-01 Colin O'Flynn + + * safemode.c: Added verbose output from safemode routines. + +2007-03-25 Colin O'Flynn + + * stk500generic.c: Forgot to close the serial port before trying to + open it again, caused problems on Windows machines. + Closes bug #19411 + +2007-02-26 Joerg Wunsch + + * avrdude.conf.in: Add the AT90PWM2/3B devices. + +2007-02-02 Thomas Fischl + + * usbasp.c: Changed return value of function usbasp_initialize to stop + avrdude on communication errors between programmer and target. + Closes bug #18581: safemode destroys fuse bits + +2007-02-01 Joerg Wunsch + + * config_gram.y: Remove duplicate definition of token K_WRITEPAGE + +2007-01-30 Joerg Wunsch + + * butterfly.c: Implement ATmega256x support for butterfly/avr109. + +2007-01-30 Joerg Wunsch + + * configure.ac: Fix subdir handling. Now finally, "make + distcheck" will include the documentation into the tarball even if + the configure had been run without the --enable-doc. + +2007-01-30 Joerg Wunsch + + * safemode.c: Obtain progname from avrdude.h rather than trying to + roll our own (duplicate) copy of it. + * avr910.c: Constify char pointers. + * avrpart.c: (Ditto.) + * avrpart.h: (Ditto.) + * butterfly.c: (Ditto.) + * config.c: (Ditto.) + * config.h: (Ditto.) + * jtagmkI.c: (Ditto.) + * jtagmkII.c: (Ditto.) + * par.c: (Ditto.) + * pgm.c: (Ditto.) + * pgm.h: (Ditto.) + * serbb_posix.c: (Ditto.) + * serbb_win32.c: (Ditto.) + * stk500.c: (Ditto.) + * stk500v2.c: (Ditto.) + * usbasp.c: (Ditto.) + +2007-01-29 Joerg Wunsch + + * avrpart.c: More backend/library abstraction and generalization: + turn the list_parts() and list_programmers() functions into + general list iteration functions that call a caller-supplied + callback for each element. Implement list_parts() and + list_programmers() as private functions in main.c based on that + approach. + * avrpart.h: (Ditto.) + * main.c: (Ditto.) + * pgm.c: (Ditto.) + * pgm.h: (Ditto.) + +2007-01-25 Joerg Wunsch + + * Makefile.am: Rearrange everything so it is now built into a + libavrdude.a library, and link main.c against that library. + * configure.ac: Add AC_PROG_RANLIB as we are building a library + now. + +2007-01-24 Joerg Wunsch + + Major code cleanup. + - Make all internal functions "static". + - Make sure each module's header and implementation file match. + - Remove all library-like functionality from main.c, so only + the actual frontend remains in main.c. + - Add C++ brackets to all header files. + * avr.c: (Ditto.) + * avr.h: (Ditto.) + * avr910.c: (Ditto.) + * avr910.h: (Ditto.) + * avrdude.h: (Ditto.) + * avrpart.c: (Ditto.) + * avrpart.h: (Ditto.) + * bitbang.h: (Ditto.) + * butterfly.h: (Ditto.) + * config.c: (Ditto.) + * config.h: (Ditto.) + * confwin.h: (Ditto.) + * crc16.c: (Ditto.) + * crc16.h: (Ditto.) + * fileio.c: (Ditto.) + * fileio.h: (Ditto.) + * jtagmkI.h: (Ditto.) + * jtagmkII.h: (Ditto.) + * lexer.l: (Ditto.) + * lists.h: (Ditto.) + * main.c: (Ditto.) + * par.h: (Ditto.) + * pgm.c: (Ditto.) + * pgm.h: (Ditto.) + * ppi.c: (Ditto.) + * ppi.h: (Ditto.) + * safemode.h: (Ditto.) + * serbb.h: (Ditto.) + * serial.h: (Ditto.) + * stk500.h: (Ditto.) + * stk500v2.c: (Ditto.) + * stk500v2.h: (Ditto.) + * term.c: (Ditto.) + * term.h: (Ditto.) + * usbasp.h: (Ditto.) + * update.c: New file. + * update.h: New file. + * Makefile.am: Include update.c and update.h. + +2007-01-24 Joerg Wunsch + + Move all "extern" declarations into a centreal header file. + * Makefile.am: Add new avrdude.h. + * avrdude.h: New file. + * avr.c: Replace private extern decl's by #include "avrdude.h". + * avr910.c: (Ditto.) + * avrpart.c: (Ditto.) + * bitbang.c: (Ditto.) + * butterfly.c: (Ditto.) + * config.c: (Ditto.) + * config_gram.y: (Ditto.) + * fileio.c: (Ditto.) + * jtagmkI.c: (Ditto.) + * jtagmkII.c: (Ditto.) + * lexer.l: (Ditto.) + * main.c: (Ditto.) + * par.c: (Ditto.) + * pgm.c: (Ditto.) + * ppi.c: (Ditto.) + * ppiwin.c: (Ditto.) + * ser_avrdoper.c: (Ditto.) + * ser_posix.c: (Ditto.) + * ser_win32.c: (Ditto.) + * serbb_posix.c: (Ditto.) + * serbb_win32.c: (Ditto.) + * stk500.c: (Ditto.) + * stk500generic.c: (Ditto.) + * stk500v2.c: (Ditto.) + * term.c: (Ditto.) + * usb_libusb.c: (Ditto.) + * usbasp.c: (Ditto.) + +2007-01-13 Joerg Wunsch + + * avrdude.conf.in (ATmega8): Bump the delay values for flash + and EEPROM, based on the current Atmel XML file. + +2007-01-12 Joerg Wunsch + + * configure.ac: Improve the detection of the Win32 HID library, + and the presence of the header ddk/hidsdi.h. It now works + correctly under Cygwin and several flavours of MinGW. + * Makefile.am: Add new LIBHID pattern. + +2007-01-11 Joerg Wunsch + + * butterfly.c (butterfly_initialize): when sending the 'T' + command (which is ignored by current AVR109 bootloaders), + send the first reply from the list of supported device + codes back rather than using avrdude.conf's idea about + an AVR910 device code. Apparently, this solves disagreements + between different versions of at least the ATmega8 AVR910 + device code. + Closes bug #18727: Writing flash failed + +2007-01-07 Joerg Wunsch + + Reported by Till Harbaum: + * avrdude.conf.in (ATtiny25/45/85): Change HVSP reset from + 500 microseconds to 1 ms, matching the most recent Atmel XML + specs. diff --git a/xs/src/avrdude/ChangeLog-2008 b/xs/src/avrdude/ChangeLog-2008 new file mode 100644 index 000000000..f43a10abb --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2008 @@ -0,0 +1,185 @@ +2008-11-20 Joerg Wunsch + + * avrdude.h: Change the prototype for usleep() to be more Cygwin- + friendly. + * ppiwin.c: (Ditto.) + +2008-11-06 Joerg Wunsch + + Submitted by limor + * usbtiny.c (usbtiny_cmd): Replace sizeof() by a fixed constant + 4 for the result array, because otherwise it would take the size + of a pointer which miserably fails on 64-bit machines. + +2008-11-05 Joerg Wunsch + + patch #6609: Using PCI parallel port cards on Windows + * ppiwin.c (ppi_open): If the port parameter passed from the + -p option is neither lpt1/2/3, try interpreting it directly as + a base address. + * avrdude.1: Document the change. + * doc/avrdude.texi: (Ditto.) + +2008-11-04 Joerg Wunsch + + bug #22882: Erase Cycle Counter does not work for stk500v2 + * stk500v2.c (stk500v2_chip_erase,stk500hv_chip_erase): Return + the expected 0 for success rather than a protocol-dependant + number. + +2008-11-04 Joerg Wunsch + + bug #22883: Chip Erase performed even with no-write flag (-n) + * main.c: Do not erase the chip if both, -e and -n options have + been specified. + +2008-11-04 Joerg Wunsch + + bug #24589: AT90USB64* have wrong signature + * avrdude.conf.in: Uncomment the correct, and delete the wrong + signature for AT90USB646/647. Alas, the datasheet has never been + corrected for years. + +2008-10-31 Joerg Wunsch + + * jtagmkII.c: Fix a serious memory corruption that happened when + using the JTAG ICE mkII (or AVR Dragon) in ISP mode. The wrong + set of per-programmer private data had been allocated (stk500v2 + vs. jtagmkII) which was too small to hold the actual data. + * jtagmkII.h: (Ditto.) + * stk500v2.c: (Ditto.) + +2008-07-29 Joerg Wunsch + + * jtagmkII.c: Implement Xmega JTAG support. + * jtagmkII_private.h: Add EMULATOR_MODE_JTAG_XMEGA. + +2008-07-29 Joerg Wunsch + + * main.c: Remember whether the device initialization worked, and + allow to continue with -F if it failed yet do not attempt to + perform anything on the device itself. That way, -tF could be + specified for programmers like the STK500/STK600 even without a + device connected, just in order to allow changing parameters on + the programmer itself. + * avrdude.1: Document that possible use of the -F option. + * doc/avrdude.texi: (Ditto.) + +2008-07-29 Joerg Wunsch + + * stk500v2.c (stk600_xprog_paged_write): Fix a fatal miscalculation + of the number of bytes to be written which caused a malloc chunk + corruption. + +2008-07-27 Joerg Wunsch + + First implementation of ATxmega support. By now, only the + PDI mode of the STK600 is supported. Single-byte EEPROM + (and flash) updates do not work yet. + * avr.c: "boot" memory is a candidate memory region for paged + operations, besides "flash" and "eeprom". + * avrdude.conf.in: add ATxmega128A1 and ATxmega128A1revD + * avrpart.h: add the AVRPART_HAS_PDI flag (used to distinguish + ATxmega parts from classic AVRs), the nvm_base part field, and + the offset field for a memory region. + * config_gram.y: add "has_pdi", "nvm_base", and "offset" + * lexer.l: (Ditto.) + * main.c: disable auto_erase for ATxmega parts + * stk500v2.c: implement the XPROG functionality, and divert to + this for ATxmega parts + * avrdude.1: Document the changes. + * doc/avrdude.texi: (Ditto.) + +2008-07-25 Joerg Wunsch + + Fix a bunch of warnings. + * avr910.c (avr910_paged_load): possible unitialized use of + rd_size + * jtagmkI.c (jtagmkI_initialize): pointer signedness mixup + * jtagmkII.c (jtagmkII_print_parms1): propagate const'ness + of parameter + * usbasp.c (usbasp_transmit): pointer signedness mixup + * ser_avrdoper.c (usbGetReport): remove useless pointer deref + +2008-07-25 Joerg Wunsch + + Contributed by Ville Voipio: + patch #6501: New autotools support for avrdude + * Makefile.am: add @WINDOWS_DIRS@ to SUBDIR + * bootstrap: allow for autconf-2.61 and automake-1.10, too + * configure.ac: fix @WINDOWS_DIRS@ recursion, replace + AC_PROG_CC by AM_PROG_CC_C_O, for esoteric reasons + +2008-06-13 Joerg Wunsch + + Contributed by Janos Sallai : + patch #6074: added support for crossbow's MIB510 programmer + * avrdude.conf.in: Add entry for mib510. + * stk500.c: Add special hooks to handle the MIB510 programmer. + It mostly talks STK500v1 protocol but has a special hello and + goodbye sequence, and uses a fixed block size of 256 bytes. + * doc/avrdude.texi: Document support for mib510. + +2008-06-07 Joerg Wunsch + + Contributed by Klaus Leidinger : + * main.c: Realign verbose messages. + * avrpart.c: (Ditto.) + * avr910.c: Print the device code selected in verbose mode. + * butterfly.c: (Ditto.) + +2008-06-07 Joerg Wunsch + + Contributed by Klaus Leidinger : + Add check for buffermode feature, and use it if present. Can be + turned off using -x no_blockmode. + * avr910.c: Implement buffermode test and usage. + * avrdude.1: Document -x no_blockmode. + * doc/avrdude.texi: (Ditto.) + +2008-03-24 Joerg Wunsch + + * usb_libusb.c: #undef interface for Win32 + +2008-03-24 Joerg Wunsch + + * avr910.c: Add support for the -x devcode option. + * avrdude.1: Document -x devcode for avr910. + * doc/avrdude.texi: (Ditto.) + +2008-03-14 Joerg Wunsch + + Add initial support for the Atmel STK600, for + "classic" AVRs (AT90, ATtiny, ATmega) in both, + ISP and high-voltage programming modes. + * Makefile.am: Add -lm. + * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. + * config_gram.y: Add support for the stk600* keywords. + * lexer.l: (Ditto.) + * pgm.h: Add the "chan" parameter to set_varef(). + * stk500.c: (Ditto.) + * serial.h: Add USB endpoint support to struct filedescriptor. + * stk500v2.c: Implement the meat of the STK600 support. + * stk500v2.h: Add new prototypes for stk600*() programmers. + * stk500v2_private.h: Add new constants used in the STK600. + * term.c: Add AREF channel support. + * usb_libusb.c: Automatically determine the correct write + endpoint ID, the STK600 uses 0x83 while all other tools use + 0x82. Propagate the EP to use through struct filedescriptor. + * usbdevs.h: Add the STK600 USB product ID. + * tools/get-stk600-cards.xsl: XSL transformation for + targetboards.xml to obtain the list of socket and routing + card IDs, to be used in stk500v2.c (for displaying the + names). + * tools/get-stk600-devices.xsl: XSL transformation for + targetboards.xml to obtain the table of socket/routing cards + and their respective AVR device support for doc/avrdude.texi. + * avrdude.1: Document all the STK600 stuff. + * doc/avrdude.texi: Ditto. Added a new chapter for + Programmer Specific Information. + +2008-01-26 Joerg Wunsch + + * stk500v2.c (stk500v2_recv): Make length computation unsigned so + it cannot accidentally become negative. + diff --git a/xs/src/avrdude/ChangeLog-2009 b/xs/src/avrdude/ChangeLog-2009 new file mode 100644 index 000000000..1f993cbcf --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2009 @@ -0,0 +1,411 @@ +2009-11-09 David Hoerl + + * fileio.c: ihex2bin did not properly handle files > 64K bytes + * usb_libusb.c: re-enabled usb_reset for Macs (no reset causes lots of failures) + * avrdude.1: spacing issue for avr32 fixed. + +2009-11-09 Michal Ludvig + + * buspirate.c: Implemented reset= and speed= extended parameters. + * avrdude.1: Document the change. + +2009-11-04 Michal Ludvig + + * configure.ac, Makefile.am: Test if GCC accepts -Wno-pointer-sign + +2009-11-04 Michal Ludvig + + * buspirate.c: Implemented 'BinMode' support for + firmware 2.7 and higher. + * avrdude.1: Added info about BusPirate. + +2009-11-03 Michal Ludvig + + * arduino.c: Add on to bug #26703 / patch #6866 - clear DTR/RTS + when closing the port. + * Makefile.am: Silent warnings about signedness - they're useless + and annoying, especially for 'char' vars. + +2009-10-22 David Hoerl + + * usb_libusb.c: disabled usb_reset for Macs (same as FreeBSD) + +2009-10-12 Michal Ludvig + + * main.c: Re-added default to serial port for BusPirate. + +2009-10-12 David Hoerl + + * main.c: removed some avr32 code that was pushed into jtagmkII.c + * jtagmkII.c: consolodated the avr32 reset code and avr32_chipreset + * avrpart.h: modified AVRPART flags for avr32 + * lexer.l: added is_avr32 flag - only way to get yacc code to set flag + * avrdude.conf.in: updated avr32 section to include "is_avr32" flag + +2009-10-12 David Hoerl + + * config_gram.y: Restored inadvertantly removed buspirate entry + * lexer.l: Restored inadvertantly removed buspirate entry + +2009-10-12 Michal Ludvig + + * buspirate.c: Replace GNU-only %as with %s in sscanf call. + * ser_win32.c(ser_set_dtr_rts): Fixed typo in parameter name. + * NEWS: Announce BusPirate. + +2009-10-11 David Hoerl + + Support for AVR32 + + * AUTHORS: added myself + * NEWS: announced AVR32 support + * main.c: AVR32 flag tests to avoid several code blocks + * fileio.c: mods to ihex read function to handle address offsets and + size of avr32 + * jtagmkI.c: added cast to printf call to remove warning + * arduino.c: added header file to bring in prototype for usleep() + * config_gram.y: added defines for avr32, new jtag_mkii variant for avr32 + * jtagmkII_private.h: new jtag_mkii message types defined (used by + avr32program) + * jtagmkII.h: extern jtagmkII_avr32_initpgm() addition + * jtagmkII.c: huge amount of code in support of avr32 + * avrpart.h: additional flags to AVRPART for avr32 + * usb_libusb.c: modified verbose test for USB read per-byte messages by + by one, so with verbose=3 you get just full messages, 4 gives you bytes + too + * lexer.l: additions for avr32 + +2009-10-10 Michal Ludvig + + Support for Arduino auto-reset: + * serial.h, ser_avrdoper.c, ser_posix.c, ser_win32.c: Added + serial_device.set_dtr_rts implementations. + * arduino.c, stk500.c, stk500.h: Call serial_set_dtr_rts() + to reset Arduino board before program upload. + Inspired by patch #6866, resolves bug #26703 + +2009-10-08 Michal Ludvig + + * buspirate.c: Optimised buspirate_cmd() - reading 1kB EEPROM now + takes only 14 sec instead of almost 2 mins with the original + implementation. + +2009-10-08 Michal Ludvig + + * buspirate.c, buspirate.h: Support for the BusPirate programmer + * config_gram.y, avrdude.conf.in, main.c, lexer.l, Makefile.am: + Glue for BusPirate. + +2009-08-17 Joerg Wunsch + + * usb_libusb.c (usbdev_close): Repair the logic around the + conditional compilation of usb_reset() introduced in r798. + +2009-07-11 Joerg Wunsch + + * configure.ac: We are post-5.8 now. + +2009-07-11 Joerg Wunsch + + * configure.ac: Prepare for releasing version 5.8 + +2009-07-11 Joerg Wunsch + + Submitted by Roger Wolff: + bug #26527: bug in unicode conversion + * ser_avrdoper.c (convertUniToAscii): when encountering a UTF-16 + character that cannot be converted to ASCII, increment the UTF-16 + pointer anyway when proceeding. + +2009-07-11 Joerg Wunsch + + * jtagmkI.c (jtagmkI_send): Replace %zd format by %u since not all + implementations do understand the C99 formatting options (sigh). + * jtagmkII.c (jtagmkII_send): (Ditto.) + * stk500v2.c (stk500v2_recv): (Ditto.) + +2009-07-11 Joerg Wunsch + + bug #26002: HVPP of EEPROM with AVR Dragon and ATmega8 Fails + * avrdude.conf.in (ATmega8): add page size for EEPROM. + +2009-07-07 Joerg Wunsch + + * stk500v2.c: Fix a serious memory corruption problem resulting + out of the chaining of both, the stk500v2 and the jtagmkII + programmers for some programming hardware (JTAG ICE mkII and AVR + Dragon running in ISP, HVSP or PP mode), where both programmers + have to maintain their private programmer data. + +2009-07-02 Joerg Wunsch + + * configure.ac: Post-release (is pre-release...) + +2009-07-02 Joerg Wunsch + + * configure.ac: Prepare for releasing version 5.7 + +2009-07-02 Joerg Wunsch + + * main.c: Add my name to the copyright output when being verbose. + +2009-07-02 Joerg Wunsch + + Contributed by Shaun Jackman + bug #21798: Fix both XSLT scripts + * tools/get-dw-params.xsl (format-hex): Add the parameter count. + * tools/get-hv-params.xsl (format_cstack): Ditto. + +2009-07-02 Joerg Wunsch + + bug #21922: ATmega163 still not working in version 5.5 + * avrdude.conf.in (atmega163): fill in stk500v2 parameters, correct + some flash programming parameters as well. + +2009-07-02 Joerg Wunsch + + bug #22206: avrdude: ser_setspeed(): tcsetattr() failed + * ser_posix.c (ser_setspeed): Don't pass TCSAFLUSH to tcsetattr() as + it apparently fails to work on Solaris. After reading the + documentation again, it seems TCSAFLUSH and TCSANOW are indeed + mutually exclusive. + +2009-07-02 Joerg Wunsch + + bug #22234: WINDOWS version: HOWTO: Specify Serial Ports Larger than COM9 + * ser_win32.c (ser_open): prepend \\.\ to any COM port name, so it is + safe to be used for COM ports above 9. + +2009-07-02 Joerg Wunsch + + bug #26408: Crash in stk500v2_open() + * stk500generic.c: Implement setup and teardown hooks, calling in turn + the respective hooks of the stk500v2 implementation. + +2009-07-02 Joerg Wunsch + + bug #26130: Avrdude doesn't display it's version. + * main.c (usage): add a version number display to the default usage + message. + +2009-07-01 Joerg Wunsch + + bug #26412: avrdude segfaults when called with a programmer that does not + support it + * main.c: do not call pgm->perform_osccal() unless it is != 0. + +2009-06-24 Joerg Wunsch + + Contributed by Zoltan Laday: + patch #6825: xmega problems with JTAGICEmkII + * jtagmkII.c: Many fixes for Xmega devices. + * jtagmkII_private.h: Add various new constants required for + Xmega devices. + * avrdude.conf.in: New devices: ATXMEGA64A1, ATXMEGA192A1, + ATXMEGA256A1, ATXMEGA64A3, ATXMEGA128A3, ATXMEGA192A3, + ATXMEGA256A3, ATXMEGA256A3B, ATXMEGA16A4, ATXMEGA32A4, + ATXMEGA64A4, ATXMEGA128A4 + * avr.c (avr_read, avr_write): Add more names for (Xmega) + memory areas that require paged operation. + +2009-06-24 Joerg Wunsch + + * stk500v2.c (stk600_xprog_write_byte): Handle writing fuse bytes. + +2009-04-28 Joerg Wunsch + + Submitted by Carl Hamilton: + * update.c (parse_op): correctly \0-terminate buf after filling + it, before it is potentially used as the source of a call to + strlen or strcpy. + +2009-04-14 Joerg Wunsch + + * doc/avrdude.texi: Merge the -P 0xXXX option description from + avrdude.1. + +2009-04-14 Joerg Wunsch + + * configure.ac: declare AM_PROG_CC_C_O to avoid the warning + "compiling `config_gram.c' with per-target flags + requires `AM_PROG_CC_C_O' in `configure.ac'" + +2009-03-22 Joerg Wunsch + + bug #25971: "error writing to " with multiple -U params. + * fileio.c: Do not close the input/output stream when working on an + stdio stream. + +2009-02-28 Thomas Fischl + + Based on patch #6484 commited by Jurgis Brigmanis: + * usbasp.c: added software control for ISP speed + * usbasp.h: (Ditto.) + +2009-02-28 Joerg Wunsch + + * avr910.c (avr910_read_byte_flash): Eliminate a static variable that + hasn't been in use for 5 years. + +2009-02-27 Joerg Wunsch + + * configure.ac: Post-release 5.6. + +2009-02-27 Joerg Wunsch + + * configure.ac: Prepare for releasing version 5.6. + +2009-02-27 Joerg Wunsch + + Submitted by Ed Okerson: + * jtagmkII.c (jtagmkII_read_byte): Fix signature reading of + Xmega. + +2009-02-26 Joerg Wunsch + + Submitted by Mikael Hermansson: + * avrdude.conf.in (ATxmega256A3): new device. + * stk500v2 (stk500v2_initialize): Enable the AVRISPmkII as a + PDI-capable device for ATxmega parts. + +2009-02-25 Joerg Wunsch + + Submitted by Lars Immisch: + patch #6750: Arduino support - new programmer-id + * arduino.c: New file, inherits stk500.c. + * arduino.h: New file. + * Makefile.am: Add arduino.c and arduino.h. + * config_gram.y: Add arduino keyword. + * lexer.l: (Ditto.) + * avrdude.conf.in: (Ditto.) + * avrdude.1: Document the new programmer type. + * doc/avrdude.texi: (Ditto.) + +2009-02-25 Joerg Wunsch + + * stk500v2.c: Turn all non-const static data into instance data. + +2009-02-25 Joerg Wunsch + + * Makefile.am: Move term.[ch] from the library into the CLI + application section, as it is not useful for anything else but + the CLI frontend. + +2009-02-25 Joerg Wunsch + + * avrdude.conf.in (ATmega1284P): new device. + +2009-02-23 Joerg Wunsch + + More fixes for Solaris, including fixes for the Sunpro compiler: + * avr.h: Remove stray semicolon. + * configure.ac: Add check for predefined types uint_t and ulong_t. + * confwin.c: Include "avrdude.h" on top to avoid empty translation + unit warning. + * ppwin.c: (Ditto.) + * ser_win32.c: (Ditto.) + * serbb_win32.c: (Ditto.) + * jtagmkII.c (jtagmkII_recv): remove unreachable "return". + * stk500.c (stk500_initialize): (Ditto.) + * par.c: Test for both, __sun__ and __sun to see whether we are + being compiled on Solaris. + * ppi.c: (Ditto.) + * stk500v2.c: Implement the DEBUG and DEBUGRECV macros in a way + that is compatible with the ISO C99 standard. + * usbtiny.c: Only typedef uint_t and ulong_t if they have not + been found already by the autoconf checks. + +2009-02-23 Joerg Wunsch + + bug #22204: Solaris10/11 Undefiniertes Symbol gethostbyname socket + connect + * configure.ac: Add checks for gethostent() and socket(). + While being here, remove some old cruft left from ancient days. + +2009-02-22 Joerg Wunsch + + * lexer.l: Bump the %p size so AT&T lex will continue to work. + +2009-02-19 Joerg Wunsch + + (Partially) submitted by John Voltz: + bug #20004: AVRDUDE update (-U) operations do not close files + * fileio.c (fmt_autodetect, fileio): fclose() files. + +2009-02-18 Joerg Wunsch + + * usbtiny.c: Replace all but one (very unlikely to trigger) exit(1) + by return -1. + +2009-02-18 Joerg Wunsch + + Submitted by Dick Streefland: + patch #6749: make reading from the USBtinyISP programmer more robust + * usbtiny.c: Add code to retry failed communication attempts. + +2009-02-17 Joerg Wunsch + + Submitted by Nick Hibma: + bug #22271: usb_reset in usb_libusb.c not necessary in FreeBSD 6.x + * usb_libusb.c (usbdev_close): Do not call usb_reset() on FreeBSD. + It is not necessary there. + +2009-02-17 Joerg Wunsch + + Submitted by Andrew O. Shadoura: + bug #25156: add direct SPI transfer mode + * bitbang.c: Implement direct SPI transfers. + * bitbang.h: (Ditto.) + * par.c: (Ditto.) + * pgm.c: (Ditto.) + * pgm.h: (Ditto.) + * term.c: Add the "spi" and "pgm" commands. + * avrdude.1: Document the changes. + * doc/avrdude.texi: (Ditto.) + +2009-02-17 Joerg Wunsch + + Submitted by Limor ("Lady Ada"): + bug #24749: add support for '328p + * avrdude.conf.in (ATmega328P): new device support. + +2009-02-17 Joerg Wunsch + + Submitted by "Womo": + bug #25241: AT90USB162, AT90USB82 device support patch for avrdude-5.5 + (also: bug #21745: AT90USBxx2 support) + * avrdude.conf.in (AT90USB162, AT90USB82): new device support. + +2009-02-17 Joerg Wunsch + + Submitted by Evangelos Arkalis: + patch #6069: Atmel AT89ISP Cable + * avrdude.conf.in (89isp): new programmer support. + +2009-02-16 Joerg Wunsch + + Submitted by Bob Paddock: + patch #6748: ATTiny88 Config + * avrdude.conf.in (ATtiny88): new device support. + +2009-02-16 Joerg Wunsch + + Submitted by Mark Litwack: + patch #6261: avrdude won't use dragon/debugwire to write a file + to eeprom + * jtagmkII.c (jtagmkII_paged_write): when in debugWire mode, + implement a paged write to EEPROM as a series of byte writes. + +2009-02-16 Joerg Wunsch + + Submitted by Janos Sallai: + patch #6542: paged_load fails on the MIB510 programming board + * stk500.c: Add a workaround for the different signon sequence on + MIB510 programmers. + +2009-02-05 Joerg Wunsch + + * avrdude.conf.in: Add the ATmega128RFA1. + * avrdude.1: document the addition of ATmega128RFA1. + * doc/avrdude.texi: (Ditto.) + diff --git a/xs/src/avrdude/ChangeLog-2010 b/xs/src/avrdude/ChangeLog-2010 new file mode 100644 index 000000000..45effefa4 --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2010 @@ -0,0 +1,354 @@ +2010-12-17 Joerg Wunsch + + * avrdude.conf.in (ATmega128RFA1): Bump two timing values in order to + improve ISP programming stability, in particular with the STK600. + +2010-12-14 Joerg Wunsch + + * stk500v2.c (stk500v2_command): Detect warning status codes. + +2010-10-22 Nils Springob + + * serial.h: serial_open() calls will now return -1 on error (no call to exit()) + * buspirate.c: (Dito.) + * jtagmkII.c: (Dito.) + * butterfly.c: (Dito.) + * jtagmkI.c: (Dito.) + * arduino.c: (Dito.) + * avr910.c: (Dito.) + * stk500.c: (Dito.) + * ser_avrdoper.c: (Dito.) + * stk500v2.c: (Dito.) + * ser_posix.c: (Dito.) + * usb_libusb.c: (Dito.) + +2010-07-27 Joerg Wunsch + + bug #30566: MinGW + Ubuntu 9.04 + * stk500v2.c (stk500v2_open): use same condition to refer to the AVR + Doper support as used in the definition in ser_avrdoper.c. + (Thanks to Christian Starkjohann for the analysis of the problem.) + +2010-07-19 Michal Ludvig + + * buspirate.c: Added compatibility with BusPirate "NewUI" firmware 5.x + (contributed by Kari Knuuttila) + +2010-07-12 Nils Springob + + * avrdude.conf.in (atmega88p): New device. + +2010-06-03 Joerg Wunsch + + bug #29913: 246 Byte Bug - AVRdude crashes + doc/avrdude.texi (Troubleshooting): Mention the libusb 0.1 API + wrapper issue that is present in some Linux versions. + +2010-03-19 Joerg Wunsch + + bug #29263: Can't build avrdude on windows using latest cygwin 1.7.1 + * doc/avrdude.texi: Remove the recommendation for building + Win32 binaries under Cygwin; mention MinGW as an alternative + environment. + +2010-03-08 Michal Ludvig + + * ser_posix.c(ser_set_dtr_rts): Fixed DTR on/off to make + Arduino auto-reset work. (bug #29108, patch #7100) + +2010-03-05 Joerg Wunsch + + * buspirate.c: Replace printf() by fprintf(stderr) + * safemode.c: (Dito.) + * usbtiny.c: (Dito.) + +2010-01-22 Joerg Wunsch + + Cleanup Cygwin builds. + * windows/Makefile.am (loaddrv_LDFLAGS): remove, the -mno-cygwin + flag is supposed to be set in CFLAGS by ./configure + * configure.ac: add a check for the presence of usleep(), add a + check whether the linker accepts -static + * avrdude.h: protect prototype for usleep by !defined(HAVE_USLEEP) + * ppwin.c (usleep): protect by !defined(HAVE_USLEEP) + * main.c: silence "array subscript of type char" compiler warnings + by casting all arguments to tolower()/toupper() and isspace()/ + isdigit()/ispunct() to "int" + * butterfly.c: (Dito.) + * avr910.c: (Dito.) + +2010-01-19 Joerg Wunsch + + * configure.ac: Bump for post-5.10. + +2010-01-19 Joerg Wunsch + + * configure.ac: Released version 5.10. + +2010-01-19 Joerg Wunsch + + bug #28677: Cygwin's GCC no longer supports -mno-cygwin option + * configure.ac: For Win32 environments, add a check whether the + compiler understands the -mno-cygwin option. If not, don't use + it but suggest using a different compiler. + +2010-01-18 David Hoerl + + bug #28660: Problem with loading intel hex rom files that exceed + 0x10000 bytes + * fileio.c: Fix two byte shifts. + +2010-01-15 Joerg Wunsch + + Submitted by Michael biebl: + * configure.ac: Fix FreeBSD default serial port name. + * doc/avrdude.texi: (Dito.) + +2010-01-15 Joerg Wunsch + + * jtagmkII.c: If entering JTAG mode fails with a bad JTAG ID + message, retry with external reset applied (in case the target + is in sleep mode or has asserted the JTD bit). + +2010-01-15 Joerg Wunsch + + Submitted by Aurelien Jarno: + * configure.ac: Fix build for GNU/kFreeBSD. + * ppi.c: (Dito.) + * par.c: (Dito.) + +2010-01-15 Joerg Wunsch + + * configure.ac: Bump version for post-5.8. + +2010-01-15 Joerg Wunsch + + * configure.ac: Bump version for release 5.8. + +2010-01-15 Joerg Wunsch + + Submitted by Soren Jorvang: + bug #28611: -i delay not being applied to all serial port + bit banging state transitions + * serbb_win32.c: Apply ispdelay everywhere. + * serbb_posix.c: (Dito.) + +2010-01-15 Joerg Wunsch + + * stk500v2_private.h: Implement TPI mode for AVRISPmkII/STK600 + * config_gram.y: (Dito.) + * avrpart.h: (Dito.) + * stk500v2.c: (Dito.) + * main.c: (Dito.) + * lexer.l: (Dito.) + * avrdude.conf.in: Add ATtiny4/5/9/10 + * avrdude.1: Document TPI and new device support. + * doc/avrdude.texi: (Dito.) + +2010-01-14 Joerg Wunsch + + Submitted by clint fisher: + patch #7038: Adding Atmega32U4 Device to avrdude.conf.in + * avrdude.conf.in (atmega32u4): New device. + * avrdude.1: Document the new device support. + * doc/avrdude.texi: (Dito.) + +2010-01-14 Joerg Wunsch + + Submitted by Thomas Pircher: + patch #6927: Documentation patches + * doc/avrdude.texi: Fix various typos, and remove the last + remnants of obsoleted options -i/-o/-m/-f. + * avrdude.1: Merge typo fixes from avrdude.texi where + applicable. + +2010-01-14 Joerg Wunsch + + * avrdude.1: Update documentation to match the reality (device + support, memory areas). + * doc/avrdude.texi: Update documentation to match the + reality (device support, programmer support, memory areas). + Merge buspirate-specific comments from avrdude.1. + * jtagmkII.c: Add some firmware feature checks. + +2010-01-13 Joerg Wunsch + + * jtagmkII.c: Implement PDI mode support for the JTAG ICE mkII + and the AVR Dragon. + * jtagmkII.h: (Dito.) + * config_gram.y: (Dito.) + * jtagmkII_private.h: (Dito.) + * avrdude.conf.in: (Dito.) + * lexer.l: (Dito.) + +2010-01-13 Joerg Wunsch + + * stk500v2.c: Update STK600 routing and socket card data from XML + file. + +2010-01-13 Joerg Wunsch + + * stk500v2.c: Cleanup the open/close handling to avoid accessing + unallocated memory (in the atexit handler) in case of bailing out. + * main.c: (Ditto.) + +2010-01-13 Joerg Wunsch + + * jtagmkII.c: Stylistic changes: move #defines out into + jtagmkII_private.h, drop all #if 0 blocks, fold overly long lines, + move the *_initpgm() functions to the end of the file; while being + here, remove all trailing whitespace. + * jtagmkII_private.h: move AVR32 #defines here. + +2010-01-12 Joerg Wunsch + + * bootstrap: autoconf 2.62 works well. + +2010-01-12 Joerg Wunsch + + Various fixes for Xmega devices. + * avrdude.conf.in: Correctly declare EEPROM page sizes for + all Xmega devices (0x20 instead of 0x100). + * avr.c: If a memory region has a page size declared, try + using the paged IO routines regardless of the target memory + name. Xmega EEPROM requires to be written in paged mode. + Correctly use a long (rather than unsigned long) variable to + evaluate the success status of the paged mode write attempt. + * stk500v2.c: Don't apply TIF space offsets twice (bug #27995: + AVRDUDE 5.8svn fails to program and read XMEGA); use + stk500v2_loadaddr() prior to paged mode (EEPROM and flash) writes, + otherwise programming of flash areas will fail; while being there, + check the return value of stk500v2_loadaddr() everywhere; use the + correct write/erase mode bits (same as AVR Studio does). + +2010-01-12 Michal Ludvig + + * buspirate.c: Initialise firmware version to v0.0 + prior to parsing the buspirate banner. + +2010-01-11 Joerg Wunsch + + Clean-up the Xmega erase functions. + * jtagmkII_private.h: Add CMND_XMEGA_ERASE as well as + the various XMEGA_ERASE_* definitions (from updated + appnote AVR067) + * jtagmkII.c (jtagmkII_chip_erase): Correctly implement Xmega chip + erase based on CMND_XMEGA_ERASE. After erasing an Xmega part, do + *not* reinitialize the world, as a subsequent programming + operation will fail (for unknown reasons). Actually, this was + really only required for ancient AVRs, but doesn't hurt on mega + and tiny devices. + * jtagmkII.c (jtagmkII_pre_write): Remove, this turned out + to be just a chip erase. + * jtagmkII.c (jtagmkII_program_disable): Don't try reading + "hfuse" for Xmega parts; they don't have it. + * main.c (main): Re-enable auto-erase. It's been done + before (as "jtagmkII_pre_write") in jtagmkII_paged_write() + anyway. Xmega boot and application flash areas should be + handled separately in the future, so auto_erase can only + affect the area just being programmed. + +2010-01-11 Joerg Wunsch + + * main.c (main): disable safemode for Xmega parts. + +2010-01-12 Michal Ludvig + + * buspirate.c: If the BusPirate doesn't respond + to a standard a reset command assume it was in binmode + and attempt to exit to text mode first. + +2010-01-08 Joerg Wunsch + + * bitbang.c: Fix Win32 build error: move freq up to the file + level. + * buspirate.c: Fix Win32 build warning: include to + to get a declaration for alloca(). + +2010-01-08 Thomas Fischl + + bug #28520: Programming with USBasp with low clock speed fails + * usbasp.c: Change blocksize depending on sck frequency to + avoid usb transmition timeouts. + +2010-01-08 Joerg Wunsch + + bug #27505: serbb_posix does not cope with inverted pins + * serbb_posix (serbb_highpulsepin): apply PIN_MASK when + checking pin numbers. + * serbb_win32 (serbb_highpulsepin): (Dito.) + +2010-01-08 Joerg Wunsch + + bug #28516: Linux/Dragon: Error message on exit + * stk500v2.c: Fix the "bad response to GO command: + RSP_ILLEGAL_EMULATOR_MODE" message. jtagmkII_close() + has been called with the wrong pgm->cookie. Wrap it + inside stk500v2_jtagmkII_close(), adjusting the cookie + data appropriately. + +2010-01-08 Joerg Wunsch + + Submitted by Doug: + patch #7010: Win32 enhanced bitbang_delay + * bitbang.c (bitbang_calibrate_delay, bitbang_delay): On Win32, + use the high-resolution performance counter rather than the + uneducated delay loop guess if it is available on the target + hardware. + +2010-01-08 Joerg Wunsch + + Submitted by Gerard: + patch #6828: Using arbitrary BAUD rates + * ser_posix.c (serial_baud_lookup): Allow non-standard baud + rates. + * ser_win32.c (serial_baud_lookup): (Dito.) + +2010-01-07 Joerg Wunsch + + Submitted by Eric Trein: + bug #27596: AT90s2333 is not correctly supported in avrdude.conf + * avrdude.conf.in (at90s2333): add various STK500v2 parameters. + +2010-01-07 Joerg Wunsch + + Submitted by Gyorgy Szekely: + bug #28458: Buffer line is incorrectly released for PP programmers + * par.c (par_close): use par_setmany() rather than par_setpin() + for PPI_AVR_BUFF. + +2010-01-07 Joerg Wunsch + + Submitted by Lukasz Goralczyk: + bug #27507: SIGSEGV when using avrdragon (avrdude 5.8) + * stk500v2.c (stk500v2_dragon_isp_initpgm): Use + stk500v2_jtagmkII_setup/stk500v2_jtagmkII_rather than their + jtagII counterparts, to get the private data properly + initialized. + +2010-01-07 Joerg Wunsch + + * buspirate.c: Cosmetics: remove UTF-8 dashes, adjust for 8-column + hard tabs. + +2010-01-07 Joerg Wunsch + + * buspirate.c: add $ Id $ line. + * buspirate.h: add $ Id $ line. + +2010-01-07 Joerg Wunsch + + Fix a few warnings that came up recently (some of them only triggered + by recent GCC versions). + * config_gram.y (parse_cmdbits): "brkt possibly used uninitialized" + (GCC errs here) + * jtagmkII.c (jtagmkII_reset32): "status possibly used uninitialized" + (I think GCC errs, too) + * buspirate.c: "pointers differ in signedness" (mismatch between + string processing and the use of "unsigned char" throughought the + AVRDUDE API) + +2010-01-01 Joerg Wunsch + + * jtagmkII.c (jtagmkII_smc_init32): replace sleep() by usleep() for + win32 compatibility. diff --git a/xs/src/avrdude/ChangeLog-2011 b/xs/src/avrdude/ChangeLog-2011 new file mode 100644 index 000000000..d8fffba01 --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2011 @@ -0,0 +1,489 @@ +2011-12-30 Rene Liebscher + + * avrdude.conf.in: Added is_at90s1200 option to part description + * doc/avrdude.texi: Added missing options to part definition + * config_gram.y: Fixed resetting of is_at90s1200 and is_avr32 flags + +2011-12-30 Rene Liebscher + + patch #7693: Fix config file atmel URLs + * avrdude.conf.in: Updated URLs + * avrpart.h: Updated URLs + * doc/avrdude.texi: Updated URLs + +2011-12-30 Joerg Wunsch + + * ser_posix.c (baud_lookup_table): Conditionalize the inclusion of + non-standard baud rates (only baud rates up to B38400 are + standardized by the Single UNIX Specification). + +2011-12-29 Rene Liebscher + + bug #34302: Feature request : device configuration with parent classes + * config_gram.y: Added part parent rule and allow overwriting existing + data at several places + * avrdude.conf.in: Added description comment and m328/m328p as example + * avrpart.c: avr_dup_mem-functions now copy buf and tags memory block + only they are already allocated. + * lexer.l: Added parent as valid token + + (not in original patch) + * avrpart.c: New function avr_dup_opcode. avr_dup_mem/avr_dup_part- + functions now duplicate the opcodes in their op-array to avoid memory leaks. + * doc/avrdude.texi: Added description of part parent feature + +2011-12-29 Rene Liebscher + + patch #7687: Autogenerating programmers and parts lists for docs + (generating the parts lists, programmers lists follows later) + * doc/Makefile.am: Add rule how to create avrdude before generating parts list + +2011-12-29 Rene Liebscher + + patch #7687: Autogenerating programmers and parts lists for docs + (generating the parts lists, programmers lists follows later) + * doc/avrdude.texi: Add include of generated table of parts + * doc/Makefile.am: Add generating of table of parts in parts.texi + * doc/parts_comments.txt: Adding file containing part commenz references + * avrdude.1: Remove table of parts and mention "-p ?" option + * avrpart.c: Use AVR_DESCLEN for strncasecmp at list sorting + +2011-12-22 Rene Liebscher + + * configure.ac: Add writing of definition of confsubst to config.status, + so it can run alone, not only called by configure. + +2011-12-17 Rene Liebscher + + patch #7680: Fixing timeout problem in ser_recv in ser_win32.c + * ser_win32.c: Return -1 at timeout in ser_recv(). + +2011-12-17 Rene Liebscher + + * config_gram.y: Fixed another memory leak, when define an operation + more than once + * avrdude.conf.in: Fixed double definition at ATmega6490 + +2011-12-17 Rene Liebscher + + * config_gram.y: Restructuring and compacting programmer definition + part of grammar (in preparation of patch #7688) + +2011-12-17 Rene Liebscher + + * avrdude.conf.in: Update documentation of programmer definition + * doc/avrdude.texi: Update documentation of programmer definition + and add list of implemented programmer types + +2011-12-17 Rene Liebscher + + patch #7667: Minor memory handling fixes + * config_gram.y: Added several free_token() calls. + +2011-12-16 Rene Liebscher + + patch #7671: Sorting programmers and parts lists for console output + * avrdude.conf.in: change part desc of several parts to common pattern + AT(mega|tiny|xmega)[0-9]+[A-Z]* (Upper case AT, lower case in middle) + * list.[ch]: added sorting function lsort() + * pgm.[ch]: added function sort_programmers() + * avrpart.[ch]: added function sort_avrparts() + * main.c: use sort functions in list_programmers() and list_parts() + * main.c: list functions show config file info only at verbose mode + +2011-10-19 Joerg Wunsch + + * configure.ac: Replace "cvs" in version number by "svn". + +2011-10-10 Joerg Wunsch + + bug #34518: loading intel hex files > 64k using record-type 4 + (Extended Linear Address Record) + fileio.c: Replace the change from r928 (handling of 0x8000000 + offset in AVR32 files) by a completely different logic that no + longer breaks hex files for other devices starting with an + offset; also apply a similar change to S-record files, as well + as when writing files. + fileio.c: (Ditto.) + +2011-09-15 Joerg Wunsch + + * avrftdi.c: Remove stray printf()s by fprintf(stderr) + * usbtiny.c: (Ditto.) + +2011-09-15 Joerg Wunsch + + * main.c: Restrict the cyclecounter readout to those cases where + it has been explicitly requested (by -y or -Y), rather than always + attempting to read the last EEPROM bytes. + +2011-09-15 Joerg Wunsch + + * stk500v2.c (stk600_xprog_paged_load, stk600_xprog_paged_write): + Fix regression in the AVRISPmkII/STK600 TPI handling introduced + by the USBasp's TPI implementation which added a pagesize even for + the minor memory regions of TPI devices. Also fix wrong offset + introduced by the memory tagging patch. + +2011-09-15 Joerg Wunsch + + * avr.c (avr_read, avr_write): Don't bail out on TPI parts if + their programmer doesn't provide a (low-level) cmd_tpi method; + instead, fall back to the normal programmer methods which are + supposed to handle the situation. + This fixes a regression where the recent bitbang-TPI implementation + broke TPI handling of STK600/AVRISPmkII. + +2011-09-14 Joerg Wunsch + + Mega-commit to bring in memory tagging. + Each memory image byte is now tagged as it's being read from a file. + Only bytes read from a file will be written or verified (modulo page + granularity requirements). + * avrpart.h: Add memory tags. + * avrpart.c: Allocate and initialize tag area. + * update.h: Drop unused parameter "verify" from do_op(). + * pgm.h: Add parameter base_addr to the paged_load and paged_write + methods, respectively. + * avr.h: New parameter to avr_read: second AVRPART to verify against. + * fileio.c: Track all memory regions that have been read from an + input file by tagging them. + * update.c: Call avr_read() with the new parameter list. + * main.c: Call avr_initmem() to initialize the memory regions, rather + than trying to duplicate an unitialized part, and then let the + original part rot away. + * avr.c: Implement the heart of the new featureset. For paged memory + areas, when writing or verifying, call the paged_write and paged_load + methods, respectively, once per page instead of on the entire memory. + When writing, only write bytes or pages that have content read from a + file. Whe verifying, only read memory bytes or pages where the + verification data have been read from a file. Only verify those bytes + that have been read from a file. + * avrftdi.c: Implement the new API for paged_load and paged_write, + respectively. + * jtagmkII.c: (Ditto.) + * butterfly.c: (Ditto.) + * jtagmkI.c: (Ditto.) + * avr910.c: (Ditto.) + * stk500.c: (Ditto.) + * usbasp.c: (Ditto.) + * stk500v2.c: (Ditto.) + * usbtiny.c: (Ditto.) + +2011-09-13 Joerg Wunsch + + * stk500v2.c (stk500v2_command): Treat warnings as errors rather than + success. + +2011-08-30 Joerg Wunsch + + bug #34027: avrdude AT90S1200 Problem (part 3 - documentation) + * avrdude.1: Document the programmer type restrictions for AT90S1200 + devices. + * doc/avrdude.texi: (Ditto.) + +2011-08-30 Joerg Wunsch + + bug #34027: avrdude AT90S1200 Problem (part 2 - stk500v2 and relatives) + * stk500v2.c (stk500v2_initialize): For the AT90S1200, release + /RESET for a moment before reinitializing, as this is required by + its programming protocol. + +2011-08-30 Joerg Wunsch + + * configure.ac: In AC_CHECK_LIB for libftdi, check for + ftdi_usb_get_strings() rathern than ftdi_init(), as this is a more + specific thing to search for in order to make sure getting a + recent enough libftdi. + +2011-08-29 Joerg Wunsch + + bug #34027: avrdude AT90S1200 Problem (part 1 - bitbang + programmers) + * config_gram.y: Introduce new keyword "is_at90s1200". + * lexer.l: (Ditto.) + * avrdude.conf.in: Applew new keyword to the AT90S1200 device. + * avrpart.h: Introduce new flag AVRPART_IS_AT90S1200, reflecting + the is_at90s1200 configuration keyword. + * bitbang.c (bitbang_initialize): Replace existing test for + AT90S1200 by AVRPART_IS_AT90S1200 + * avr.c (avr_write_byte_default): Avoid the pre-write reading for + the AT90S1200, as this appears to sometimes corrupt the high byte + by pre-programming the low byte just written into it. + +2011-08-27 Joerg Wunsch + + * configure.ac: Bump version for post-5.11. + +2011-08-27 Joerg Wunsch + + * configure.ac: Bump version for releasing AVRDUDE 5.11. + +2011-08-26 Joerg Wunsch + + * avrdude.1: Update the list of supported AVR devices. + * doc/avrdude.texi: (Ditto). + +2011-08-26 Joerg Wunsch + + * configure.ac: add -lusb as "other libraries" when checking + for libftdi. + +2011-08-26 Joerg Wunsch + + Submitted by Juergen Weigert: + patch #7056: adding support for mikrokopter bootloader to butterfly + * butterfly.c: Add some specific logic to handle the + mikrokopter.de butterfly bootloader. + * butterfly.h: Add one related function declaration. + * config_gram.y: Add butterfly_mk keyword. + * lexer.l: (Ditto.) + * avrdude.conf.in: Add entry for butterfly_mk. + +2011-08-26 Joerg Wunsch + + Submitted by Stefan Tomanek: + patch #7542: add default_bitclock to configuration files + * config.c: Add the new keyword and its handling. + * config.h: (Ditto.) + * config_gram.y: (Ditto.) + * avrdude.conf.in: (Ditto.) + * main.c: (Ditto.) + * lexer.l: (Ditto.) + * avrdude.1: Document the change. + * doc/avrdude.texi: (Ditto.) + +2011-08-26 Joerg Wunsch + + Submitted by Brett Hagman: + patch #7603: wiring - programmer type for Wiring boards + (based on STK500v2) + * wiring.c: New file. + * wiring.h: (Ditto.) + * Makefile.am: Add new files. + * stk500v2_private.h: Reorganize so some functions and struct + pdata are globally known. + * stk500v2.c: (Ditto.) + * stk500v2.h: (Ditto.) + * lexer.l: Add new programmer keywords. + * config_gram.y: (Ditto.) + * avrdude.conf.in: Add "wiring" programmer entry. + * avrdude.1: Document the new programmer. + * doc/avrdude.texi: (Ditto.) + * AUTHORS: Add Brett Hagman. + +2011-08-26 Joerg Wunsch + + Submitted by an anonymous contributor on the mailinglist: + * avrdude.conf (jtagkey): Add a definition for the Amontec + JTAGKey + +2011-08-26 Joerg Wunsch + + Submitted by Juergen Weigert: + bug #22720: avrdude-5.5 ignores buff settings in avrdude.conf + (Note that the actual bug the subject is about has been fixed + long ago.) + * update.c (do_op): fix a diagnostic message + * pgm.h: add exit_datahigh field + * par.c: set and act upon the exit_datahigh field + * avrdude.1: document the new -E options + * doc/avrdude.texi: (Ditto.) + +2011-08-26 Joerg Wunsch + + bug #33811: Parallel make fails + * Makefile.am (BUILT_SOURCES): Add this macro. + +2011-08-26 Joerg Wunsch + + bug #33114: Segfault after setting the DWEN fuse with Dragon + * jtagII.c (jtagmkII_getsync): Instead of exit()ing from + deep within the tree when detecting the "need debugWIRE" + situation, properly pass this up as a return code. + * jtagII_private.h (JTAGII_GETSYNC_FAIL_GRACEFUL): New constant. + * stk500v2.c (stk500v2_jtagmkII_open): Don't tell anything + anymore when receiving a JTAGII_GETSYNC_FAIL_GRACEFUL from + jtagmkII_getsync(); silently give up (all necessary has been + said already). + +2011-08-26 Joerg Wunsch + + Reported by Jason Hecker: + * usbasp.c (libusb_to_errno): Conditionalize some error codes + that apparently are lacking on MinGW. + +2011-08-25 Joerg Wunsch + + Fix warnings. + * ser_avrdoper.c: add so exit() is declared. + * usbtiny.c (usbtiny_open): provide an initializer to a + "may be used uninitialized" variable (since GCC could not + fully detect the logic behind). + +2011-08-25 Joerg Wunsch + + * configure.ac: Add a check for FreeBSD's libusb-1.0 + compatible library that is found in libusb.a/.so on + FreeBSD 8+. + +2011-08-25 Joerg Wunsch + + Submitted by Doug Springer, based on work by + Wolfgang Moser, Ville Voipio, Hannes Weisbach + patch #7486: Patch to add FT2232C/D, FT2232H, FT4232H, + usbvid, usbpid, usbdev for USB support - Based on #7062 + * avrftdi.c: New file. + * avrftdi.h: (Ditto.) + * configure.ac: Add check for libftdi. + * config_gram.y: Add AVRFTDI and per-programmer USB string + keywords. + * lexer.l: (Ditto.) + * avrdude.conf.in: Add avrftdi and 2232HIO programmers. + * pgm.h: Add USB parameters. + * Makefile.am: Add avrftdi.c and avrftdi.h. + * AUTHORS: Mention the new authors. + * avrdude.1: Document the changes. + * doc/avrdude.texi: (Ditto.) + +2011-08-23 Joerg Wunsch + + bug #29585: Fix license + * doc/avrdude.texi: Add FDL as an option to the licensing + statement, as the savannah administration would like it + that way. + +2011-08-23 Joerg Wunsch + + Submitted by Darell Tan: + patch #7244: TPI bitbang implementation + * bitbang.c: Add TPI bitbang stuff. + * bitbang.h: (Ditto.) + * avr.c: (Ditto.) + * avr.h: (Ditto.) + * pgm.c: (Ditto.) + * pgm.h: (Ditto.) + * serbb_posix.c: Wire bitbang_cmd_tpi into the struct pgm. + * serbb_win32.c: (Ditto.) + * par.c: (Ditto.) + * doc/avrdude.texi: Document the TPI bitbang support. + +2011-08-17 Joerg Wunsch + + Submitted by Grygoriy Fuchedzhy: + bug #31779: Add support for addressing usbtinyisp with -P option + * usbtiny.c (usbtiny_open): Add logic to distinguish multiple USBtinyISP + programmers by their bus:device tuple. + * doc/avrdude.texi: Document the new functionality. + * avrdude.1: (Ditto.) + +2011-08-16 Joerg Wunsch + + Submitted by Timon Van Overveldt: + bug #30268: Debugwire broken in avrdude-5.10 + * jtagmkII.c (jtagmkII_initialize): only try setting up a JTAG chain when + the programmer is using JTAG. + +2011-08-16 Joerg Wunsch + + bug #29636: AVRDude issues invalid CMD_CHECK_TARGET_CONNECTION + on the AVRISP-MKII + * stk500v2.c (stk500v2_program_enable): Rewrite the logic to + explain ISP activation failures. + * stk500v2_private.h: Fix the various STATUS_* constants; + AVR069 and AVR079 disagreed in their values, even though they + are apparently implementing the same logic behind. + +2011-08-16 Joerg Wunsch + + bug #29650: Programming timeouts in ATmega128RFA1 are too slow + * avrdude.conf.in (ATmega128RFA1): Bump write delay values for flash and + EEPROM to 50 ms. + +2011-08-16 Joerg Wunsch + + * avrdude.conf.in (ATmega8515, ATmega8535, ATmega48, ATmega88, ATmega88P, + ATtiny88, ATmega168, ATmega168P, ATmega328P): Bump delay value for STK500v2 + EEPROM write operation to 5, according to the respective XML files. + +2011-08-16 Joerg Wunsch + + Submitted by Darcy Houlahan: + bug #29694: error in avrdude.conf for attiny84 eeprom + * avrdude.conf.in (ATtiny84, ATtiny85): fix A7 bit in EEPROM write + command. + +2011-08-16 Joerg Wunsch + + Submitted by Durant Gilles: + * avrdude.conf.in (ATtiny4313): Fix flash addressing bits for manual ISP + algorithm. + +2011-08-16 Joerg Wunsch + + Submitted by Philip: + bug #31386: A "BUILD.svn" or similar "how to get started" doc would be helpful + * BUILD-FROM-SVN: New file. + +2011-08-15 Joerg Wunsch + + Submitted by Nic Jones: + bug #32539: [Documentation][Patch] Man page is misleading + re: Dragon & PDI + * doc/avrdude.texi: Update information about PDI connections + on AVR Dragon + +2011-08-12 Joerg Wunsch + + * usbasp.c: Add so this actually compiles + again. + +2011-08-12 Joerg Wunsch + + Contributed by tixiv@gmx.net: + bug #33345: File auto detection as binary doesn't open + file in binary mode on Windows + * fileio.c: Move the decision about opening files in + binary mode until before the fopen() call. + +2011-06-16 Thomas Fischl + + * avrdude.conf.in: Fix part id of ATtiny9. + +2011-05-28 Thomas Fischl + + Based on patch #7440 commited by Slawomir FraÅ›: + * usbasp.c: added TPI support for USBasp + * usbasp.h: (Ditto.) + +2011-05-11 Joerg Wunsch + + * avrdude.conf.in: Add support for ATmega168P. + +2011-05-11 Joerg Wunsch + + * avrdude.conf.in: Fix abbreviated name for ATmega324PA. + +2011-05-11 Joerg Wunsch + + Submitted by Lech Perczak: + bug #30946: Added support for ATmega8/16/32U2 + * avrdude.conf.in: Add ATmega8/16/32U2 entries. + +2011-05-11 Joerg Wunsch + + Submitted by David A Lyons: + patch #7393: Adding ATtiny4313 Device to avrdude.conf.in + * avrdude.conf.in: Add ATtiny4313 data. + +2011-05-11 Joerg Wunsch + + * usb_libusb.c: Bump timeout values to allow for slow clock + speeds. + * jtagmkII.c: (Ditto.) + +2011-03-04 Eric B. Weddington + + Thanks to Vitaly Chernookiy for the patch. + * avrdude.conf.in: Add support for atmega324pa. + * ChangeLog-2010: New file, rotate ChangeLog for new year. diff --git a/xs/src/avrdude/ChangeLog-2012 b/xs/src/avrdude/ChangeLog-2012 new file mode 100644 index 000000000..bb5751a6d --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2012 @@ -0,0 +1,729 @@ +2012-12-18 Joerg Wunsch + + * usbdefs.h (USBDEV_BULK_EP_WRITE_STK600) + (USBDEV_BULK_EP_READ_STK600): new define values + * stk500v2.c (stk600_open): use the STK600 EP values, + as they are different from AVRISPmkII + +2012-12-18 Joerg Wunsch + + bug #37942: Latest SVN can't program in dragon_jtag mode + * jtagmkII.c (jtagmkII_initialize): For Xmega devices, and + firmware >= 7.x, don't trigger a RESET, in order to work around a + firmware bug that appears to be present in at least firmware 7.24 + for the Dragon. + +2012-12-04 Joerg Wunsch + + * config_gram.y: Implement the "ocdrev" keyword + * avrpart.c: (Dito) + * avrpart.h: (Dito) + * lexer.l: (Dito) + * avrdude.conf.in: Add "ocdrev" key/value pairs, based + on the AS6 XML file information. + * jtag3.c: Use the ocdrev in the parameter block. + +2012-12-03 Joerg Wunsch + + * jtag3.c: Make jtag3_command() public + * jtag3.h: (Dito.) + * jtag3_private.h: Add two new commands + * stk500v2.c: Implement the "MonCon disable" hack that + allows temporarily falling back to ISP when trying to + talk to a part that has debugWIRE enabled + +2012-12-03 Rene Liebscher + + * pickit2.c: reordered #includes for non-usb configuration + +2012-12-03 Joerg Wunsch + + * jtag3.c: Enable interactive adjustment of the various + clock frequencies (JTAG Xmega, JTAG megaAVR, PDI Xmega) + through the set_sck_period() callback. + +2012-12-03 Joerg Wunsch + + * jtag3.c: Remove unused code that was left over from + cloning the jtagmkII.c implementation + +2012-12-03 Joerg Wunsch + + * pgm_type.c: Add "jtagice3_isp" programmer hook + * avrdude.conf.in: Add "jtag3isp" programmer + * jtag3.c: jtag3_setparm() is now public + * jtag3.h: (Dito) + * stk500v2_private.h: Command 0x1D is CMD_SPI_MULTI only + for STK500v2, AVRISPmkII, and JTAGICEmkII; for JTAGICE3, + it's CMD_SET_SCK now; also add CMD_GET_SCK + * avrpart.c (avr_get_output_index): New function + * avrpart.h: (Dito) + * stk500v2.c: Implement the pasthrough programmer glue logic + for JTAGICE3 in ISP mode + * stk500v2.h: (Dito) + * avrdude.1: Document the JTAGICE3 support. + +2012-11-30 Joerg Wunsch + + * jtag3.c (jtag3_read_byte, jtag3_write_byte): Remove the + m->offset from addr, JTAGICE3 doesn't need it anymore (similar + to JTAGICEmkII with 7+ firmware) + * jtag3.c (jtag3_read_byte): Allow for full-page reads of + EEPROM also for Xmega and debugWIRE, allow for signature + read in debugWIRE + +2012-11-30 Joerg Wunsch + + * jtag3_private.h: Add two more error detail codes I stumbled + across during development + * jtag3.c: (Dito.) + * usb_libusb.c: Reduce timeouts from 100 to 10 s, still long + enough, but not getting cold feet when something goes wrong. + +2012-11-29 Joerg Wunsch + + * jtag3.c: Handle events returned by the ICE + * usbdevs.h: Add defines that mark an event in return + from usb_recv_frame(). + * usb_libusb.c: (Dito.) + +2012-11-29 Joerg Wunsch + + * avrdude.conf.in: Remove "has_jtag" from Xmega A4 and D4 + devices, as they only have PDI. + * jtag3.c (jtag3_page_erase): Actually implement this. + +2012-11-29 Joerg Wunsch + + bug #37265: wrong page sizes for XMega64xx in avrdude.conf + * avrdude.conf.in: Fix page sizes for all Xmega devices, + by cross-checking against Atmel Studio's device XML files + +2012-11-29 Joerg Wunsch + + * jtag3.c: Fill in the missing pieces for Xmega support (both, + PDI and JTAG). + * jtagmkII.c (jtagmkII_set_xmega_params): Use "fuse1" rather + than "fuse0" memory space to fill in the NVM offset from, as + there is no "fuse0" on some Xmega devices. + +2012-11-29 Joerg Wunsch + + * avrdude.conf.in (ATmega256RFR2, ATmega128RFR2, ATmega64RFR2): + New devices + +2012-11-28 Joerg Wunsch + + First support for Atmel JTAGICE3. Guessed from USB sniffer + traces made by Knut Schwichtenberg, and by similarity to + JTAGICEmkII. + Still quite incomplete, just megaAVR/JTAG is done by now. + * jtag3.c: New file. + * jtag3.h: (Dito.) + * jtag3_private.h: (Dito.) + * pgm_type.c: Add new programmers + * avrdude.conf.in: (Dito.) + * usbdevs.h: Add new parameters + * Makefile.am: Add new files + * usb_libusb.c: Handle separate event endpoint, and larger + (USB 2.0) packet sizes + +2012-11-26 Joerg Wunsch + + * jtagmkII.c: Change all the USB details (endpoint numbers, + max transfer size etc.) to a per-programmer adjustable value. + * serial.h: (Dito.) + * stk500v2.c: (Dito.) + * usbdevs.h: (Dito.) + * usb_libusb.c: (Dito.) + +2012-11-20 Joerg Wunsch + + * buspirate.c: Replace outdated FSF postal address by a reference to + the GPL info on their website. + * jtagmkII.c: (Dito.) + * avrftdi.c: (Dito.) + * wiring.c: (Dito.) + * linux_ppdev.h: (Dito.) + * serbb.h: (Dito.) + * usbtiny.h: (Dito.) + * confwin.c: (Dito.) + * buspirate.h: (Dito.) + * avrftdi.h: (Dito.) + * wiring.h: (Dito.) + * jtagmkII.h: (Dito.) + * pickit2.c: (Dito.) + * config.c: (Dito.) + * term.c: (Dito.) + * confwin.h: (Dito.) + * avrdude.1: (Dito.) + * windows/Makefile.am: (Dito.) + * config.h: (Dito.) + * pickit2.h: (Dito.) + * term.h: (Dito.) + * tools/get-hv-params.xsl: (Dito.) + * tools/get-stk600-cards.xsl: (Dito.) + * tools/get-stk600-devices.xsl: (Dito.) + * tools/get-dw-params.xsl: (Dito.) + * butterfly.c: (Dito.) + * configure.ac: (Dito.) + * doc/Makefile.am: (Dito.) + * pgm_type.c: (Dito.) + * butterfly.h: (Dito.) + * jtagmkI.c: (Dito.) + * ft245r.c: (Dito.) + * COPYING: (Dito.) + * pgm_type.h: (Dito.) + * jtagmkI.h: (Dito.) + * pindefs.h: (Dito.) + * config_gram.y: (Dito.) + * arduino.c: (Dito.) + * arduino.h: (Dito.) + * ser_win32.c: (Dito.) + * serbb_win32.c: (Dito.) + * avr910.c: (Dito.) + * stk500.c: (Dito.) + * freebsd_ppi.h: (Dito.) + * avr910.h: (Dito.) + * solaris_ecpp.h: (Dito.) + * stk500.h: (Dito.) + * jtagmkII_private.h: (Dito.) + * avrdude.h: (Dito.) + * bitbang.c: (Dito.) + * bitbang.h: (Dito.) + * avrpart.c: (Dito.) + * safemode.c: (Dito.) + * stk500generic.c: (Dito.) + * serial.h: (Dito.) + * avrpart.h: (Dito.) + * jtagmkI_private.h: (Dito.) + * ppi.c: (Dito.) + * avr.c: (Dito.) + * safemode.h: (Dito.) + * stk500generic.h: (Dito.) + * ser_avrdoper.c: (Dito.) + * avr.h: (Dito.) + * ppi.h: (Dito.) + * usbasp.c: (Dito.) + * lists.c: (Dito.) + * stk500v2.c: (Dito.) + * my_ddk_hidsdi.h: (Dito.) + * tpi.h: (Dito.) + * usbasp.h: (Dito.) + * lists.h: (Dito.) + * stk500v2.h: (Dito.) + * ppiwin.c: (Dito.) + * fileio.c: (Dito.) + * ser_posix.c: (Dito.) + * fileio.h: (Dito.) + * serbb_posix.c: (Dito.) + * usbdevs.h: (Dito.) + * par.c: (Dito.) + * update.c: (Dito.) + * pgm.c: (Dito.) + * main.c: (Dito.) + * par.h: (Dito.) + * update.h: (Dito.) + * lexer.l: (Dito.) + * Makefile.am: (Dito.) + * pgm.h: (Dito.) + * usb_libusb.c: (Dito.) + * usbtiny.c: (Dito.) + +2012-11-13 Rene Liebscher + + bug #35186 inverting pins with "~" doesn't work for pin lists (i.e. vcc) + bug #37727 Add support for LM3S811 dev board as a programmer + * lexer.l,config_gram.y: accepting inverted pins at pin lists + syntax: ~num or ~(num,num,...) + * par.c: par_set_many_bits is now usable with inverted pins + * avrftdi.c: fixed wrong index in ftdi_pin_name + * avrdude.conf.in: added programmer lm3s811 + +2012-11-04 Rene Liebscher + + * lexer.l,config_gram.y,config.[hc]: changed reading of numbers to integers + except of default_bitclock which is the only real number. + No signs are allowed as negative values do not make sense for current + config values. + * buspirate.c: include own header file buspirate.h + * doc/.cvsignore: add programmers.texi to ignore list + +2012-09-06 Joerg Wunsch + + * doc/Makefile.am: add EXTRA_DIST, replace $(srcdir) by + $(builddir) for generated files, so "make distcheck" + works again + +2012-09-05 Rene Liebscher + + * doc/Makefile.am: add $(srcdir) to name of generated files, so BSD make + find the files ( GNU make sees no difference if the + file is called version.texi or ./version.texi ) + +2012-08-15 Rene Liebscher + + patch #7184 Support for PICKit2 programmer + * Makefile.am: add pickit2 files + * pickit2.[ch]: new programmer implementation + * pgm_type.c: add pickit to list + * avrdude.1: documentation for pickit2 + * doc/avrdude.texi: documentation for pickit2 + * avrdude.conf.in: add pickit2 programmer entry + +2012-08-15 Rene Liebscher + + bug #30559 Ft232 bit-bang support, see comment #30 + * ft245r.c: added semaphore workaround for MacOS X, + added pthread_testcancel in reader thread + + * configure.ac: added check for TYPE_232H in libftdi (not in libftdi < 0.20) + * avrftdi.c: do not use TYPE_232H if not declared + +2012-08-13 Hannes Weisbach + + * avrftdi.c: fixes pin_limit for different FTDI devices (there was a mixup + between 2232C and 2232H) + +2012-07-29 Hannes Weisbach + + * avrftdi.c: bugfixes (synchronisation) and maintenance (paged programming, + nicer output, separation of parameter checking and actual code) + +2012-07-25 Joerg Wunsch + + * jtagmkII.c (jtagmkII_memtype): return MTYPE_FLASH rather than + MTYPE_SPM for non-Xmega flash regions + +2012-07-20 Hannes Weisbach + + * avrpart.c, avrpart.h: adds avr_pin_name() + +2012-07-18 Joerg Wunsch + + * configure.ac: check for libelf.h also in libelf/ + * fileio.c: include if configure found this + to be the case + +2012-06-13 Rene Liebscher + + * configure.ac: Check for presence of + * ft245r.c: Depend on HAVE_PTHREAD_H + * Makefile.am: Add -lpthread if needed. + +2012-06-07 Joerg Wunsch + + * usbtiny.c (usbtiny_paged_load, usbtiny_paged_write): + fix breakage introduced by the recent page handling reorg; + it used to cause an infinite loop + +2012-05-04 Joerg Wunsch + + Xmega page erase implementation for XPROG (AVRISPmkII, STK600) + * stk500v2.c (stk600_xprog_page_erase): New function. + +2012-05-04 Joerg Wunsch + + Xmega page erase implementation for JTAGICEmkII + * jtagmkII.c: Handle flash pages sizes > 256 bytes, implement + page_erase() method + * avrdude.conf.in: Change flash pagesize for all Xmega devices + to 512 bytes + * avr.c: Implement auto_erase, using page_erase if available + * avr.h: Remove unused parameters from avr_read(), replace + unused parameter in avr_write)() by auto_erase + * stk500v2.c: Handle flash page sizes > 256 bytes + * update.c (do_op): Handle new updateflags parameter + * main.c: Implement auto_erase as page_erase if possible + * update.h (enum updateflags): New enum + * pgm.h (struct programmer_t): Add page_erase method + +2012-04-26 Joerg Wunsch + + * jtagmkII.c (jtagmkII_paged_load, jtagmkII_paged_write): fix bug + in memory type calculation for Xmega "boot" memory region. + +2012-04-25 Joerg Wunsch + + * update.c (parse_op): do not assume default memtype here + * main.c: after locating the part information, determine default + memtype for all update options that didn't have a memtype + specified; this is "application" for Xmega parts, and "flash" for + everything else. + +2012-04-24 Joerg Wunsch + + * fileio.c: Rework the way ELF file sections are considered: while + scanning the program header table, the offsets from a program + header entry must never be used directly when checking the bounds + of the current AVR memory region. Instead, they must always be + checked based on the corresponding section's entry. That way, + Xmega devices now properly take into account whether the segment + fits into any of the application/apptable/boot memory region. + +2012-04-20 Joerg Wunsch + + bug #30756: When setting SUT to 64ms on XMEGA, avrdude doesn't + read device signature + * main.c: When reading the signature yields 0x000000 or 0xffffff, + retry (up to twice) after some progressive delay. + +2012-04-20 Joerg Wunsch + + * avrdude.conf.in (ATxmega16D4, ATxmega32D4, ATxmega64D4, + ATxmega128D4): New devices. As Xmega D doesn't feature a fuse0 + memory cell, move that one out from the generic .xmega part into + the individual Xmega A parts. + +2012-04-19 Joerg Wunsch + + bug #29019: pagel/bs2 warning when uploading using stk500 to xmega + * stk500.c (stk500_initialize): Insert dummy values for PAGEL and + BS2 if they are not present in the config file, in order to be able + to proceed with the stk500_set_extended_parms() anyway. + +2012-04-19 Joerg Wunsch + + * stk500v2_private.h (struct pdata): add boot_start + * stk500v2.c: For the "flash" pseudo-memory of Xmega devices, + distinguish addresses between "application" and "boot" area. + +2012-04-18 Joerg Wunsch + + * fileio.c (elf2b): When checking the bounds of the current + program header segment, subtract `low' from ph[n].p_paddr in order + to correct the magic section offsets for the AVR's non-flash + memory regions. + +2012-04-18 Joerg Wunsch + + * fileio.c (elf_get_scn): Rather than trying to just match whether + any given section maps straight to a program header segment, use a + more sophisticated decision that matches any section as long as it + fits into the segment. This is needed for situations where the + program header segment spans a larger area than the section data + provided. (This can e.g. happen in an ELF file that contains no + data at address 0, like a bootloader only.) + +2012-04-13 Joerg Wunsch + + bug #28744: Can't load bootloader to xmega128a1 (part 2, fix for + firmware >= V7.x) + * jtagmkII.c: Add firmware-version dependent handling of Xmega parameters. + V7.x firmware expects the NVM offsets being specified through the Xmega + parameters command, but left out as part of the memory address itself. + * jtagmkII_private.h: Add CMND_SET_XMEGA_PARAMS, and struct xmega_device_desc. + * config_gram.y: Add mcu_base keyword. + * avrpart.h: (Dito.) + * lexer.l: (Dito.) + * avrdude.conf.in (.xmega): add mcu_base, and data memory segment. + +2012-03-30 Joerg Wunsch + + bug #28744: Can't load bootloader to xmega128a1 (part 1, fix for + firmware < V7.x) + * jtagmkII.c: When going to write to the boot section of flash, + use MTYPE_BOOT_FLASH rather than MTYPE_FLASH + * jtagmkII_private.h: add MTYPE_BOOT_FLASH constant + +2012-03-30 Joerg Wunsch + + * jtagmkII_private.h: Sort commands, response codes and events + into numerical order. + +2012-03-29 Joerg Wunsch + + bug #30451: Accessing some Xmega memory sections gives not + supported error + * stk500v2.c: Handle all Xmega memory sections (except + "prodsig" which is not documented in AVR079) + * fileio.c: Treat the "boot", "application", and "apptable" + regions (which are actually subregions of "flash") all as + being flash, i.e. suppress trailing 0xFF bytes when reading + them + * avr.c: (Dito.) + +2012-03-20 Joerg Wunsch + + * jtagmkII.c (jtagmkII_close): The GO command before signing off + turned out to be not required for normal megaAVR devices, and to + cause the exact opposite (i.e. the target stopping) on Xmega + devices being programmed to JTAG. However, programming Xmega + devcies through PDI *does* need the GO command. + +2012-03-20 Joerg Wunsch + + * configure.ac: Print a configuration summary at the end of the + configure run + +2012-02-11 Rene Liebscher + + patch #7718: Merge global data of avrftdi in a private data structure + * avrftdi.[ch]: moved global data into private data structure, moved + private defines from header file into source file + +2012-02-06 Rene Liebscher + + patch #7720 Bug in EEPROM write + * avrftdi.c: fixed wrong buffer address initialization in paged_write + * fileio.c: added #include + +2012-02-05 Rene Liebscher + + bug #30559 Ft232 bit-bang support + * ft245r.c: cancel reader thread before exiting program + +2012-02-04 Rene Liebscher + + patch #7717 avrftdi_flash_write is broken + * avrftdi.c: fixed wrong buffer address initialization in paged_write + bug #35296 Extraneous newlines in output. + * main.c: fixed output of newlines at 100% progress + +2012-02-03 Rene Liebscher + + patch #7715 FT4232H support + * avrdude.conf.in: added programmer 4232h + +2012-02-03 Rene Liebscher + + patch #7687: Autogenerating programmers and parts lists for docs + (generating the programmers lists) + * doc/avrdude.texi: Add include of generated table of programmers + * doc/Makefile.am: Add generating of table of programmers in programmers.texi + +2012-02-03 Rene Liebscher + + bug #34768 Proposition: Change the name of the AVR32 devices + * avrdude.conf.in: renamed ucr2 to uc3a0512 + * avrpart.c: added cast to avoid compiler warning + +2012-02-03 Joerg Wunsch + + * fileio.c (fileio_elf): Fix a copy'n-paste-o. + +2012-02-03 Joerg Wunsch + + * par.c (par_desc): Move to end of file, outside the #if + HAVE_PARPORT + +2012-02-02 Joerg Wunsch + + Implement ELF file reading (finally). Requires libelf(3) to be + present on the host system. + * configure.ac (HAVE_LIBELF): Add logic to detect presence of + libelf(3) + * Makefile.am (avrdude_LDADD): Add @LIBELF@ + * fileio.h (FILEFMT): add FMT_ELF + * fileio.c: Implement ELF file reader. + * update.c (parse_op): add 'e' format specifier + * avrdude.1: Document the ELF file reading capability + * doc/avrdude.texi: (Dito.) + +2012-02-01 Rene Liebscher + + bug #30559 Ft232 bit-bang support + * ft245r.[ch]: new programmer type implementation + * configure.ac: add pthread as link library + * avrdude.conf.in: added some new programmers + * Makefile.am: added new source files to compile + * pindefs.h: change PIN_MASK, PIN_INVERSE to highest bit of unsigned int + * pgm.[ch]: added generic function to print pin assignments (taken from par.c) + * par.c: moved pin assigment print function to pgm.c + +2012-02-01 Joerg Wunsch + + * lexer.l: Sort keyword tokens into alphabetic order. + +2012-01-31 Rene Liebscher + + * config_gram.y, lexer.l: removed unused ID/TKN_ID definitions + * config.[hc]: removed unused function id(), use value.type to select + values + +2012-01-31 Rene Liebscher + + patch #7437 modifications to Bus Pirate module + patch #7686 Updating buspirate ascii mode to current firmware, use AUX + as clock generator, and setting of serial receive timeout + * buspirate.c: added paged_write, changed binary mode setup/detection, + added clock output on AUX pin + * avrdude.1: updated documentation + * doc/avrdude.texi: updated documentation + +2012-01-31 Rene Liebscher + + Parser does not need to know all programmer types now, new programmers + will update only the table in pgm_type.c. + * config_gram.y, lexer.l: removed programmer type keywords, + use now locate_programmer_type() function + * pgm_type.[ch]: added new files for table of programmer types + * main.c: allow list of programmer types by -c ?type + * avrdude.conf.in: changed all type keywords to quoted strings + * doc/avrdude.texi: changed description of type definition, list + of valid types is now included from generated file + * doc/Makefile.am: generate list of programmer types for doc + * all programmers [hc]: add xxx_desc string for description of programmer + +2012-01-30 Rene Liebscher + + * configure.ac: fixed detection of yylex_destroy availability + by checking the version number of flex; bump required autoconf + version to 2.60 (for AC_PROG_SED) + +2012-01-30 Joerg Wunsch + + * lexer.l: Replace the old, now-defunct #define YY_NO_UNPUT by + the new %option nounput. This gets rid of a compiler warning. + +2012-01-30 Joerg Wunsch + + Add a connection_type attribute to each programmer, rather than + trying to hard-code the default port name in main.c. + * pgm.h: Add conntype to struct pgm. + * lexer.l: Extend grammar for connection_type. + * config_gram.y: (Dito.) + * config.h: Add DEFAULT_USB, for symmetry with default_parallel + and default_serial. + * main.c: Replace old default portname hack by avrdude.conf-based + knowledge. + * usbtiny.c: Drop an old hack that's no longer necessary. + * avrdude.conf.in: Add connection_type to each programmer + definition. + +2012-01-27 Rene Liebscher + + * avrdude.conf.in: used parent parts for some other parts, added + abstract .xmega part as parent for xmegas + * main.c: hide parts starting with '.' from parts list + +2012-01-22 Rene Liebscher + + patch #7688: Implement parent programmers feature + * avrdude.conf.in: updated documentation comment and some programmers + have now parents + * config_gram.y: initpgm will now called at first use of programmer + in main. parser sets only the function pointer in the pgm structure. + Pin and pin lists definitions can now be empty to remove the parents + setting. + * doc/avrdude.texi: updated documentation + * main.c: added call to pgm->initpgm after locate_programmer + * pgm.[hc]: added field initpgm in structure, added function pgm_dup + +2012-01-21 Rene Liebscher + + bug #21797: AT90PWM316: New part description + * avrdude.conf.in: added pwm316 with parent pwm3b but 16KB flash + +2012-01-20 Joerg Wunsch + + * configure.ac: Check for presence of lusb_usb.h as an alternative + to usb.h; libusb-win32 switched to this name in version 1.2.5.0. + * avrftdi.c: Decide whether to include , or . + * ser_avrdoper.c: (Dito.) + * usbasp.c: (Dito.) + * usb_libusb.c: (Dito.) + * usbtiny.c: (Dito.) + +2012-01-19 Rene Liebscher + + * avr.c: Unsigned variable was used for return code of paged_write/load + functions. So a negative return code led never to a fallback to byte + functions. + +2012-01-17 Rene Liebscher + + bug #34302: Feature request : device configuration with parent classes + * config_gram.y: if memory section is overwritten old entry is removed + + (not in original patch) + * config_gram.y: if programmer or part is defined twice, a warning is + output and the first instance is removed + + General cleanup and free functions, so valgrind does not report any lost + blocks at program end. + * avrpart.[hc]: added avr_free_(opcode|mem|part) functions + * pgm.[hc]: added pgm_free function + * update.[hc]: added free_update functions + * config.[hc]: added cleanup_config function, use yylex_destroy to reset + the lexer after usage. (So it can be reused.) + * main.c: add cleanup_main function which is called by atexit() (This + frees all lists so that at program exit only really lost memory is + reported by valgrind.) + * usbasp.c: added libusb_free_device_list() and libusb_exit() calls to + avoid lost memory + * buspirate.c: moved memory allocation from initpgm to setup and added + free in teardown + * configure.ac: add definition of HAVE_YYLEX_DESTROY if $LEX is flex. + * Makefile.am: added . in front of SUBDIRS to build avrdude before trying + to use it for creating the part list for the docs. + +2012-01-17 Rene Liebscher + + * usbasp.c: USB vid/pid/vendor/product from config file are used, for + id "usbasp" nibobee and old usbasp are tried as they were currently + implemented within usbasp + * avrdude.conf.in: added usb params to "usbasp", added new entry "nibobee" + with params which were hardcoded in usbasp.c, and added an entry + "usbasb-clone" which only checks vid/pid. + +2012-01-10 Rene Liebscher + + bug #35261 avrftdi uses wrong interface in avrftdi_paged_(write|load) + * avrftdi.c: Fixed interface and implementation of avrftdi_paged_(write|load) + patch #7672 adding support for O-Link (FTDI based JTAG) as programmer + * avrdude.conf.in: added o-link entry + +2012-01-10 Rene Liebscher + + patch #7699 Read additional config files + * main.c: Added reading of additional config files + * avrdude.1: updated man page + * doc/avrdude.texi: updated documentation + +2012-01-10 Joerg Wunsch + + Submitted by Bob Frazier: + bug #35208: avrdude 5.11 on freebsd 8.2-STABLE does not reset + Arduino Uno properly + * arduino.c (arduino_open): Bump the timeout between pulling + the DTR and RTS lines low and high. + +2012-01-08 Rene Liebscher + + Fixed following findings reported by cppcheck + * avr910.c:625 (error) Possible null pointer dereference: cmd - otherwise it is redundant to check if cmd is null at line 624 + * avr910.c:626 (error) Possible null pointer dereference: cmd - otherwise it is redundant to check if cmd is null at line 624 + * avr910.c:168 (information) The scope of the variable 'devtype_1st' can be reduced + * avr910.c:169 (information) The scope of the variable 'dev_supported' can be reduced + * avrftdi.c:647 (error) Using sizeof for array given as function argument returns the size of pointer. + * stk500v2.c:3347 (error) Memory leak: b + * stk500v2.c:3452 (error) Memory leak: b + * usbasp.c:554 (error) Using sizeof for array given as function argument returns the size of pointer. + * usbasp.c:485 (information) The scope of the variable 'dly' can be reduced + +2012-01-03 Joerg Wunsch + + Reported by Jason Kotzin: + * usbasp.c (usbasp_spi_paged_load, usbasp_spi_paged_write): + Fix buffer address calculation. + +2012-01-03 Rene Liebscher + + patch #7629 add support for atmega48p + * avrdude.conf.in: Added m48p with parent m48 + different signature + + * avrdude.conf.in: made part parents (m88p = m88 + different signature, + m168p = m168 + different signature) + +2012-01-02 Rene Liebscher + + bug #21663 AT90PWM efuse incorrect + bug #30438 efuse bits written as 0 on at90pwmxx parts + * avrdude.conf.in: (pwm2, pwm2b, pwm3, pwm3b) : Write + eight bits + + * avrdude.conf.in: made part parents (pwm3 = pwm2, pwm3b = pwm2b, + pwm2b = pwm2 + different signature) + + * ChangeLog-2011: New file, rotate ChangeLog for new year. diff --git a/xs/src/avrdude/ChangeLog-2013 b/xs/src/avrdude/ChangeLog-2013 new file mode 100644 index 000000000..8e975ef6e --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2013 @@ -0,0 +1,618 @@ +2013-12-15 Nils Springob + + * pgm.c/pgm.h: fixed syntax error in const pointer to const + +2013-12-05 Joerg Wunsch + + * configure.ac: bump version to 6.1-svn-20131205 + +2013-12-05 Joerg Wunsch + + bug #40817: Elf file support (possibly) not working on 6.0.1 windows build + * fileio.c (fileio): open file in binary mode also for FMT_ELF + +2013-12-04 Rene Liebscher + + Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use + of new pindefs data in pgm structure + * linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed + interface of setpin, getpin, highpulsepin to take pin function as parameter + (not the real number, which can be found by pgm->pinno[function]) + +2013-11-30 Rene Liebscher + + bug #40748 linuxgpio doesn't work on Raspberry PI rev. 2. + * linuxgpio.c: fixed check for unused pins to ignore the inverse flag + * pindefs.c: fixed fill_old_pinlist to not create an empty mask with inverse flag set + +2013-10-18 Nils Springob + + * avrdude.conf.in (atmega1284): ATmega1284 variant added (same as ATmega1284p but with different signature) + +2013-09-25 Hannes Weisbach + + First part of patch #7720: + * avrdude.conf.in: Add UM232H and C232H programmers + +2013-09-22 Joerg Wunsch + + Submitted by Daniel Rozsnyo: + bug #40085: Typo fix in fuses report (for 6.1-svn-20130917) + * main.c: Fix a typo. + +2013-09-19 Hannes Weisbach + + task #12798: Please cleanup #ifdef notyet entries in avrftdi.c + * avrftdi.c: ditto. + avrftdi.c: Remove DRYRUN-option. + +2013-09-17 Joerg Wunsch + + bug #40055: AVRDUDE segfaults when writing eeprom + * main.c: Always clear the UF_AUTO_ERASE flag if either a + non-Xmega device was found, or the programmer does not offer a + page_erase method. + +2013-09-17 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version to post-6.0. + +2013-09-17 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version to 6.0. + +2013-09-17 Joerg Wunsch + + * jtag3.c (jtag3_initialize): Fix a buffer overflow by limiting + the flash page cache size to at most "readsize". For Xmegas with + a page size of 512 bytes, the maximum USB packet size was + overflowed, and subsequently, a memmove copied beyond the end of + the allocated buffer. + * jtag3.c (jtag3_read_byte): Add the correct offset also for the + various flash regions, so reading the apptable or boot regions + yields the correct data. + +2013-09-16 Joerg Wunsch + + Submitted by Joakim Lubeck: + bug #40040: Support for ATtiny20 and ATtiny40 + * avrdude.conf.in: Restructure the reduced-core tiny devices + to use a common entry .reduced_core_tiny; add ATtiny20 and + ATtiny40 + +2013-09-15 Joerg Wunsch + + Submitted by Joakim Lubeck: + bug #40033: Support for the XMegaE5 family + * avrdude.conf.in (ATxmega8E5, ATxmega16E5, ATxmega32E5): New + entries. + +2013-09-13 Joerg Wunsch + + * stk500v2.c (stk500v2_set_sck_period): Revamp this to match the + description/pseudo-code in appnote AVR068. + +2013-09-13 Joerg Wunsch + + Submitted by Stephen Roe: + patch #7710: usb_libusb: Check VID/PID before opening device + * usb_libusb.c (usbdev_open): Swap the sequence of verifying the + VID:PID, and opening the device. + +2013-09-13 Joerg Wunsch + + patch #8176: butterfly.c (AVR109 protocol implementation) clean-up and bug-fixing + * butterfly.c (butterfly_page_erase): Add dummy function to avoid + segfault when writing to EEPROM. + +2013-09-13 Joerg Wunsch + + bug #35474 Feature request: print fuse values in safemode output + * config_gram.y: New configuration token "default_safemode". + * lexer.l: (Dito.) + * avrdude.conf.in: (Dito.) + * config.h: Add variable default_safemode. + * config.c: (Dito.) + * main.c: Handle default_safemode, including -u option. + * avrdude.1: Document all this. + * doc/avrdude.texi: (Dito.) + +2013-09-13 Joerg Wunsch + + Submitted by HubertB: + patch #7657 Add ATmega406 support for avrdude using DRAGON + JTAG + * avrdude.conf.in (ATmega406): New entry. + +2013-09-13 Joerg Wunsch + + Submitted by Marc de Hoop: + patch #7606 ATtiny43u support + * avrdude.conf.in (ATtiny43U): New entry. + +2013-09-13 Joerg Wunsch + + patch #5708 avrdude should make 10 synchronization attempts instead of just one + * stk500.c (stk500_getsync): Loop 10 times trying to get in + sync with the programmer. + +2013-09-13 Joerg Wunsch + + Contributed by Ricardo Martins: + bug #36384 ATxmega32A4 usersig size + * avrdude.conf.in: Revamp all the ATxmega* entries. Add new + entries for ATxmega128A1U, ATxmega128A3U, ATxmega128A4U, + ATxmega128B1, ATxmega128B3, ATxmega128C3, ATxmega128D3, + ATxmega16A4U, ATxmega16C4, ATxmega192A3U, ATxmega192C3, + ATxmega192D3, ATxmega256A3BU, ATxmega256A3U, ATxmega256C3, + ATxmega256D3, ATxmega32A4U, ATxmega32C4, ATxmega384C3, + ATxmega384D3, ATxmega64A1U, ATxmega64A3U, ATxmega64A4U, + ATxmega64B1, ATxmega64B3, ATxmega64C3, ATxmega64D3 + +2013-09-13 Joerg Wunsch + + bug #35456 The progress bar for STK500V2 programmer is "wrong". + * avr.c (avr_read, avr_write): Change the progress reporting for + paged read/write from per-address to per-considered-page. This + ought to give a realistic estimation about the time still to be + spent. + +2013-09-13 Joerg Wunsch + + bug #34277: avrdude reads wrong byte order if using avr911 (aka butterfly) + * butterfly.c (butterfly_read_byte_flash): Swap bytes received. + +2013-09-12 Joerg Wunsch + + bug #37768 Poll usbtiny 100 times at init time to handle low-clock devices + * doc/avrdude.texi: Add a FAQ entry about how to connect to a + target where the firmware has reduced the internal clock speed. + +2013-09-11 Joerg Wunsch + + bug #28344 chip_erase_delay too short for ATmega324P, 644, 644P, and 1284P + * avrdude.conf: Bump the chip_erase_delay for all ATmega*4 devices + to 55 ms. While the datasheet still claims 9 ms, all the XML files + tell either 45 or 55 ms, depending on STK600 or not. + +2013-09-11 Joerg Wunsch + + * fileio.c (fileio): Don't exit(1) if something goes wrong; return + -1 instead. Don't refer to obsolete option -f to specify the file + format. + +2013-09-10 Joerg Wunsch + + Submitted by Matthias Trute: + bug #36901 flashing Atmega32U4 EEPROM produces garbage on chip + * avrdude.conf.in (ATmega32U4): Fix EEPROM pagesize to 4, the + datasheet is wrong here. + +2013-09-09 Joerg Wunsch + + * configure.ac: check for ar and ranlib in the target tool + namespace, rather than on the host. + +2013-09-08 Joerg Wunsch + + Fix byte-wise EEPROM and flash writes on Xmega + * jtagmkII_private.h (MTYPE_EEPROM_XMEGA): New memory type. + * jtagmkII.c (jtagmkII_write_byte): For Xmega EEPROM, use + memory type MTYPE_EEPROM_XMEGA; for flash writes, always + write 2 bytes starting on an even address. + +2013-09-08 Joerg Wunsch + + * term.c: Implement the "verbose" terminal mode command. + * avrdude.1: Document this. + * doc/avrdude.texi: (Dito.) + +2013-09-07 Joerg Wunsch + + * jtag3.c (jtag3_write_byte): Do not attempt to start the paged + algorithm for EEPROM when being connected through debugWIRE. + +2013-09-06 Joerg Wunsch + + Extend the single-byte algorithm to all devices, both flash and + EEPROM. (Flash cells must have been erased before though.) + * jtag3.c (jtag3_initialize): OCDEN no longer needs to be + considered; a session with "programming" purpose is sufficient + * jtag3.c (jtag3_write_byte): Use the paged algorithm for all + flash and EEPROM areas, not just Xmega. + +2013-09-05 Joerg Wunsch + + Fix single-byte EEPROM updates on Xmega: + * jtag3_private.h (MTYPE_EEPROM_XMEGA): New define. + * jtag3.c (jtag3_write_byte): When updating flash or + EEPROM on Xmega devices, resort to jtag3_paged_write() + after filling and modifying the page cache. + * jtag3.c (jtag3_paged_write): use MTYPE_EEPROM_XMEGA + where appropriate. + * jtag3.c (jtag3_initialize): Open with debugging intent + for Xmega devices, so single-byte EEPROM updates will + work. + +2013-09-04 Joerg Wunsch + + Submitted by Matthias Neeracher: + bug #38732: Support for ATtiny1634 + * avrdude.conf.in (ATtiny1634): New entry. + +2013-09-03 Joerg Wunsch + + Submitted by Brane Ždralo: + patch #7769: Write flash fails for AVR910 programmers + * avr910.c (avr910_paged_write): Fix flash addresses in + 'A' command. + +2013-09-03 Joerg Wunsch + + Submitted by Fred (magister): + bug #38951: AVR109 use byte offset instead of word offset + patch #8045: AVR109 butterfly failing + * butterfly.c (butterfly_paged_load, butterfly_paged_write): + fix calculation of 'A' address when operating on flash memory. + It must be given in terms of 16-bit words rather than bytes. + +2013-09-03 Rene Liebscher + + * avrftdi.c, avrftdi_private.h: added tx buffer size, and use + smaller block sizes as larger sometimes hang + +2013-09-03 Joerg Wunsch + + * avrdude.h: Remove the erase cycle counter (options -y / -Y). + * avr.c: (Dito.) + * main.c: (Dito.) + * avrdude.1: Undocument -y / -Y. + * doc/avrdude.texi: (Dito.) + +2013-09-03 Joerg Wunsch + + bug #39691 Buffer overrun when reading EEPROM byte with JTAGICE3 + * jtag3.c (jtag3_initialize): initialize the eeprom_pagesize + private attribute so the page cache will actually be usable + +2013-09-03 Joerg Wunsch + + bug #38580 Current svn head, xmega and fuses, all fuses tied to fuse0 + * jtag3.c (jtag3_read_byte, jtag3_write_byte): Correctly apply the + relevant part of mem->offset as the address to operate on. + +2013-09-03 Joerg Wunsch + + * fileio.c: Fix "unused variable" warnings. + * avr.c: (Dito.) + * stk500v2.c: (Dito.) + * stk500.c: (Dito.) + * jtagmkII.c: (Dito.) + * term.c: (Dito.) + * ser_posix.c: (Dito.) + +2013-09-02 Joerg Wunsch + + Submitted by Travis Griggs: + bug #38307: Can't write usersig of an xmega256a3 + * stk500v2.c (stk600_xprog_page_erase): allow erasing the usersig space. + +2013-09-02 Joerg Wunsch + + Submitted by Robert Niemi: + bug #35800: Compilation error on certain systems if parport is disabled + * linux_ppdev.h: Conditionalize inclusion of and + on HAVE_PARPORT + +2013-09-02 Joerg Wunsch + + bug #39794: warnings when building avrdude 6.0rc1 under CentOS 6.4 + * pickit.c (usb_open_device): Use %p rather than %X to print "handle" + which is a pointer + * jtag3.c (jtag3_initialize): Initialize "flashsize" to be sure it + proceeds with a valid value. + +2013-09-02 Joerg Wunsch + + bug #39794: warnings when building avrdude 6.0rc1 under CentOS 6.4 + * buspirate.c: Turn the "cmd" argument of the various methods into + a "const unsigned char *"; while doing this, declare all arrays being + passed as arguments to be pointers rather than arrays, as the latter + obfuscates the way arrays are being passed to a callee in C. + * avrftdi.c: (Dito.) + * pickit2.c: (Dito.) + * ft245r.c: (Dito.) + * avr910.c: (Dito.) + * stk500.c: (Dito.) + * bitbang.c: (Dito.) + * bitbang.h: (Dito.) + * avrftdi_tpi.c: (Dito.) + * avrftdi_tpi.h: (Dito.) + * usbasp.c: (Dito.) + * stk500v2.c: (Dito.) + * pgm.h: (Dito.) + * usbtiny.c: (Dito.) + +2013-09-02 Joerg Wunsch + + bug #38023: avrdude doesn't return an error code when attempting + to upload an invalid Intel HEX file + * fileio.c (ihex2b): Turn the "No end of file record found" warning + into an error if no valid record was found at all. + +2013-09-02 Joerg Wunsch + + Submitted by Claus-Justus Heine: + bug #38713: Compilation of the documentation breaks with texinfo-5 + * doc/avrdude.texi: Turn @itemx into @item, add @headitem to STK600 + Routing/Socket card table + +2013-09-02 Joerg Wunsch + + * usbasp.c: Add trace output for -vvv to non-TPI functions, too. + +2013-09-01 Joerg Wunsch + + * usbasp.c (usbasp_tpi_paged_load): Calculate correct + buffer address. + * usbasp.c (usbasp_tpi_paged_write): Calculate correct + buffer address; don't issue a SECTION_ERASE command for + each page (a CHIP_ERASE has been done before anyway); + remove the code that attempted to handle partial page + writes, as all writes are now done with a full page. + +2013-09-01 Joerg Wunsch + + * usbasp.c: Add more trace output, by now only for the TPI + functions. + +2013-08-31 Joerg Wunsch + + * usbasp.c (usbasp_transmit): Add -vvvv trace output. + +2013-08-30 Joerg Wunsch + + bug #39893: Verification failure with AVRISPmkII and Xmega + * stk500v2.c (stk600_xprog_page_erase): Fix argument that is + passed to stk600_xprog_memtype() + +2013-07-11 Joerg Wunsch + + * fileio.c (elf2b): replace elf_getshstrndx() by + elf_getshdrstrndx() as the former one is deprecated + +2013-06-19 Rene Liebscher + + use bitbanging on ftdi mpsse when wrong pins are used + * avrftdi.c, avrftdi_private.h: added additional pin check + and bitbanging fallback + * pindefs.[ch]: added a flag to enable/disable output + * ft245r.c: changes because of added flag above + +2013-05-17 Joerg Wunsch + + Submitted by "Malte" and John McCorquodale: + patch #7876 JTAGICE mkII fails to connect to attiny if debugwire + is enabled AND target has a very slow clock + * jtagmkII.c (jtagmkII_getsync): When leaving debugWIRE mode + temporarily, immediately retry with ISP, rather than leaving. + * stk500v2 (stk500v2_program_enable): Implemented similar logic + for the JTAGICE3. + +2013-05-16 Rene Liebscher + + * configure.ac: reactivate check for TYPE_232H, which does not + exist in libftdi < 0.20 + * avrftdi*.*: changed include check for libftdi/libusb, deactivate + 232H if not available + * ft245r.c: changed include check for libftdi/libusb + +2013-05-08 Joerg Wunsch + + * main.c (main): Add option -l logfile. + * avrdude.1: Document -l option. + * doc/avrdude.texi: (Dito.) + +2013-05-15 Rene Liebscher + + * configure.ac: if both found libftdi and libftdi1 use only libftdi1 + * avrdude.conf.in: fixed buff pins of avrftdi programmers (low + active buffer need now inverted numbers) + * avrftdi*.*: accept also old libftdi (0.20 still works with it), + added powerup to initialize + * ft245r.c: accept libftdi1, code cleanup and make it more similar + to avrfdti (os they might be merged someday) + +2013-05-08 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version to 6.0rc1. + +2013-05-07 Hannes Weisbach + + * avrftdi_private.h: Change size of pin_checklist to N_PINS (from N_PINS-1) + * avrftdi.c: Adapt code to new size of pin_checklist. Remove pins_check() + from set_pin(). + Add pgm->power[up|down] functions as well as fill pgm->enable|disable with + proper content as suggested by Rene Liebscher. + +2013-05-05 Rene Liebscher + + * pindefs.h: use unsigned int if stdint.h is not available and UINT_MAX is 0xffffffff + otherwise use unsinged long + * ft245r.c: added support for more pin functions led, vcc, buff + +2013-05-06 Hannes Weisbach + + * avrftdi_tpi.c: instead of private set_pin() function pointer use the one + declared in struct PROGRAMMER. + * avrftdi_private.h: remove set_pin function pointer. Add pin_checklist_t + member to check pgm->setpin calls during runtime. + * avrftdi.c: remove set_pin function pointer init, add pgm->setpin init. + Convert avrftdi to new 0-based pindefs infrastructure. + * avrdude.conf.in: Change all avrftdi-based programmers' pin definitions to + 0-based. + +2013-05-06 Joerg Wunsch + + * pindefs.h: Include "ac_cfg.h" before testing for HAVE_* macros. + +2013-05-05 Rene Liebscher + + * main.c: revert to rev 1159 (doing pgm_display after pgm_open) + * avrpart.[ch]: moved avr_pin_name to pindefs.[ch] + * pgm.c: moved pins_to_str to pindefs.[ch], added initialization of + new pin definitions in pgm_new() + * pindefs.[ch]: added moved functions from other files, added a lot of + documentation, reformatted files using astyle to have consistent spacing, + added a new generic check function for pins + * ft245r.c: used new generic pin check function + +2013-05-03 Rene Liebscher + + Create new pin definition data structures to support 0-based pin numbers, + and mixed inverse/non-inverse pin lists. + * avrftdi.c,buspirate.c,linuxgpio.c,par.c,serbb_*.c: added function call + to fill old pinno entries from new pin definitions. + * pindefs.[hc]: added data struct and helper functions for new pin definitions + * avrdude.conf.in: pins in entries using ftdi_syncbb are now 0-based + * config_gram.y: allow combinations of inverted and non-inverted pins in pin lists + * ft245r.c: reworked to work directly with the new pin definitions, + pins are now 0-based, inverse pins are supported, buff is supported + * pgm.[ch]: added new pin definitions field to programmer structure, + adapted pin display functions + +2013-05-03 Hannes Weisbach + + * avrftdi_private.h: Remove update forward declaration from avrftdi_print to + avrftdi_log. + * avrftdi_tpi.c: Do all I/O in terms of pgm->cmd_tpi()-calls instead of + avrftdi_tpi_[read,write]_byte(). + Remove unnecessary set_pin call to set MOSI high, speeds up I/O. + Removes SKEY array, moves it to tpi.h. + Integrate new avr_tpi_[program_enable,chip_erase]() and functions into + avrftdi_tpi. + * avrftdi_tpi.h: Remove avrftdi_tpi_[program_enable,chip_erase] forward + declarations. + * avr.c: Adds avr_tpi_chip_erase() generic TPI chip erase function. + Adds avr_tpi_program_enable() - generic TPI external programming enable + function. Sets guard time, reads identification register, sends SKEY command + and key, checks NVMEN bit. The required guard time has to be passed as + parameter. + * tpi.h: Adds SKEY array including CMD_SKEY in "correct" order. + +2013-05-02 Hannes Weisbach + + * avrftdi_private.h: Add libusb-1.0 include to fix include order in windows. + * NEWS: Add notice avrftdi supporting TPI + * avr.c: Fix avr_tpi_poll_nvmbsy() - poll read data instead of return code + * avrftdi_private.h, avrftdi.c: move logging #defines to from avrftdi.c to + avrftdi_private.h, so that they are available for avrftdi_tpi, too. + +2013-04-30 Hannes Weisbach + + * tpi.h: Add definition for TPI Identification Code + * avrftdi_tpi.c: Add TPI-support for FTDI-based programmers + * avrftdi_private.h: Add common include file for FTDI-based programmers + +2013-04-28 Hannes Weisbach + + * avrftdic: Rework of textual output. Messages are divided by severity and + printed accordingly to the verbosity, as specified by the user. The provided + severity level are (ERROR, WARN, INFO, DEBUG, TRACE). Where "ERROR" messages + are always printed. Shortcut-macros including function, from which the + output was generated, and line number were also added. + Some log messages were updated and other code warnings removed. + +2013-04-27 Hannes Weisbach + + * configure.ac: Add libftdi1 library check, remove TYPE_232H DECL check + * Makefile.am: Add @LIBFTDI1@ to avrdude_LDADD + * avrftdi.c: Update from libftdi0 to libftdi1. Use libftdi1's function to + find a device by vid/pid/serial instead of doing it ourself and add/update + error messages. avrftdi_print is changed so that a message is printed when + the verbosity level is greater or equal the message level, to have always-on + messages. + Fix a bug where the RX fifo of the FTDI chip is full, resulting in STALL/NAK + of the ongoing OUT request and subsequently timeout, because an IN request + cannot be issued due to the synchronous part of libftdi. This should fix + #38831 and #38659. + +2013-04-25 Joerg Wunsch + + * configure.ac(AC_CONFIG_HEADERS): Replace the old AM_CONFIG_HEADER + by this; automake 1.13+ barfs. + +2013-03-12 Joerg Wunsch + + * avrdude.conf.in (ATmega2564RFR2, ATmega1284RFR2, ATmega644RFR2): + New devices + +2013-01-30 Rene Liebscher + + patch #7724 Add TPI support for Bus Pirate using bitbang mode + * buspirate.[ch]: added support for BusPirate Bitbanging + * pgm_type.c: added entry for buspirate_bb + * avrdude.conf.in: added entry for buspirate_bb + +2013-01-30 Rene Liebscher + + patch #7936 Patch to support BusPirate AVR Extended Commands mode + * buspirate.c: added support for BusPirate AVR Extended Commands mode + * avrdude.1: added doc for nopagedread parameter + * doc/avrdude.texi: added doc for nopagedread parameter + +2013-01-30 Rene Liebscher + + patch #7723 Bus Pirate “raw-wire†mode which can run down to 5 kHz + * buspirate.c: added raw wire mode + * avrdude.1: added doc for rawfreq parameter + * doc/avrdude.texi: added doc for rawfreq parameter + +2013-01-30 Rene Liebscher + + bug #37977 Support for Openmoko Debug Board + * avrdude.conf.in: added openmoko entry + +2013-01-29 Rene Liebscher + + patch #7932 Read USBtiny VID and PID from avrdude.conf if provided. + * avrdude.conf.in: added usbpid, usbvid to usbtiny + * usbtiny.[ch]: use usbpid, usbpid if provided in config file + +2013-01-26 Joerg Wunsch + + bug #38172: avrftdi: Incorrect information in avrdude.conf + * avrdude.conf.in (avrftdi): fix comments about ACBUS vs. ADBUS; + add a comment that the MPSSE signals are fixed by the FTDI + hardware and cannot be changed + +2013-01-09 Rene Liebscher + + patch #7165 Add support for bitbanging GPIO lines using the Linux sysf GPIO interface + * doc/avrdude.texi,avrdude.1: added doc for linuxgpio + * avrdude.conf.in: added template for linuxgpio programmer + * config_gram.y: pin numbers restricted to [PIN_MIN, PIN_MAX] + * pindefs.h: added PIN_MIN, PIN_MAX, removed unused LED_ON/OFF + * configure.ac: configure option enable-linuxgpio, print of enabled options + * linuxgpio.[ch]: new source for linuxgpio programmer + * Makefile.am: added linuxgpio to sources list + * pgm_type.c: added linuxgpio to programmer types list + +2013-01-08 Joerg Wunsch + + * jtagmkI.c (jtagmkI_prmsg): replace a putchar() by putc(...stderr) + * jtagmkII.c (jtagmkII_prmsg): (Dito.) + * jtag3.c (jtag3_prevent, jtag3_prmsg): (Dito.) + +2013-01-02 Joerg Wunsch + + * usb_libusb.c (usbdev_open): Downgrade the max transfer size for + the main data endpoints when being forced so by the USB; this can + happen when attaching the JTAGICE3 to a USB 1.1 connection + * jtag3.c (jtag3_initialize): When detecting a downgraded max + transfer size on the JTAGICE3 (presumably, due to being connected + to USB 1.1 only), bail out as its firmware cannot properly handle + this (by now) + +2013-01-02 Joerg Wunsch + + * ChangeLog: annual ChangeLog rotation time diff --git a/xs/src/avrdude/ChangeLog-2014 b/xs/src/avrdude/ChangeLog-2014 new file mode 100644 index 000000000..3fe7a53aa --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2014 @@ -0,0 +1,697 @@ +2014-11-26 Joerg Wunsch + + * ser_win32.c (net_send): Properly declare argument 2 as being a + pointer to const data. + +2014-11-25 Joerg Wunsch + + patch #8380: adds 500k 1M 2M baud to ser_posix.c + * ser_posix.c: Add a hack to allow for arbitrary baud rates on + Linux + +2014-11-25 Joerg Wunsch + + patch #8437: [PATCH] Serial-over-ethernet for Win32 + * configure.ac: Check for ws2_32 library + * ser_win32.c: Add hooks for forwarding serial data over + TCP connections + * avrdude.1: Drop previous restriction of -P net: + * doc/avrdude.conf: (Dito.) + +2014-11-24 Joerg Wunsch + + bug #42908: no external reset at JTAGICE3 + * jtag3.c (jtag3_initialize): Retry with external reset applied if + the first sign-on attempt fails. + +2014-11-23 Joerg Wunsch + + * main.c: Allow the -B option argument to be suffixed with Hz, + kHz, or MHz, in order to specify a bitclock frequency rather than + period. + * avrdude.1: Document the -B option changes. + * doc/avrdude.texi: (Dito.) + +2014-11-23 Joerg Wunsch + + bug #40870: config nitpick: ATtiny25/45/85 have 1 calibration byte not 2 + * avrdude.conf.in (ATtiny25, ATtiny45, ATtiny85): Fix size of + "calibration" memory area + +2014-11-23 Joerg Wunsch + + bug #43137: Writing and reading incorrect pages when using jtagicemkI + * jtagmkI.c (jtagmkI_paged_write, jtagmkI_paged_load): correctly + calculate the size of a partial (non-pagesize) buffer + +2014-11-23 Joerg Wunsch + + bug #43078: AVRDUDE crashes after sucessfully reading/writing eeprom + * jtag3.c (jtag3_edbg_recv_frame): Return correct length as + reported in the response packet, rather than full 512 byte which + are always reported by the CMSIS-DAP layer. Miscalculations + based on the wrongly reported length caused heap corruption + elsewhere, so this is presumably also a fix for bug #43078. + +2014-11-20 Joerg Wunsch + + bug #41561: AVRDUDE 6.0.1/USBasp doesn't write first bytes of + flash page + * usbasp.c (usbasp_spi_paged_write): Remove USBASP_BLOCKFLAG_LAST. + It is no longer needed, as we always write full pages now in paged + write mode. + +2014-11-19 Joerg Wunsch + + bug #43626: Inconsistent timeouts in stk500v2 + * stk500v2.c (stk500v2_recv): Add a reference to the bug report + but don't change anything, lest to break it somehow + +2014-11-14 Rene Liebscher + + patch #8529 2 more ftdi_syncbb devices + * avrdude.conf.in: added 2 new programmers + +2014-11-14 Rene Liebscher + + bug #40142 Floating point exception on Ubuntu 10.04 + * avr.c: avoid division by zero in report_progress(), eg. when + writing an empty eeprom file were total becomes 0 + +2014-11-13 Rene Liebscher + + patch #8504 buspirate: Also support "cpufreq" extended parameter + in binary mode + * buspirate.c: applied patch + switch off at disable (even when + a reset follows) + some general whitespace/tab cleanup + +2014-10-15 Joerg Wunsch + + bug #37441: lockbits in ATxmega + avrdude = problem + * fileio.c: replace strmcp(..., "lock") by strncmp(..., "lock", 4) + where applicable + * jtag3.c: (Dito.) + * jtagmkII.c: (Dito.) + +2014-10-07 Joerg Wunsch + + bug #42267: jtag3isp fails to read lock and fuse bytes directly + after changing lock byte + * stk500v2.c (stk500isp_write_byte): As a workaround for broken + tool firmware, add 10 ms of delay before returning from any + single-byte write operation. + +2014-10-06 Joerg Wunsch + + * stk500v2.c: Use stk500isp_read_byte/stk500isp_write_byte for + every byte-wide access (rather than JTAGICE3 only). This finally + obsoletes the use of the prehistoric SPI_MULTI command where + AVRDUDE used to assemble all the low-level ISP stuff by itself. + +2014-10-06 Joerg Wunsch + + bug #22248: Read efuse error + * avrdude.conf.in (m168, m328, m48, m88, t1634, t26, t261, t461, + t861, t88): In efuse (or hfuse for t26) read operation, turn all + bits in byte 3 from "x" to "o" (output); this is a first step + towards fixing the symptoms mentioned in the bug, by unifying the + behaviour between different AVRs. Not touched are the historic + devices where the fuses are not documented to form a full byte + each (2333, 4433, 4434, 8535, m103, m161, m163). + +2014-09-22 Joerg Wunsch + + bug #43268: usb_drain() call causes LUFA AVR-ISP MKII Code to Fail + * usb_libusb.c (usbdev_drain): Make this a dummy function only. + +2014-08-19 Rene Liebscher + + patch #7694 Add support for the atmega32m1 + * avrdude.conf.in: added ATmega32M1 + +2014-08-18 Rene Liebscher + + patch #8440 Print part id after signature + When printing the part signature also print the part id. + * avrpart.c (locate_part_by_signature): New function. + * libavrdude.h (locate_part_by_signature): New function. + * main.c (main): Use the new function to find the part and print its id. + +2014-08-18 Rene Liebscher + + patch #8511 Fix reset on FT245R + * ft245r.c: applied patch + +2014-08-18 Rene Liebscher + + bug #43002 usbasp debug output typo + * usbasp.c: fixed typos + +2014-07-16 Joerg Wunsch + + bug #42662 clang warnings under FreeBSD 10.x + * avrftdi.h: Fix header guard macro name. + * pgm_type.c (programmers_types): Remove duplicate "const". + +2014-07-16 Rene Liebscher + + bug #42662 clang warnings under FreeBSD 10.x + * avrftdi.c: remove warnings + * buspirate.c: (Dito.) + * dfu.c: (Dito.) + * fileio.c: (Dito.) + * libavrdude.h: (Dito.) + * pickit2.c: (Dito.) + * safemode.c: (Dito.) + * ser_avrdoper.c: (Dito.) + * ser_posix.c: (Dito.) + * ser_win32.c: (Dito.) + * stk500v2.c: (Dito.) + * usb_libusb.c: (Dito.) + * usbasp.c: (Dito.) + + * config_gram.y: fix problem when using parent part with usbpid lists + (existing list was extended not overwritten) + +2014-07-11 Axel Wachtler + + * avrftdi.c: rollback to vfprintf, fixed error from -r1305, (patch #8463) + +2014-06-23 Rene Liebscher + + * linux_ppdev.h: added missing msg level for avrdude_message + in ppi_claim/ppi_release macros + * avrftdi.c: added break at end of default + +2014-06-21 Rene Liebscher + + patch #8419 fix ftdi_syncbb hang with libftdi 1 + * ft245r.c: set pthread cancel type to asynchronous, reorder ftdi_usb_close/deinit + +2014-06-17 Rene Liebscher + + * avrftdi_private.h: added missing msg level for avrdude_message + in E/E_VOID macros + +2014-06-17 Rene Liebscher + + Removing exit calls from config parser + * config.h: cleanup, left only internally needed definitions + * config.c: removed exit calls, use yyerror and yywarning + * config_gram.y: (Dito.) + * lexer.l: (Dito.) + * libavrdude.h: removed internal definitions of config parser + * main.c: removed yyerror, it is now in config.c + * jtagmkII.c: added missing free in error case + * pgm.c: replaced exits by returns + * pickit2.c: add missing return + +2014-06-13 Axel Wachtler + + start removing global "verbose" variable, for avrdude library. + * arduino.c: added verbose level in avrdude_message() + * avr910.c: (Dito.) + * avr.c: (Dito.) + * avrdude.h: (Dito.) + * avrftdi.c: (Dito.) + * avrpart.c: (Dito.) + * bitbang.c: (Dito.) + * buspirate.c: (Dito.) + * butterfly.c: (Dito.) + * config.c: (Dito.) + * config_gram.y: (Dito.) + * dfu.c: (Dito.) + * fileio.c: (Dito.) + * flip1.c: (Dito.) + * flip2.c: (Dito.) + * ft245r.c: (Dito.) + * jtag3.c: (Dito.) + * jtagmkI.c: (Dito.) + * jtagmkII.c: (Dito.) + * lexer.l: (Dito.) + * libavrdude.h: (Dito.) + * linuxgpio.c: (Dito.) + * main.c: (Dito.) + * par.c: (Dito.) + * pgm.c: (Dito.) + * pickit2.c: (Dito.) + * pindefs.c: (Dito.) + * ppi.c: (Dito.) + * ppiwin.c: (Dito.) + * safemode.c: (Dito.) + * ser_avrdoper.c: (Dito.) + * serbb_posix.c: (Dito.) + * serbb_win32.c: (Dito.) + * ser_posix.c: (Dito.) + * ser_win32.c: (Dito.) + * stk500.c: (Dito.) + * stk500generic.c: (Dito.) + * stk500v2.c: (Dito.) + * term.c: (Dito.) + * update.c: (Dito.) + * usbasp.c: (Dito.) + * usb_libusb.c: (Dito.) + * usbtiny.c: (Dito.) + * wiring.c: (Dito.) + +2014-06-11 Rene Liebscher + + bug #42516 spelling-error-in-binary + * stk500v2.c, avrftdi.c, usbasp.c: fixed spelling errors + +2014-06-01 Rene Liebscher + + bug #42337 avrdude.conf updates for UM232H/CM232H + * avrdude.conf.in: fixed entries as proposed + +2014-05-19 Joerg Wunsch + + bug #41854: avrdude 6.1 does not compile on systems without libUSB + Submitted by Didrik Madheden: + * flip1.c: Provide dummy functions for the #ifndef HAVE_LIBUSB case + * flip2.c: (Dito.) + +2014-05-19 Joerg Wunsch + + * libavrdude.h: Join the former "public" header files (avr.h avrpart.h pindefs.h + serial.h fileio.h safemode.h update.h pgm_type.h config.h confwin.h lists.h) into + a single header that can be included by anyone wanting to link against the + library + * avr.h: Remove file. + * avrpart.h: (Dito.) + * pindefs.h: (Dito.) + * serial.h: (Dito.) + * fileio.h: (Dito.) + * safemode.h: (Dito.) + * update.h: (Dito.) + * pgm.h: (Dito.) + * pgm_type.h: (Dito.) + * config.h: (Dito.) + * confwin.h: (Dito.) + * lists.h: (Dito.) + * Makefile.am: Adapt for new include file constellation; install shared lib + * configure.ac: Bump version date + * arduino.c: #include rather than a bunch of different headers + * avr910.c: (Dito.) + * avr910.h: (Dito.) + * avr.c: (Dito.) + * avrftdi.c: (Dito.) + * avrftdi_private.h: (Dito.) + * avrftdi_tpi.c: (Dito.) + * avrftdi_tpi.h: (Dito.) + * avr.h: (Dito.) + * avrpart.c: (Dito.) + * avrpart.h: (Dito.) + * bitbang.c: (Dito.) + * buspirate.c: (Dito.) + * butterfly.c: (Dito.) + * config.c: (Dito.) + * config_gram.y: (Dito.) + * config.h: (Dito.) + * confwin.c: (Dito.) + * confwin.h: (Dito.) + * dfu.c: (Dito.) + * fileio.c: (Dito.) + * fileio.h: (Dito.) + * flip1.c: (Dito.) + * flip1.h: (Dito.) + * flip2.c: (Dito.) + * flip2.h: (Dito.) + * ft245r.c: (Dito.) + * ft245r.h: (Dito.) + * jtag3.c: (Dito.) + * jtagmkI.c: (Dito.) + * jtagmkII.c: (Dito.) + * lexer.l: (Dito.) + * libavrdude.h: (Dito.) + * linuxgpio.c: (Dito.) + * lists.c: (Dito.) + * lists.h: (Dito.) + * main.c: (Dito.) + * par.c: (Dito.) + * pgm.c: (Dito.) + * pgm_type.c: (Dito.) + * pgm_type.h: (Dito.) + * pickit2.c: (Dito.) + * pickit2.h: (Dito.) + * pindefs.c: (Dito.) + * pindefs.h: (Dito.) + * ppi.c: (Dito.) + * ppiwin.c: (Dito.) + * safemode.c: (Dito.) + * safemode.h: (Dito.) + * ser_avrdoper.c: (Dito.) + * serbb_posix.c: (Dito.) + * serbb_win32.c: (Dito.) + * serial.h: (Dito.) + * ser_posix.c: (Dito.) + * ser_win32.c: (Dito.) + * stk500.c: (Dito.) + * stk500generic.c: (Dito.) + * stk500v2.c: (Dito.) + * stk500v2_private.h: (Dito.) + * term.c: (Dito.) + * term.h: (Dito.) + * update.c: (Dito.) + * update.h: (Dito.) + * usbasp.c: (Dito.) + * usbasp.h: (Dito.) + * usb_libusb.c: (Dito.) + * usbtiny.c: (Dito.) + * usbtiny.h: (Dito.) + * wiring.c: (Dito.) + +2014-05-19 Joerg Wunsch + + * main.c: Cleanup unused include files. + +2014-05-19 Joerg Wunsch + + * linux_ppdev.h: Caught two more instances of exit() + * configure.ac: Add AC_CONFIG_MACRO_DIR as suggested by libtoolize + * Makefile.am: add -I m4 to ACLOCAL_AMFLAGS as suggested by libtoolize + +2014-05-16 Axel Wachtler + + * arduino.c: Replacing all occurences of fprintf(stderr,...) with avrdude_message(...) + in potential library functions. + * avr910.c: (Dito.) + * avr.c: (Dito.) + * avrdude.h: (Dito.) + * avrftdi.c: (Dito.) + * avrftdi_private.h: (Dito.) + * avrpart.c: (Dito.) + * bitbang.c: (Dito.) + * buspirate.c: (Dito.) + * butterfly.c: (Dito.) + * config.c: (Dito.) + * config_gram.y: (Dito.) + * dfu.c: (Dito.) + * fileio.c: (Dito.) + * flip1.c: (Dito.) + * flip2.c: (Dito.) + * ft245r.c: (Dito.) + * jtag3.c: (Dito.) + * jtagmkI.c: (Dito.) + * jtagmkII.c: (Dito.) + * lexer.l: (Dito.) + * linuxgpio.c: (Dito.) + * linux_ppdev.h: (Dito.) + * main.c: (Dito.) + * par.c: (Dito.) + * pgm.c: (Dito.) + * pickit2.c: (Dito.) + * pindefs.c: (Dito.) + * ppi.c: (Dito.) + * ppiwin.c: (Dito.) + * safemode.c: (Dito.) + * ser_avrdoper.c: (Dito.) + * serbb_posix.c: (Dito.) + * serbb_win32.c: (Dito.) + * ser_posix.c: (Dito.) + * ser_win32.c: (Dito.) + * stk500.c: (Dito.) + * stk500generic.c: (Dito.) + * stk500v2.c: (Dito.) + * term.c: (Dito.) + * update.c: (Dito.) + * usbasp.c: (Dito.) + * usb_libusb.c: (Dito.) + * usbtiny.c: (Dito.) + * wiring.c: (Dito.) + +2014-05-16 Joerg Wunsch + + * configure.ac: Bump version, add libtool hooks + * Makefile.am: First attempt to define building a shared library + (not to be installed by now) + +2014-05-16 Joerg Wunsch + + * dfu.c (dfu_open, dfu_init): Fix signature of the dummy functions + (in the !HAVE_LIBUSB case) to match prototypes. + +2014-05-16 Joerg Wunsch + + * avr910.c: Replace all occurences of exit() in potential library + functions by appropriate return values + * avrftdi.c: (Dito.) + * bitbang.c: (Dito.) + * bitbang.h: (Dito.) + * buspirate.c: (Dito.) + * butterfly.c: (Dito.) + * config.c: (Dito.) + * flip2.c: (Dito.) + * ft245r.c: (Dito.) + * jtagmkI.c: (Dito.) + * jtagmkII.c: (Dito.) + * linuxgpio.c: (Dito.) + * main.c: (Dito.) + * par.c: (Dito.) + * pgm.c: (Dito.) + * pickit2.c: (Dito.) + * pindefs.c: (Dito.) + * pindefs.h: (Dito.) + * ser_avrdoper.c: (Dito.) + * ser_posix.c: (Dito.) + * ser_win32.c: (Dito.) + * serbb_posix.c: (Dito.) + * serbb_win32.c: (Dito.) + * stk500.c: (Dito.) + * stk500v2.c: (Dito.) + +2014-05-07 Rene Liebscher + + bug #42310: New part description for AT90PWM216 + * avrdude.conf.in: added pwm216 entry + +2014-05-07 Rene Liebscher + + bug #42158: Linux GPIO - Source Typo + * pindefs.h: fixed typo + +2014-04-14 Rene Liebscher + + bug #42056: double free or corruption triggered at exit + * pgm.c: copy usbpid list in pgm_dup + +2014-04-05 Joerg Wunsch + + * avrdude.1: Remove the note that users might edit the system-wide + config file. This file will be overwritten by the next + installation, so it's not a good idea to manually modify it. + Using the -C +file option is a much better way for user + modifications. + * doc/avrdude.texi: (Dito.) + * avrdude.conf.in: Add a warning to not modify the file manually. + +2014-03-13 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version for post-6.1. + +2014-03-12 Joerg Wunsch + + * configure.ac (AC_INIT): Bump version to 6.1. + +2014-03-12 Joerg Wunsch + + * pgm.c (pgm_free): Cleanup police: destroy the p->usbpid + list when freeing the programmer struct. + +2014-03-12 Joerg Wunsch + + bug #40782: Verify errors for object size > 16 k on x32e5 due + to typo in avrdude.conf + * avrdude.conf.in (ATmega8E5, ATmega32E5): fix boot location + +2014-02-28 Joerg Wunsch + + * avrdude.conf.in (atmelice, atmelice_pdi, atmelice_dw, atmelice_isp): + New entries. + * avrdude.1: Document the Atmel-ICE addition. + * doc/avrdude.texi: (Dito.) + * usbdevs.c (USB_DEVICE_ATMEL_ICE): New entry. + +2014-02-28 Joerg Wunsch + + * main.c: Bump copyright year. + +2014-02-28 Joerg Wunsch + + * jtag3.c (jtag3_recv): avoid memmov'ing more data than available + +2014-02-27 Joerg Wunsch + + * avrdude.1: Documentation update for EDBG. + * doc/avrdude.texi: (Dito.) + +2014-02-27 Joerg Wunsch + + * jtag3.c: For EDBG protocol, always use 512-byte block I/O. The + lower layers will split this according to the EP's maxsize. This + makes it work over USB 1.1 connections (albeit very slowly, due to + the interrupt transfers used). + +2014-02-27 Joerg Wunsch + + * config_gram.y: Turn the usbpid parameter of the programmer into + a list of PIDs. Make the JTAGICE3 programmer handle a list of + PIDs, by trying each of them in sequence. Use a single, central + jtag3_open_common() function to handle the common code of all + jtag3_open_* functions. Centralize all USB VID/PID definitions in + usbdevs.h. + * flip1.c: (Dito.) + * ft245r.c: (Dito.) + * stk500v2.c: (Dito.) + * jtag3.c: (Dito.) + * jtag3.h: (Dito.) + * flip2.c: (Dito.) + * usbdevs.h: (Dito.) + * pgm.c: (Dito.) + * serial.h: (Dito.) + * pgm.h: (Dito.) + * usbtiny.c: (Dito.) + * usbasp.c: (Dito.) + * avrftdi.c: (Dito.) + * usbtiny.h: (Dito.) + * avrdude.conf.in: (Dito.) + * usbasp.h: (Dito.) + * usb_libusb.c: (Dito.) + +2014-02-27 Joerg Wunsch + + * usb_libusb.c (usbdev_open): Replace all calls to exit(1) by + return -1 + +2014-02-26 Joerg Wunsch + + * jtag3_private.h: Add EDBG/CMSIS-DAP specific constants. + * jtag3.c: Add EDBG/CMSIS-DAP protocol implementation. + * serial.h: (Dito.) + * usbdevs.h: (Dito.) + * usb_libusb.c: (Dito.) + * configure.ac: (Dito.) + * avrdude.conf.in: Add JTAGICE3 and XplainedPro entries using + EDBG. + * configure.ac: Bump version date. + +2014-02-22 Joerg Wunsch + + * usb_libusb.c (usbdev_recv_frame): Fix a bug where a new recv + request was issued even though all desired data had aldready + been received. + +2014-02-21 Joerg Wunsch + + * serial.h: Change the second parameter of the ser_open method + from "baud" into a "union pinfo", so the USB parameters can be + passed without hacks. + * arduino.c: (Dito.) + * avr910.c: (Dito.) + * buspirate.c: (Dito.) + * butterfly.c: (Dito.) + * jtag3.c: (Dito.) + * jtagmkI.c: (Dito.) + * jtagmkII.c: (Dito.) + * ser_avrdoper.c: (Dito.) + * ser_posix.c: (Dito.) + * ser_win32.c: (Dito.) + * stk500.c: (Dito.) + * stk500v2.c: (Dito.) + * usb_libusb.c: (Dito.) + * wiring.c: (Dito.) + +2014-01-30 Joerg Wunsch + + [bug #41402] dfu.c missing include + * dfu.c: include where uint16_t is defined + +2014-01-28 Joerg Wunsch + + * avrdude.conf.in (ATmega256RFR2 et al.): Fix EEPROM size. + +2014-01-27 Joerg Wunsch + + [bug #41357] OS X: Avrdude messes with the usb stack? + * usb_libusb.c (usbdev_close): Only issue the usb_reset() for + Linux systems, as these are the only ones that seem to require + it under some circumstances. + +2014-01-22 Joerg Wunsch + + * configure.ac (libelf): check against elf_getshdrstrndx() rather + than just elf_begin() only, so it is clear we found a sufficiently + recent libelf to work with. + +2014-01-22 Joerg Wunsch + + Contributed by Alan Horstmann: + bug #40897: AT Mega2560 not correctly programmed with stk500(v1) ISP (solution patch) + * stk500.c: Implement extended address byte handling. + * avrdude.conf.in (ATmega2560): enable stk500_devcode so + STK500v1 protocol actually starts at all. + +2014-01-17 Joerg Wunsch + + * flip1.c: Implement the meat of FLIP version 1 protocol. + * avrdude.1: Document the new protocol. + * doc/avrdude.texi: (Dito.) + +2014-01-17 Joerg Wunsch + + * flip2.c (flip2_page_erase): Remove unimplemented function. + * dfu.h: Correctly conditionalize vs. ; + add adjustable timeout (struct dfu_dev); add dfu_abort() + * dfu.c (dfu_abort): New function; implement adjustable timeout. + +2014-01-17 Joerg Wunsch + + * configure.ac (libhid): Turn from AC_TRY_RUN into + AC_TRY_COMPILE, so it also works for cross-compilation + setups. + +2014-01-16 Joerg Wunsch + + * dfu.c (dfu_init): Move the descriptor checks up into the + FLIP protocol implementation. + * flip2.c (flip2_initialize): (Dito.) + * flip1.c (flip1_initialize): (Dito.) + +2014-01-16 Joerg Wunsch + + * flip2.c: Rename from flip.c + * flip2.h: Rename from flip.h + * Makefile.am: Reflect the renaming. + * dfu.c: Update information how to get GPL. + * dfu.h: (Dito.) + +2014-01-16 Joerg Wunsch + + * flip.c (flip2_initialize): Check user is running on an Xmega + device. + +2014-01-15 Joerg Wunsch + + * flip.c: Added some verbose-level messages (-vv) + * dfu.c: Added some verbose-level messages (-vvvv) + +2014-01-15 Joerg Wunsch + + Submitted by Kirill Levchenko: + patch #7896: DFU FLIPv2 programming support + * pgm_type.c: Add the flip2 programmer type. + * config_gram.y: Allow for the usbid keyword in a device definition. + * avrdude.conf.in: Add usbpid values to those Xmega devices where + applicable. + * avrpart.h: Add usbpid device field. + * dfu.c: (New file.) + * dfu.h: (New file.) + * flip.c: (New file.) + * flip.h: (New file.) + * Makefile.am: Add new files. + * doc/avrdude.texi: Document the changes. + * avrdude.1: (Dito.) + +2014-01-15 Joerg Wunsch + + * ChangeLog-2013: Annual changelog rotation. diff --git a/xs/src/avrdude/ChangeLog-2015 b/xs/src/avrdude/ChangeLog-2015 new file mode 100644 index 000000000..edc274188 --- /dev/null +++ b/xs/src/avrdude/ChangeLog-2015 @@ -0,0 +1,54 @@ +2015-12-15 Joerg Wunsch + + * avrdude.1 (-C): Do not suggest users might change the + default config file. It will be overwritten by updates. + +2015-12-09 Joerg Wunsch + + bug #46610: Floating point exception (core dumped) arch linux rpi2 + bug #46483: version 6.2. ser_open(): can't set attributes for device + * ser_posix.c: Back out change from patch #8380 + +2015-11-16 Joerg Wunsch + + * configure.ac: Bump for post-release 6.2. + +2015-11-16 Joerg Wunsch + + * configure.ac: Released version 6.2. + +2015-10-31 Joerg Wunsch + + Submitted by Martino Facchin: + bug #45727: Wrong atmega8u2 flash parameters + * avrdude.conf.in (ATmega8U2): correct page and block size + +2015-10-31 Joerg Wunsch + + Submitted by Pasquale Cocchini: + bug #46020: Add TIAO TUMPA to the conf file. + * avrdude.conf.in (tumpa): New entry. + +2015-10-31 Joerg Wunsch + + Submitted by Pasquale Cocchini: + bug #46021: Please add read in the memory lock section of ATtiny85 + * avrdude.conf.in (ATtiny25/45/85): add read pattern for lock bits + +2015-10-31 Joerg Wunsch + + * Makefile.am (libavrdude_a_SOURCES): reflect recent changes + (pgm.h is gone, config.h is new). + +2015-04-09 Joerg Wunsch + + bug #44717: avrdude creates empty flash dump + * update.c (do_op): When about to write an empty flash dump file, + warn about this to avoid surprises. + * avrdude.1: Document the truncation of trailing 0xFF bytes for + flash memory areas. + * doc/avrdude.texi: (Dito.) + +2015-04-09 Joerg Wunsch + + Annual ChangeLog rotation. diff --git a/xs/src/avrdude/Makefile.am b/xs/src/avrdude/Makefile.am new file mode 100644 index 000000000..d1ed47845 --- /dev/null +++ b/xs/src/avrdude/Makefile.am @@ -0,0 +1,206 @@ +# +# avrdude - A Downloader/Uploader for AVR device programmers +# 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 +# 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$ +# + +EXTRA_DIST = \ + ChangeLog \ + ChangeLog-2001 \ + ChangeLog-2002 \ + ChangeLog-2003 \ + ChangeLog-2004-2006 \ + ChangeLog-2007 \ + ChangeLog-2008 \ + ChangeLog-2009 \ + ChangeLog-2010 \ + ChangeLog-2011 \ + ChangeLog-2012 \ + ChangeLog-2013 \ + avrdude.1 \ + avrdude.spec \ + bootstrap + +CLEANFILES = \ + config_gram.c \ + config_gram.h \ + lexer.c + +BUILT_SOURCES = $(CLEANFILES) + +#SUBDIRS = doc @WINDOWS_DIRS@ +#DIST_SUBDIRS = doc windows + +# . lets build this directory before the following in SUBDIRS +SUBDIRS = . +# doc comes here, and we want to use the built avrdude to generate the parts list +SUBDIRS += @SUBDIRS_AC@ +SUBDIRS += @WINDOWS_DIRS@ +DIST_SUBDIRS = @DIST_SUBDIRS_AC@ + +AM_YFLAGS = -d + +avrdude_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" + +libavrdude_a_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" +libavrdude_la_CPPFLAGS = $(libavrdude_a_CPPFLAGS) + +avrdude_CFLAGS = @ENABLE_WARNINGS@ + +libavrdude_a_CFLAGS = @ENABLE_WARNINGS@ +libavrdude_la_CFLAGS = $(libavrdude_a_CFLAGS) + +avrdude_LDADD = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB_1_0@ @LIBHIDAPI@ @LIBUSB@ @LIBFTDI1@ @LIBFTDI@ @LIBHID@ @LIBELF@ @LIBPTHREAD@ -lm + +bin_PROGRAMS = avrdude + +noinst_LIBRARIES = libavrdude.a +lib_LTLIBRARIES = libavrdude.la + +# automake thinks these generated files should be in the distribution, +# but this might cause trouble for some users, so we rather don't want +# to have them there. +# +# See +# +# https://savannah.nongnu.org/bugs/index.php?func=detailitem&item_id=15536 +# +# for why we don't want to have them. +dist-hook: + rm -f \ + $(distdir)/lexer.c \ + $(distdir)/config_gram.c \ + $(distdir)/config_gram.h + +libavrdude_a_SOURCES = \ + config_gram.y \ + lexer.l \ + arduino.h \ + arduino.c \ + avr.c \ + avr910.c \ + avr910.h \ + avrdude.h \ + avrftdi.c \ + avrftdi.h \ + avrftdi_private.h \ + avrftdi_tpi.c \ + avrftdi_tpi.h \ + avrpart.c \ + bitbang.c \ + bitbang.h \ + buspirate.c \ + buspirate.h \ + butterfly.c \ + butterfly.h \ + config.c \ + config.h \ + confwin.c \ + crc16.c \ + crc16.h \ + dfu.c \ + dfu.h \ + fileio.c \ + flip1.c \ + flip1.h \ + flip2.c \ + flip2.h \ + freebsd_ppi.h \ + ft245r.c \ + ft245r.h \ + jtagmkI.c \ + jtagmkI.h \ + jtagmkI_private.h \ + jtagmkII.c \ + jtagmkII.h \ + jtagmkII_private.h \ + jtag3.c \ + jtag3.h \ + jtag3_private.h \ + libavrdude.h \ + linuxgpio.c \ + linuxgpio.h \ + linux_ppdev.h \ + lists.c \ + my_ddk_hidsdi.h \ + par.c \ + par.h \ + pgm.c \ + pgm_type.c \ + pickit2.c \ + pickit2.h \ + pindefs.c \ + ppi.c \ + ppi.h \ + ppiwin.c \ + safemode.c \ + serbb.h \ + serbb_posix.c \ + serbb_win32.c \ + ser_avrdoper.c \ + ser_posix.c \ + ser_win32.c \ + solaris_ecpp.h \ + stk500.c \ + stk500.h \ + stk500_private.h \ + stk500v2.c \ + stk500v2.h \ + stk500v2_private.h \ + stk500generic.c \ + stk500generic.h \ + tpi.h \ + usbasp.c \ + usbasp.h \ + usbdevs.h \ + usb_hidapi.c \ + usb_libusb.c \ + usbtiny.h \ + usbtiny.c \ + update.c \ + wiring.h \ + wiring.c +libavrdude_la_SOURCES = $(libavrdude_a_SOURCES) +libavrdude_la_LDFLAGS = -version-info 1:0 + +include_HEADERS = libavrdude.h + +avrdude_SOURCES = \ + main.c \ + term.c \ + term.h + +man_MANS = avrdude.1 + +sysconf_DATA = avrdude.conf + +install-exec-local: backup-avrdude-conf + +distclean-local: + rm -f avrdude.conf + +# This will get run before the config file is installed. +backup-avrdude-conf: + @echo "Backing up avrdude.conf in ${DESTDIR}${sysconfdir}" + @if test -e ${DESTDIR}${sysconfdir}/avrdude.conf; then \ + cp -pR ${DESTDIR}${sysconfdir}/avrdude.conf \ + ${DESTDIR}${sysconfdir}/avrdude.conf.bak; \ + fi + +ACLOCAL_AMFLAGS = -I m4 diff --git a/xs/src/avrdude/NEWS b/xs/src/avrdude/NEWS new file mode 100644 index 000000000..ced93cd35 --- /dev/null +++ b/xs/src/avrdude/NEWS @@ -0,0 +1,913 @@ +$Id$ + +Approximate change log for AVRDUDE by version. + +(For more detailed changes, see the ChangeLog file.) + +---------------------------------------------------------------------- +Current: + + * Major changes compared to the previous version: + + - libhidapi support (part of patch #8717) + - use libhidapi as (optional) transport for CMSIS-DAP compliant + debuggers (JTAGICE3 with firmware 3+, AtmelICE, EDBG, mEDBG) + + * New devices supported: + + * New programmers supported: + + - ehajo-isp (commercial version of USBtiny) + + * Bugfixes: + bug #47550: Linux GPIO broken + + * Internals: + + +Version 6.3: + + * Major changes compared to the previous version: + + - Backout of + patch #8380: adds 500k 1M 2M baud to ser_posix.c + It broke the functionality in too many situations + (bug #46610/46483) + + * New devices supported: + + - ATmega48PB, ATmega88PB, ATmega168PB + - ATtiny28 (HVPP-only device) + + * New programmers supported: + + - Atmel mEDBG: xplainedmini, xplainedmini_dw + + * Bugfixes + + - bug #46610: Floating point exception (core dumped) arch linux rpi2 + - bug #46483: version 6.2. ser_open(): can't set attributes for device + - patch #8435: Implementing mEDBG CMSIS-DAP protocol + - patch #8735: ATtiny28 support in avrdude.conf + - patch #8896: Silence cppcheck warnings in 6.2 code + - patch #8895: Spelling in 6.2 code + + +Version 6.2: + + * Major changes compared to the previous version: + + - The stk500v2 implementation now uses its own higher-level + command implementation for byte-wide access, rather than the + historic SPI_MULTI command where all the low-level ISP + implementation had to be assembled manually inside AVRDUDE. In + addition to the traditional STK500, this implementation is also + used by all the more modern Atmel tools (AVRISPmkII, JTAGICEmkII + in ISP mode, STK600 in ISP mode). + + - The -B option can be suffixed with "Hz", "kHz", or "MHz", in + order to specify a bitclock frequency rather than period. + + - Print part id after signature (patch #8440 ) + + - buspirate: Also support "cpufreq" extended parameter + in binary mode (patch #8504 ) + + - The "-P net:" syntax (forwarding of serial data over TCP) is now + also implemented for Win32 systems. + + - Allow for arbitrary serial baudrates under Linux (OSX and *BSD + could already handle it). + + + * New devices supported: + - AT90PWM216 (bug #42310: New part description for AT90PWM216) + - ATmega32M1 (patch #7694 Add support for the atmega32m1) + + * New programmers supported: + - ftdi_syncbb + + uncompatino, ttl232r (FTDI TTL232R-5V with ICSP adapter) + (patch #8529 2 more ftdi_syncbb devices) + + * Bugfixes + - bug #45727: Wrong atmega8u2 flash parameters + - bug #46020: Add TIAO TUMPA to the conf file. + - bug #46021: Please add read in the memory lock section of ATtiny85 + - bug #42337 avrdude.conf updates for UM232H/CM232H + - bug #42056: double free or corruption triggered at exit + - bug #42158: Linux GPIO - Source Typo + - bug #42516 spelling-error-in-binary + - patch #8419 fix ftdi_syncbb hang with libftdi 1 + - bug #43002 usbasp debug output typo + - patch #8511 Fix reset on FT245R + - bug #40142 Floating point exception on Ubuntu 10.04 + - bug #22248: Read efuse error (partial fix) + - bug #42267: jtag3isp fails to read lock and fuse bytes directly + after changing lock byte + - bug #41561: AVRDUDE 6.0.1/USBasp doesn't write first bytes of + flash page + - bug #43078: AVRDUDE crashes after sucessfully reading/writing eeprom + - bug #43137: Writing and reading incorrect pages when using jtagicemkI + - bug #40870: config nitpick: ATtiny25/45/85 have 1 calibration byte not 2 + - bug #42908: no external reset at JTAGICE3 + - patch #8437: [PATCH] Serial-over-ethernet for Win32 + - bug #44717: avrdude creates empty flash dump + + * Internals: + - Removing exit calls from config parser + - bug #42662 clang warnings under FreeBSD 10.x + +Version 6.1: + + * Major changes compared to the previous version: + - Atmel EDBG protocol support added (JTAGICE3, XplainedPro, Atmel-ICE) + + * New programmers supported: + - Atmel DFU, using FLIP protocol version 1 (AT90USB and ATmega*U* devices), + or version 2 (Xmega devices) + - Atmel-ICE (ARM/AVR), JTAG, PDI, debugWIRE, ISP modi + + * Bugfixes + - bug #40055: AVRDUDE segfaults when writing eeprom + - bug #40085: Typo fix in fuses report (for 6.1-svn-20130917) + - bug #40782: Verify errors for object size > 16 k on x32e5 due + to typo in avrdude.conf + - bug #40817: Elf file support (possibly) not working on 6.0.1 windows build + - bug #40897: AT Mega2560 not correctly programmed with stk500(v1) + ISP (solution patch) + - bug #41357: OS X: Avrdude messes with the usb stack? + - bug #41402: dfu.c missing include + - patch #7896: DFU FLIPv2 programming support + - patch #XXXX: xxx + + * Internals: + - (Some) programmers can take a list of USB PIDs now. + + +Version 6.0: + + * Major changes compared to the previous version: + + - Programmer types in configuration file are no longer keywords but + specified as string. + + So you need to change 'type = XYZ;' to 'type = "XYZ";' in own + config files. (internal: The parser does not need to know all + programmer types now, new programmers will update only the table + in pgm_type.c.) + + - The erase cycle counter (formerly options -y / -Y) has been + removed. + + - Specifying a -U option without a memory type (short form of + option argument list) now defaults to "application" memory for + Xmega devices, and "flash" for everything else. This ensures + the Xmega bootloader is not accidentally touched. + + - For programmers that support it, the default erase method is a + page erase now, rather than a chip erase (Xmega only). + + - Keep track of input file contents + + Memory segments are being tracked to remember whether they've + been actually read from a file. Only segments that came from a + file are being programmed into the device, or considered for + verification. This drastically improves handling speed for + sparse files (e.g. files that have a second bootloader segment), + and it ensures the device contents is actually compared for + everything mentioned in the file (even in case the file has + large 0xFF blocks). + + - The -U option now accepts ELF files as input files, and extracts + the appropriate section contents that matches the requested memory + region. To enable this feature, the host system used for the + compilation must have a libelf around, including the respective + header files (i.e., package "libelf-devel" on many Linux systems). + + - Programmers and parts lists + + They are now sorted at output with '-c ?'/'-p ?'. (patch #7671: + Sorting programmers and parts lists for console output) + + Programmers and parts lists in documentation generated from lists + mentioned above. (patch #7687: Autogenerating programmers and + parts lists for docs) + + Output list of programmer types with '-c ?type', add list to + documentation + + - Configuration files now accepts parent parts/programmers, parts + starting with '.' (eg. .xmega) are not included in output parts + list and can be used as abstract parents + + (bug #34302: Feature request : device configuration with parent classes) + (patch #7688: Implement parent programmers feature) + + - Additional config files which are read after default can be + specified on command line using '-C +filename' + + (patch #7699 Read additional config files) + + - "Safemode" can now be turned off by default from within a + configuration file (like ~/.avrduderc). + + - The new option -l logfile allows to redirect diagnostic messages + to a logfile rather than stderr. Useful to record debugging + traces, in particular in environments which do not offer + shell-style redirection functionality for standard streams. + + - When leaving debugWIRE mode, immediately retry with ISP rather + than bailing out completely. + + - The USBasp programmer implementation now supports detailed traces + with -vvv, and device communication traces with -vvvv. + + - The "verbose" terminal mode command allows to query or modify the + verbosity level. + + * New devices supported: + - ATmega48P (patch #7629 add support for atmega48p) + - AT90PWM316 (bug #21797: AT90PWM316: New part description) + - ATxmega16D4, ATxmega32D4, ATxmega64D4, ATxmega128D4 + - ATmega256RFR2, ATmega128RFR2, ATmega64RFR2, ATmega2564RFR2, + ATmega1284RFR2, ATmega644RFR2 + - ATtiny1634 + - ATxmega128A1U, ATxmega128A3U, ATxmega128A4U, ATxmega128B1, + ATxmega128B3, ATxmega128C3, ATxmega128D3, ATxmega16A4U, + ATxmega16C4, ATxmega192A3U, ATxmega192C3, ATxmega192D3, + ATxmega256A3BU, ATxmega256A3U, ATxmega256C3, ATxmega256D3, + ATxmega32A4U, ATxmega32C4, ATxmega384C3, ATxmega384D3, + ATxmega64A1U, ATxmega64A3U, ATxmega64A4U, ATxmega64B1, + ATxmega64B3, ATxmega64C3, ATxmega64D3 + - ATtiny43U + - ATmega406 + - ATxmega8E5, ATxmega16E5, ATxmega32E5 + - ATtiny20, ATtiny40 + + + * New programmers supported: + - linuxgpio + + any (embedded) Linux system with 4 GPIOs available can be used + as a programmer with little or no additional hardware. + + - avrftdi + + o-link (patch #7672 adding support for O-Link (FTDI based + JTAG) as programmer) + + 4232h (patch #7715 FT4232H support) + - TPI support + + openmoko (bug #37977 Support for Openmoko Debug Board) + + - usbasp + + nibobee (previously specified as '-c usbasp -P nibobee) + + usbasp-clone (same as usbasp but ignores vendor and product + string, checks only vid/pid) + + - ftdi_syncbb (new type for synchronous bitbanging with ft232r/ft245r) + + ft245r (FT245R Synchronous BitBang, miso = D1, sck = D0, mosi + = D2, reset = D4) + + ft232r (FT232R Synchronous BitBang, miso = RxD, sck = RTS, + mosi = TxD, reset = DTR) + + bwmega (BitWizard ftdi_atmega builtin programmer, miso = DSR, + sck = DCD, mosi = CTS, reset = RI) + + arduino-ft232r (Arduino: FT232R connected to ISP, miso = CTS + X3(1), sck = DSR X3(2), mosi = DCD X3(3), reset = RI X3(4)) + + diecimila (alias for arduino-ft232r) + + - pickit2 + + - Atmel JTAGICE3 + + - buspirate_bb (TPI programming using the BusPirate in bitbang mode) + + * Bugfixes + - bug #34027: avrdude AT90S1200 Problem + - bug #34518: loading intel hex files > 64k using record-type 4 + - patch #7667: Minor memory handling fixes + - patch #7680: Fixing timeout problem in ser_recv in ser_win32.c + - patch #7693: Fix config file atmel URLs (+ URLs in + avrdude.texi and avrpart.h) + - bug #21663: AT90PWM efuse incorrect, bug #30438: efuse bits + written as 0 on at90pwmxx parts + - bug #35261: avrftdi uses wrong interface in avrftdi_paged_(write|load) + - patch #7437 modifications to Bus Pirate module + - patch #7686 Updating buspirate ascii mode to current firmware, + use AUX as clock generator, and setting of serial receive + timeout + - bug #34768 Proposition: Change the name of the AVR32 devices + - patch #7718: Merge global data of avrftdi in a private data + structure + - bug #35208: avrdude 5.11 on freebsd 8.2-STABLE does not reset + Arduino Uno properly + - bug #34518: loading intel hex files > 64k using record-type 4 + (Extended Linear Address Record) + - bug #34027: avrdude AT90S1200 Problem + - bug #30451: Accessing some Xmega memory sections gives not + supported error + - bug #28744: Can't load bootloader to xmega128a1 + - bug #29019: pagel/bs2 warning when uploading using stk500 to xmega + - bug #30756: When setting SUT to 64ms on XMEGA, avrdude doesn't + read device signature + - bug #37265: wrong page sizes for XMega64xx in avrdude.conf + - bug #37942: Latest SVN can't program in dragon_jtag mode + - patch #7876 JTAGICE mkII fails to connect to attiny if debugwire + is enabled AND target has a very slow clock + - bug #39893: Verification failure with AVRISPmkII and Xmega + - bug #38713: Compilation of the documentation breaks with texinfo-5 + - bug #38023: avrdude doesn't return an error code when attempting + to upload an invalid Intel HEX file + - bug #39794: warnings when building avrdude 6.0rc1 under CentOS 6.4 + - bug #35800: Compilation error on certain systems if parport is disabled + - bug #38307: Can't write usersig of an xmega256a3 + - bug #38580: Current svn head, xmega and fuses, all fuses tied to fuse0 + - bug #39691: Buffer overrun when reading EEPROM byte with JTAGICE3 + - bug #38951: AVR109 use byte offset instead of word offset + - patch #7769: Write flash fails for AVR910 programmers + - bug #38732: Support for ATtiny1634 + - bug #36901: flashing Atmega32U4 EEPROM produces garbage on chip + - bug #28344: chip_erase_delay too short for ATmega324P, 644, 644P, and 1284P + - bug #34277: avrdude reads wrong byte order if using avr911 (aka butterfly) + - bug #35456: The progress bar for STK500V2 programmer is "wrong". + - patch #5708: avrdude should make 10 synchronization attempts instead of just one + - patch #7606: ATtiny43u support + - patch #7657: Add ATmega406 support for avrdude using DRAGON + JTAG + - bug #35474: Feature request: print fuse values in safemode output. + - patch #7710: usb_libusb: Check VID/PID before opening device + - [no-id]: Fix SCK period adjustment for STK500v2 + - bug #40040: Support for ATtiny20 and ATtiny40 + + * Internals: + + - Restructuring and compacting programmer definition part of + grammar for config file. + - Cleanup of parser code, removing unused definitions/ + functions. Using yylex_destroy if available. + - Fixed some more memory leaks, added cleanup code at program exit + (to minimize the number of non-freed memory blocks reported by + valgrind) + - Fixed some findings reported by cppcheck. + +Version 5.11: + + * New devices supported: + - ATmega88P/168P + - ATmega8U2/16U2/32U2 + - ATtiny4313 + + * New programmers supported: + - TPI programming through bitbang programmers (both, serial + and parallel ones) + - FT2232 (and relatives) based programmers (MPSSE bitbang mode) + - Wiring environment (http://wiring.org.co/) + - butterfly-style bootloader of the Mikrokopter.de device + + * Bugfixes + + +Version 5.10: + + * Bugfixes + - bug #28660: Problem with loading intel hex rom files that exceed + 0x10000 bytes + - see ChangeLog for further details + + * New Features + - (JTAG ICE / AVR Dragon) apply external reset if JTAG ID could + not be read + +Version 5.9: + + * New devices supported: + + - AVR32A0512 (JTAGMKII only) + - ATmega32U4 + - ATtiny4 + - ATtiny5 + - ATtiny9 + - ATtiny10 + + * New programmers supported: + + - BusPirate + - Arduino + - JTAGICEmkII and AVR Dragon in PDI mode (ATxmega devices) + - STK600 and AVRISP mkII in TPI mode (ATtiny4/5/9/10) + + * Bugfixes + + - see ChangeLog and ChangeLog-2009 for details + +Version 5.8: + + * Bugfixes; most importantly, fix a serious memory corruption for + that JTAG ICE mkII and AVR Dragon in ISP/HVSP/PP mode. + +Version 5.7: + + * New devices supported: + + - ATXMEGA64A1 + - ATXMEGA192A1 + - ATXMEGA256A1 + - ATXMEGA64A3 + - ATXMEGA128A3 + - ATXMEGA192A3 + - ATXMEGA256A3 + - ATXMEGA256A3B + - ATXMEGA16A4 + - ATXMEGA32A4 + - ATXMEGA64A4 + - ATXMEGA128A4 + + * Major Xmega fixes for the JTAG ICE mkII (patch #6825) + + * Bugfixes. + +Version 5.6: + + * New devices supported: + + - AT90USB82 + - AT90USB162 + - ATtiny88 + - ATmega328P + - ATmega1284P + - ATmega128RFA1 + - ATxmega128A1 rev D + - ATxmega128A1 + - ATxmega256A3 + + * New programmers supported: + + - AT89ISP cable (patch #6069) + - Arduino + + * Add support for the -x option to pass extended parameters to the + programmer backend. + + * Add support for JTAG daisy-chains, using the -x daisychain= + option. + + * Add support for the Atmel STK600 for "classic" AVRs (AT90, ATtiny, + ATmega), using either ISP or high-voltage programming modes. + + * Add support for the -x devcode extended parameter to the avr910 + programmer, to allow overriding the device code sent to the + programmer. + + * Add support for the Crossbow MIB510 programmer (patch #6074, #6542). + + * Add support to bootstrap with GNU autoconf 2.61, and automake 1.10, + respectively. + + * Add support for ATxmega128A1 (including the revision D engineering + samples) for STK600 and AVRISPmkII tools using PDI + + * The option combination -tF now enters terminal mode even if the + device initialization failed, so the user can modify programmer + parameters (like Vtarget). + + * Add preliminary support for ATxmega128A1 for the JTAG ICE mkII using + JTAG. + + * Add support for direct SPI transfers (bug #25156). + + * Bugfixes. + +Version 5.5: + + * Add support for the USBtinyISP programmer (patch #6233) + + * Add support for the C2N232I serial bitbang programmer (patch #6121) + + * Bugfixes. + +Version 5.4: + + * New devices supported: + + - AT90PWM2B/AT90PWM3B + + * Bugfixes. + + * Source code rearranged so that the functionality is now built + into a libavrdude.a library where main.c is currently the only + existing frontend. + + * Implement ATmega256x support for butterfly/avr109. + +Version 5.3.1: + + * Add support for the AVR Dragon (all modes: ISP, JTAG, HVSP, PP, + debugWire). + + * Add support for debugWire (both, JTAG ICE mkII, and AVR Dragon). + + * Add support for the AVR Doper USB HID-class programmer. + + * Bugfixes. + +Version 5.2: + + * New devices supported: + + - AT90USB646/647/1286/1287 + - ATmega2560/2561 + - ATmega325/3250/645/6450 + - ATtiny11 (HVSP only device) + - ATtiny261/461/861 + + * Fixed paged flash write operations for AT90PWMx devices + (error in datasheet). + + * Add signature verification. + + * Add high-voltage mode programming for the STK500 (both, + parallel, and high-voltage serial programming). + + * Add support for using the JTAG ICE mkII as a generic ISP + programmer. + + * Allow for specifying the ISP clock delay as an option for + bit-bang programming adapters. + + * Add support for Thomas Fischl's USBasp low-cost USB-attached + programmer. + + * The "stk500" programmer type is now implemented as a stub + that tries to probe for either "stk500v1" or "stk500v2". + + * Many bugfixes. + +Version 5.1: + + * New devices supported: + + - ATmega640/1280/1281 + - ATtiny24/44/84 + + * JTAG mkII support now works with libusb-win32, too + + * JTAG ICE mkI support has been added + + * Solaris support has been added (including ecpp(7D) parallel-port + bit-bang mode) + + +Version 5.0: + + * Support for JTAGICE MkII device + + * Support for STK500 Version 2 Protocol + + * New devices supported: + + - AT90CAN128 + - ATmega329x/649x + - ATmega164/324/644 + - AT90PWM2/3, + - ATmega164/324/644 + - ATmega329x/649x + - ATtiny25/45/85 + + * Support for serial bit-bang adapters: Ponyprog serial, UISP DASA, + UISP DASA3. + + * DAPA programmer pinout supported + + * New "safemode" feature where fuse bits are verified before exit + and if possible recovered if they have changed. This is intended + to protect against changed fuses which were not requested which is + reported to sometimes happen due to improper power supply or other + reasons. + + * Various fixes for avr910 and butterfly programmers + + * Full support for AVR109 boot loaders (butterfly) + + * Adding -q -q suppresses most terminal output + + +Version 4.4.0: + + * Native Win32 support: The windows build doesn't need Cygwin + anymore. Additionally, the delay timing on windows should be + more accurate now. + Contributed by Martin Thomas + + * Add support for + - ATmega48, ATmega88 (contributed by Galen Seitz) + - ATtiny2313 (contributed by Bob Paddock) + - ATtiny13 (contributed by Pawel Moll) + + * Added command to change the SCK of STK500-programmers. Now it + is possible to program uC with slow oscillator. + Contributed by Galen Seitz + + * Baudrate for serial programmers (STK500 and AVR910) is + configurable in the config or at the command-line. + This way some more tweaked bootloaders and programmers can be used. + + * Deprecated options have been removed. + Now the "-U" option must be used. + + * MacOS X now supported by default. + +Version 4.3.0: + + * Added support for "Butterfly" evaluation board. + + * Make cycle-count work with AVR910-programmers. + + * Added "Troubleshooting"-Appendix to the manual. + + * Add ATmega8515 support. + Contributed by: Matthias Weißer + + * Add ATmega64 support. + Contributed by: Erik Christiansen + + * Improved polling algorithm to speed up + programming of byte oriented parallel programmers. + Contributed by: Jan-Hinnerk Reichert + + * Add "fuse" and "lock" definitions for the AT90S8535. + + * STK500 skips empty pages in paged write resulting in faster downloads + when there are empty blocks in between code (such as files that contain + application code and bootloader code). + +Version 4.2.0: + + * Add basic support for reading and writing fuses via SPI with avr910 + programmers. Submitted by + Jan-Hinnerk Reichert . + + * Perform an auto erase before programming if the flash memory is + anywhere specified to be written by any of the -U requests. Old + style memory specification options (-f, -i, -I, -m, and -o) are + deprecated in favor of the new -U options. Auto erase is disabled + if any of the old-style options (specifically -i and -o) are + specified. + + * Add new -U option for specifying programming operations - allows + multiple memory operations on a single command line. + + * New progress reporting, looks nicer and is nicer to wrapper + environments such as emacs. + + * Fix long-standing timing (verify) problems on Windows platform. + Submitted by Alex Shepherd . + + * Add new file format option - 'm' for "immediate mode." In this + case, the filename argument of the -o, -i, or -U options is + treated as the data for uploading - useful for specifying fuse + bits without having to create a single-byte file for uploading. + + * Add support for displaying and setting the various STK500 operational + parameters (Vtarget, Varef, Master clock). + + * Add 'picoweb' programming cable programmer. + Contributed by Rune Christensen . + + * Add support for the sp12 programmer. Submitted by + Larry Barello . + + +Version 4.1.0 + + * Add support for the Bascom SAMPLE programmer. Submitted by + Larry Barello . + + * Add support for avr910 type programmers (mcu00100, pavr avr910, etc). + + * Support new devices: ATmega8535, ATtiny26 + + +Version 4.0.0 + + * Now support Linux - added by "Theodore A. Roth" . + + * Now support Windows - added by "Eric B. Weddington" . + + * Use 'configure' scripts to tailor the code to the system avrdude + is getting ready to be compiled on - added by "Theodore A. Roth" + . + + * Motorola S-Record support - submitted by "Alexey V.Levdikov " + . + + * Support parallel programming on the STK500. Introduce 'pagel' and + 'bs2' keywords to the config file for this purpose. + + * Add support for the AT90S2343 + + * Add support for the ATmega169 + + * Add ability to specify system defaults within the config file + (default parallel port, default serial port). + + * Specify the default programmer seperately from the programmer + definition. This is now done in the config file using the + 'default_programmer' keyword. + + * Support a per-user config file (~/.avrduderc) so that one can + override system wide defaults if desired. + + * Follow the datasheet more closely for several parts in the "retry" + code when entering programming mode fails initially. Introduce + 'retry_pulse' to the config file for this purpose. + + + +Version 3.1.0 + + * This change represents a name change only. There is currently an + effort to port AVRPROG to other platforms including Linux and + Windows. Since Atmel's programmer binary that's included within + their AVR Studio software is named AVRPROG.EXE on the Windows OS, + there is the chance for confusion if we keep calling this program + AVRPROG as well. Up until now the name hasn't really been a + problem since there was no chance to confuse 'avrprog' on Unix + with Atmel's AVRPROG because Atmel's tools only run on Windows. + But with the Unix 'avrprog' possibly being ported to Windows, I + felt a name change was the best way to avoid problems. + + So - from this point forward, my FreeBSD Unix program formerly + known as AVRPROG will subsequently be known as AVRDUDE (AVR + Downloader/UploaDEr). + + This change also represents a time when the AVRDUDE sources move + from my own private repository to a public repository. This will + give other developers a chance to port AVRDUDE to other platforms + and extend its functionality to support additional programming + hardware, etc. + + So goodbye AVRPROG, welcome AVRDUDE! + +Version 3.0.0 + + * Rewrite parts of the code to make it easy to support other types + of programmers besides the directly connected parallel port + programmer (PPI). + + * Add support for Atmel's STK500 programmer/development board. The + STK500's "paged mode" read/write is supported which makes this + programmer very fast. This is sorely needed on parts with large + memories such as the ATmega128. My 12K test program burns in + about 5 seconds, add another 5 to read it back out for + verification. + + +Version 2.1.5: + + * When getting ready to initiate communications with the AVR device, + first pull /RESET low for a short period of time before enabling + the buffer chip. This sequence allows the AVR to be reset before + the buffer is enabled to avoid a short period of time where the + AVR may be driving the programming lines at the same time the + programmer tries to. Of course, if a buffer is being used, then + the /RESET line from the programmer needs to be directly connected + to the AVR /RESET line and not via the buffer chip. + + Feature contributed by Rick C. Petty . + + * When in interactive terminal mode and dumping memory using the + 'dump ' command without any address information, and the + end of memory is reached, wrap back around to zero on the next + invocation. + + +Version 2.1.4: + + * Fix -Y option. + + +Version 2.1.3: + + * Be backward compatible when reading 2-byte rewrite cycle counters + as written by avrprog version 2.1.0. Version 2.1.1 changed over + to a 4-byte counter, which caused avrprog versions 2.1.1 and 2.1.2 + to report a negative count for parts that were initialized using + version 2.1.0. Thanks to Joerg Wunsch for noticing this. + + +Version 2.1.2: + + * Add '-V' option to disable automatic verify check with uploading + data. + + +Version 2.1.1: + + * Fix ATmega128 instruction sequences for reading fuse bits - + contributed by Joerg Wunsch. + + * Modify erase-rewrite cycle counter code to use a 4 byte counter + instead of a two byte counter. + + +Version 2.1.0: + + * Implement a per-part erase-rewrite cycle counter; requires the use + of two bytes of EEPROM memory. + + +Version 2.0.5: + + * Support for ATtiny15 - contributed by Asher Hoskins + + +Version 2.0.4: + + * Config file fixes for various parts. + + +Version 2.0.3: + + * Work around problem programming fuse bits on parts like the + at90s4433 as described in the following errata: + + http://www.atmel.com/atmel/acrobat/doc1280.pdf + + * Add part definition for at90s4414, at90s4433. + + * Add fuse/lock bit memory instructions for the at90s1200, + at90s2333, at90s4433 and at90s8515. + + * Fix setting of programmer status LEDs under certain write-fail + conditions. + + +Version 2.0.2 : + + * Fix writing to read-only memories such as the lock bits of the + AT90S2313. + + * Copyright updates. + + +Version 2.0.1 : + + * Use correct parallel port pins for VCC. + + * Add programmer definition for Atmel's STK200. + + * Add programmer definition for the AVR3 board. + + * Fix address bit encoding for many parts. + + * Allow the ``BUFF'' signal to be asserted by multiple pins of the + parallel port (like VCC) instead of just one. The STK200 appears + to need this feature. + + +Version 2.0.0 : + + * Add support for programming fuse and lock bits if supported by the + part. + + * Move instruction encoding into the config file. Now any part can + be supported as long as it uses the same basic serial programming + instruction format. + + * Add part definitions for the ATMega163 and ATMega8 devices. + + +Version 1.4.3 : + + * Mostly internal code cleanup. + + +Version 1.4.2 : + + * Fixes for ATMega paged memory support. + + * Support for ATMega16 device. + + +Version 1.4.1 : + + * No functional changes, update to Copyrights only. + + +Version 1.4.0 : + + * Add part definitions to the config file. + + * Add initial support for Atmel's ATMega paged memory parts. + + * Config file documentation added. + + * Add a definition for the Dontronics DT006 programmer. + + * Fix Intel Hex support for addresses larger than 64k. + + +Version 1.3.0 : + + * Make programmer pin assignments configurable. + + +Version 1.2.2 : + + * Initial public release. diff --git a/xs/src/avrdude/README b/xs/src/avrdude/README new file mode 100644 index 000000000..2ca0009a3 --- /dev/null +++ b/xs/src/avrdude/README @@ -0,0 +1,64 @@ +THIS IS A PRUSA3D BRANCH, WORKING AROUND A SPECIFIC PROBLEM +IN THE EARLY I3 MK2 USB COMMUNICATION CHIPS. + +Some of the early Prusa3D i3 MK2 printers were shipped with a buggy +USB communication controller firmware. This fork of avrdude contains +a workaround inside the stk500v2 protocol implementation. + +The workaround depends on a specific behavior of the Arduino AVR 2560 +bootloader, which is installed on the i3 MK2 printers: + +https://github.com/arduino/Arduino-stk500v2-bootloader + +The avrdude binary modified by Prusa3D could replace the avrdude bianary +of arduino to program the RAMBo board. In that case the modified binary +is identified by a "-prusa3d" suffix to the version information. + +------------------------------------------------------------------- + +See the documentation file for the details. + +The latest version of AVRDUDE is always available here: + + http://savannah.nongnu.org/projects/avrdude + + +Important environment variables for ./configure: +================================================ + +CPPFLAGS: C preprocessor flags (*not* "C++") + +This is the place to put additional (non-standard) -I options into. +For example, if your Windows system has LibUSB-Win32 installed into +\\WINDOWS\ProgramFiles\LibUSB-Win32, use + +CPPFLAGS=-I/WINDOWS/ProgramFiles/LibUSB-Win32/include + +to tell configure where to search for the header files. (The use of +forward slashes rather than backslashes can often simplify things. +Note that the Windows system services internally treat both the same. +It's only cmd.exe which requires backslashes as the directory +separator.) + +LDFLAGS: Linker options + +This is the place to make additional library locations known to the +linker. To continue the above example, use + +LDFLAGS=-L/WINDOWS/ProgramFiles/LibUSB-Win32/lib/gcc + +to make the linker search for "libusb.a" in that directory. + + +Linux users: make sure the header files are installed +===================================================== + +While many Linux distributions install the libraries needed by AVRDUDE +(libusb, libelf) by default, they leave out the corresponding header +files. Consequently, the configure script won't find them, so these +libraries could not be used. + +Usually, the packages with the header files (and static libraries) are +derived from the regular package name by appending "-devel". Thus, +make sure you have "libusb-devel" and "libelf-devel" installed before +running the configure script. (Same goes for libftdi.) diff --git a/xs/src/avrdude/ac_cfg.h b/xs/src/avrdude/ac_cfg.h new file mode 100644 index 000000000..2461bf307 --- /dev/null +++ b/xs/src/avrdude/ac_cfg.h @@ -0,0 +1,206 @@ +/* ac_cfg.h. Generated from ac_cfg.h.in by configure. */ +/* ac_cfg.h.in. Generated from configure.ac by autoheader. */ + + +// Edited by hand for usage with Slic3r PE + +#define CONFIG_DIR "CONFIG_DIR" + + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DDK_HIDSDI_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#if defined (WIN32NATIVE) +/* #undef HAVE_GETTIMEOFDAY */ +// We have a gettimeofday() replacement in unistd.cpp (there is also one in ppiwin.c, but that file is written for Cygwin/MinGW) +#else +#define HAVE_GETTIMEOFDAY 1 +#endif + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_HIDAPI_HIDAPI_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define if ELF support is enabled via libelf */ +// #define HAVE_LIBELF 1 + +/* Define to 1 if you have the header file. */ +// #define HAVE_LIBELF_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBELF_LIBELF_H */ + +/* Define if FTDI support is enabled via libftdi */ +/* #undef HAVE_LIBFTDI */ + +/* Define if FTDI support is enabled via libftdi1 */ +// #define HAVE_LIBFTDI1 1 + +/* Define if libftdi supports FT232H, libftdi version >= 0.20 */ +/* #undef HAVE_LIBFTDI_TYPE_232H */ + +/* Define if HID support is enabled via the Win32 DDK */ +/* #undef HAVE_LIBHID */ + +/* Define if HID support is enabled via libhidapi */ +/* #undef HAVE_LIBHIDAPI */ + +/* Define to 1 if you have the `ncurses' library (-lncurses). */ +// #define HAVE_LIBNCURSES 1 + +/* Define to 1 if you have the `readline' library (-lreadline). */ +// #define HAVE_LIBREADLINE 1 + +/* Define to 1 if you have the `termcap' library (-ltermcap). */ +/* #undef HAVE_LIBTERMCAP */ + +/* Define if USB support is enabled via libusb */ +// #define HAVE_LIBUSB 1 + +/* Define if USB support is enabled via a libusb-1.0 compatible libusb */ +// #define HAVE_LIBUSB_1_0 1 + +/* Define to 1 if you have the header file. */ +// #define HAVE_LIBUSB_1_0_LIBUSB_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUSB_H */ + +/* Define to 1 if you have the `ws2_32' library (-lws2_32). */ +/* #undef HAVE_LIBWS2_32 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Linux sysfs GPIO support enabled */ +/* #undef HAVE_LINUXGPIO */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LUSB0_USB_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* parallel port access enabled */ +// #define HAVE_PARPORT 1 + +/* Define to 1 if you have the header file. */ +// #define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strcasecmp' function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strncasecmp' function. */ +#define HAVE_STRNCASECMP 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if the system has the type `uint_t'. */ +/* #undef HAVE_UINT_T */ + +/* Define to 1 if the system has the type `ulong_t'. */ +/* #undef HAVE_ULONG_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_USB_H 1 + +/* Define to 1 if you have the `usleep' function. */ +#define HAVE_USLEEP 1 + +/* Define if lex/flex has yylex_destroy */ +#define HAVE_YYLEX_DESTROY 1 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "avrdude" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "avrdude-dev@nongnu.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "avrdude" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "avrdude 6.3-20160220" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "avrdude" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "6.3-20160220" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Version number of package */ +#define VERSION "6.3-20160220" + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#define YYTEXT_POINTER 1 + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ diff --git a/xs/src/avrdude/ac_cfg.h.in b/xs/src/avrdude/ac_cfg.h.in new file mode 100644 index 000000000..9dda33a53 --- /dev/null +++ b/xs/src/avrdude/ac_cfg.h.in @@ -0,0 +1,194 @@ +/* ac_cfg.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_DDK_HIDSDI_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 if you have the header file. */ +#undef HAVE_HIDAPI_HIDAPI_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define if ELF support is enabled via libelf */ +#undef HAVE_LIBELF + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBELF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBELF_LIBELF_H + +/* Define if FTDI support is enabled via libftdi */ +#undef HAVE_LIBFTDI + +/* Define if FTDI support is enabled via libftdi1 */ +#undef HAVE_LIBFTDI1 + +/* Define if libftdi supports FT232H, libftdi version >= 0.20 */ +#undef HAVE_LIBFTDI_TYPE_232H + +/* Define if HID support is enabled via the Win32 DDK */ +#undef HAVE_LIBHID + +/* Define if HID support is enabled via libhidapi */ +#undef HAVE_LIBHIDAPI + +/* Define to 1 if you have the `ncurses' library (-lncurses). */ +#undef HAVE_LIBNCURSES + +/* Define to 1 if you have the `readline' library (-lreadline). */ +#undef HAVE_LIBREADLINE + +/* Define to 1 if you have the `termcap' library (-ltermcap). */ +#undef HAVE_LIBTERMCAP + +/* Define if USB support is enabled via libusb */ +#undef HAVE_LIBUSB + +/* Define if USB support is enabled via a libusb-1.0 compatible libusb */ +#undef HAVE_LIBUSB_1_0 + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBUSB_1_0_LIBUSB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBUSB_H + +/* Define to 1 if you have the `ws2_32' library (-lws2_32). */ +#undef HAVE_LIBWS2_32 + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Linux sysfs GPIO support enabled */ +#undef HAVE_LINUXGPIO + +/* Define to 1 if you have the header file. */ +#undef HAVE_LUSB0_USB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* parallel port access enabled */ +#undef HAVE_PARPORT + +/* Define to 1 if you have the header file. */ +#undef HAVE_PTHREAD_H + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strncasecmp' function. */ +#undef HAVE_STRNCASECMP + +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + +/* Define to 1 if you have the `strtoul' function. */ +#undef HAVE_STRTOUL + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define to 1 if the system has the type `uint_t'. */ +#undef HAVE_UINT_T + +/* Define to 1 if the system has the type `ulong_t'. */ +#undef HAVE_ULONG_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_USB_H + +/* Define to 1 if you have the `usleep' function. */ +#undef HAVE_USLEEP + +/* Define if lex/flex has yylex_destroy */ +#undef HAVE_YYLEX_DESTROY + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#undef LT_OBJDIR + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#undef YYTEXT_POINTER + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const diff --git a/xs/src/avrdude/arduino.c b/xs/src/avrdude/arduino.c new file mode 100644 index 000000000..566f56abd --- /dev/null +++ b/xs/src/avrdude/arduino.c @@ -0,0 +1,132 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2009 Lars Immisch + * + * 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$ */ + +/* + * avrdude interface for Arduino programmer + * + * The Arduino programmer is mostly a STK500v1, just the signature bytes + * are read differently. + */ + +#include "ac_cfg.h" + +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" +#include "stk500_private.h" +#include "stk500.h" +#include "arduino.h" + +/* read signature bytes - arduino version */ +static int arduino_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m) +{ + unsigned char buf[32]; + + /* Signature byte reads are always 3 bytes. */ + + if (m->size < 3) { + avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read", progname); + return -1; + } + + buf[0] = Cmnd_STK_READ_SIGN; + buf[1] = Sync_CRC_EOP; + + serial_send(&pgm->fd, buf, 2); + + if (serial_recv(&pgm->fd, buf, 5) < 0) + return -1; + if (buf[0] == Resp_STK_NOSYNC) { + avrdude_message(MSG_INFO, "%s: stk500_cmd(): programmer is out of sync\n", + progname); + return -1; + } else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "\n%s: arduino_read_sig_bytes(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -2; + } + if (buf[4] != Resp_STK_OK) { + avrdude_message(MSG_INFO, "\n%s: arduino_read_sig_bytes(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_OK, buf[4]); + return -3; + } + + m->buf[0] = buf[1]; + m->buf[1] = buf[2]; + m->buf[2] = buf[3]; + + return 3; +} + +static int arduino_open(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + strcpy(pgm->port, port); + pinfo.baud = pgm->baudrate? pgm->baudrate: 115200; + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* Clear DTR and RTS to unload the RESET capacitor + * (for example in Arduino) */ + serial_set_dtr_rts(&pgm->fd, 0); + usleep(250*1000); + /* Set DTR and RTS back to high */ + serial_set_dtr_rts(&pgm->fd, 1); + usleep(50*1000); + + /* + * drain any extraneous input + */ + stk500_drain(pgm, 0); + + if (stk500_getsync(pgm) < 0) + return -1; + + return 0; +} + +static void arduino_close(PROGRAMMER * pgm) +{ + serial_set_dtr_rts(&pgm->fd, 0); + serial_close(&pgm->fd); + pgm->fd.ifd = -1; +} + +const char arduino_desc[] = "Arduino programmer"; + +void arduino_initpgm(PROGRAMMER * pgm) +{ + /* This is mostly a STK500; just the signature is read + differently than on real STK500v1 + and the DTR signal is set when opening the serial port + for the Auto-Reset feature */ + stk500_initpgm(pgm); + + strcpy(pgm->type, "Arduino"); + pgm->read_sig_bytes = arduino_read_sig_bytes; + pgm->open = arduino_open; + pgm->close = arduino_close; +} diff --git a/xs/src/avrdude/arduino.h b/xs/src/avrdude/arduino.h new file mode 100644 index 000000000..024d711b9 --- /dev/null +++ b/xs/src/avrdude/arduino.h @@ -0,0 +1,29 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2009 Lars Immisch + * + * 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 arduino_h__ +#define arduino_h__ + +extern const char arduino_desc[]; +void arduino_initpgm (PROGRAMMER * pgm); + +#endif + + diff --git a/xs/src/avrdude/atmel-docs/AVR109.pdf b/xs/src/avrdude/atmel-docs/AVR109.pdf new file mode 100644 index 000000000..0942f44bc Binary files /dev/null and b/xs/src/avrdude/atmel-docs/AVR109.pdf differ diff --git a/xs/src/avrdude/atmel-docs/AVR910.pdf b/xs/src/avrdude/atmel-docs/AVR910.pdf new file mode 100644 index 000000000..585703aac Binary files /dev/null and b/xs/src/avrdude/atmel-docs/AVR910.pdf differ diff --git a/xs/src/avrdude/atmel-docs/AVRISPmkII-AVR069.pdf b/xs/src/avrdude/atmel-docs/AVRISPmkII-AVR069.pdf new file mode 100644 index 000000000..dc4254954 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/AVRISPmkII-AVR069.pdf differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/browserDetect.js b/xs/src/avrdude/atmel-docs/EDBG/common/browserDetect.js new file mode 100644 index 000000000..2a7aa08a4 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/browserDetect.js @@ -0,0 +1,116 @@ +var BrowserDetect = { + init: function () { + this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; + this.version = this.searchVersion(navigator.userAgent) + || this.searchVersion(navigator.appVersion) + || "an unknown version"; + this.OS = this.searchString(this.dataOS) || "an unknown OS"; + }, + searchString: function (data) { + for (var i=0;i> Global +----------------------------------------------------------------------------------------------------*/ + +.grid_1, +.grid_2, +.grid_3 { + display:inline; + float: left; + position: relative; + margin-left: 1%; + margin-right: 1%; +} + +/* Grid >> Children (Alpha ~ First, Omega ~ Last) +----------------------------------------------------------------------------------------------------*/ + +.alpha { + margin-left: 0; +} + +.omega { + margin-right: 0; +} + +/* Grid >> 3 Columns +----------------------------------------------------------------------------------------------------*/ + + +.container_3 .grid_1 { + width:31.333%; +} + +.container_3 .grid_2 { + width:64.667%; +} + +.container_3 .grid_3 { + width:98.0%; +} + + + +/* Prefix Extra Space >> 3 Columns +----------------------------------------------------------------------------------------------------*/ + + +.container_3 .prefix_1 { + padding-left:33.333%; +} + +.container_3 .prefix_2 { + padding-left:66.667%; +} + + + +/* Suffix Extra Space >> 3 Columns +----------------------------------------------------------------------------------------------------*/ + + +.container_3 .suffix_1 { + padding-right:33.333%; +} + +.container_3 .suffix_2 { + padding-right:66.667%; +} + + + +/* Push Space >> 3 Columns +----------------------------------------------------------------------------------------------------*/ + + +.container_3 .push_1 { + left:33.333%; +} + +.container_3 .push_2 { + left:66.667%; +} + + + +/* Pull Space >> 3 Columns +----------------------------------------------------------------------------------------------------*/ + + +.container_3 .pull_1 { + left:-33.333%; +} + +.container_3 .pull_2 { + left:-66.667%; +} + + + + +/* Clear Floated Elements +----------------------------------------------------------------------------------------------------*/ + +/* http://sonspring.com/journal/clearing-floats */ + +.clear { + clear: both; + display: block; + overflow: hidden; + visibility: hidden; + width: 0; + height: 0; +} + +/* http://perishablepress.com/press/2008/02/05/lessons-learned-concerning-the-clearfix-css-hack */ + +.clearfix:after { + clear: both; + content: ' '; + display: block; + font-size: 0; + line-height: 0; + visibility: hidden; + width: 0; + height: 0; +} + +.clearfix { + display: inline-block; +} + +* html .clearfix { + height: 1%; +} + +.clearfix { + display: block; +} \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/css/index.css b/xs/src/avrdude/atmel-docs/EDBG/common/css/index.css new file mode 100644 index 000000000..eb1b8c24f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/css/index.css @@ -0,0 +1,59 @@ +body { + font-size: 12px; + font-family: Verdana, Geneva, sans-serif; +} + +.a { + text-decoration: none; +} + +.title { + padding: 31px 0 0 0; +} + +.group +{ + /*background-color: pink;*/ + width:966px; +} + +.group_header { + color: #0066CB; + font: bold 14pt IntervalLight, sans-serif; + text-decoration: none; + padding: 8px; + background-color: #EEEEEE; + margin-top: 24px; + /*margin-bottom: 8px;*/ +} + +.products +{ + float:left; + /*background:#FFF8F8;*/ +} + +.product { + /*background: url("../images/panelbg.png") 0 0 no-repeat;*/ + width: 300px; + height: 130px; + /*margin-left: 20px;*/ + padding: 10px; + border: 1px solid #EEEEEE; + display:block; + float: left; +} + +.product span { + font-size: 16px; + color: #0066CB; + margin-bottom: 8px; + clear:both; +} + +.product img +{ + margin-right:12px; + float:left; +} + diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/css/positioning.css b/xs/src/avrdude/atmel-docs/EDBG/common/css/positioning.css new file mode 100644 index 000000000..7c9658c41 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/css/positioning.css @@ -0,0 +1,493 @@ +tr th .added { color: #E6E6FA; } +tr th .changed {color: #99ff99; } +div.added tr, div.added { background-color: #E6E6FA; } +div.deleted tr, div.deleted { text-decoration: line-through; + background-color: #FF7F7F; } +div.changed tr, div.changed { background-color: #99ff99; } +div.off { } + +span.added { background-color: #E6E6FA; } +span.deleted { text-decoration: line-through; + background-color: #FF7F7F; } +span.changed { background-color: #99ff99; } +span.off { } + + +body { font: 12px Verdana, Geneva, sans-serif; } +p, ul, ol, li { font: 10pt Verdana, Geneva, sans-serif; } +h1 { font: 15pt Arial, Helvetica, geneva; + color: black!important; +} +h2 { font: normal 12pt Arial, Helvetica, geneva; } + +#header { + background: white; + position: fixed; + width: 100%; + height: 99px; + top: 0; + right: 0; + bottom: auto; + left: 0; + border-bottom: 1px solid #bbc4c5; + z-index: 2000; +} + +#header h1 { + margin-left: 310px; + position: fixed; + top: 20px; + left: -15px; + color: #404040 !important; +} + + +#header h1 { + margin-top: 2px; +} + + +p.breadcrumbs { + margin-top: 30px; + margin-left: 310px; +} + +#header img { + float: left; + margin-left: 20px; +} + +#header p.breadcrumbs a { + color: #bbb; +} + +#leftnavigation { + overflow: auto; + position: fixed; + height: auto; + top:100px; + /*right:10px;*/ + /*left:10px;*/ + bottom: 0; + left: 0; + width:inherit; + z-index: 1500; + border-right:2px solid #bbc4c5; + padding:1px; + background-color: #ededed!important; +} + +#treeDiv { + overflow: auto; + /* position: fixed;*/ + height: auto; + top: 136px; + bottom: 0; + left: 0; + /* width: 18%;*/ + z-index: 1500; + /* border-right:2px solid #CCCCCC; + background-color: #f0f0f0!important;*/ +} + +/*#searchDiv { + overflow: auto; + position: fixed; + height: auto; + top: 138px; + bottom: 0; + left: 0; + width: 243px; + z-index: 1500; + border-right:2px solid #CCCCCC; + background-color: #f0f0f0!important; +}*/ + +#content { + position: relative; + top: 90px; /*left: 240px;*/ + right: auto; bottom: 20px; + /*margin: 0px 0px 0px 280px;*/ + width: auto; + height: inherit; + padding-left: 5px; + padding-right: 30px; + border-left: 1px solid #cccccc; + overflow :scroll; + overflow-x:auto; + z-index: 1000; + +} + +#navheader { + position: fixed; + background: #DCDCDC; + padding-left: 10px; + right: 0px; + top: 10px; + text-align: right; +} + +#content h1, #content h2 { +color: #404040 !important; +font-size: 170%; +font-weight: normal; +} +.navfooter { bottom: 2%; } +.highlight { background-color: #c5d3c3; } +.highlightButton{ font-size: 0; } + +/* Show Hide TOC tree */ +.pointLeft { + padding-right: 15px; + display: block; + cursor: pointer; +} +.pointRight { + padding-right: 15px; + display: block; + cursor: pointer; +} + +/* Search results Styling */ +.searchExpression { + color: #0050A0; + background-color: #EBEFF8; + font-size: 12pt; +} +.searchresult li a { + text-decoration: none; + color: #0050A0; +} +.searchresult li { color: #0050A0; } +.shortdesclink { color: gray; font-size: 9pt; } +.searchText { float:left;width:150px; } +.searchButton { + padding: 2px 12px 2px 12px; + background-color:#bbb; + border:#bbb solid 1pt; + font-weight: bold; + font-size: 10pt +} +.searchButton:hover{ + background-color: #cccccc; +} +.searchFieldSet {} + +.title, div.toc>p{ font-weight: bold; } + +p.breadcrumbs { + display: inline; + margin-bottom: 0px; + margin-top: 33px; +} + +p.breadcrumbs a { + padding-right: 12px; + margin-right: 5px; + text-decoration: none; + color: #575757; + text-transform: uppercase; + font-size: 10px; +} + +p.breadcrumbs a:first-child {background: url(../images/breadcrumb-arrow-white.png) no-repeat right center;} + +p.breadcrumbs a:hover {text-decoration: underline;} + +#star ul.star { + LIST-STYLE: none; + MARGIN: 0; + PADDING: 0; + WIDTH: 85px; + /* was 100 */ + HEIGHT: 20px; + LEFT: 1px; + TOP: -5px; + POSITION: relative; + FLOAT: right; + BACKGROUND: url('../images/starsSmall.png') repeat-x 0 -25px; +} +#star li { + PADDING: 0; + MARGIN: 0; + FLOAT: right; + DISPLAY: block; + WIDTH: 85px; + /* was 100 */ + HEIGHT: 20px; + TEXT-DECORATION: none; + text-indent: -9000px; + Z-INDEX: 20; + POSITION: absolute; + PADDING: 0; +} +#star li.curr { + BACKGROUND: url('../images/starsSmall.png') left 25px; + FONT-SIZE: 1px; +} + +table.navLinks {margin-right: 20px;} + +table.navLinks td a { + text-decoration: none; + text-transform: uppercase; + color: black; + font-size: 11px; +} + +a.navLinkPrevious { + padding-left: 12px; + background: url(../images/previous-arrow.png) no-repeat left center; +} + +a.navLinkNext { + padding-right: 12px; + background: url(../images/next-arrow.png) no-repeat right center; +} + +a#showHideButton { + padding-left: 20px; + background: url(../images/sidebar.png) no-repeat left center; +} + + +.filetree li span a { color: #777; } + +#treediv { -webkit-box-shadow: #CCC 0px 1px 2px 0px inset; } + +.legal, .legal *{ + color: #555; + text-align: center; + padding-bottom: 10px; +} + +.internal { color : #0000CC;} + +.writeronly {color : red;} + +.remark, .remark .added, .remark .changed, .remark .deleted{ background: yellow;} + +tr th, tr th .internal, tr th .added, tr th .changed { + background: #00589E; + color: white; + font-weight: bold; + text-align: left; +} + +.statustext{ + position:fixed; + top:105px; + width: 0%; + height: 0%; + opacity: .3; + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -o-transform: rotate(90deg); + white-space: nowrap; + color: red; + font-weight: bold; + font-size: 2em; + margin-top: 30px; +} + +#toolbar { + width: 100%; + height: 33px; + position: fixed; + top: 93px; + z-index: 99; + left: 280px; + color: #333; + line-height: 28px; + padding-left: 10px; +} + +#toolbar-left { + position: relative; + left: 0px; +} + +body p.breadcrumbs { + margin: 0px; + padding: 0px; + line-height: 28px; +} + +/*body #content { + position: static; + margin-top: 126px; + top: 0px; +}*/ + +body.sidebar #toolbar{left: 0px;} + +body.sidebar #toolbar-left{left: 0px;} + +div#toolbar-left img {vertical-align: text-top;} + +div.note *, div.caution *, div.important *, div.tip *, div.warning * { + background: inherit !important; + color: inherit !important; + border: inherit /*!important*/; +} + +#content table thead, #content table th, #content table th p{ + color: white; + font-weight: bold; +} + +#content table caption{font-weight: bold;} + +#content table td, #content table {border: 1px solid black;} + +#content table td, #content table th { padding: 5px;} + +#content table {margin-bottom: 20px;} + +*[align = 'center']{ text-align: center;} + +#content .qandaset>table, #content .qandaset>table td, #content .calloutlist table, #content .calloutlist table td, #content .navfooter table, #content .navfooter table td { + border: 0px solid; +} + +#sidebar +{ + position: fixed; + margin: 0px; + left: 0px; + right: auto; + top: 99px; + bottom: 0px; + height: 543px; + z-index: 0; + display: block; + visibility: visible; + width: 280px; +} + +@media print { + + body * { + visibility: hidden; + } + + #content, #content * { + visibility: visible; + } + + #sidebar, .navfooter { + display: none; + } + + #content { + margin: 0 0 0 0; + } + +} + +#expanders { + float: left; + width: 100%; + padding-bottom: 1em; +} + +#expanders dt { + padding-bottom: 4px; + border-bottom: 2px solid #cccccc; + margin-top: 1em; + margin-bottom: 1em; + background: url(../images/plus.png) 0px 7px no-repeat; + /*background: pink;*/ + cursor: pointer; +} + +#expanders dt h2 { + font: bold 14pt IntervalLight, sans-serif; + text-decoration: none; + color: #0066CB; + /*background-position: -16px 0;*/ + padding-left: 13px; +} + +#expanders dt.plus { + background: url(../images/plus.png) 0px 7px no-repeat; +} + +#expanders dt.minus { + background: url(../images/minus.png) 0px 7px no-repeat; +} + + +#expanders dd { + display: none; + margin-bottom: 3em; + /*background: yellow;*/ +} + +#expanders .hitarea { + background: url(../images/ui-icons_217bc0_256x240.png) 0 -208px no-repeat; + height: 16px; + width: 16px; + float: left; + cursor: pointer; +} +/* fix for IE6 */ +/** html .hitarea { + display: inline; + float:none; +}*/ + + + +#expanders .prod +{ + width: 300px; + border: #DDD solid 1px; + float: left; + margin: 1px; + height: 160px; + margin-top: 0px; +} + +#expanders .prodimg +{ + /*border: #DDD solid 1px;*/ + float: left; +} + +.prodimg img { + display: block; + margin-left: 3px; + margin-top: auto; + margin-bottom: auto; + width: 100px; + vertical-align: middle; +} + +#expanders .prodtext +{ + /*background: #F8F8F8;*/ + width: 165px; + float: left; + margin-left: 1em; +} + +#expanders .prod p { + clear: both; +} + +#expanders ul { + margin: 0; + padding: 0; + list-style-type: none; +} + +#expanders li { + padding-left: 0.5em; +} + +a.external { + background: url("../images/external_link.gif") no-repeat scroll right top transparent; + padding: 0 13px 0 0; +} \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/css/print.css b/xs/src/avrdude/atmel-docs/EDBG/common/css/print.css new file mode 100644 index 000000000..a52a074e7 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/css/print.css @@ -0,0 +1,28 @@ +body { + color : #000000 !important; + background : #ffffff !important; + font-family : "Times New Roman", Times, serif !important; + font-size : 12pt !important; +} + +#sidebar, #sidebar-resizer, #header-resizer, #header { display: none !important;} + +#content { + position: absolute !important; + margin: 0px !important; + left: 0px !important; + right: auto !important; + top: 0px !important; + height: auto !important; + overflow: visible !important; + overflow-x: visible !important; + border-left: 0px solid #000000 !important; +} + +.ui-layout-container { + overflow: visible !important; +} + +.mediaobject { + text-align: left !important; +} \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/css/reset.css b/xs/src/avrdude/atmel-docs/EDBG/common/css/reset.css new file mode 100644 index 000000000..27802c681 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/css/reset.css @@ -0,0 +1 @@ +a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,html,i,iframe,img,ins,kbd,label,legend,li,main,mark,menu,meter,nav,object,ol,output,p,pre,progress,q,rp,rt,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video,xmp{border:0;margin:0;padding:0;font-size:100%}html,body{height:100%}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section{display:block}b,strong{font-weight:bold}img{color:transparent;font-size:0;vertical-align:middle;-ms-interpolation-mode:bicubic}ol,ul{list-style:none}li{display:list-item}table{border-collapse:collapse;border-spacing:0}th,td,caption{font-weight:normal;vertical-align:top;text-align:left}q{quotes:none}q:before,q:after{content:'';content:none}sub,sup,small{font-size:75%}sub,sup{line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}svg{overflow:hidden} \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/css/text.css b/xs/src/avrdude/atmel-docs/EDBG/common/css/text.css new file mode 100644 index 000000000..0ef67296a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/css/text.css @@ -0,0 +1 @@ +body{font:13px/1.5 'Helvetica Neue',Arial,'Liberation Sans',FreeSans,sans-serif}pre,code{font-family:'DejaVu Sans Mono',Menlo,Consolas,monospace}hr{border:0 solid #ccc;border-top-width:1px;clear:both;height:0}h1{font-size:25px}h2{font-size:23px}h3{font-size:21px}h4{font-size:19px}h5{font-size:17px}h6{font-size:15px}ol{list-style:decimal}ul{list-style:disc}li{margin-left:30px}p,dl,hr,h1,h2,h3,h4,h5,h6,ol,ul,pre,table,address,fieldset,figure{margin-bottom:20px} \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/fonts/DroidSansMono.eot b/xs/src/avrdude/atmel-docs/EDBG/common/fonts/DroidSansMono.eot new file mode 100644 index 000000000..e4e3d1701 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/fonts/DroidSansMono.eot differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/fonts/DroidSansMono.ttf b/xs/src/avrdude/atmel-docs/EDBG/common/fonts/DroidSansMono.ttf new file mode 100644 index 000000000..4546611d4 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/fonts/DroidSansMono.ttf differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/Book_Closed.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/Book_Closed.png new file mode 100644 index 000000000..294fbf6b0 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/Book_Closed.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/Book_Open.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/Book_Open.png new file mode 100644 index 000000000..d78710e77 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/Book_Open.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/Document_Text.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/Document_Text.png new file mode 100644 index 000000000..416b5380d Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/Document_Text.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/Library.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/Library.png new file mode 100644 index 000000000..a2fa8fce4 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/Library.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/external_link.gif b/xs/src/avrdude/atmel-docs/EDBG/common/images/external_link.gif new file mode 100644 index 000000000..177cbbc72 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/external_link.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/loading.gif b/xs/src/avrdude/atmel-docs/EDBG/common/images/loading.gif new file mode 100644 index 000000000..085ccaeca Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/loading.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/logo.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/logo.png new file mode 100644 index 000000000..df85ffbeb Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/logo.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/minus.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/minus.png new file mode 100644 index 000000000..9b5244afb Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/minus.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/next-arrow.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/next-arrow.png new file mode 100644 index 000000000..db595f465 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/next-arrow.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/plus.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/plus.png new file mode 100644 index 000000000..31010fe96 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/plus.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/previous-arrow.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/previous-arrow.png new file mode 100644 index 000000000..347bc5347 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/previous-arrow.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/search-icon.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/search-icon.png new file mode 100644 index 000000000..715f62d08 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/search-icon.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/sidebar.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/sidebar.png new file mode 100644 index 000000000..549267187 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/sidebar.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/starsSmall.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/starsSmall.png new file mode 100644 index 000000000..490a27b92 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/starsSmall.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/toc-icon.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/toc-icon.png new file mode 100644 index 000000000..40b34bce5 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/toc-icon.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/images/ui-icons_217bc0_256x240.png b/xs/src/avrdude/atmel-docs/EDBG/common/images/ui-icons_217bc0_256x240.png new file mode 100644 index 000000000..6f4bd87c0 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/images/ui-icons_217bc0_256x240.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/jquery-1.7.2.min.js b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/jquery-1.7.2.min.js new file mode 100644 index 000000000..93adea19f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/jquery-1.7.2.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.2 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"":"")+""),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;e=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q="
"+""+"
",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="
t
",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="
",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function( +a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler,g=p.selector),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&j.push({elem:this,matches:d.slice(e)});for(k=0;k0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));o.match.globalPOS=p;var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/]","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f +.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(;d1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||f.isXMLDoc(a)||!bc.test("<"+a.nodeName+">")?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g,h,i,j=[];b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);for(var k=0,l;(l=a[k])!=null;k++){typeof l=="number"&&(l+="");if(!l)continue;if(typeof l=="string")if(!_.test(l))l=b.createTextNode(l);else{l=l.replace(Y,"<$1>");var m=(Z.exec(l)||["",""])[1].toLowerCase(),n=bg[m]||bg._default,o=n[0],p=b.createElement("div"),q=bh.childNodes,r;b===c?bh.appendChild(p):U(b).appendChild(p),p.innerHTML=n[1]+l+n[2];while(o--)p=p.lastChild;if(!f.support.tbody){var s=$.test(l),t=m==="table"&&!s?p.firstChild&&p.firstChild.childNodes:n[1]===""&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV,bW=["*/"]+["*"];try{bU=e.href}catch(bX){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b$(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b$(a,b);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bW},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bY(bS),ajaxTransport:bY(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?ca(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cb(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bZ(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bW+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bZ(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=typeof b.data=="string"&&/^application\/x\-www\-form\-urlencoded/.test(b.contentType);if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n);try{m.text=h.responseText}catch(a){}try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(ct("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);f.fn[a]=function(e){return f.access(this,function(a,e,g){var h=cy(a);if(g===b)return h?c in h?h[c]:f.support.boxModel&&h.document.documentElement[e]||h.document.body[e]:a[e];h?h.scrollTo(d?f(h).scrollLeft():g,d?g:f(h).scrollTop()):a[e]=g},a,e,arguments.length,null)}}),f.each({Height:"height",Width:"width"},function(a,c){var d="client"+a,e="scroll"+a,g="offset"+a;f.fn["inner"+a]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,c,"padding")):this[c]():null},f.fn["outer"+a]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,c,a?"margin":"border")):this[c]():null},f.fn[c]=function(a){return f.access(this,function(a,c,h){var i,j,k,l;if(f.isWindow(a)){i=a.document,j=i.documentElement[d];return f.support.boxModel&&j||i.body&&i.body[d]||j}if(a.nodeType===9){i=a.documentElement;if(i[d]>=i[e])return i[d];return Math.max(a.body[e],i[e],a.body[g],i[g])}if(h===b){k=f.css(a,c),l=parseFloat(k);return f.isNumeric(l)?l:k}f(a).css(c,h)},c,a,arguments.length,null)}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/jquery.cookie.js b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/jquery.cookie.js new file mode 100644 index 000000000..bada7bff7 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/jquery.cookie.js @@ -0,0 +1,93 @@ +/** + * Cookie plugin + * + * Copyright (c) 2006 Klaus Hartl (stilbuero.de) + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + */ + +/** + * Create a cookie with the given name and value and other optional parameters. + * + * @example $.cookie('the_cookie', 'the_value'); + * @desc Set the value of a cookie. + * @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true}); + * @desc Create a cookie with all available options. + * @example $.cookie('the_cookie', 'the_value'); + * @desc Create a session cookie. + * @example $.cookie('the_cookie', null); + * @desc Delete a cookie by passing null as value. + * + * @param String name The name of the cookie. + * @param String value The value of the cookie. + * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. + * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. + * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. + * If set to null or omitted, the cookie will be a session cookie and will not be retained + * when the the browser exits. + * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). + * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). + * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will + * require a secure protocol (like HTTPS). + * @type undefined + * + * @name $.cookie + * @cat Plugins/Cookie + * @author Klaus Hartl/klaus.hartl@stilbuero.de + */ + +/** + * Get the value of a cookie with the given name. + * + * @example $.cookie('the_cookie'); + * @desc Get the value of a cookie. + * + * @param String name The name of the cookie. + * @return The value of the cookie. + * @type String + * + * @name $.cookie + * @cat Plugins/Cookie + * @author Klaus Hartl/klaus.hartl@stilbuero.de + */ +jQuery.cookie = function(name, value, options) { + if (typeof value != 'undefined') { // name and value given, set cookie + options = options || {}; + if (value === null) { + value = ''; + options.expires = -1; + } + var expires = ''; + if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { + var date; + if (typeof options.expires == 'number') { + date = new Date(); + date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); + } else { + date = options.expires; + } + expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE + } + var path = options.path ? '; path=' + options.path : ''; + var domain = options.domain ? '; domain=' + options.domain : ''; + var secure = options.secure ? '; secure' : ''; + document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); + + } else { // only name given, get cookie + var cookieValue = null; + if (document.cookie && document.cookie != '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = jQuery.trim(cookies[i]); + // Does this cookie string begin with the name we want? + if (cookie.substring(0, name.length + 1) == (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; + } +}; \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/jquery.ui.all.js b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/jquery.ui.all.js new file mode 100644 index 000000000..943d3b357 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/jquery.ui.all.js @@ -0,0 +1,418 @@ +/*! + * jQuery UI 1.8.18 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI + */ +(function(b,a){function c(c,a){var e=c.nodeName.toLowerCase();if("area"===e){var e=c.parentNode,f=e.name;if(!c.href||!f||"map"!==e.nodeName.toLowerCase())return!1;e=b("img[usemap=#"+f+"]")[0];return!!e&&d(e)}return(/input|select|textarea|button|object/.test(e)?!c.disabled:"a"==e?c.href||a:a)&&d(c)}function d(c){return!b(c).parents().andSelf().filter(function(){return"hidden"===b.curCSS(this,"visibility")||b.expr.filters.hidden(this)}).length}b.ui=b.ui||{};b.ui.version||(b.extend(b.ui,{version:"1.8.14", +keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),b.fn.extend({_focus:b.fn.focus,focus:function(c,a){return"number"===typeof c?this.each(function(){var d=this;setTimeout(function(){b(d).focus(); +a&&a.call(d)},c)}):this._focus.apply(this,arguments)},scrollParent:function(){var c;c=b.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(b.curCSS(this,"position",1))&&/(auto|scroll)/.test(b.curCSS(this,"overflow",1)+b.curCSS(this,"overflow-y",1)+b.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(b.curCSS(this,"overflow",1)+b.curCSS(this, +"overflow-y",1)+b.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!c.length?b(document):c},zIndex:function(c){if(c!==a)return this.css("zIndex",c);if(this.length)for(var c=b(this[0]),d;c.length&&c[0]!==document;){d=c.css("position");if("absolute"===d||"relative"===d||"fixed"===d)if(d=parseInt(c.css("zIndex"),10),!isNaN(d)&&0!==d)return d;c=c.parent()}return 0},disableSelection:function(){return this.bind((b.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection", +function(b){b.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),b.each(["Width","Height"],function(c,d){function e(c,a,d,g){b.each(f,function(){a-=parseFloat(b.curCSS(c,"padding"+this,!0))||0;d&&(a-=parseFloat(b.curCSS(c,"border"+this+"Width",!0))||0);g&&(a-=parseFloat(b.curCSS(c,"margin"+this,!0))||0)});return a}var f="Width"===d?["Left","Right"]:["Top","Bottom"],i=d.toLowerCase(),j={innerWidth:b.fn.innerWidth,innerHeight:b.fn.innerHeight,outerWidth:b.fn.outerWidth, +outerHeight:b.fn.outerHeight};b.fn["inner"+d]=function(f){return f===a?j["inner"+d].call(this):this.each(function(){b(this).css(i,e(this,f)+"px")})};b.fn["outer"+d]=function(f,c){return"number"!==typeof f?j["outer"+d].call(this,f):this.each(function(){b(this).css(i,e(this,f,!0,c)+"px")})}}),b.extend(b.expr[":"],{data:function(c,a,d){return!!b.data(c,d[3])},focusable:function(a){return c(a,!isNaN(b.attr(a,"tabindex")))},tabbable:function(a){var d=b.attr(a,"tabindex"),e=isNaN(d);return(e||0<=d)&&c(a, +!e)}}),b(function(){var c=document.body,a=c.appendChild(a=document.createElement("div"));b.extend(a.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});b.support.minHeight=100===a.offsetHeight;b.support.selectstart="onselectstart"in a;c.removeChild(a).style.display="none"}),b.extend(b.ui,{plugin:{add:function(c,a,d){var c=b.ui[c].prototype,f;for(f in d)c.plugins[f]=c.plugins[f]||[],c.plugins[f].push([a,d[f]])},call:function(b,c,a){if((c=b.plugins[c])&&b.element[0].parentNode)for(var f= +0;fc&&b=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})})(jQuery); +(function(b){b.ui=b.ui||{};var a=/left|center|right/,c=/top|center|bottom/,d=b.fn.position,g=b.fn.offset;b.fn.position=function(g){if(!g||!g.of)return d.apply(this,arguments);var g=b.extend({},g),e=b(g.of),f=e[0],i=(g.collision||"flip").split(" "),j=g.offset?g.offset.split(" "):[0,0],k,l,m;9===f.nodeType?(k=e.width(),l=e.height(),m={top:0,left:0}):f.setTimeout?(k=e.width(),l=e.height(),m={top:e.scrollTop(),left:e.scrollLeft()}):f.preventDefault?(g.at="left top",k=l=0,m={top:g.of.pageY,left:g.of.pageX}): +(k=e.outerWidth(),l=e.outerHeight(),m=e.offset());b.each(["my","at"],function(){var b=(g[this]||"").split(" ");b.length===1&&(b=a.test(b[0])?b.concat(["center"]):c.test(b[0])?["center"].concat(b):["center","center"]);b[0]=a.test(b[0])?b[0]:"center";b[1]=c.test(b[1])?b[1]:"center";g[this]=b});1===i.length&&(i[1]=i[0]);j[0]=parseInt(j[0],10)||0;1===j.length&&(j[1]=j[0]);j[1]=parseInt(j[1],10)||0;"right"===g.at[0]?m.left+=k:"center"===g.at[0]&&(m.left+=k/2);"bottom"===g.at[1]?m.top+=l:"center"===g.at[1]&& +(m.top+=l/2);m.left+=j[0];m.top+=j[1];return this.each(function(){var f=b(this),c=f.outerWidth(),a=f.outerHeight(),d=parseInt(b.curCSS(this,"marginLeft",true))||0,e=parseInt(b.curCSS(this,"marginTop",true))||0,r=c+d+(parseInt(b.curCSS(this,"marginRight",true))||0),u=a+e+(parseInt(b.curCSS(this,"marginBottom",true))||0),s=b.extend({},m),v;if(g.my[0]==="right")s.left=s.left-c;else if(g.my[0]==="center")s.left=s.left-c/2;if(g.my[1]==="bottom")s.top=s.top-a;else if(g.my[1]==="center")s.top=s.top-a/2; +s.left=Math.round(s.left);s.top=Math.round(s.top);v={left:s.left-d,top:s.top-e};b.each(["left","top"],function(f,d){if(b.ui.position[i[f]])b.ui.position[i[f]][d](s,{targetWidth:k,targetHeight:l,elemWidth:c,elemHeight:a,collisionPosition:v,collisionWidth:r,collisionHeight:u,offset:j,my:g.my,at:g.at})});b.fn.bgiframe&&f.bgiframe();f.offset(b.extend(s,{using:g.using}))})};b.ui.position={fit:{left:function(c,a){var f=b(window),f=a.collisionPosition.left+a.collisionWidth-f.width()-f.scrollLeft();c.left= +0a.collisionPosition.left?d+g+k:0a.collisionPosition.top?d+g+k:0
').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(b(this).offset()).appendTo("body")});return!0},_mouseStart:function(a){var c=this.options;this.helper=this._createHelper(a);this._cacheHelperProportions();b.ui.ddmanager&&(b.ui.ddmanager.current=this); +this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};b.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY= +a.pageY;c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt);c.containment&&this._setContainment();if(!1===this._trigger("start",a))return this._clear(),!1;this._cacheHelperProportions();b.ui.ddmanager&&!c.dropBehaviour&&b.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,!0);b.ui.ddmanager&&b.ui.ddmanager.dragStart(this,a);return!0},_mouseDrag:function(a,c){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute"); +if(!c){var d=this._uiHash();if(!1===this._trigger("drag",a,d))return this._mouseUp({}),!1;this.position=d.position}if(!this.options.axis||"y"!=this.options.axis)this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||"x"!=this.options.axis)this.helper[0].style.top=this.position.top+"px";b.ui.ddmanager&&b.ui.ddmanager.drag(this,a);return!1},_mouseStop:function(a){var c=!1;b.ui.ddmanager&&!this.options.dropBehaviour&&(c=b.ui.ddmanager.drop(this,a));this.dropped&&(c=this.dropped,this.dropped= +!1);if((!this.element[0]||!this.element[0].parentNode)&&"original"==this.options.helper)return!1;if("invalid"==this.options.revert&&!c||"valid"==this.options.revert&&c||!0===this.options.revert||b.isFunction(this.options.revert)&&this.options.revert.call(this.element,c)){var d=this;b(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){d._trigger("stop",a)!==false&&d._clear()})}else!1!==this._trigger("stop",a)&&this._clear();return!1},_mouseUp:function(a){!0=== +this.options.iframeFix&&b("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});b.ui.ddmanager&&b.ui.ddmanager.dragStop(this,a);return b.ui.mouse.prototype._mouseUp.call(this,a)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var c=!this.options.handle||!b(this.options.handle,this.element).length?!0:!1;b(this.options.handle,this.element).find("*").andSelf().each(function(){this==a.target&&(c= +!0)});return c},_createHelper:function(a){var c=this.options,a=b.isFunction(c.helper)?b(c.helper.apply(this.element[0],[a])):"clone"==c.helper?this.element.clone().removeAttr("id"):this.element;a.parents("body").length||a.appendTo("parent"==c.appendTo?this.element[0].parentNode:c.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&&a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){"string"==typeof a&&(a=a.split(" "));b.isArray(a)&&(a={left:+a[0],top:+a[1]|| +0});"left"in a&&(this.offset.click.left=a.left+this.margins.left);"right"in a&&(this.offset.click.left=this.helperProportions.width-a.right+this.margins.left);"top"in a&&(this.offset.click.top=a.top+this.margins.top);"bottom"in a&&(this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var a=this.offsetParent.offset();"absolute"==this.cssPosition&&(this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0], +this.offsetParent[0]))&&(a.left+=this.scrollParent.scrollLeft(),a.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&"html"==this.offsetParent[0].tagName.toLowerCase()&&b.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"==this.cssPosition){var b=this.element.position();return{top:b.top- +(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:b.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(), +height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;"parent"==a.containment&&(a.containment=this.helper[0].parentNode);if("document"==a.containment||"window"==a.containment)this.containment=["document"==a.containment?0:b(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,"document"==a.containment?0:b(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,("document"==a.containment?0:b(window).scrollLeft())+b("document"==a.containment?document: +window).width()-this.helperProportions.width-this.margins.left,("document"==a.containment?0:b(window).scrollTop())+(b("document"==a.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){var a=b(a.containment),c=a[0];if(c){a.offset();var d="hidden"!=b(c).css("overflow");this.containment=[(parseInt(b(c).css("borderLeftWidth"),10)||0)+(parseInt(b(c).css("paddingLeft"), +10)||0),(parseInt(b(c).css("borderTopWidth"),10)||0)+(parseInt(b(c).css("paddingTop"),10)||0),(d?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(b(c).css("borderLeftWidth"),10)||0)-(parseInt(b(c).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(d?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(b(c).css("borderTopWidth"),10)||0)-(parseInt(b(c).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom]; +this.relative_container=a}}else a.containment.constructor==Array&&(this.containment=a.containment)},_convertPositionTo:function(a,c){c||(c=this.position);var d="absolute"==a?1:-1,g="absolute"==this.cssPosition&&!(this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,h=/(html|body)/i.test(g[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(b.browser.safari&&526>b.browser.version&&"fixed"==this.cssPosition? +0:("fixed"==this.cssPosition?-this.scrollParent.scrollTop():h?0:g.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(b.browser.safari&&526>b.browser.version&&"fixed"==this.cssPosition?0:("fixed"==this.cssPosition?-this.scrollParent.scrollLeft():h?0:g.scrollLeft())*d)}},_generatePosition:function(a){var c=this.options,d="absolute"==this.cssPosition&&!(this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent, +g=/(html|body)/i.test(d[0].tagName),h=a.pageX,e=a.pageY;if(this.originalPosition){var f;this.containment&&(this.relative_container?(f=this.relative_container.offset(),f=[this.containment[0]+f.left,this.containment[1]+f.top,this.containment[2]+f.left,this.containment[3]+f.top]):f=this.containment,a.pageX-this.offset.click.leftf[2]&&(h=f[2]+this.offset.click.left), +a.pageY-this.offset.click.top>f[3]&&(e=f[3]+this.offset.click.top));c.grid&&(e=c.grid[1]?this.originalPageY+Math.round((e-this.originalPageY)/c.grid[1])*c.grid[1]:this.originalPageY,e=f?!(e-this.offset.click.topf[3])?e:!(e-this.offset.click.topf[2])?h:!(h-this.offset.click.left< +f[0])?h-c.grid[0]:h+c.grid[0]:h)}return{top:e-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(b.browser.safari&&526>b.browser.version&&"fixed"==this.cssPosition?0:"fixed"==this.cssPosition?-this.scrollParent.scrollTop():g?0:d.scrollTop()),left:h-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(b.browser.safari&&526>b.browser.version&&"fixed"==this.cssPosition?0:"fixed"==this.cssPosition?-this.scrollParent.scrollLeft():g?0:d.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"); +this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=!1},_trigger:function(a,c,d){d=d||this._uiHash();b.ui.plugin.call(this,a,[c,d]);"drag"==a&&(this.positionAbs=this._convertPositionTo("absolute"));return b.Widget.prototype._trigger.call(this,a,c,d)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});b.extend(b.ui.draggable,{version:"1.8.14"}); +b.ui.plugin.add("draggable","connectToSortable",{start:function(a,c){var d=b(this).data("draggable"),g=d.options,h=b.extend({},c,{item:d.element});d.sortables=[];b(g.connectToSortable).each(function(){var c=b.data(this,"sortable");c&&!c.options.disabled&&(d.sortables.push({instance:c,shouldRevert:c.options.revert}),c.refreshPositions(),c._trigger("activate",a,h))})},stop:function(a,c){var d=b(this).data("draggable"),g=b.extend({},c,{item:d.element});b.each(d.sortables,function(){this.instance.isOver? +(this.instance.isOver=0,d.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(a),this.instance.options.helper=this.instance.options._helper,"original"==d.options.helper&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",a,g))})},drag:function(a,c){var d=b(this).data("draggable"),g=this;b.each(d.sortables,function(){this.instance.positionAbs= +d.positionAbs;this.instance.helperProportions=d.helperProportions;this.instance.offset.click=d.offset.click;this.instance._intersectsWith(this.instance.containerCache)?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=b(g).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return c.helper[0]},a.target=this.instance.currentItem[0],this.instance._mouseCapture(a, +!0),this.instance._mouseStart(a,!0,!0),this.instance.offset.click.top=d.offset.click.top,this.instance.offset.click.left=d.offset.click.left,this.instance.offset.parent.left-=d.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=d.offset.parent.top-this.instance.offset.parent.top,d._trigger("toSortable",a),d.dropped=this.instance.element,d.currentItem=d.element,this.instance.fromOutside=d),this.instance.currentItem&&this.instance._mouseDrag(a)):this.instance.isOver&& +(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",a,this.instance._uiHash(this.instance)),this.instance._mouseStop(a,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),d._trigger("fromSortable",a),d.dropped=!1)})}});b.ui.plugin.add("draggable","cursor",{start:function(){var a=b("body"),c=b(this).data("draggable").options; +a.css("cursor")&&(c._cursor=a.css("cursor"));a.css("cursor",c.cursor)},stop:function(){var a=b(this).data("draggable").options;a._cursor&&b("body").css("cursor",a._cursor)}});b.ui.plugin.add("draggable","opacity",{start:function(a,c){var d=b(c.helper),g=b(this).data("draggable").options;d.css("opacity")&&(g._opacity=d.css("opacity"));d.css("opacity",g.opacity)},stop:function(a,c){var d=b(this).data("draggable").options;d._opacity&&b(c.helper).css("opacity",d._opacity)}});b.ui.plugin.add("draggable", +"scroll",{start:function(){var a=b(this).data("draggable");a.scrollParent[0]!=document&&"HTML"!=a.scrollParent[0].tagName&&(a.overflowOffset=a.scrollParent.offset())},drag:function(a){var c=b(this).data("draggable"),d=c.options,g=!1;if(c.scrollParent[0]!=document&&"HTML"!=c.scrollParent[0].tagName){if(!d.axis||"x"!=d.axis)c.overflowOffset.top+c.scrollParent[0].offsetHeight-a.pageY=k&&e<=l||f>=k&&f<=l||el)&&(g>=i&&g<=j||h>=i&&h<=j||gj);default:return!1}}; +b.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,c){var d=b.ui.ddmanager.droppables[a.options.scope]||[],g=c?c.type:null,h=(a.currentItem||a.element).find(":data(droppable)").andSelf(),e=0;a:for(;e').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})), +this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize", +"none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize());this.handles=a.handles||(!b(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"});if(this.handles.constructor==String){"all"== +this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw");var h=this.handles.split(",");this.handles={};for(var e=0;e');/sw|se|ne|nw/.test(f)&&i.css({zIndex:++a.zIndex});"se"==f&&i.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[f]=".ui-resizable-"+f;this.element.append(i)}}this._renderAxis=function(f){var f=f||this.element,c;for(c in this.handles){this.handles[c].constructor==String&&(this.handles[c]= +b(this.handles[c],this.element).show());if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var a=b(this.handles[c],this.element),d=0,d=/sw|ne|nw|se|n|s/.test(c)?a.outerHeight():a.outerWidth(),a=["padding",/ne|nw|n/.test(c)?"Top":/se|sw|s/.test(c)?"Bottom":/^e$/.test(c)?"Right":"Left"].join("");f.css(a,d);this._proportionallyResize()}b(this.handles[c])}};this._renderAxis(this.element);this._handles=b(".ui-resizable-handle",this.element).disableSelection(); +this._handles.mouseover(function(){if(!c.resizing){if(this.className)var b=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);c.axis=b&&b[1]?b[1]:"se"}});a.autoHide&&(this._handles.hide(),b(this.element).addClass("ui-resizable-autohide").hover(function(){if(!a.disabled){b(this).removeClass("ui-resizable-autohide");c._handles.show()}},function(){if(!a.disabled&&!c.resizing){b(this).addClass("ui-resizable-autohide");c._handles.hide()}}));this._mouseInit()},destroy:function(){this._mouseDestroy(); +var c=function(c){b(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){c(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);c(this.originalElement);return this},_mouseCapture:function(c){var a= +!1,h;for(h in this.handles)b(this.handles[h])[0]==c.target&&(a=!0);return!this.options.disabled&&a},_mouseStart:function(c){var g=this.options,h=this.element.position(),e=this.element;this.resizing=!0;this.documentScroll={top:b(document).scrollTop(),left:b(document).scrollLeft()};(e.is(".ui-draggable")||/absolute/.test(e.css("position")))&&e.css({position:"absolute",top:h.top,left:h.left});b.browser.opera&&/relative/.test(e.css("position"))&&e.css({position:"relative",top:"auto",left:"auto"});this._renderProxy(); +var h=a(this.helper.css("left")),f=a(this.helper.css("top"));g.containment&&(h+=b(g.containment).scrollLeft()||0,f+=b(g.containment).scrollTop()||0);this.offset=this.helper.offset();this.position={left:h,top:f};this.size=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalSize=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalPosition={left:h,top:f};this.sizeDiff={width:e.outerWidth()- +e.width(),height:e.outerHeight()-e.height()};this.originalMousePosition={left:c.pageX,top:c.pageY};this.aspectRatio="number"==typeof g.aspectRatio?g.aspectRatio:this.originalSize.width/this.originalSize.height||1;g=b(".ui-resizable-"+this.axis).css("cursor");b("body").css("cursor","auto"==g?this.axis+"-resize":g);e.addClass("ui-resizable-resizing");this._propagate("start",c);return!0},_mouseDrag:function(b){var c=this.helper,a=this.originalMousePosition,e=this._change[this.axis];if(!e)return!1;a= +e.apply(this,[b,b.pageX-a.left||0,b.pageY-a.top||0]);this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)a=this._updateRatio(a,b);a=this._respectSize(a,b);this._propagate("resize",b);c.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(a);this._trigger("resize",b,this.ui());return!1},_mouseStop:function(c){this.resizing= +!1;var a=this.options;if(this._helper){var h=this._proportionallyResizeElements,e=h.length&&/textarea/i.test(h[0].nodeName),h=e&&b.ui.hasScroll(h[0],"left")?0:this.sizeDiff.height,e=e?0:this.sizeDiff.width,e={width:this.helper.width()-e,height:this.helper.height()-h},h=parseInt(this.element.css("left"),10)+(this.position.left-this.originalPosition.left)||null,f=parseInt(this.element.css("top"),10)+(this.position.top-this.originalPosition.top)||null;a.animate||this.element.css(b.extend(e,{top:f,left:h})); +this.helper.height(this.size.height);this.helper.width(this.size.width);this._helper&&!a.animate&&this._proportionallyResize()}b("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",c);this._helper&&this.helper.remove();return!1},_updateVirtualBoundaries:function(b){var a=this.options,h,e,f,a={minWidth:c(a.minWidth)?a.minWidth:0,maxWidth:c(a.maxWidth)?a.maxWidth:Infinity,minHeight:c(a.minHeight)?a.minHeight:0,maxHeight:c(a.maxHeight)?a.maxHeight:Infinity}; +if(this._aspectRatio||b)if(b=a.minHeight*this.aspectRatio,e=a.minWidth/this.aspectRatio,h=a.maxHeight*this.aspectRatio,f=a.maxWidth/this.aspectRatio,b>a.minWidth&&(a.minWidth=b),e>a.minHeight&&(a.minHeight=e),hb.width,j=c(b.height)&&a.minHeight&&a.minHeight> +b.height;i&&(b.width=a.minWidth);j&&(b.height=a.minHeight);e&&(b.width=a.maxWidth);f&&(b.height=a.maxHeight);var k=this.originalPosition.left+this.originalSize.width,l=this.position.top+this.size.height,m=/sw|nw|w/.test(h),h=/nw|ne|n/.test(h);i&&m&&(b.left=k-a.minWidth);e&&m&&(b.left=k-a.maxWidth);j&&h&&(b.top=l-a.minHeight);f&&h&&(b.top=l-a.maxHeight);(a=!b.width&&!b.height)&&!b.left&&b.top?b.top=null:a&&(!b.top&&b.left)&&(b.left=null);return b},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var c= +this.helper||this.element,a=0;a');var a=b.browser.msie&&7>b.browser.version,h=a?1:0,a=a?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-h+"px",top:this.elementOffset.top- +h+"px",zIndex:++c.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(b,c){return{width:this.originalSize.width+c}},w:function(b,c){return{left:this.originalPosition.left+c,width:this.originalSize.width-c}},n:function(b,c,a){return{top:this.originalPosition.top+a,height:this.originalSize.height-a}},s:function(b,c,a){return{height:this.originalSize.height+a}},se:function(c,a,h){return b.extend(this._change.s.apply(this,arguments),this._change.e.apply(this, +[c,a,h]))},sw:function(c,a,h){return b.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[c,a,h]))},ne:function(c,a,h){return b.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[c,a,h]))},nw:function(c,a,h){return b.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[c,a,h]))}},_propagate:function(c,a){b.ui.plugin.call(this,c,[a,this.ui()]);"resize"!=c&&this._trigger(c,a,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement, +element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});b.extend(b.ui.resizable,{version:"1.8.14"});b.ui.plugin.add("resizable","alsoResize",{start:function(){var c=b(this).data("resizable").options,a=function(c){b(c).each(function(){var c=b(this);c.data("resizable-alsoresize",{width:parseInt(c.width(),10),height:parseInt(c.height(),10),left:parseInt(c.css("left"),10),top:parseInt(c.css("top"),10),position:c.css("position")})})}; +"object"==typeof c.alsoResize&&!c.alsoResize.parentNode?c.alsoResize.length?(c.alsoResize=c.alsoResize[0],a(c.alsoResize)):b.each(c.alsoResize,function(b){a(b)}):a(c.alsoResize)},resize:function(c,a){var h=b(this).data("resizable"),e=h.options,f=h.originalSize,i=h.originalPosition,j={height:h.size.height-f.height||0,width:h.size.width-f.width||0,top:h.position.top-i.top||0,left:h.position.left-i.left||0},k=function(c,f){b(c).each(function(){var c=b(this),d=b(this).data("resizable-alsoresize"),i={}, +e=f&&f.length?f:c.parents(a.originalElement[0]).length?["width","height"]:["width","height","top","left"];b.each(e,function(b,c){var a=(d[c]||0)+(j[c]||0);a&&0<=a&&(i[c]=a||null)});b.browser.opera&&/relative/.test(c.css("position"))&&(h._revertToRelativePosition=!0,c.css({position:"absolute",top:"auto",left:"auto"}));c.css(i)})};"object"==typeof e.alsoResize&&!e.alsoResize.nodeType?b.each(e.alsoResize,function(b,c){k(b,c)}):k(e.alsoResize)},stop:function(){var c=b(this).data("resizable"),a=c.options, +h=function(c){b(c).each(function(){var c=b(this);c.css({position:c.data("resizable-alsoresize").position})})};c._revertToRelativePosition&&(c._revertToRelativePosition=!1,"object"==typeof a.alsoResize&&!a.alsoResize.nodeType?b.each(a.alsoResize,function(b){h(b)}):h(a.alsoResize));b(this).removeData("resizable-alsoresize")}});b.ui.plugin.add("resizable","animate",{stop:function(c){var a=b(this).data("resizable"),h=a.options,e=a._proportionallyResizeElements,f=e.length&&/textarea/i.test(e[0].nodeName), +i=f&&b.ui.hasScroll(e[0],"left")?0:a.sizeDiff.height,f={width:a.size.width-(f?0:a.sizeDiff.width),height:a.size.height-i},i=parseInt(a.element.css("left"),10)+(a.position.left-a.originalPosition.left)||null,j=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;a.element.animate(b.extend(f,j&&i?{top:j,left:i}:{}),{duration:h.animateDuration,easing:h.animateEasing,step:function(){var f={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10), +top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};e&&e.length&&b(e[0]).css({width:f.width,height:f.height});a._updateCache(f);a._propagate("resize",c)}})}});b.ui.plugin.add("resizable","containment",{start:function(){var c=b(this).data("resizable"),g=c.element,h=c.options.containment;if(g=h instanceof b?h.get(0):/parent/.test(h)?g.parent().get(0):h)if(c.containerElement=b(g),/document/.test(h)||h==document)c.containerOffset={left:0,top:0},c.containerPosition={left:0,top:0}, +c.parentData={element:b(document),left:0,top:0,width:b(document).width(),height:b(document).height()||document.body.parentNode.scrollHeight};else{var e=b(g),f=[];b(["Top","Right","Left","Bottom"]).each(function(b,c){f[b]=a(e.css("padding"+c))});c.containerOffset=e.offset();c.containerPosition=e.position();c.containerSize={height:e.innerHeight()-f[3],width:e.innerWidth()-f[1]};var h=c.containerOffset,i=c.containerSize.height,j=c.containerSize.width,j=b.ui.hasScroll(g,"left")?g.scrollWidth:j,i=b.ui.hasScroll(g)? +g.scrollHeight:i;c.parentData={element:g,left:h.left,top:h.top,width:j,height:i}}},resize:function(c){var a=b(this).data("resizable"),h=a.options,e=a.containerOffset,f=a.position,c=a._aspectRatio||c.shiftKey,i={top:0,left:0},j=a.containerElement;j[0]!=document&&/static/.test(j.css("position"))&&(i=e);if(f.left<(a._helper?e.left:0))a.size.width+=a._helper?a.position.left-e.left:a.position.left-i.left,c&&(a.size.height=a.size.width/h.aspectRatio),a.position.left=h.helper?e.left:0;if(f.top<(a._helper? +e.top:0))a.size.height+=a._helper?a.position.top-e.top:a.position.top,c&&(a.size.width=a.size.height*h.aspectRatio),a.position.top=a._helper?e.top:0;a.offset.left=a.parentData.left+a.position.left;a.offset.top=a.parentData.top+a.position.top;h=Math.abs(a.offset.left-i.left+a.sizeDiff.width);e=Math.abs((a._helper?a.offset.top-i.top:a.offset.top-e.top)+a.sizeDiff.height);f=a.containerElement.get(0)==a.element.parent().get(0);i=/relative|absolute/.test(a.containerElement.css("position"));f&&i&&(h-=a.parentData.left); +h+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-h,c&&(a.size.height=a.size.width/a.aspectRatio));e+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-e,c&&(a.size.width=a.size.height*a.aspectRatio))},stop:function(){var a=b(this).data("resizable"),c=a.options,h=a.containerOffset,e=a.containerPosition,f=a.containerElement,i=b(a.helper),j=i.offset(),k=i.outerWidth()-a.sizeDiff.width,i=i.outerHeight()-a.sizeDiff.height;a._helper&&(!c.animate&&/relative/.test(f.css("position")))&& +b(this).css({left:j.left-e.left-h.left,width:k,height:i});a._helper&&(!c.animate&&/static/.test(f.css("position")))&&b(this).css({left:j.left-e.left-h.left,width:k,height:i})}});b.ui.plugin.add("resizable","ghost",{start:function(){var a=b(this).data("resizable"),c=a.options,h=a.size;a.ghost=a.originalElement.clone();a.ghost.css({opacity:0.25,display:"block",position:"relative",height:h.height,width:h.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof c.ghost?c.ghost: +"");a.ghost.appendTo(a.helper)},resize:function(){var a=b(this).data("resizable");a.ghost&&a.ghost.css({position:"relative",height:a.size.height,width:a.size.width})},stop:function(){var a=b(this).data("resizable");a.ghost&&a.helper&&a.helper.get(0).removeChild(a.ghost.get(0))}});b.ui.plugin.add("resizable","grid",{resize:function(){var a=b(this).data("resizable"),c=a.options,h=a.size,e=a.originalSize,f=a.originalPosition,i=a.axis;c.grid="number"==typeof c.grid?[c.grid,c.grid]:c.grid;var j=Math.round((h.width- +e.width)/(c.grid[0]||1))*(c.grid[0]||1),c=Math.round((h.height-e.height)/(c.grid[1]||1))*(c.grid[1]||1);/^(se|s|e)$/.test(i)?(a.size.width=e.width+j,a.size.height=e.height+c):/^(ne)$/.test(i)?(a.size.width=e.width+j,a.size.height=e.height+c,a.position.top=f.top-c):(/^(sw)$/.test(i)?(a.size.width=e.width+j,a.size.height=e.height+c):(a.size.width=e.width+j,a.size.height=e.height+c,a.position.top=f.top-c),a.position.left=f.left-j)}});var a=function(b){return parseInt(b,10)||0},c=function(b){return!isNaN(parseInt(b, +10))}})(jQuery); +(function(b){b.widget("ui.selectable",b.ui.mouse,{options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var a=this;this.element.addClass("ui-selectable");this.dragged=!1;var c;this.refresh=function(){c=b(a.options.filter,a.element[0]);c.each(function(){var a=b(this),c=a.offset();b.data(this,"selectable-item",{element:this,$element:a,left:c.left,top:c.top,right:c.left+a.outerWidth(),bottom:c.top+a.outerHeight(),startselected:!1,selected:a.hasClass("ui-selected"),selecting:a.hasClass("ui-selecting"), +unselecting:a.hasClass("ui-unselecting")})})};this.refresh();this.selectees=c.addClass("ui-selectee");this._mouseInit();this.helper=b("
")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(a){var c=this;this.opos=[a.pageX,a.pageY];if(!this.options.disabled){var d= +this.options;this.selectees=b(d.filter,this.element[0]);this._trigger("start",a);b(d.appendTo).append(this.helper);this.helper.css({left:a.clientX,top:a.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var d=b.data(this,"selectable-item");d.startselected=!0;a.metaKey||(d.$element.removeClass("ui-selected"),d.selected=!1,d.$element.addClass("ui-unselecting"),d.unselecting=!0,c._trigger("unselecting",a,{unselecting:d.element}))});b(a.target).parents().andSelf().each(function(){var d= +b.data(this,"selectable-item");if(d){var h=!a.metaKey||!d.$element.hasClass("ui-selected");d.$element.removeClass(h?"ui-unselecting":"ui-selected").addClass(h?"ui-selecting":"ui-unselecting");d.unselecting=!h;d.selecting=h;(d.selected=h)?c._trigger("selecting",a,{selecting:d.element}):c._trigger("unselecting",a,{unselecting:d.element});return!1}})}},_mouseDrag:function(a){var c=this;this.dragged=!0;if(!this.options.disabled){var d=this.options,g=this.opos[0],h=this.opos[1],e=a.pageX,f=a.pageY;if(g> +e)var i=e,e=g,g=i;h>f&&(i=f,f=h,h=i);this.helper.css({left:g,top:h,width:e-g,height:f-h});this.selectees.each(function(){var i=b.data(this,"selectable-item");if(i&&i.element!=c.element[0]){var k=false;d.tolerance=="touch"?k=!(i.left>e||i.rightf||i.bottomg&&i.righth&&i.bottom *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){var b=this.options;this.containerCache={};this.element.addClass("ui-sortable");this.refresh(); +this.floating=this.items.length?"x"===b.axis||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var b=this.items.length-1;0<=b;b--)this.items[b].item.removeData("sortable-item");return this},_setOption:function(a,c){"disabled"===a?(this.options[a]= +c,this.widget()[c?"addClass":"removeClass"]("ui-sortable-disabled")):b.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(a,c){if(this.reverting||this.options.disabled||"static"==this.options.type)return!1;this._refreshItems(a);var d=null,g=this;b(a.target).parents().each(function(){if(b.data(this,"sortable-item")==g)return d=b(this),!1});b.data(a.target,"sortable-item")==g&&(d=b(a.target));if(!d)return!1;if(this.options.handle&&!c){var h=!1;b(this.options.handle,d).find("*").andSelf().each(function(){this== +a.target&&(h=!0)});if(!h)return!1}this.currentItem=d;this._removeCurrentsFromItems();return!0},_mouseStart:function(a,c,d){c=this.options;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(a);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition= +this.helper.css("position");b.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder(); +c.containment&&this._setContainment();c.cursor&&(b("body").css("cursor")&&(this._storedCursor=b("body").css("cursor")),b("body").css("cursor",c.cursor));c.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",c.opacity));c.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",c.zIndex));this.scrollParent[0]!=document&&"HTML"!=this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()); +this._trigger("start",a,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!d)for(d=this.containers.length-1;0<=d;d--)this.containers[d]._trigger("activate",a,this._uiHash(this));b.ui.ddmanager&&(b.ui.ddmanager.current=this);b.ui.ddmanager&&!c.dropBehaviour&&b.ui.ddmanager.prepareOffsets(this,a);this.dragging=!0;this.helper.addClass("ui-sortable-helper");this._mouseDrag(a);return!0},_mouseDrag:function(a){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute"); +this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var c=this.options,d=!1;this.scrollParent[0]!=document&&"HTML"!=this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-a.pageYb[this.floating?"width":"height"]?g+k>i&&g+ke&&c+lthis.containment[2]&&(h=this.containment[2]+this.offset.click.left),a.pageY-this.offset.click.top>this.containment[3]&&(e=this.containment[3]+this.offset.click.top)),c.grid))e=this.originalPageY+Math.round((e-this.originalPageY)/c.grid[1])*c.grid[1],e=this.containment?!(e-this.offset.click.topthis.containment[3])?e:!(e-this.offset.click.top< +this.containment[1])?e-c.grid[1]:e+c.grid[1]:e,h=this.originalPageX+Math.round((h-this.originalPageX)/c.grid[0])*c.grid[0],h=this.containment?!(h-this.offset.click.leftthis.containment[2])?h:!(h-this.offset.click.left li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:!1,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var a=this,c=a.options;a.running=0;a.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix");a.headers= +a.element.find(c.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){c.disabled||b(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){c.disabled||b(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){c.disabled||b(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){c.disabled||b(this).removeClass("ui-state-focus")});a.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom"); +if(c.navigation){var d=a.element.find("a").filter(c.navigationFilter).eq(0);if(d.length){var g=d.closest(".ui-accordion-header");a.active=g.length?g:d.closest(".ui-accordion-content").prev()}}a.active=a._findActive(a.active||c.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");a.active.next().addClass("ui-accordion-content-active");a._createIcons();a.resize();a.element.attr("role","tablist");a.headers.attr("role","tab").bind("keydown.accordion", +function(b){return a._keydown(b)}).next().attr("role","tabpanel");a.headers.not(a.active||"").attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).next().hide();a.active.length?a.active.attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}):a.headers.eq(0).attr("tabIndex",0);b.browser.safari||a.headers.find("a").attr("tabIndex",-1);c.event&&a.headers.bind(c.event.split(" ").join(".accordion ")+".accordion",function(b){a._clickHandler.call(a,b,this);b.preventDefault()})},_createIcons:function(){var a= +this.options;a.icons&&(b("").addClass("ui-icon "+a.icons.header).prependTo(this.headers),this.active.children(".ui-icon").toggleClass(a.icons.header).toggleClass(a.icons.headerSelected),this.element.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.children(".ui-icon").remove();this.element.removeClass("ui-accordion-icons")},destroy:function(){var a=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role");this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("tabIndex"); +this.headers.find("a").removeAttr("tabIndex");this._destroyIcons();var c=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");(a.autoHeight||a.fillHeight)&&c.css("height","");return b.Widget.prototype.destroy.call(this)},_setOption:function(a,c){b.Widget.prototype._setOption.apply(this,arguments);"active"==a&&this.activate(c);"icons"==a&&(this._destroyIcons(), +c&&this._createIcons());if("disabled"==a)this.headers.add(this.headers.next())[c?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")},_keydown:function(a){if(!this.options.disabled&&!a.altKey&&!a.ctrlKey){var c=b.ui.keyCode,d=this.headers.length,g=this.headers.index(a.target),h=!1;switch(a.keyCode){case c.RIGHT:case c.DOWN:h=this.headers[(g+1)%d];break;case c.LEFT:case c.UP:h=this.headers[(g-1+d)%d];break;case c.SPACE:case c.ENTER:this._clickHandler({target:a.target},a.target),a.preventDefault()}return h? +(b(a.target).attr("tabIndex",-1),b(h).attr("tabIndex",0),h.focus(),!1):!0}},resize:function(){var a=this.options,c;if(a.fillSpace){if(b.browser.msie){var d=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}c=this.element.parent().height();b.browser.msie&&this.element.parent().css("overflow",d);this.headers.each(function(){c-=b(this).outerHeight(!0)});this.headers.next().each(function(){b(this).height(Math.max(0,c-b(this).innerHeight()+b(this).height()))}).css("overflow", +"auto")}else a.autoHeight&&(c=0,this.headers.next().each(function(){c=Math.max(c,b(this).height("").height())}).height(c));return this},activate:function(b){this.options.active=b;b=this._findActive(b)[0];this._clickHandler({target:b},b);return this},_findActive:function(a){return a?"number"===typeof a?this.headers.filter(":eq("+a+")"):this.headers.not(this.headers.not(a)):!1===a?b([]):this.headers.filter(":eq(0)")},_clickHandler:function(a,c){var d=this.options;if(!d.disabled)if(a.target){var g=b(a.currentTarget|| +c),h=g[0]===this.active[0];d.active=d.collapsible&&h?!1:this.headers.index(g);if(!(this.running||!d.collapsible&&h)){var e=this.active,f=g.next(),i=this.active.next(),j={options:d,newHeader:h&&d.collapsible?b([]):g,oldHeader:this.active,newContent:h&&d.collapsible?b([]):f,oldContent:i},k=this.headers.index(this.active[0])>this.headers.index(g[0]);this.active=h?b([]):g;this._toggle(f,i,j,h,k);e.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header); +h||(g.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(d.icons.header).addClass(d.icons.headerSelected),g.next().addClass("ui-accordion-content-active"))}}else if(d.collapsible){this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header);this.active.next().addClass("ui-accordion-content-active");var i=this.active.next(), +j={options:d,newHeader:b([]),oldHeader:d.active,newContent:b([]),oldContent:i},f=this.active=b([]);this._toggle(f,i,j)}},_toggle:function(a,c,d,g,h){var e=this,f=e.options;e.toShow=a;e.toHide=c;e.data=d;var i=function(){if(e)return e._completed.apply(e,arguments)};e._trigger("changestart",null,e.data);e.running=0===c.size()?a.size():c.size();if(f.animated){d={};d=f.collapsible&&g?{toShow:b([]),toHide:c,complete:i,down:h,autoHeight:f.autoHeight||f.fillSpace}:{toShow:a,toHide:c,complete:i,down:h,autoHeight:f.autoHeight|| +f.fillSpace};f.proxied||(f.proxied=f.animated);f.proxiedDuration||(f.proxiedDuration=f.duration);f.animated=b.isFunction(f.proxied)?f.proxied(d):f.proxied;f.duration=b.isFunction(f.proxiedDuration)?f.proxiedDuration(d):f.proxiedDuration;var g=b.ui.accordion.animations,j=f.duration,k=f.animated;k&&(!g[k]&&!b.easing[k])&&(k="slide");g[k]||(g[k]=function(b){this.slide(b,{easing:k,duration:j||700})});g[k](d)}else f.collapsible&&g?a.toggle():(c.hide(),a.show()),i(!0);c.prev().attr({"aria-expanded":"false", +"aria-selected":"false",tabIndex:-1}).blur();a.prev().attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}).focus()},_completed:function(b){this.running=b?0:--this.running;this.running||(this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""}),this.toHide.removeClass("ui-accordion-content-active"),this.toHide.length&&(this.toHide.parent()[0].className=this.toHide.parent()[0].className),this._trigger("change",null,this.data))}});b.extend(b.ui.accordion,{version:"1.8.14", +animations:{slide:function(a,c){a=b.extend({easing:"swing",duration:300},a,c);if(a.toHide.size())if(a.toShow.size()){var d=a.toShow.css("overflow"),g=0,h={},e={},f,i=a.toShow;f=i[0].style.width;i.width(parseInt(i.parent().width(),10)-parseInt(i.css("paddingLeft"),10)-parseInt(i.css("paddingRight"),10)-(parseInt(i.css("borderLeftWidth"),10)||0)-(parseInt(i.css("borderRightWidth"),10)||0));b.each(["height","paddingTop","paddingBottom"],function(c,f){e[f]="hide";var i=(""+b.css(a.toShow[0],f)).match(/^([\d+-.]+)(.*)$/); +h[f]={value:i[1],unit:i[2]||"px"}});a.toShow.css({height:0,overflow:"hidden"}).show();a.toHide.filter(":hidden").each(a.complete).end().filter(":visible").animate(e,{step:function(b,c){"height"==c.prop&&(g=0===c.end-c.start?0:(c.now-c.start)/(c.end-c.start));a.toShow[0].style[c.prop]=g*h[c.prop].value+h[c.prop].unit},duration:a.duration,easing:a.easing,complete:function(){a.autoHeight||a.toShow.css("height","");a.toShow.css({width:f,overflow:d});a.complete()}})}else a.toHide.animate({height:"hide", +paddingTop:"hide",paddingBottom:"hide"},a);else a.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},a)},bounceslide:function(b){this.slide(b,{easing:b.down?"easeOutBounce":"swing",duration:b.down?1E3:200})}}})})(jQuery); +(function(b){var a=0;b.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var c=this,a=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(a){if(!c.options.disabled&&!c.element.attr("readonly")){g=!1;var d= +b.ui.keyCode;switch(a.keyCode){case d.PAGE_UP:c._move("previousPage",a);break;case d.PAGE_DOWN:c._move("nextPage",a);break;case d.UP:c._move("previous",a);a.preventDefault();break;case d.DOWN:c._move("next",a);a.preventDefault();break;case d.ENTER:case d.NUMPAD_ENTER:c.menu.active&&(g=!0,a.preventDefault());case d.TAB:if(!c.menu.active)break;c.menu.select(a);break;case d.ESCAPE:c.element.val(c.term);c.close(a);break;default:clearTimeout(c.searching),c.searching=setTimeout(function(){c.term!=c.element.val()&& +(c.selectedItem=null,c.search(null,a))},c.options.delay)}}}).bind("keypress.autocomplete",function(b){g&&(g=!1,b.preventDefault())}).bind("focus.autocomplete",function(){c.options.disabled||(c.selectedItem=null,c.previous=c.element.val())}).bind("blur.autocomplete",function(b){c.options.disabled||(clearTimeout(c.searching),c.closing=setTimeout(function(){c.close(b);c._change(b)},150))});this._initSource();this.response=function(){return c._response.apply(c,arguments)};this.menu=b("
    ").addClass("ui-autocomplete").appendTo(b(this.options.appendTo|| +"body",a)[0]).mousedown(function(a){var d=c.menu.element[0];b(a.target).closest(".ui-menu-item").length||setTimeout(function(){b(document).one("mousedown",function(a){a.target!==c.element[0]&&(a.target!==d&&!b.ui.contains(d,a.target))&&c.close()})},1);setTimeout(function(){clearTimeout(c.closing)},13)}).menu({focus:function(b,a){var f=a.item.data("item.autocomplete");!1!==c._trigger("focus",b,{item:f})&&/^key/.test(b.originalEvent.type)&&c.element.val(f.value)},selected:function(b,e){var f=e.item.data("item.autocomplete"), +i=c.previous;c.element[0]!==a.activeElement&&(c.element.focus(),c.previous=i,setTimeout(function(){c.previous=i;c.selectedItem=f},1));!1!==c._trigger("select",b,{item:f})&&c.element.val(f.value);c.term=c.element.val();c.close(b);c.selectedItem=f},blur:function(){c.menu.element.is(":visible")&&c.element.val()!==c.term&&c.element.val(c.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");b.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup"); +this.menu.element.remove();b.Widget.prototype.destroy.call(this)},_setOption:function(a,d){b.Widget.prototype._setOption.apply(this,arguments);"source"===a&&this._initSource();"appendTo"===a&&this.menu.element.appendTo(b(d||"body",this.element[0].ownerDocument)[0]);"disabled"===a&&(d&&this.xhr)&&this.xhr.abort()},_initSource:function(){var c=this,d,g;b.isArray(this.options.source)?(d=this.options.source,this.source=function(a,c){c(b.ui.autocomplete.filter(d,a.term))}):"string"===typeof this.options.source? +(g=this.options.source,this.source=function(d,e){c.xhr&&c.xhr.abort();c.xhr=b.ajax({url:g,data:d,dataType:"json",autocompleteRequest:++a,success:function(b){this.autocompleteRequest===a&&e(b)},error:function(){this.autocompleteRequest===a&&e([])}})}):this.source=this.options.source},search:function(b,a){b=null!=b?b:this.element.val();this.term=this.element.val();if(b.length").data("item.autocomplete",d).append(b("").text(d.label)).appendTo(a)},_move:function(b,a){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(b)||this.menu.last()&& +/^next/.test(b))this.element.val(this.term),this.menu.deactivate();else this.menu[b](a);else this.search(null,a)},widget:function(){return this.menu.element}});b.extend(b.ui.autocomplete,{escapeRegex:function(b){return b.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(a,d){var g=RegExp(b.ui.autocomplete.escapeRegex(d),"i");return b.grep(a,function(b){return g.test(b.label||b.value||b)})}})})(jQuery); +(function(b){b.widget("ui.menu",{_create:function(){var a=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(c){b(c.target).closest(".ui-menu-item a").length&&(c.preventDefault(),a.select(c))});this.refresh()},refresh:function(){var a=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex", +-1).mouseenter(function(c){a.activate(c,b(this).parent())}).mouseleave(function(){a.deactivate()})},activate:function(b,c){this.deactivate();if(this.hasScroll()){var d=c.offset().top-this.element.offset().top,g=this.element.scrollTop(),h=this.element.height();0>d?this.element.scrollTop(g+d):d>=h&&this.element.scrollTop(g+d-h+c.height())}this.active=c.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",b,{item:c})},deactivate:function(){this.active&& +(this.active.children("a").removeClass("ui-state-hover").removeAttr("id"),this._trigger("blur"),this.active=null)},next:function(b){this.move("next",".ui-menu-item:first",b)},previous:function(b){this.move("prev",".ui-menu-item:last",b)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(b,c,d){this.active?(b=this.active[b+"All"](".ui-menu-item").eq(0),b.length?this.activate(d, +b):this.activate(d,this.element.children(c))):this.activate(d,this.element.children(c))},nextPage:function(a){if(this.hasScroll())if(!this.active||this.last())this.activate(a,this.element.children(".ui-menu-item:first"));else{var c=this.active.offset().top,d=this.element.height(),g=this.element.children(".ui-menu-item").filter(function(){var a=b(this).offset().top-c-d+b(this).height();return 10>a&&-10a&&-10").addClass("ui-button-text").html(this.options.label).appendTo(a.empty()).text(),d=this.options.icons,h=d.primary&&d.secondary,e=[];d.primary||d.secondary?(this.options.text&&e.push("ui-button-text-icon"+(h?"s":d.primary?"-primary":"-secondary")),d.primary&&a.prepend(""),d.secondary&&a.append(""),this.options.text||(e.push(h?"ui-button-icons-only": +"ui-button-icon-only"),this.hasTitle||a.attr("title",c))):e.push("ui-button-text-only");a.addClass(e.join(" "))}}});b.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(a,c){"disabled"===a&&this.buttons.button("option",a,c);b.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var a="ltr"===this.element.css("direction"); +this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(a?"ui-corner-left":"ui-corner-right").end().filter(":last").addClass(a?"ui-corner-right":"ui-corner-left").end().end()},destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy"); +b.Widget.prototype.destroy.call(this)}})})(jQuery); +(function(b,a){var c={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},d={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0},g=b.attrFn||{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0,click:!0};b.widget("ui.dialog",{options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",collision:"fit",using:function(a){var c= +b(this).css(a).offset().top;0>c&&b(this).css("top",a.top-c)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");"string"!==typeof this.originalTitle&&(this.originalTitle="");this.options.title=this.options.title||this.originalTitle;var a=this,c=a.options,f=c.title||" ",i=b.ui.dialog.getTitleId(a.element),d=(a.uiDialog=b("
    ")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+ +c.dialogClass).css({zIndex:c.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(f){if(c.closeOnEscape&&f.keyCode&&f.keyCode===b.ui.keyCode.ESCAPE){a.close(f);f.preventDefault()}}).attr({role:"dialog","aria-labelledby":i}).mousedown(function(b){a.moveToTop(false,b)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(d);var g=(a.uiDialogTitlebar=b("
    ")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(d), +l=b('').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){l.addClass("ui-state-hover")},function(){l.removeClass("ui-state-hover")}).focus(function(){l.addClass("ui-state-focus")}).blur(function(){l.removeClass("ui-state-focus")}).click(function(b){a.close(b);return false}).appendTo(g);(a.uiDialogTitlebarCloseText=b("")).addClass("ui-icon ui-icon-closethick").text(c.closeText).appendTo(l);b("").addClass("ui-dialog-title").attr("id", +i).html(f).prependTo(g);b.isFunction(c.beforeclose)&&!b.isFunction(c.beforeClose)&&(c.beforeClose=c.beforeclose);g.find("*").add(g).disableSelection();c.draggable&&b.fn.draggable&&a._makeDraggable();c.resizable&&b.fn.resizable&&a._makeResizable();a._createButtons(c.buttons);a._isOpen=!1;b.fn.bgiframe&&d.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){this.overlay&&this.overlay.destroy();this.uiDialog.hide();this.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"); +this.uiDialog.remove();this.originalTitle&&this.element.attr("title",this.originalTitle);return this},widget:function(){return this.uiDialog},close:function(a){var c=this,f,d;if(!1!==c._trigger("beforeClose",a))return c.overlay&&c.overlay.destroy(),c.uiDialog.unbind("keypress.ui-dialog"),c._isOpen=!1,c.options.hide?c.uiDialog.hide(c.options.hide,function(){c._trigger("close",a)}):(c.uiDialog.hide(),c._trigger("close",a)),b.ui.dialog.overlay.resize(),c.options.modal&&(f=0,b(".ui-dialog").each(function(){if(this!== +c.uiDialog[0]){d=b(this).css("z-index");isNaN(d)||(f=Math.max(f,d))}}),b.ui.dialog.maxZ=f),c},isOpen:function(){return this._isOpen},moveToTop:function(a,c){var f=this.options;if(f.modal&&!a||!f.stack&&!f.modal)return this._trigger("focus",c);f.zIndex>b.ui.dialog.maxZ&&(b.ui.dialog.maxZ=f.zIndex);this.overlay&&(b.ui.dialog.maxZ+=1,this.overlay.$el.css("z-index",b.ui.dialog.overlay.maxZ=b.ui.dialog.maxZ));f={scrollTop:this.element.attr("scrollTop"),scrollLeft:this.element.attr("scrollLeft")};b.ui.dialog.maxZ+= +1;this.uiDialog.css("z-index",b.ui.dialog.maxZ);this.element.attr(f);this._trigger("focus",c);return this},open:function(){if(!this._isOpen){var a=this.options,c=this.uiDialog;this.overlay=a.modal?new b.ui.dialog.overlay(this):null;this._size();this._position(a.position);c.show(a.show);this.moveToTop(!0);a.modal&&c.bind("keypress.ui-dialog",function(a){if(a.keyCode===b.ui.keyCode.TAB){var c=b(":tabbable",this),d=c.filter(":first"),c=c.filter(":last");if(a.target===c[0]&&!a.shiftKey)return d.focus(1), +!1;if(a.target===d[0]&&a.shiftKey)return c.focus(1),!1}});b(this.element.find(":tabbable").get().concat(c.find(".ui-dialog-buttonpane :tabbable").get().concat(c.get()))).eq(0).focus();this._isOpen=!0;this._trigger("open");return this}},_createButtons:function(a){var c=this,f=!1,d=b("
    ").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),j=b("
    ").addClass("ui-dialog-buttonset").appendTo(d);c.uiDialog.find(".ui-dialog-buttonpane").remove();"object"===typeof a&& +null!==a&&b.each(a,function(){return!(f=!0)});f&&(b.each(a,function(a,f){var f=b.isFunction(f)?{click:f,text:a}:f,d=b('').click(function(){f.click.apply(c.element[0],arguments)}).appendTo(j);b.each(f,function(b,a){if("click"!==b)if(b in g)d[b](a);else d.attr(b,a)});b.fn.button&&d.button()}),d.appendTo(c.uiDialog))},_makeDraggable:function(){function a(b){return{position:b.position,offset:b.offset}}var c=this,f=c.options,d=b(document),g;c.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close", +handle:".ui-dialog-titlebar",containment:"document",start:function(d,i){g="auto"===f.height?"auto":b(this).height();b(this).height(b(this).height()).addClass("ui-dialog-dragging");c._trigger("dragStart",d,a(i))},drag:function(b,f){c._trigger("drag",b,a(f))},stop:function(k,l){f.position=[l.position.left-d.scrollLeft(),l.position.top-d.scrollTop()];b(this).removeClass("ui-dialog-dragging").height(g);c._trigger("dragStop",k,a(l));b.ui.dialog.overlay.resize()}})},_makeResizable:function(c){function d(b){return{originalPosition:b.originalPosition, +originalSize:b.originalSize,position:b.position,size:b.size}}var c=c===a?this.options.resizable:c,f=this,i=f.options,g=f.uiDialog.css("position"),c="string"===typeof c?c:"n,e,s,w,se,sw,ne,nw";f.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:f.element,maxWidth:i.maxWidth,maxHeight:i.maxHeight,minWidth:i.minWidth,minHeight:f._minHeight(),handles:c,start:function(a,c){b(this).addClass("ui-dialog-resizing");f._trigger("resizeStart",a,d(c))},resize:function(b,a){f._trigger("resize", +b,d(a))},stop:function(a,c){b(this).removeClass("ui-dialog-resizing");i.height=b(this).height();i.width=b(this).width();f._trigger("resizeStop",a,d(c));b.ui.dialog.overlay.resize()}}).css("position",g).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var b=this.options;return"auto"===b.height?b.minHeight:Math.min(b.minHeight,b.height)},_position:function(a){var c=[],f=[0,0],d;if(a){if("string"===typeof a||"object"===typeof a&&"0"in a)c=a.split?a.split(" "): +[a[0],a[1]],1===c.length&&(c[1]=c[0]),b.each(["left","top"],function(b,a){+c[b]===c[b]&&(f[b]=c[b],c[b]=a)}),a={my:c.join(" "),at:c.join(" "),offset:f.join(" ")};a=b.extend({},b.ui.dialog.prototype.options.position,a)}else a=b.ui.dialog.prototype.options.position;(d=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(b.extend({of:window},a));d||this.uiDialog.hide()},_setOptions:function(a){var g=this,f={},i=!1;b.each(a,function(b,a){g._setOption(b,a);b in +c&&(i=!0);b in d&&(f[b]=a)});i&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",f)},_setOption:function(a,c){var f=this.uiDialog;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":this._createButtons(c);break;case "closeText":this.uiDialogTitlebarCloseText.text(""+c);break;case "dialogClass":f.removeClass(this.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+c);break;case "disabled":c?f.addClass("ui-dialog-disabled"): +f.removeClass("ui-dialog-disabled");break;case "draggable":var d=f.is(":data(draggable)");d&&!c&&f.draggable("destroy");!d&&c&&this._makeDraggable();break;case "position":this._position(c);break;case "resizable":(d=f.is(":data(resizable)"))&&!c&&f.resizable("destroy");d&&"string"===typeof c&&f.resizable("option","handles",c);!d&&!1!==c&&this._makeResizable(c);break;case "title":b(".ui-dialog-title",this.uiDialogTitlebar).html(""+(c||" "))}b.Widget.prototype._setOption.apply(this,arguments)}, +_size:function(){var a=this.options,c,f,d=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});a.minWidth>a.width&&(a.width=a.minWidth);c=this.uiDialog.css({height:"auto",width:a.width}).height();f=Math.max(0,a.minHeight-c);"auto"===a.height?b.support.minHeight?this.element.css({minHeight:f,height:"auto"}):(this.uiDialog.show(),a=this.element.css("height","auto").height(),d||this.uiDialog.hide(),this.element.height(Math.max(a,f))):this.element.height(Math.max(a.height- +c,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}});b.extend(b.ui.dialog,{version:"1.8.14",uuid:0,maxZ:0,getTitleId:function(b){b=b.attr("id");b||(b=this.uuid+=1);return"ui-dialog-title-"+b},overlay:function(a){this.$el=b.ui.dialog.overlay.create(a)}});b.extend(b.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:b.map("focus mousedown mouseup keydown keypress click".split(" "),function(b){return b+".dialog-overlay"}).join(" "), +create:function(a){0===this.instances.length&&(setTimeout(function(){b.ui.dialog.overlay.instances.length&&b(document).bind(b.ui.dialog.overlay.events,function(a){if(b(a.target).zIndex()").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(), +height:this.height()});b.fn.bgiframe&&c.bgiframe();this.instances.push(c);return c},destroy:function(a){var c=b.inArray(a,this.instances);-1!=c&&this.oldInstances.push(this.instances.splice(c,1)[0]);0===this.instances.length&&b([document,window]).unbind(".dialog-overlay");a.remove();var f=0;b.each(this.instances,function(){f=Math.max(f,this.css("z-index"))});this.maxZ=f},height:function(){var a,c;return b.browser.msie&&7>b.browser.version?(a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight), +c=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),a").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+("min"===c.range||"max"===c.range?" ui-slider-range-"+c.range:""))}for(var e=d.length;e"); +this.handles=d.add(b(h.join("")).appendTo(a.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(b){b.preventDefault()}).hover(function(){c.disabled||b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")}).focus(function(){c.disabled?b(this).blur():(b(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),b(this).addClass("ui-state-focus"))}).blur(function(){b(this).removeClass("ui-state-focus")});this.handles.each(function(a){b(this).data("index.ui-slider-handle", +a)});this.handles.keydown(function(c){var d=!0,g=b(this).data("index.ui-slider-handle"),e,h,m;if(!a.options.disabled){switch(c.keyCode){case b.ui.keyCode.HOME:case b.ui.keyCode.END:case b.ui.keyCode.PAGE_UP:case b.ui.keyCode.PAGE_DOWN:case b.ui.keyCode.UP:case b.ui.keyCode.RIGHT:case b.ui.keyCode.DOWN:case b.ui.keyCode.LEFT:if(d=!1,!a._keySliding&&(a._keySliding=!0,b(this).addClass("ui-state-active"),e=a._start(c,g),!1===e))return}m=a.options.step;e=a.options.values&&a.options.values.length?h=a.values(g): +h=a.value();switch(c.keyCode){case b.ui.keyCode.HOME:h=a._valueMin();break;case b.ui.keyCode.END:h=a._valueMax();break;case b.ui.keyCode.PAGE_UP:h=a._trimAlignValue(e+(a._valueMax()-a._valueMin())/5);break;case b.ui.keyCode.PAGE_DOWN:h=a._trimAlignValue(e-(a._valueMax()-a._valueMin())/5);break;case b.ui.keyCode.UP:case b.ui.keyCode.RIGHT:if(e===a._valueMax())return;h=a._trimAlignValue(e+m);break;case b.ui.keyCode.DOWN:case b.ui.keyCode.LEFT:if(e===a._valueMin())return;h=a._trimAlignValue(e-m)}a._slide(c, +g,h);return d}}).keyup(function(c){var d=b(this).data("index.ui-slider-handle");a._keySliding&&(a._keySliding=!1,a._stop(c,d),a._change(c,d),b(this).removeClass("ui-state-active"))});this._refreshValue();this._animateOff=!1},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();return this},_mouseCapture:function(a){var c= +this.options,d,g,h,e,f;if(c.disabled)return!1;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();d=this._normValueFromMouse({x:a.pageX,y:a.pageY});g=this._valueMax()-this._valueMin()+1;e=this;this.handles.each(function(a){var c=Math.abs(d-e.values(a));g>c&&(g=c,h=b(this),f=a)});!0===c.range&&this.values(1)===c.min&&(f+=1,h=b(this.handles[f]));if(!1===this._start(a,f))return!1;this._mouseSliding=!0;e._handleIndex=f;h.addClass("ui-state-active").focus(); +c=h.offset();this._clickOffset=!b(a.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:a.pageX-c.left-h.width()/2,top:a.pageY-c.top-h.height()/2-(parseInt(h.css("borderTopWidth"),10)||0)-(parseInt(h.css("borderBottomWidth"),10)||0)+(parseInt(h.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(a,f,d);return this._animateOff=!0},_mouseStart:function(){return!0},_mouseDrag:function(b){var c=this._normValueFromMouse({x:b.pageX,y:b.pageY});this._slide(b, +this._handleIndex,c);return!1},_mouseStop:function(b){this.handles.removeClass("ui-state-active");this._mouseSliding=!1;this._stop(b,this._handleIndex);this._change(b,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(b){var c;"horizontal"===this.orientation?(c=this.elementSize.width,b=b.x-this.elementOffset.left-(this._clickOffset? +this._clickOffset.left:0)):(c=this.elementSize.height,b=b.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0));c=b/c;1c&&(c=0);"vertical"===this.orientation&&(c=1-c);b=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+c*b)},_start:function(b,c){var d={handle:this.handles[c],value:this.value()};this.options.values&&this.options.values.length&&(d.value=this.values(c),d.values=this.values());return this._trigger("start",b,d)},_slide:function(b, +c,d){var g;if(this.options.values&&this.options.values.length){g=this.values(c?0:1);if(2===this.options.values.length&&!0===this.options.range&&(0===c&&d>g||1===c&&d=this._valueMax())return this._valueMax();var c=0=c&&(alignValue+=0",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
  • #{label}
  • "},_create:function(){this._tabify(!0)},_setOption:function(b,a){"selected"==b?this.options.collapsible&&a==this.options.selected||this.select(a): +(this.options[b]=a,this._tabify())},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+ ++c},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var a=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++d);return b.cookie.apply(null,[a].concat(b.makeArray(arguments)))},_ui:function(b,a){return{tab:b,panel:a,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var a= +b(this);a.html(a.data("label.tabs")).removeData("label.tabs")})},_tabify:function(c){function d(a,c){a.css("display","");!b.support.opacity&&c.opacity&&a[0].style.removeAttribute("filter")}var e=this,f=this.options,i=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=b(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return b("a",this)[0]});this.panels=b([]);this.anchors.each(function(a,c){var d=b(c).attr("href"),g=d.split("#")[0],h;if(g&&(g===location.toString().split("#")[0]|| +(h=b("base")[0])&&g===h.href))d=c.hash,c.href=d;i.test(d)?e.panels=e.panels.add(e.element.find(e._sanitizeSelector(d))):d&&"#"!==d?(b.data(c,"href.tabs",d),b.data(c,"load.tabs",d.replace(/#.*$/,"")),d=e._tabId(c),c.href="#"+d,g=e.element.find("#"+d),g.length||(g=b(f.panelTemplate).attr("id",d).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(e.panels[a-1]||e.list),g.data("destroy.tabs",!0)),e.panels=e.panels.add(g)):f.disabled.push(a)});c?(this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"), +this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),this.lis.addClass("ui-state-default ui-corner-top"),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom"),f.selected===a?(location.hash&&this.anchors.each(function(b,a){if(a.hash==location.hash)return f.selected=b,!1}),"number"!==typeof f.selected&&f.cookie&&(f.selected=parseInt(e._cookie(),10)),"number"!==typeof f.selected&&this.lis.filter(".ui-tabs-selected").length&&(f.selected= +this.lis.index(this.lis.filter(".ui-tabs-selected"))),f.selected=f.selected||(this.lis.length?0:-1)):null===f.selected&&(f.selected=-1),f.selected=0<=f.selected&&this.anchors[f.selected]||0>f.selected?f.selected:0,f.disabled=b.unique(f.disabled.concat(b.map(this.lis.filter(".ui-state-disabled"),function(b){return e.lis.index(b)}))).sort(),-1!=b.inArray(f.selected,f.disabled)&&f.disabled.splice(b.inArray(f.selected,f.disabled),1),this.panels.addClass("ui-tabs-hide"),this.lis.removeClass("ui-tabs-selected ui-state-active"), +0<=f.selected&&this.anchors.length&&(e.element.find(e._sanitizeSelector(e.anchors[f.selected].hash)).removeClass("ui-tabs-hide"),this.lis.eq(f.selected).addClass("ui-tabs-selected ui-state-active"),e.element.queue("tabs",function(){e._trigger("show",null,e._ui(e.anchors[f.selected],e.element.find(e._sanitizeSelector(e.anchors[f.selected].hash))[0]))}),this.load(f.selected)),b(window).bind("unload",function(){e.lis.add(e.anchors).unbind(".tabs");e.lis=e.anchors=e.panels=null})):f.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); +this.element[f.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");f.cookie&&this._cookie(f.selected,f.cookie);for(var c=0,j;j=this.lis[c];c++)b(j)[-1!=b.inArray(c,f.disabled)&&!b(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");!1===f.cache&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if("mouseover"!==f.event){var k=function(b,a){a.is(":not(.ui-state-disabled)")&&a.addClass("ui-state-"+b)};this.lis.bind("mouseover.tabs", +function(){k("hover",b(this))});this.lis.bind("mouseout.tabs",function(){b(this).removeClass("ui-state-hover")});this.anchors.bind("focus.tabs",function(){k("focus",b(this).closest("li"))});this.anchors.bind("blur.tabs",function(){b(this).closest("li").removeClass("ui-state-focus")})}var l,m;f.fx&&(b.isArray(f.fx)?(l=f.fx[0],m=f.fx[1]):l=m=f.fx);var p=m?function(a,c){b(a).closest("li").addClass("ui-tabs-selected ui-state-active");c.hide().removeClass("ui-tabs-hide").animate(m,m.duration||"normal", +function(){d(c,m);e._trigger("show",null,e._ui(a,c[0]))})}:function(a,c){b(a).closest("li").addClass("ui-tabs-selected ui-state-active");c.removeClass("ui-tabs-hide");e._trigger("show",null,e._ui(a,c[0]))},n=l?function(b,a){a.animate(l,l.duration||"normal",function(){e.lis.removeClass("ui-tabs-selected ui-state-active");a.addClass("ui-tabs-hide");d(a,l);e.element.dequeue("tabs")})}:function(b,a){e.lis.removeClass("ui-tabs-selected ui-state-active");a.addClass("ui-tabs-hide");e.element.dequeue("tabs")}; +this.anchors.bind(f.event+".tabs",function(){var a=this,c=b(a).closest("li"),d=e.panels.filter(":not(.ui-tabs-hide)"),i=e.element.find(e._sanitizeSelector(a.hash));if(c.hasClass("ui-tabs-selected")&&!f.collapsible||c.hasClass("ui-state-disabled")||c.hasClass("ui-state-processing")||e.panels.filter(":animated").length||e._trigger("select",null,e._ui(this,i[0]))===false){this.blur();return false}f.selected=e.anchors.index(this);e.abort();if(f.collapsible){if(c.hasClass("ui-tabs-selected")){f.selected= +-1;f.cookie&&e._cookie(f.selected,f.cookie);e.element.queue("tabs",function(){n(a,d)}).dequeue("tabs");this.blur();return false}if(!d.length){f.cookie&&e._cookie(f.selected,f.cookie);e.element.queue("tabs",function(){p(a,i)});e.load(e.anchors.index(this));this.blur();return false}}f.cookie&&e._cookie(f.selected,f.cookie);if(i.length){d.length&&e.element.queue("tabs",function(){n(a,d)});e.element.queue("tabs",function(){p(a,i)});e.load(e.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; +b.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){"string"==typeof b&&(b=this.anchors.index(this.anchors.filter("[href$="+b+"]")));return b},destroy:function(){var a=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var a= +b.data(this,"href.tabs");a&&(this.href=a);var c=b(this).unbind(".tabs");b.each(["href","load","cache"],function(b,a){c.removeData(a+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){b.data(this,"destroy.tabs")?b(this).remove():b(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});a.cookie&&this._cookie(null,a.cookie);return this},add:function(c, +d,e){e===a&&(e=this.anchors.length);var f=this,i=this.options,d=b(i.tabTemplate.replace(/#\{href\}/g,c).replace(/#\{label\}/g,d)),c=!c.indexOf("#")?c.replace("#",""):this._tabId(b("a",d)[0]);d.addClass("ui-state-default ui-corner-top").data("destroy.tabs",!0);var j=f.element.find("#"+c);j.length||(j=b(i.panelTemplate).attr("id",c).data("destroy.tabs",!0));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");e>=this.lis.length?(d.appendTo(this.list),j.appendTo(this.list[0].parentNode)): +(d.insertBefore(this.lis[e]),j.insertBefore(this.panels[e]));i.disabled=b.map(i.disabled,function(b){return b>=e?++b:b});this._tabify();1==this.anchors.length&&(i.selected=0,d.addClass("ui-tabs-selected ui-state-active"),j.removeClass("ui-tabs-hide"),this.element.queue("tabs",function(){f._trigger("show",null,f._ui(f.anchors[0],f.panels[0]))}),this.load(0));this._trigger("add",null,this._ui(this.anchors[e],this.panels[e]));return this},remove:function(a){var a=this._getIndex(a),c=this.options,d=this.lis.eq(a).remove(), +f=this.panels.eq(a).remove();d.hasClass("ui-tabs-selected")&&1=a?--b:b});this._tabify();this._trigger("remove",null,this._ui(d.find("a")[0],f[0]));return this},enable:function(a){var a=this._getIndex(a),c=this.options;if(-1!=b.inArray(a,c.disabled))return this.lis.eq(a).removeClass("ui-state-disabled"),c.disabled=b.grep(c.disabled,function(b){return b!= +a}),this._trigger("enable",null,this._ui(this.anchors[a],this.panels[a])),this},disable:function(b){var b=this._getIndex(b),a=this.options;b!=a.selected&&(this.lis.eq(b).addClass("ui-state-disabled"),a.disabled.push(b),a.disabled.sort(),this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b])));return this},select:function(b){b=this._getIndex(b);if(-1==b)if(this.options.collapsible&&-1!=this.options.selected)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+ +".tabs");return this},load:function(a){var a=this._getIndex(a),c=this,d=this.options,f=this.anchors.eq(a)[0],i=b.data(f,"load.tabs");this.abort();if(!i||0!==this.element.queue("tabs").length&&b.data(f,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(a).addClass("ui-state-processing");if(d.spinner){var j=b("span",f);j.data("label.tabs",j.html()).html(d.spinner)}this.xhr=b.ajax(b.extend({},d.ajaxOptions,{url:i,success:function(i,j){c.element.find(c._sanitizeSelector(f.hash)).html(i);c._cleanup(); +d.cache&&b.data(f,"cache.tabs",!0);c._trigger("load",null,c._ui(c.anchors[a],c.panels[a]));try{d.ajaxOptions.success(i,j)}catch(m){}},error:function(b,i){c._cleanup();c._trigger("load",null,c._ui(c.anchors[a],c.panels[a]));try{d.ajaxOptions.error(b,i,a,f)}catch(m){}}}));c.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(!1,!0);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));this.xhr&&(this.xhr.abort(),delete this.xhr);this._cleanup(); +return this},url:function(b,a){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",a);return this},length:function(){return this.anchors.length}});b.extend(b.ui.tabs,{version:"1.8.14"});b.extend(b.ui.tabs.prototype,{rotation:null,rotate:function(b,a){var c=this,f=this.options,d=c._rotate||(c._rotate=function(a){clearTimeout(c.rotation);c.rotation=setTimeout(function(){var b=f.selected;c.select(++b'))}function d(a){return a.bind("mouseout",function(a){a=b(a.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a"); +a.length&&a.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(c){c=b(c.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");if(!b.datepicker._isDisabledDatepicker(e.inline?a.parent()[0]:e.input[0])&&c.length)c.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),c.addClass("ui-state-hover"),c.hasClass("ui-datepicker-prev")&&c.addClass("ui-datepicker-prev-hover"),c.hasClass("ui-datepicker-next")&& +c.addClass("ui-datepicker-next-hover")})}function g(c,d){b.extend(c,d);for(var e in d)if(null==d[e]||d[e]==a)c[e]=d[e];return c}b.extend(b.ui,{datepicker:{version:"1.8.14"}});var h=(new Date).getTime(),e;b.extend(c.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(b){g(this._defaults,b||{});return this},_attachDatepicker:function(a,c){var d=null,e;for(e in this._defaults){var g= +a.getAttribute("date:"+e);if(g){d=d||{};try{d[e]=eval(g)}catch(m){d[e]=g}}}e=a.nodeName.toLowerCase();g="div"==e||"span"==e;a.id||(this.uuid+=1,a.id="dp"+this.uuid);var h=this._newInst(b(a),g);h.settings=b.extend({},c||{},d||{});"input"==e?this._connectDatepicker(a,h):g&&this._inlineDatepicker(a,h)},_newInst:function(a,c){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:c,dpDiv:!c?this.dpDiv:d(b('
    '))}},_connectDatepicker:function(a,c){var d=b(a);c.append=b([]);c.trigger=b([]);d.hasClass(this.markerClassName)||(this._attachments(d,c),d.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(b,a,f){c.settings[a]=f}).bind("getData.datepicker",function(b,a){return this._get(c,a)}),this._autoSize(c),b.data(a,"datepicker", +c))},_attachments:function(a,c){var d=this._get(c,"appendText"),e=this._get(c,"isRTL");c.append&&c.append.remove();d&&(c.append=b(''+d+""),a[e?"before":"after"](c.append));a.unbind("focus",this._showDatepicker);c.trigger&&c.trigger.remove();d=this._get(c,"showOn");("focus"==d||"both"==d)&&a.focus(this._showDatepicker);if("button"==d||"both"==d){var d=this._get(c,"buttonText"),g=this._get(c,"buttonImage");c.trigger=b(this._get(c,"buttonImageOnly")?b("").addClass(this._triggerClass).attr({src:g, +alt:d,title:d}):b('').addClass(this._triggerClass).html(""==g?d:b("").attr({src:g,alt:d,title:d})));a[e?"before":"after"](c.trigger);c.trigger.click(function(){b.datepicker._datepickerShowing&&b.datepicker._lastInput==a[0]?b.datepicker._hideDatepicker():b.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(b){if(this._get(b,"autoSize")&&!b.inline){var a=new Date(2009,11,20),c=this._get(b,"dateFormat");if(c.match(/[DM]/)){var d=function(b){for(var a= +0,c=0,f=0;fa&&(a=b[f].length,c=f);return c};a.setMonth(d(this._get(b,c.match(/MM/)?"monthNames":"monthNamesShort")));a.setDate(d(this._get(b,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-a.getDay())}b.input.attr("size",this._formatDate(b,a).length)}},_inlineDatepicker:function(a,c){var d=b(a);d.hasClass(this.markerClassName)||(d.addClass(this.markerClassName).append(c.dpDiv).bind("setData.datepicker",function(b,a,f){c.settings[a]=f}).bind("getData.datepicker",function(b, +a){return this._get(c,a)}),b.data(a,"datepicker",c),this._setDate(c,this._getDefaultDate(c),!0),this._updateDatepicker(c),this._updateAlternate(c),c.dpDiv.show())},_dialogDatepicker:function(a,c,d,e,h){a=this._dialogInst;a||(this.uuid+=1,this._dialogInput=b(''),this._dialogInput.keydown(this._doKeyDown),b("body").append(this._dialogInput),a=this._dialogInst=this._newInst(this._dialogInput,!1), +a.settings={},b.data(this._dialogInput[0],"datepicker",a));g(a.settings,e||{});c=c&&c.constructor==Date?this._formatDate(a,c):c;this._dialogInput.val(c);this._pos=h?h.length?h:[h.pageX,h.pageY]:null;this._pos||(this._pos=[document.documentElement.clientWidth/2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)]);this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+ +"px");a.settings.onSelect=d;this._inDialog=!0;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);b.blockUI&&b.blockUI(this.dpDiv);b.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var c=b(a),d=b.data(a,"datepicker");if(c.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();b.removeData(a,"datepicker");"input"==e?(d.append.remove(),d.trigger.remove(),c.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown", +this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):("div"==e||"span"==e)&&c.removeClass(this.markerClassName).empty()}},_enableDatepicker:function(a){var c=b(a),d=b.data(a,"datepicker");if(c.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if("input"==e)a.disabled=!1,d.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""});else if("div"==e||"span"==e)c=c.children("."+this._inlineClass),c.children().removeClass("ui-state-disabled"), +c.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled");this._disabledInputs=b.map(this._disabledInputs,function(b){return b==a?null:b})}},_disableDatepicker:function(a){var c=b(a),d=b.data(a,"datepicker");if(c.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if("input"==e)a.disabled=!0,d.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"});else if("div"==e||"span"==e)c=c.children("."+this._inlineClass), +c.children().addClass("ui-state-disabled"),c.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled");this._disabledInputs=b.map(this._disabledInputs,function(b){return b==a?null:b});this._disabledInputs[this._disabledInputs.length]=a}},_isDisabledDatepicker:function(b){if(!b)return!1;for(var a=0;ae||!d||-1n&&n>e?Math.abs(c.left+e-n):0);c.top-=Math.min(c.top,c.top+g>q&&q>g?Math.abs(g+p):0);return c},_findPos:function(a){for(var c= +this._get(this._getInst(a),"isRTL");a&&("hidden"==a.type||1!=a.nodeType||b.expr.filters.hidden(a));)a=a[c?"previousSibling":"nextSibling"];a=b(a).offset();return[a.left,a.top]},_triggerOnClose:function(a){var b=this._get(a,"onClose");b&&b.apply(a.input?a.input[0]:null,[a.input?a.input.val():"",a])},_hideDatepicker:function(a){var c=this._curInst;if(c&&!(a&&c!=b.data(a,"datepicker"))&&this._datepickerShowing){var a=this._get(c,"showAnim"),d=this._get(c,"duration"),e=function(){b.datepicker._tidyDialog(c); +this._curInst=null};if(b.effects&&b.effects[a])c.dpDiv.hide(a,b.datepicker._get(c,"showOptions"),d,e);else c.dpDiv["slideDown"==a?"slideUp":"fadeIn"==a?"fadeOut":"hide"](a?d:null,e);a||e();b.datepicker._triggerOnClose(c);this._datepickerShowing=!1;this._lastInput=null;this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),b.blockUI&&(b.unblockUI(),b("body").append(this.dpDiv)));this._inDialog=!1}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")}, +_checkExternalClick:function(a){b.datepicker._curInst&&(a=b(a.target),a[0].id!=b.datepicker._mainDivId&&(0==a.parents("#"+b.datepicker._mainDivId).length&&!a.hasClass(b.datepicker.markerClassName)&&!a.hasClass(b.datepicker._triggerClass)&&b.datepicker._datepickerShowing&&(!b.datepicker._inDialog||!b.blockUI))&&b.datepicker._hideDatepicker())},_adjustDate:function(a,c,d){var a=b(a),e=this._getInst(a[0]);this._isDisabledDatepicker(a[0])||(this._adjustInstDate(e,c+("M"==d?this._get(e,"showCurrentAtPos"): +0),d),this._updateDatepicker(e))},_gotoToday:function(a){var a=b(a),c=this._getInst(a[0]);if(this._get(c,"gotoCurrent")&&c.currentDay)c.selectedDay=c.currentDay,c.drawMonth=c.selectedMonth=c.currentMonth,c.drawYear=c.selectedYear=c.currentYear;else{var d=new Date;c.selectedDay=d.getDate();c.drawMonth=c.selectedMonth=d.getMonth();c.drawYear=c.selectedYear=d.getFullYear()}this._notifyChange(c);this._adjustDate(a)},_selectMonthYear:function(a,c,d){var a=b(a),e=this._getInst(a[0]);e._selectingMonthYear= +!1;e["selected"+("M"==d?"Month":"Year")]=e["draw"+("M"==d?"Month":"Year")]=parseInt(c.options[c.selectedIndex].value,10);this._notifyChange(e);this._adjustDate(a)},_clickMonthYear:function(a){var c=this._getInst(b(a)[0]);c.input&&c._selectingMonthYear&&setTimeout(function(){c.input.focus()},0);c._selectingMonthYear=!c._selectingMonthYear},_selectDay:function(a,c,d,e){var g=b(a);!b(e).hasClass(this._unselectableClass)&&!this._isDisabledDatepicker(g[0])&&(g=this._getInst(g[0]),g.selectedDay=g.currentDay= +b("a",e).html(),g.selectedMonth=g.currentMonth=c,g.selectedYear=g.currentYear=d,this._selectDate(a,this._formatDate(g,g.currentDay,g.currentMonth,g.currentYear)))},_clearDate:function(a){a=b(a);this._getInst(a[0]);this._selectDate(a,"")},_selectDate:function(a,c){var d=this._getInst(b(a)[0]),c=null!=c?c:this._formatDate(d);d.input&&d.input.val(c);this._updateAlternate(d);var e=this._get(d,"onSelect");e?e.apply(d.input?d.input[0]:null,[c,d]):d.input&&d.input.trigger("change");d.inline?this._updateDatepicker(d): +(this._hideDatepicker(),this._lastInput=d.input[0],"object"!=typeof d.input[0]&&d.input.focus(),this._lastInput=null)},_updateAlternate:function(a){var c=this._get(a,"altField");if(c){var d=this._get(a,"altFormat")||this._get(a,"dateFormat"),e=this._getDate(a),g=this.formatDate(d,e,this._getFormatConfig(a));b(c).each(function(){b(this).val(g)})}},noWeekends:function(a){a=a.getDay();return[0a,""]},iso8601Week:function(a){a=new Date(a.getTime());a.setDate(a.getDate()+4-(a.getDay()||7));var b= +a.getTime();a.setMonth(0);a.setDate(1);return Math.floor(Math.round((b-a)/864E5)/7)+1},parseDate:function(a,c,d){if(null==a||null==c)throw"Invalid arguments";c="object"==typeof c?c.toString():c+"";if(""==c)return null;for(var e=(d?d.shortYearCutoff:null)||this._defaults.shortYearCutoff,e="string"!=typeof e?e:(new Date).getFullYear()%100+parseInt(e,10),g=(d?d.dayNamesShort:null)||this._defaults.dayNamesShort,h=(d?d.dayNames:null)||this._defaults.dayNames,p=(d?d.monthNamesShort:null)||this._defaults.monthNamesShort, +n=(d?d.monthNames:null)||this._defaults.monthNames,q=d=-1,o=-1,w=-1,r=!1,u=function(b){(b=E+1d&&(d+=(new Date).getFullYear()-(new Date).getFullYear()%100+(d<=e?0:-100));if(-1b.getYear()%100?"0":"")+b.getYear()%100;break;case "@":o+=b.getTime();break;case "!":o+=1E4*b.getTime()+this._ticksTo1970;break;case "'":h("'")?o+="'":w=!0;break;default:o+=a.charAt(r)}return o},_possibleChars:function(a){for(var b= +"",c=!1,d=function(b){(b=e+1n&&(n+=12,s--);if(u)for(var v=this._daylightSavingAdjust(new Date(u.getFullYear(),u.getMonth()-p[0]*p[1]+1,u.getDate())),v=r&&vv;)n--,0>n&&(n=11,s--);a.drawMonth=n;a.drawYear=s;var v=this._get(a,"prevText"),v=!m?v:this.formatDate(v,this._daylightSavingAdjust(new Date(s,n-q,1)),this._getFormatConfig(a)), +v=this._canAdjustMonth(a,-1,s,n)?''+v+"":g?"":''+v+"",z=this._get(a,"nextText"),z=!m?z:this.formatDate(z,this._daylightSavingAdjust(new Date(s, +n+q,1)),this._getFormatConfig(a)),g=this._canAdjustMonth(a,1,s,n)?''+z+"":g?"":''+z+"",q=this._get(a,"currentText"),z=this._get(a,"gotoCurrent")&& +a.currentDay?w:c,q=!m?q:this.formatDate(q,z,this._getFormatConfig(a)),m=!a.inline?'":"",e=e?'
    '+(d?m:"")+(this._isInRange(a,z)?'":"")+(d?"":m)+"
    ":"",m=parseInt(this._get(a,"firstDay"),10),m=isNaN(m)?0:m,q=this._get(a,"showWeek"),z=this._get(a,"dayNames");this._get(a,"dayNamesShort");var B=this._get(a,"dayNamesMin"),E=this._get(a,"monthNames"),C=this._get(a,"monthNamesShort"),O=this._get(a,"beforeShowDay"),K=this._get(a,"showOtherMonths"),S=this._get(a,"selectOtherMonths");this._get(a,"calculateWeek");for(var P=this._getDefaultDate(a),G="",H=0;H'+(/all|left/.test(A)&& +0==H?d?g:v:"")+(/all|right/.test(A)&&0==H?d?v:g:"")+this._generateMonthYearHeader(a,n,s,r,u,0
    '),D=q?'":"",A=0;7>A;A++)var x=(A+m)%7,D=D+("'+B[x]+"");y+=D+"";D=this._getDaysInMonth(s,n);s==a.selectedYear&&n==a.selectedMonth&&(a.selectedDay=Math.min(a.selectedDay, +D));A=(this._getFirstDayOfMonth(s,n)-m+7)%7;D=Math.ceil((A+D)/7);this.maxRows=D=o?this.maxRows>D?this.maxRows:D:D;for(var x=this._daylightSavingAdjust(new Date(s,n,1-A)),R=0;R",M=!q?"":'",A=0;7>A;A++){var J=O?O.apply(a.input?a.input[0]:null,[x]):[!0,""],F=x.getMonth()!=n,N=F&&!S||!J[0]||r&&xu,M=M+('");x.setDate(x.getDate()+1);x=this._daylightSavingAdjust(x)}y+=M+""}n++;11
    '+this._get(a,"weekHeader")+"
    '+this._get(a,"calculateWeek")(x)+""+(F&&!K? +" ":N?''+x.getDate()+"":''+x.getDate()+"")+"
    "+(o?""+(0':""):"");L+=y}G+=L}G+=e+(b.browser.msie&& +7>parseInt(b.browser.version,10)&&!a.inline?'':"");a._keyEvent=!1;return G},_generateMonthYearHeader:function(a,b,c,d,e,g,p,n){var q=this._get(a,"changeMonth"),o=this._get(a,"changeYear"),w=this._get(a,"showMonthAfterYear"),r='
    ',u="";if(g||!q)u+=''+p[b]+"";else{for(var p=d&&d.getFullYear()==c,s=e&&e.getFullYear()==c,u=u+('"}w||(r+=u+(g||!q||!o?" ":""));if(!a.yearshtml)if(a.yearshtml="",g||!o)r+=''+c+"";else{var n=this._get(a,"yearRange").split(":"),z=(new Date).getFullYear(),p=function(a){a= +a.match(/c[+-].*/)?c+parseInt(a.substring(1),10):a.match(/[+-].*/)?z+parseInt(a,10):parseInt(a,10);return isNaN(a)?z:a},b=p(n[0]),n=Math.max(b,p(n[1]||"")),b=d?Math.max(b,d.getFullYear()):b,n=e?Math.min(n,e.getFullYear()):n;for(a.yearshtml+='";r+=a.yearshtml;a.yearshtml=null}r+=this._get(a,"yearSuffix");w&&(r+=(g||!q||!o?" ":"")+u);return r+"
    "},_adjustInstDate:function(a,b,c){var d=a.drawYear+("Y"==c?b:0),e=a.drawMonth+("M"==c?b:0),b=Math.min(a.selectedDay,this._getDaysInMonth(d,e))+("D"==c?b:0),d=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(d,e,b)));a.selectedDay=d.getDate();a.drawMonth=a.selectedMonth=d.getMonth();a.drawYear=a.selectedYear=d.getFullYear();("M"==c|| +"Y"==c)&&this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max"),c=c&&bd?d:c},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");b&&b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return null==a?[1,1]:"number"==typeof a?[1,a]:a},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a, +b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,d){var e=this._getNumberOfMonths(a),c=this._daylightSavingAdjust(new Date(c,d+(0>b?b:e[0]*e[1]),1));0>b&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(a,c)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!d||b.getTime()<= +d.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff"),b="string"!=typeof b?b:(new Date).getFullYear()%100+parseInt(b,10);return{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,d){b||(a.currentDay=a.selectedDay,a.currentMonth=a.selectedMonth,a.currentYear=a.selectedYear);b=b?"object"==typeof b?b:this._daylightSavingAdjust(new Date(d, +c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),b,this._getFormatConfig(a))}});b.fn.datepicker=function(a){if(!this.length)return this;b.datepicker.initialized||(b(document).mousedown(b.datepicker._checkExternalClick).find("body").append(b.datepicker.dpDiv),b.datepicker.initialized=!0);var c=Array.prototype.slice.call(arguments,1);return"string"==typeof a&&("isDisabled"==a||"getDate"==a||"widget"==a)||"option"== +a&&2==arguments.length&&"string"==typeof arguments[1]?b.datepicker["_"+a+"Datepicker"].apply(b.datepicker,[this[0]].concat(c)):this.each(function(){typeof a=="string"?b.datepicker["_"+a+"Datepicker"].apply(b.datepicker,[this].concat(c)):b.datepicker._attachDatepicker(this,a)})};b.datepicker=new c;b.datepicker.initialized=!1;b.datepicker.uuid=(new Date).getTime();b.datepicker.version="1.8.14";window["DP_jQuery_"+h]=b})(jQuery); +(function(b,a){b.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()});this.valueDiv=b("
    ").appendTo(this.element);this.oldValue=this._value();this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"); +this.valueDiv.remove();b.Widget.prototype.destroy.apply(this,arguments)},value:function(b){if(b===a)return this._value();this._setOption("value",b);return this},_setOption:function(a,d){"value"===a&&(this.options.value=d,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete"));b.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;"number"!==typeof a&&(a=0);return Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100* +this._value()/this.options.max},_refreshValue:function(){var a=this.value(),b=this._percentage();this.oldValue!==a&&(this.oldValue=a,this._trigger("change"));this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(b.toFixed(0)+"%");this.element.attr("aria-valuenow",a)}});b.extend(b.ui.progressbar,{version:"1.8.14"})})(jQuery); +jQuery.effects||function(b,a){function c(a){var c;return a&&a.constructor==Array&&3==a.length?a:(c=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(a))?[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10)]:(c=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(a))?[2.55*parseFloat(c[1]),2.55*parseFloat(c[2]),2.55*parseFloat(c[3])]:(c=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(a))?[parseInt(c[1],16),parseInt(c[2], +16),parseInt(c[3],16)]:(c=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(a))?[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)]:/rgba\(0, 0, 0, 0\)/.exec(a)?i.transparent:i[b.trim(a).toLowerCase()]}function d(){var a=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,b={},c,d;if(a&&a.length&&a[0]&&a[a[0]])for(var e=a.length;e--;)c=a[e],"string"==typeof a[c]&&(d=c.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()}),b[d]=a[c]);else for(c in a)"string"=== +typeof a[c]&&(b[c]=a[c]);return b}function g(a){var c,d;for(c in a)d=a[c],(null==d||b.isFunction(d)||c in k||/scrollbar/.test(c)||!/color/i.test(c)&&isNaN(parseFloat(d)))&&delete a[c];return a}function h(a,b){var c={_:0},d;for(d in b)a[d]!=b[d]&&(c[d]=b[d]);return c}function e(a,c,d,e){"object"==typeof a&&(e=c,d=null,c=a,a=c.effect);b.isFunction(c)&&(e=c,d=null,c={});if("number"==typeof c||b.fx.speeds[c])e=d,d=c,c={};b.isFunction(d)&&(e=d,d=null);c=c||{};d=d||c.duration;d=b.fx.off?0:"number"==typeof d? +d:d in b.fx.speeds?b.fx.speeds[d]:b.fx.speeds._default;e=e||c.complete;return[a,c,d,e]}function f(a){return!a||("number"===typeof a||b.fx.speeds[a])||"string"===typeof a&&!b.effects[a]?!0:!1}b.effects={};b.each("backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor borderColor color outlineColor".split(" "),function(a,d){b.fx.step[d]=function(a){if(!a.colorInit){var e;e=a.elem;var f=d,g;do{g=b.curCSS(e,f);if(g!=""&&g!="transparent"||b.nodeName(e,"body"))break;f="backgroundColor"}while(e= +e.parentNode);e=c(g);a.start=e;a.end=c(a.end);a.colorInit=true}a.elem.style[d]="rgb("+Math.max(Math.min(parseInt(a.pos*(a.end[0]-a.start[0])+a.start[0],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[1]-a.start[1])+a.start[1],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[2]-a.start[2])+a.start[2],10),255),0)+")"}});var i={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139], +darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255], +maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},j=["add","remove","toggle"],k={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};b.effects.animateClass=function(a,c,e,f){b.isFunction(e)&&(f=e,e=null);return this.queue(function(){var i=b(this),o=i.attr("style")|| +" ",k=g(d.call(this)),r,u=i.attr("class");b.each(j,function(b,c){if(a[c])i[c+"Class"](a[c])});r=g(d.call(this));i.attr("class",u);i.animate(h(k,r),{queue:false,duration:c,easing:e,complete:function(){b.each(j,function(b,c){if(a[c])i[c+"Class"](a[c])});if(typeof i.attr("style")=="object"){i.attr("style").cssText="";i.attr("style").cssText=o}else i.attr("style",o);f&&f.apply(this,arguments);b.dequeue(this)}})})};b.fn.extend({_addClass:b.fn.addClass,addClass:function(a,c,d,e){return c?b.effects.animateClass.apply(this, +[{add:a},c,d,e]):this._addClass(a)},_removeClass:b.fn.removeClass,removeClass:function(a,c,d,e){return c?b.effects.animateClass.apply(this,[{remove:a},c,d,e]):this._removeClass(a)},_toggleClass:b.fn.toggleClass,toggleClass:function(c,d,e,f,g){return"boolean"==typeof d||d===a?e?b.effects.animateClass.apply(this,[d?{add:c}:{remove:c},e,f,g]):this._toggleClass(c,d):b.effects.animateClass.apply(this,[{toggle:c},d,e,f])},switchClass:function(a,c,d,e,f){return b.effects.animateClass.apply(this,[{add:c, +remove:a},d,e,f])}});b.extend(b.effects,{version:"1.8.14",save:function(a,b){for(var c=0;c").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});a.wrap(d);d=a.parent();"static"==a.css("position")?(d.css({position:"relative"}),a.css({position:"relative"})): +(b.extend(c,{position:a.css("position"),zIndex:a.css("z-index")}),b.each(["top","left","bottom","right"],function(b,d){c[d]=a.css(d);isNaN(parseInt(c[d],10))&&(c[d]="auto")}),a.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"}));return d.css(c).show()},removeWrapper:function(a){return a.parent().is(".ui-effects-wrapper")?a.parent().replaceWith(a):a},setTransition:function(a,c,d,e){e=e||{};b.each(c,function(b,c){unit=a.cssUnit(c);0(b/=e/2)?d/2*b*b+c:-d/2*(--b*(b-2)-1)+c},easeInCubic:function(a,b,c,d,e){return d*(b/=e)*b*b+c},easeOutCubic:function(a,b,c,d,e){return d*((b=b/e-1)*b*b+1)+c},easeInOutCubic:function(a,b,c,d,e){return 1>(b/=e/2)?d/2*b*b*b+c:d/2*((b-=2)*b*b+2)+c},easeInQuart:function(a,b,c,d,e){return d*(b/=e)*b*b*b+c}, +easeOutQuart:function(a,b,c,d,e){return-d*((b=b/e-1)*b*b*b-1)+c},easeInOutQuart:function(a,b,c,d,e){return 1>(b/=e/2)?d/2*b*b*b*b+c:-d/2*((b-=2)*b*b*b-2)+c},easeInQuint:function(a,b,c,d,e){return d*(b/=e)*b*b*b*b+c},easeOutQuint:function(a,b,c,d,e){return d*((b=b/e-1)*b*b*b*b+1)+c},easeInOutQuint:function(a,b,c,d,e){return 1>(b/=e/2)?d/2*b*b*b*b*b+c:d/2*((b-=2)*b*b*b*b+2)+c},easeInSine:function(a,b,c,d,e){return-d*Math.cos(b/e*(Math.PI/2))+d+c},easeOutSine:function(a,b,c,d,e){return d*Math.sin(b/ +e*(Math.PI/2))+c},easeInOutSine:function(a,b,c,d,e){return-d/2*(Math.cos(Math.PI*b/e)-1)+c},easeInExpo:function(a,b,c,d,e){return 0==b?c:d*Math.pow(2,10*(b/e-1))+c},easeOutExpo:function(a,b,c,d,e){return b==e?c+d:d*(-Math.pow(2,-10*b/e)+1)+c},easeInOutExpo:function(a,b,c,d,e){return 0==b?c:b==e?c+d:1>(b/=e/2)?d/2*Math.pow(2,10*(b-1))+c:d/2*(-Math.pow(2,-10*--b)+2)+c},easeInCirc:function(a,b,c,d,e){return-d*(Math.sqrt(1-(b/=e)*b)-1)+c},easeOutCirc:function(a,b,c,d,e){return d*Math.sqrt(1-(b=b/e-1)* +b)+c},easeInOutCirc:function(a,b,c,d,e){return 1>(b/=e/2)?-d/2*(Math.sqrt(1-b*b)-1)+c:d/2*(Math.sqrt(1-(b-=2)*b)+1)+c},easeInElastic:function(a,b,c,d,e){var a=1.70158,f=0,g=d;if(0==b)return c;if(1==(b/=e))return c+d;f||(f=0.3*e);gb?-0.5*g*Math.pow(2,10*(b-=1))*Math.sin((b*e-a)*2*Math.PI/f)+c:0.5*g*Math.pow(2,-10*(b-=1))*Math.sin((b*e-a)*2*Math.PI/f)+d+c},easeInBack:function(b,c,d,e,f,g){g==a&&(g=1.70158);return e*(c/=f)*c*((g+1)*c-g)+d},easeOutBack:function(b,c,d,e, +f,g){g==a&&(g=1.70158);return e*((c=c/f-1)*c*((g+1)*c+g)+1)+d},easeInOutBack:function(b,c,d,e,f,g){g==a&&(g=1.70158);return 1>(c/=f/2)?e/2*c*c*(((g*=1.525)+1)*c-g)+d:e/2*((c-=2)*c*(((g*=1.525)+1)*c+g)+2)+d},easeInBounce:function(a,c,d,e,f){return e-b.easing.easeOutBounce(a,f-c,0,e,f)+d},easeOutBounce:function(a,b,c,d,e){return(b/=e)<1/2.75?d*7.5625*b*b+c:b<2/2.75?d*(7.5625*(b-=1.5/2.75)*b+0.75)+c:b<2.5/2.75?d*(7.5625*(b-=2.25/2.75)*b+0.9375)+c:d*(7.5625*(b-=2.625/2.75)*b+0.984375)+c},easeInOutBounce:function(a, +c,d,e,f){return c").css({position:"absolute",visibility:"visible",left:-j*(e/d),top:-i*(f/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:e/d,height:f/c,left:h.left+j*(e/d)+("show"==a.options.mode?(j-Math.floor(d/2))*(e/d):0),top:h.top+i*(f/c)+("show"==a.options.mode?(i-Math.floor(c/2))*(f/c):0),opacity:"show"==a.options.mode?0:1}).animate({left:h.left+j*(e/d)+("show"==a.options.mode?0:(j-Math.floor(d/2))*(e/d)),top:h.top+ +i*(f/c)+("show"==a.options.mode?0:(i-Math.floor(c/2))*(f/c)),opacity:"show"==a.options.mode?1:0},a.duration||500);setTimeout(function(){"show"==a.options.mode?g.css({visibility:"visible"}):g.css({visibility:"visible"}).hide();a.callback&&a.callback.apply(g[0]);g.dequeue();b("div.ui-effects-explode").remove()},a.duration||500)})}})(jQuery); +(function(b){b.effects.fade=function(a){return this.queue(function(){var c=b(this),d=b.effects.setMode(c,a.options.mode||"hide");c.animate({opacity:d},{queue:!1,duration:a.duration,easing:a.options.easing,complete:function(){a.callback&&a.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery); +(function(b){b.effects.fold=function(a){return this.queue(function(){var c=b(this),d=["position","top","bottom","left","right"],g=b.effects.setMode(c,a.options.mode||"hide"),h=a.options.size||15,e=!!a.options.horizFirst,f=a.duration?a.duration/2:b.fx.speeds._default/2;b.effects.save(c,d);c.show();var i=b.effects.createWrapper(c).css({overflow:"hidden"}),j="show"==g!=e,k=j?["width","height"]:["height","width"],j=j?[i.width(),i.height()]:[i.height(),i.width()],l=/([0-9]+)%/.exec(h);l&&(h=parseInt(l[1], +10)/100*j["hide"==g?0:1]);"show"==g&&i.css(e?{height:0,width:h}:{height:h,width:0});e={};l={};e[k[0]]="show"==g?j[0]:h;l[k[1]]="show"==g?j[1]:0;i.animate(e,f,a.options.easing).animate(l,f,a.options.easing,function(){"hide"==g&&c.hide();b.effects.restore(c,d);b.effects.removeWrapper(c);a.callback&&a.callback.apply(c[0],arguments);c.dequeue()})})}})(jQuery); +(function(b){b.effects.highlight=function(a){return this.queue(function(){var c=b(this),d=["backgroundImage","backgroundColor","opacity"],g=b.effects.setMode(c,a.options.mode||"show"),h={backgroundColor:c.css("backgroundColor")};"hide"==g&&(h.opacity=0);b.effects.save(c,d);c.show().css({backgroundImage:"none",backgroundColor:a.options.color||"#ffff99"}).animate(h,{queue:!1,duration:a.duration,easing:a.options.easing,complete:function(){g=="hide"&&c.hide();b.effects.restore(c,d);g=="show"&&!b.support.opacity&& +this.style.removeAttribute("filter");a.callback&&a.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery); +(function(b){b.effects.pulsate=function(a){return this.queue(function(){var c=b(this),d=b.effects.setMode(c,a.options.mode||"show");times=2*(a.options.times||5)-1;duration=a.duration?a.duration/2:b.fx.speeds._default/2;isVisible=c.is(":visible");animateTo=0;isVisible||(c.css("opacity",0).show(),animateTo=1);("hide"==d&&isVisible||"show"==d&&!isVisible)&×--;for(d=0;d').appendTo(document.body).addClass(a.options.className).css({top:g.top,left:g.left,height:c.innerHeight(),width:c.innerWidth(),position:"absolute"}).animate(d,a.duration,a.options.easing,function(){h.remove();a.callback&&a.callback.apply(c[0],arguments);c.dequeue()})})}})(jQuery); +/* + * jQuery Highlight plugin + * Based on highlight v3 by Johann Burkard + * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html + * Copyright (c) 2009 Bartek Szopka http://bartaz.github.com/sandbox.js/jquery.highlight.html + * Licensed under MIT license. + */ +jQuery.extend({highlight:function(a,c,b,e){if(a.nodeType===3){if(c=a.data.match(c)){b=document.createElement(b||"span");b.className=e||"highlight";a=a.splitText(c.index);a.splitText(c[0].length);e=a.cloneNode(true);b.appendChild(e);a.parentNode.replaceChild(b,a);return 1}}else if(a.nodeType===1&&a.childNodes&&!/(script|style)/i.test(a.tagName)&&!(a.tagName===b.toUpperCase()&&a.className===e))for(var d=0;d').appendTo("body"); + var d = { width: $c.width() - $c[0].clientWidth, height: $c.height() - $c[0].clientHeight }; + $c.remove(); + window.scrollbarWidth = d.width; + window.scrollbarHeight = d.height; + return dim.match(/^(width|height)$/) ? d[dim] : d; + } + + + /** + * Returns hash container 'display' and 'visibility' + * + * @see $.swap() - swaps CSS, runs callback, resets CSS + */ +, showInvisibly: function ($E, force) { + if (!$E) return {}; + if (!$E.jquery) $E = $($E); + var CSS = { + display: $E.css('display') + , visibility: $E.css('visibility') + }; + if (force || CSS.display === "none") { // only if not *already hidden* + $E.css({ display: "block", visibility: "hidden" }); // show element 'invisibly' so can be measured + return CSS; + } + else return {}; + } + + /** + * Returns data for setting size of an element (container or a pane). + * + * @see _create(), onWindowResize() for container, plus others for pane + * @return JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc + */ +, getElementDimensions: function ($E) { + var + d = {} // dimensions hash + , x = d.css = {} // CSS hash + , i = {} // TEMP insets + , b, p // TEMP border, padding + , N = $.layout.cssNum + , off = $E.offset() + ; + d.offsetLeft = off.left; + d.offsetTop = off.top; + + $.each("Left,Right,Top,Bottom".split(","), function (idx, e) { // e = edge + b = x["border" + e] = $.layout.borderWidth($E, e); + p = x["padding"+ e] = $.layout.cssNum($E, "padding"+e); + i[e] = b + p; // total offset of content from outer side + d["inset"+ e] = p; + }); + + d.offsetWidth = $E.innerWidth(); // offsetWidth is used in calc when doing manual resize + d.offsetHeight = $E.innerHeight(); // ditto + d.outerWidth = $E.outerWidth(); + d.outerHeight = $E.outerHeight(); + d.innerWidth = max(0, d.outerWidth - i.Left - i.Right); + d.innerHeight = max(0, d.outerHeight - i.Top - i.Bottom); + + x.width = $E.width(); + x.height = $E.height(); + x.top = N($E,"top",true); + x.bottom = N($E,"bottom",true); + x.left = N($E,"left",true); + x.right = N($E,"right",true); + + //d.visible = $E.is(":visible");// && x.width > 0 && x.height > 0; + + return d; + } + +, getElementCSS: function ($E, list) { + var + CSS = {} + , style = $E[0].style + , props = list.split(",") + , sides = "Top,Bottom,Left,Right".split(",") + , attrs = "Color,Style,Width".split(",") + , p, s, a, i, j, k + ; + for (i=0; i < props.length; i++) { + p = props[i]; + if (p.match(/(border|padding|margin)$/)) + for (j=0; j < 4; j++) { + s = sides[j]; + if (p === "border") + for (k=0; k < 3; k++) { + a = attrs[k]; + CSS[p+s+a] = style[p+s+a]; + } + else + CSS[p+s] = style[p+s]; + } + else + CSS[p] = style[p]; + }; + return CSS + } + + /** + * Return the innerWidth for the current browser/doctype + * + * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles() + * @param {Array.} $E Must pass a jQuery object - first element is processed + * @param {number=} outerWidth (optional) Can pass a width, allowing calculations BEFORE element is resized + * @return {number} Returns the innerWidth of the elem by subtracting padding and borders + */ +, cssWidth: function ($E, outerWidth) { + var + b = $.layout.borderWidth + , n = $.layout.cssNum + ; + // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed + if (outerWidth <= 0) return 0; + + if (!$.support.boxModel) return outerWidth; + + // strip border and padding from outerWidth to get CSS Width + var W = outerWidth + - b($E, "Left") + - b($E, "Right") + - n($E, "paddingLeft") + - n($E, "paddingRight") + ; + + return max(0,W); + } + + /** + * Return the innerHeight for the current browser/doctype + * + * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles() + * @param {Array.} $E Must pass a jQuery object - first element is processed + * @param {number=} outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized + * @return {number} Returns the innerHeight of the elem by subtracting padding and borders + */ +, cssHeight: function ($E, outerHeight) { + var + b = $.layout.borderWidth + , n = $.layout.cssNum + ; + // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed + if (outerHeight <= 0) return 0; + + if (!$.support.boxModel) return outerHeight; + + // strip border and padding from outerHeight to get CSS Height + var H = outerHeight + - b($E, "Top") + - b($E, "Bottom") + - n($E, "paddingTop") + - n($E, "paddingBottom") + ; + + return max(0,H); + } + + /** + * Returns the 'current CSS numeric value' for a CSS property - 0 if property does not exist + * + * @see Called by many methods + * @param {Array.} $E Must pass a jQuery object - first element is processed + * @param {string} prop The name of the CSS property, eg: top, width, etc. + * @param {boolean=} [allowAuto=false] true = return 'auto' if that is value; false = return 0 + * @return {(string|number)} Usually used to get an integer value for position (top, left) or size (height, width) + */ +, cssNum: function ($E, prop, allowAuto) { + if (!$E.jquery) $E = $($E); + var CSS = $.layout.showInvisibly($E) + , p = $.curCSS($E[0], prop, true) + , v = allowAuto && p=="auto" ? p : (parseInt(p, 10) || 0); + $E.css( CSS ); // RESET + return v; + } + +, borderWidth: function (el, side) { + if (el.jquery) el = el[0]; + var b = "border"+ side.substr(0,1).toUpperCase() + side.substr(1); // left => Left + return $.curCSS(el, b+"Style", true) === "none" ? 0 : (parseInt($.curCSS(el, b+"Width", true), 10) || 0); + } + + /** + * Mouse-tracking utility - FUTURE REFERENCE + * + * init: if (!window.mouse) { + * window.mouse = { x: 0, y: 0 }; + * $(document).mousemove( $.layout.trackMouse ); + * } + * + * @param {Object} evt + * +, trackMouse: function (evt) { + window.mouse = { x: evt.clientX, y: evt.clientY }; + } + */ + + /** + * SUBROUTINE for preventPrematureSlideClose option + * + * @param {Object} evt + * @param {Object=} el + */ +, isMouseOverElem: function (evt, el) { + var + $E = $(el || this) + , d = $E.offset() + , T = d.top + , L = d.left + , R = L + $E.outerWidth() + , B = T + $E.outerHeight() + , x = evt.pageX // evt.clientX ? + , y = evt.pageY // evt.clientY ? + ; + // if X & Y are < 0, probably means is over an open SELECT + return ($.layout.browser.msie && x < 0 && y < 0) || ((x >= L && x <= R) && (y >= T && y <= B)); + } + + /** + * Message/Logging Utility + * + * @example $.layout.msg("My message"); // log text + * @example $.layout.msg("My message", true); // alert text + * @example $.layout.msg({ foo: "bar" }, "Title"); // log hash-data, with custom title + * @example $.layout.msg({ foo: "bar" }, true, "Title", { sort: false }); -OR- + * @example $.layout.msg({ foo: "bar" }, "Title", { sort: false, display: true }); // alert hash-data + * + * @param {(Object|string)} info String message OR Hash/Array + * @param {(Boolean|string|Object)=} [popup=false] True means alert-box - can be skipped + * @param {(Object|string)=} [debugTitle=""] Title for Hash data - can be skipped + * @param {Object=} [debutOpts={}] Extra options for debug output + */ +, msg: function (info, popup, debugTitle, debugOpts) { + if ($.isPlainObject(info) && window.debugData) { + if (typeof popup === "string") { + debugOpts = debugTitle; + debugTitle = popup; + } + else if (typeof debugTitle === "object") { + debugOpts = debugTitle; + debugTitle = null; + } + var t = debugTitle || "log( )" + , o = $.extend({ sort: false, returnHTML: false, display: false }, debugOpts); + if (popup === true || o.display) + debugData( info, t, o ); + else if (window.console) + console.log(debugData( info, t, o )); + } + else if (popup) + alert(info); + else if (window.console) + console.log(info); + else { + var id = "#layoutLogger" + , $l = $(id); + if (!$l.length) + $l = createLog(); + $l.children("ul").append('
  • '+ info.replace(/\/g,">") +'
  • '); + } + + function createLog () { + var pos = $.support.fixedPosition ? 'fixed' : 'absolute' + , $e = $('
    ' + + '
    ' + + 'XLayout console.log
    ' + + '
      ' + + '
      ' + ).appendTo("body"); + $e.css('left', $(window).width() - $e.outerWidth() - 5) + if ($.ui.draggable) $e.draggable({ handle: ':first-child' }); + return $e; + }; + } + +}; + +var lang = $.layout.language; // alias used in defaults... + +// DEFAULT OPTIONS - CHANGE IF DESIRED +$.layout.defaults = { +/* + * LAYOUT & LAYOUT-CONTAINER OPTIONS + * - none of these options are applicable to individual panes + */ + name: "" // Not required, but useful for buttons and used for the state-cookie +, containerSelector: "" // ONLY used when specifying a childOptions - to find container-element that is NOT directly-nested +, containerClass: "ui-layout-container" // layout-container element +, scrollToBookmarkOnLoad: true // after creating a layout, scroll to bookmark in URL (.../page.htm#myBookmark) +, resizeWithWindow: true // bind thisLayout.resizeAll() to the window.resize event +, resizeWithWindowDelay: 200 // delay calling resizeAll because makes window resizing very jerky +, resizeWithWindowMaxDelay: 0 // 0 = none - force resize every XX ms while window is being resized +, onresizeall_start: null // CALLBACK when resizeAll() STARTS - NOT pane-specific +, onresizeall_end: null // CALLBACK when resizeAll() ENDS - NOT pane-specific +, onload_start: null // CALLBACK when Layout inits - after options initialized, but before elements +, onload_end: null // CALLBACK when Layout inits - after EVERYTHING has been initialized +, onunload_start: null // CALLBACK when Layout is destroyed OR onWindowUnload +, onunload_end: null // CALLBACK when Layout is destroyed OR onWindowUnload +, autoBindCustomButtons: false // search for buttons with ui-layout-button class and auto-bind them +, initPanes: true // false = DO NOT initialize the panes onLoad - will init later +, showErrorMessages: true // enables fatal error messages to warn developers of common errors +, showDebugMessages: false // display console-and-alert debug msgs - IF this Layout version _has_ debugging code! +// Changing this zIndex value will cause other zIndex values to automatically change +, zIndex: null // the PANE zIndex - resizers and masks will be +1 +// DO NOT CHANGE the zIndex values below unless you clearly understand their relationships +, zIndexes: { // set _default_ z-index values here... + pane_normal: 0 // normal z-index for panes + , content_mask: 1 // applied to overlays used to mask content INSIDE panes during resizing + , resizer_normal: 2 // normal z-index for resizer-bars + , pane_sliding: 100 // applied to *BOTH* the pane and its resizer when a pane is 'slid open' + , pane_animate: 1000 // applied to the pane when being animated - not applied to the resizer + , resizer_drag: 10000 // applied to the CLONED resizer-bar when being 'dragged' + } +/* + * PANE DEFAULT SETTINGS + * - settings under the 'panes' key become the default settings for *all panes* + * - ALL pane-options can also be set specifically for each panes, which will override these 'default values' + */ +, panes: { // default options for 'all panes' - will be overridden by 'per-pane settings' + applyDemoStyles: false // NOTE: renamed from applyDefaultStyles for clarity + , closable: true // pane can open & close + , resizable: true // when open, pane can be resized + , slidable: true // when closed, pane can 'slide open' over other panes - closes on mouse-out + , initClosed: false // true = init pane as 'closed' + , initHidden: false // true = init pane as 'hidden' - no resizer-bar/spacing + // SELECTORS + //, paneSelector: "" // MUST be pane-specific - jQuery selector for pane + , contentSelector: ".ui-layout-content" // INNER div/element to auto-size so only it scrolls, not the entire pane! + , contentIgnoreSelector: ".ui-layout-ignore" // element(s) to 'ignore' when measuring 'content' + , findNestedContent: false // true = $P.find(contentSelector), false = $P.children(contentSelector) + // GENERIC ROOT-CLASSES - for auto-generated classNames + , paneClass: "ui-layout-pane" // Layout Pane + , resizerClass: "ui-layout-resizer" // Resizer Bar + , togglerClass: "ui-layout-toggler" // Toggler Button + , buttonClass: "ui-layout-button" // CUSTOM Buttons - eg: '[ui-layout-button]-toggle/-open/-close/-pin' + // ELEMENT SIZE & SPACING + //, size: 100 // MUST be pane-specific -initial size of pane + , minSize: 0 // when manually resizing a pane + , maxSize: 0 // ditto, 0 = no limit + , spacing_open: 6 // space between pane and adjacent panes - when pane is 'open' + , spacing_closed: 6 // ditto - when pane is 'closed' + , togglerLength_open: 50 // Length = WIDTH of toggler button on north/south sides - HEIGHT on east/west sides + , togglerLength_closed: 50 // 100% OR -1 means 'full height/width of resizer bar' - 0 means 'hidden' + , togglerAlign_open: "center" // top/left, bottom/right, center, OR... + , togglerAlign_closed: "center" // 1 => nn = offset from top/left, -1 => -nn == offset from bottom/right + , togglerTip_open: lang.Close // Toggler tool-tip (title) + , togglerTip_closed: lang.Open // ditto + , togglerContent_open: "" // text or HTML to put INSIDE the toggler + , togglerContent_closed: "" // ditto + // RESIZING OPTIONS + , resizerDblClickToggle: true // + , autoResize: true // IF size is 'auto' or a percentage, then recalc 'pixel size' whenever the layout resizes + , autoReopen: true // IF a pane was auto-closed due to noRoom, reopen it when there is room? False = leave it closed + , resizerDragOpacity: 1 // option for ui.draggable + //, resizerCursor: "" // MUST be pane-specific - cursor when over resizer-bar + , maskContents: false // true = add DIV-mask over-or-inside this pane so can 'drag' over IFRAMES + , maskObjects: false // true = add IFRAME-mask over-or-inside this pane to cover objects/applets - content-mask will overlay this mask + , maskZindex: null // will override zIndexes.content_mask if specified - not applicable to iframe-panes + , resizingGrid: false // grid size that the resizers will snap-to during resizing, eg: [20,20] + , livePaneResizing: false // true = LIVE Resizing as resizer is dragged + , liveContentResizing: false // true = re-measure header/footer heights as resizer is dragged + , liveResizingTolerance: 1 // how many px change before pane resizes, to control performance + // TIPS & MESSAGES - also see lang object + , noRoomToOpenTip: lang.noRoomToOpenTip + , resizerTip: lang.Resize // Resizer tool-tip (title) + , sliderTip: lang.Slide // resizer-bar triggers 'sliding' when pane is closed + , sliderCursor: "pointer" // cursor when resizer-bar will trigger 'sliding' + , slideTrigger_open: "click" // click, dblclick, mouseenter + , slideTrigger_close: "mouseleave"// click, mouseleave + , slideDelay_open: 300 // applies only for mouseenter event - 0 = instant open + , slideDelay_close: 300 // applies only for mouseleave event (300ms is the minimum!) + , hideTogglerOnSlide: false // when pane is slid-open, should the toggler show? + , preventQuickSlideClose: $.layout.browser.webkit // Chrome triggers slideClosed as it is opening + , preventPrematureSlideClose: false // handle incorrect mouseleave trigger, like when over a SELECT-list in IE + // HOT-KEYS & MISC + , showOverflowOnHover: false // will bind allowOverflow() utility to pane.onMouseOver + , enableCursorHotkey: true // enabled 'cursor' hotkeys + //, customHotkey: "" // MUST be pane-specific - EITHER a charCode OR a character + , customHotkeyModifier: "SHIFT" // either 'SHIFT', 'CTRL' or 'CTRL+SHIFT' - NOT 'ALT' + // PANE ANIMATION + // NOTE: fxSss_open, fxSss_close & fxSss_size options (eg: fxName_open) are auto-generated if not passed + , fxName: "slide" // ('none' or blank), slide, drop, scale -- only relevant to 'open' & 'close', NOT 'size' + , fxSpeed: null // slow, normal, fast, 200, nnn - if passed, will OVERRIDE fxSettings.duration + , fxSettings: {} // can be passed, eg: { easing: "easeOutBounce", duration: 1500 } + , fxOpacityFix: true // tries to fix opacity in IE to restore anti-aliasing after animation + , animatePaneSizing: false // true = animate resizing after dragging resizer-bar OR sizePane() is called + /* NOTE: Action-specific FX options are auto-generated from the options above if not specifically set: + fxName_open: "slide" // 'Open' pane animation + fnName_close: "slide" // 'Close' pane animation + fxName_size: "slide" // 'Size' pane animation - when animatePaneSizing = true + fxSpeed_open: null + fxSpeed_close: null + fxSpeed_size: null + fxSettings_open: {} + fxSettings_close: {} + fxSettings_size: {} + */ + // CHILD/NESTED LAYOUTS + , childOptions: null // Layout-options for nested/child layout - even {} is valid as options + , initChildLayout: true // true = child layout will be created as soon as _this_ layout completes initialization + , destroyChildLayout: true // true = destroy child-layout if this pane is destroyed + , resizeChildLayout: true // true = trigger child-layout.resizeAll() when this pane is resized + // PANE CALLBACKS + , triggerEventsOnLoad: false // true = trigger onopen OR onclose callbacks when layout initializes + , triggerEventsDuringLiveResize: true // true = trigger onresize callback REPEATEDLY if livePaneResizing==true + , onshow_start: null // CALLBACK when pane STARTS to Show - BEFORE onopen/onhide_start + , onshow_end: null // CALLBACK when pane ENDS being Shown - AFTER onopen/onhide_end + , onhide_start: null // CALLBACK when pane STARTS to Close - BEFORE onclose_start + , onhide_end: null // CALLBACK when pane ENDS being Closed - AFTER onclose_end + , onopen_start: null // CALLBACK when pane STARTS to Open + , onopen_end: null // CALLBACK when pane ENDS being Opened + , onclose_start: null // CALLBACK when pane STARTS to Close + , onclose_end: null // CALLBACK when pane ENDS being Closed + , onresize_start: null // CALLBACK when pane STARTS being Resized ***FOR ANY REASON*** + , onresize_end: null // CALLBACK when pane ENDS being Resized ***FOR ANY REASON*** + , onsizecontent_start: null // CALLBACK when sizing of content-element STARTS + , onsizecontent_end: null // CALLBACK when sizing of content-element ENDS + , onswap_start: null // CALLBACK when pane STARTS to Swap + , onswap_end: null // CALLBACK when pane ENDS being Swapped + , ondrag_start: null // CALLBACK when pane STARTS being ***MANUALLY*** Resized + , ondrag_end: null // CALLBACK when pane ENDS being ***MANUALLY*** Resized + } +/* + * PANE-SPECIFIC SETTINGS + * - options listed below MUST be specified per-pane - they CANNOT be set under 'panes' + * - all options under the 'panes' key can also be set specifically for any pane + * - most options under the 'panes' key apply only to 'border-panes' - NOT the the center-pane + */ +, north: { + paneSelector: ".ui-layout-north" + , size: "auto" // eg: "auto", "30%", .30, 200 + , resizerCursor: "n-resize" // custom = url(myCursor.cur) + , customHotkey: "" // EITHER a charCode (43) OR a character ("o") + } +, south: { + paneSelector: ".ui-layout-south" + , size: "auto" + , resizerCursor: "s-resize" + , customHotkey: "" + } +, east: { + paneSelector: ".ui-layout-east" + , size: 200 + , resizerCursor: "e-resize" + , customHotkey: "" + } +, west: { + paneSelector: ".ui-layout-west" + , size: 200 + , resizerCursor: "w-resize" + , customHotkey: "" + } +, center: { + paneSelector: ".ui-layout-center" + , minWidth: 0 + , minHeight: 0 + } +}; + +$.layout.optionsMap = { + // layout/global options - NOT pane-options + layout: ("stateManagement,effects,zIndexes," + + "name,zIndex,scrollToBookmarkOnLoad,showErrorMessages," + + "resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay," + + "onresizeall,onresizeall_start,onresizeall_end,onload,onunload,autoBindCustomButtons").split(",") +// borderPanes: [ ALL options that are NOT specified as 'layout' ] + // default.panes options that apply to the center-pane (most options apply _only_ to border-panes) +, center: ("paneClass,contentSelector,contentIgnoreSelector,findNestedContent,applyDemoStyles,triggerEventsOnLoad," + + "showOverflowOnHover,maskContents,maskObjects,liveContentResizing," + + "childOptions,initChildLayout,resizeChildLayout,destroyChildLayout," + + "onresize,onresize_start,onresize_end,onsizecontent,onsizecontent_start,onsizecontent_end").split(",") + // options that MUST be specifically set 'per-pane' - CANNOT set in the panes (defaults) key +, noDefault: ("paneSelector,resizerCursor,customHotkey").split(",") +}; + +/** + * Processes options passed in converts flat-format data into subkey (JSON) format + * In flat-format, subkeys are _currently_ separated with 2 underscores, like north__optName + * Plugins may also call this method so they can transform their own data + * + * @param {!Object} hash Data/options passed by user - may be a single level or nested levels + * @return {Object} Returns hash of minWidth & minHeight + */ +$.layout.transformData = function (hash) { + var json = { panes: {}, center: {} } // init return object + , data, branch, optKey, keys, key, val, i, c; + + if (typeof hash !== "object") return json; // no options passed + + // convert all 'flat-keys' to 'sub-key' format + for (optKey in hash) { + branch = json; + data = $.layout.optionsMap.layout; + val = hash[ optKey ]; + keys = optKey.split("__"); // eg: west__size or north__fxSettings__duration + c = keys.length - 1; + // convert underscore-delimited to subkeys + for (i=0; i <= c; i++) { + key = keys[i]; + if (i === c) + branch[key] = val; + else if (!branch[key]) + branch[key] = {}; // create the subkey + // recurse to sub-key for next loop - if not done + branch = branch[key]; + } + } + + return json; +} + +// INTERNAL CONFIG DATA - DO NOT CHANGE THIS! +$.layout.backwardCompatibility = { + // data used by renameOldOptions() + map: { + // OLD Option Name: NEW Option Name + applyDefaultStyles: "applyDemoStyles" + , resizeNestedLayout: "resizeChildLayout" + , resizeWhileDragging: "livePaneResizing" + , resizeContentWhileDragging: "liveContentResizing" + , triggerEventsWhileDragging: "triggerEventsDuringLiveResize" + , maskIframesOnResize: "maskContents" + , useStateCookie: "stateManagement.enabled" + , "cookie.autoLoad": "stateManagement.autoLoad" + , "cookie.autoSave": "stateManagement.autoSave" + , "cookie.keys": "stateManagement.stateKeys" + , "cookie.name": "stateManagement.cookie.name" + , "cookie.domain": "stateManagement.cookie.domain" + , "cookie.path": "stateManagement.cookie.path" + , "cookie.expires": "stateManagement.cookie.expires" + , "cookie.secure": "stateManagement.cookie.secure" + } + /** + * @param {Object} opts + */ +, renameOptions: function (opts) { + var map = $.layout.backwardCompatibility.map + , oldData, newData, value + ; + for (var itemPath in map) { + oldData = getBranch( itemPath ); + value = oldData.branch[ oldData.key ] + if (value !== undefined) { + newData = getBranch( map[itemPath], true ) + newData.branch[ newData.key ] = value; + delete oldData.branch[ oldData.key ]; + } + } + + /** + * @param {string} path + * @param {boolean=} [create=false] Create path if does not exist + */ + function getBranch (path, create) { + var a = path.split(".") // split keys into array + , c = a.length - 1 + , D = { branch: opts, key: a[c] } // init branch at top & set key (last item) + , i = 0, k, undef; + for (; i 0) { + if (autoHide && $E.data('autoHidden') && $E.innerHeight() > 0) { + $E.show().data('autoHidden', false); + if (!browser.mozilla) // FireFox refreshes iframes - IE does not + // make hidden, then visible to 'refresh' display after animation + $E.css(_c.hidden).css(_c.visible); + } + } + else if (autoHide && !$E.data('autoHidden')) + $E.hide().data('autoHidden', true); + } + + /** + * @param {(string|!Object)} el + * @param {number=} outerHeight + * @param {boolean=} [autoHide=false] + */ +, setOuterHeight = function (el, outerHeight, autoHide) { + var $E = el, h; + if (isStr(el)) $E = $Ps[el]; // west + else if (!el.jquery) $E = $(el); + h = cssH($E, outerHeight); + $E.css({ height: h, visibility: "visible" }); // may have been 'hidden' by sizeContent + if (h > 0 && $E.innerWidth() > 0) { + if (autoHide && $E.data('autoHidden')) { + $E.show().data('autoHidden', false); + if (!browser.mozilla) // FireFox refreshes iframes - IE does not + $E.css(_c.hidden).css(_c.visible); + } + } + else if (autoHide && !$E.data('autoHidden')) + $E.hide().data('autoHidden', true); + } + + /** + * @param {(string|!Object)} el + * @param {number=} outerSize + * @param {boolean=} [autoHide=false] + */ +, setOuterSize = function (el, outerSize, autoHide) { + if (_c[pane].dir=="horz") // pane = north or south + setOuterHeight(el, outerSize, autoHide); + else // pane = east or west + setOuterWidth(el, outerSize, autoHide); + } + + + /** + * Converts any 'size' params to a pixel/integer size, if not already + * If 'auto' or a decimal/percentage is passed as 'size', a pixel-size is calculated + * + /** + * @param {string} pane + * @param {(string|number)=} size + * @param {string=} [dir] + * @return {number} + */ +, _parseSize = function (pane, size, dir) { + if (!dir) dir = _c[pane].dir; + + if (isStr(size) && size.match(/%/)) + size = (size === '100%') ? -1 : parseInt(size, 10) / 100; // convert % to decimal + + if (size === 0) + return 0; + else if (size >= 1) + return parseInt(size, 10); + + var o = options, avail = 0; + if (dir=="horz") // north or south or center.minHeight + avail = sC.innerHeight - ($Ps.north ? o.north.spacing_open : 0) - ($Ps.south ? o.south.spacing_open : 0); + else if (dir=="vert") // east or west or center.minWidth + avail = sC.innerWidth - ($Ps.west ? o.west.spacing_open : 0) - ($Ps.east ? o.east.spacing_open : 0); + + if (size === -1) // -1 == 100% + return avail; + else if (size > 0) // percentage, eg: .25 + return round(avail * size); + else if (pane=="center") + return 0; + else { // size < 0 || size=='auto' || size==Missing || size==Invalid + // auto-size the pane + var dim = (dir === "horz" ? "height" : "width") + , $P = $Ps[pane] + , $C = dim === 'height' ? $Cs[pane] : false + , vis = $.layout.showInvisibly($P) // show pane invisibly if hidden + , szP = $P.css(dim) // SAVE current pane size + , szC = $C ? $C.css(dim) : 0 // SAVE current content size + ; + $P.css(dim, "auto"); + if ($C) $C.css(dim, "auto"); + size = (dim === "height") ? $P.outerHeight() : $P.outerWidth(); // MEASURE + $P.css(dim, szP).css(vis); // RESET size & visibility + if ($C) $C.css(dim, szC); + return size; + } + } + + /** + * Calculates current 'size' (outer-width or outer-height) of a border-pane - optionally with 'pane-spacing' added + * + * @param {(string|!Object)} pane + * @param {boolean=} [inclSpace=false] + * @return {number} Returns EITHER Width for east/west panes OR Height for north/south panes - adjusted for boxModel & browser + */ +, getPaneSize = function (pane, inclSpace) { + var + $P = $Ps[pane] + , o = options[pane] + , s = state[pane] + , oSp = (inclSpace ? o.spacing_open : 0) + , cSp = (inclSpace ? o.spacing_closed : 0) + ; + if (!$P || s.isHidden) + return 0; + else if (s.isClosed || (s.isSliding && inclSpace)) + return cSp; + else if (_c[pane].dir === "horz") + return $P.outerHeight() + oSp; + else // dir === "vert" + return $P.outerWidth() + oSp; + } + + /** + * Calculate min/max pane dimensions and limits for resizing + * + * @param {string} pane + * @param {boolean=} [slide=false] + */ +, setSizeLimits = function (pane, slide) { + if (!isInitialized()) return; + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , dir = c.dir + , side = c.side.toLowerCase() + , type = c.sizeType.toLowerCase() + , isSliding = (slide != undefined ? slide : s.isSliding) // only open() passes 'slide' param + , $P = $Ps[pane] + , paneSpacing = o.spacing_open + // measure the pane on the *opposite side* from this pane + , altPane = _c.oppositeEdge[pane] + , altS = state[altPane] + , $altP = $Ps[altPane] + , altPaneSize = (!$altP || altS.isVisible===false || altS.isSliding ? 0 : (dir=="horz" ? $altP.outerHeight() : $altP.outerWidth())) + , altPaneSpacing = ((!$altP || altS.isHidden ? 0 : options[altPane][ altS.isClosed !== false ? "spacing_closed" : "spacing_open" ]) || 0) + // limitSize prevents this pane from 'overlapping' opposite pane + , containerSize = (dir=="horz" ? sC.innerHeight : sC.innerWidth) + , minCenterDims = cssMinDims("center") + , minCenterSize = dir=="horz" ? max(options.center.minHeight, minCenterDims.minHeight) : max(options.center.minWidth, minCenterDims.minWidth) + // if pane is 'sliding', then ignore center and alt-pane sizes - because 'overlays' them + , limitSize = (containerSize - paneSpacing - (isSliding ? 0 : (_parseSize("center", minCenterSize, dir) + altPaneSize + altPaneSpacing))) + , minSize = s.minSize = max( _parseSize(pane, o.minSize), cssMinDims(pane).minSize ) + , maxSize = s.maxSize = min( (o.maxSize ? _parseSize(pane, o.maxSize) : 100000), limitSize ) + , r = s.resizerPosition = {} // used to set resizing limits + , top = sC.insetTop + , left = sC.insetLeft + , W = sC.innerWidth + , H = sC.innerHeight + , rW = o.spacing_open // subtract resizer-width to get top/left position for south/east + ; + switch (pane) { + case "north": r.min = top + minSize; + r.max = top + maxSize; + break; + case "west": r.min = left + minSize; + r.max = left + maxSize; + break; + case "south": r.min = top + H - maxSize - rW; + r.max = top + H - minSize - rW; + break; + case "east": r.min = left + W - maxSize - rW; + r.max = left + W - minSize - rW; + break; + }; + } + + /** + * Returns data for setting the size/position of center pane. Also used to set Height for east/west panes + * + * @return JSON Returns a hash of all dimensions: top, bottom, left, right, (outer) width and (outer) height + */ +, calcNewCenterPaneDims = function () { + var d = { + top: getPaneSize("north", true) // true = include 'spacing' value for pane + , bottom: getPaneSize("south", true) + , left: getPaneSize("west", true) + , right: getPaneSize("east", true) + , width: 0 + , height: 0 + }; + + // NOTE: sC = state.container + // calc center-pane outer dimensions + d.width = sC.innerWidth - d.left - d.right; // outerWidth + d.height = sC.innerHeight - d.bottom - d.top; // outerHeight + // add the 'container border/padding' to get final positions relative to the container + d.top += sC.insetTop; + d.bottom += sC.insetBottom; + d.left += sC.insetLeft; + d.right += sC.insetRight; + + return d; + } + + + /** + * @param {!Object} el + * @param {boolean=} [allStates=false] + */ +, getHoverClasses = function (el, allStates) { + var + $El = $(el) + , type = $El.data("layoutRole") + , pane = $El.data("layoutEdge") + , o = options[pane] + , root = o[type +"Class"] + , _pane = "-"+ pane // eg: "-west" + , _open = "-open" + , _closed = "-closed" + , _slide = "-sliding" + , _hover = "-hover " // NOTE the trailing space + , _state = $El.hasClass(root+_closed) ? _closed : _open + , _alt = _state === _closed ? _open : _closed + , classes = (root+_hover) + (root+_pane+_hover) + (root+_state+_hover) + (root+_pane+_state+_hover) + ; + if (allStates) // when 'removing' classes, also remove alternate-state classes + classes += (root+_alt+_hover) + (root+_pane+_alt+_hover); + + if (type=="resizer" && $El.hasClass(root+_slide)) + classes += (root+_slide+_hover) + (root+_pane+_slide+_hover); + + return $.trim(classes); + } +, addHover = function (evt, el) { + var $E = $(el || this); + if (evt && $E.data("layoutRole") === "toggler") + evt.stopPropagation(); // prevent triggering 'slide' on Resizer-bar + $E.addClass( getHoverClasses($E) ); + } +, removeHover = function (evt, el) { + var $E = $(el || this); + $E.removeClass( getHoverClasses($E, true) ); + } + +, onResizerEnter = function (evt) { // ALSO called by toggler.mouseenter + if ($.fn.disableSelection) + $("body").disableSelection(); + } +, onResizerLeave = function (evt, el) { + var + e = el || this // el is only passed when called by the timer + , pane = $(e).data("layoutEdge") + , name = pane +"ResizerLeave" + ; + timer.clear(pane+"_openSlider"); // cancel slideOpen timer, if set + timer.clear(name); // cancel enableSelection timer - may re/set below + // this method calls itself on a timer because it needs to allow + // enough time for dragging to kick-in and set the isResizing flag + // dragging has a 100ms delay set, so this delay must be >100 + if (!el) // 1st call - mouseleave event + timer.set(name, function(){ onResizerLeave(evt, e); }, 200); + // if user is resizing, then dragStop will enableSelection(), so can skip it here + else if (!state[pane].isResizing && $.fn.enableSelection) // 2nd call - by timer + $("body").enableSelection(); + } + +/* + * ########################### + * INITIALIZATION METHODS + * ########################### + */ + + /** + * Initialize the layout - called automatically whenever an instance of layout is created + * + * @see none - triggered onInit + * @return mixed true = fully initialized | false = panes not initialized (yet) | 'cancel' = abort + */ +, _create = function () { + // initialize config/options + initOptions(); + var o = options; + + // TEMP state so isInitialized returns true during init process + state.creatingLayout = true; + + // init plugins for this layout, if there are any (eg: stateManagement) + runPluginCallbacks( Instance, $.layout.onCreate ); + + // options & state have been initialized, so now run beforeLoad callback + // onload will CANCEL layout creation if it returns false + if (false === _runCallbacks("onload_start")) + return 'cancel'; + + // initialize the container element + _initContainer(); + + // bind hotkey function - keyDown - if required + initHotkeys(); + + // bind window.onunload + $(window).bind("unload."+ sID, unload); + + // init plugins for this layout, if there are any (eg: customButtons) + runPluginCallbacks( Instance, $.layout.onLoad ); + + // if layout elements are hidden, then layout WILL NOT complete initialization! + // initLayoutElements will set initialized=true and run the onload callback IF successful + if (o.initPanes) _initLayoutElements(); + + delete state.creatingLayout; + + return state.initialized; + } + + /** + * Initialize the layout IF not already + * + * @see All methods in Instance run this test + * @return boolean true = layoutElements have been initialized | false = panes are not initialized (yet) + */ +, isInitialized = function () { + if (state.initialized || state.creatingLayout) return true; // already initialized + else return _initLayoutElements(); // try to init panes NOW + } + + /** + * Initialize the layout - called automatically whenever an instance of layout is created + * + * @see _create() & isInitialized + * @return An object pointer to the instance created + */ +, _initLayoutElements = function (retry) { + // initialize config/options + var o = options; + + // CANNOT init panes inside a hidden container! + if (!$N.is(":visible")) { + // handle Chrome bug where popup window 'has no height' + // if layout is BODY element, try again in 50ms + // SEE: http://layout.jquery-dev.net/samples/test_popup_window.html + if ( !retry && browser.webkit && $N[0].tagName === "BODY" ) + setTimeout(function(){ _initLayoutElements(true); }, 50); + return false; + } + + // a center pane is required, so make sure it exists + if (!getPane("center").length) { + if (options.showErrorMessages) + _log( lang.errCenterPaneMissing, true ); + return false; + } + + // TEMP state so isInitialized returns true during init process + state.creatingLayout = true; + + // update Container dims + $.extend(sC, elDims( $N )); + + // initialize all layout elements + initPanes(); // size & position panes - calls initHandles() - which calls initResizable() + + if (o.scrollToBookmarkOnLoad) { + var l = self.location; + if (l.hash) l.replace( l.hash ); // scrollTo Bookmark + } + + // check to see if this layout 'nested' inside a pane + if (Instance.hasParentLayout) + o.resizeWithWindow = false; + // bind resizeAll() for 'this layout instance' to window.resize event + else if (o.resizeWithWindow) + $(window).bind("resize."+ sID, windowResize); + + delete state.creatingLayout; + state.initialized = true; + + // init plugins for this layout, if there are any + runPluginCallbacks( Instance, $.layout.onReady ); + + // now run the onload callback, if exists + _runCallbacks("onload_end"); + + return true; // elements initialized successfully + } + + /** + * Initialize nested layouts - called when _initLayoutElements completes + * + * NOT CURRENTLY USED + * + * @see _initLayoutElements + * @return An object pointer to the instance created + */ +, _initChildLayouts = function () { + $.each(_c.allPanes, function (idx, pane) { + if (options[pane].initChildLayout) + createChildLayout( pane ); + }); + } + + /** + * Initialize nested layouts for a specific pane - can optionally pass layout-options + * + * @see _initChildLayouts + * @param {string} pane The pane being opened, ie: north, south, east, or west + * @param {Object=} [opts] Layout-options - if passed, will OVERRRIDE options[pane].childOptions + * @return An object pointer to the layout instance created - or null + */ +, createChildLayout = function (evt_or_pane, opts) { + var pane = evtPane.call(this, evt_or_pane) + , $P = $Ps[pane] + , C = children + ; + if ($P) { + var $C = $Cs[pane] + , o = opts || options[pane].childOptions + , d = "layout" + // determine which element is supposed to be the 'child container' + // if pane has a 'containerSelector' OR a 'content-div', use those instead of the pane + , $Cont = o.containerSelector ? $P.find( o.containerSelector ) : ($C || $P) + , containerFound = $Cont.length + // see if a child-layout ALREADY exists on this element + , child = containerFound ? (C[pane] = $Cont.data(d) || null) : null + ; + // if no layout exists, but childOptions are set, try to create the layout now + if (!child && containerFound && o) + child = C[pane] = $Cont.eq(0).layout(o) || null; + if (child) + child.hasParentLayout = true; // set parent-flag in child + } + Instance[pane].child = C[pane]; // ALWAYS set pane-object pointer, even if null + } + +, windowResize = function () { + var delay = Number(options.resizeWithWindowDelay); + if (delay < 10) delay = 100; // MUST have a delay! + // resizing uses a delay-loop because the resize event fires repeatly - except in FF, but delay anyway + timer.clear("winResize"); // if already running + timer.set("winResize", function(){ + timer.clear("winResize"); + timer.clear("winResizeRepeater"); + var dims = elDims( $N ); + // only trigger resizeAll() if container has changed size + if (dims.innerWidth !== sC.innerWidth || dims.innerHeight !== sC.innerHeight) + resizeAll(); + }, delay); + // ALSO set fixed-delay timer, if not already running + if (!timer.data["winResizeRepeater"]) setWindowResizeRepeater(); + } + +, setWindowResizeRepeater = function () { + var delay = Number(options.resizeWithWindowMaxDelay); + if (delay > 0) + timer.set("winResizeRepeater", function(){ setWindowResizeRepeater(); resizeAll(); }, delay); + } + +, unload = function () { + var o = options; + + _runCallbacks("onunload_start"); + + // trigger plugin callabacks for this layout (eg: stateManagement) + runPluginCallbacks( Instance, $.layout.onUnload ); + + _runCallbacks("onunload_end"); + } + + /** + * Validate and initialize container CSS and events + * + * @see _create() + */ +, _initContainer = function () { + var + N = $N[0] + , tag = sC.tagName = N.tagName + , id = sC.id = N.id + , cls = sC.className = N.className + , o = options + , name = o.name + , fullPage= (tag === "BODY") + , props = "overflow,position,margin,padding,border" + , css = "layoutCSS" + , CSS = {} + , hid = "hidden" // used A LOT! + // see if this container is a 'pane' inside an outer-layout + , parent = $N.data("parentLayout") // parent-layout Instance + , pane = $N.data("layoutEdge") // pane-name in parent-layout + , isChild = parent && pane + ; + // sC -> state.container + sC.selector = $N.selector.split(".slice")[0]; + sC.ref = (o.name ? o.name +' layout / ' : '') + tag + (id ? "#"+id : cls ? '.['+cls+']' : ''); // used in messages + + $N .data({ + layout: Instance + , layoutContainer: sID // FLAG to indicate this is a layout-container - contains unique internal ID + }) + .addClass(o.containerClass) + ; + var layoutMethods = { + destroy: '' + , initPanes: '' + , resizeAll: 'resizeAll' + , resize: 'resizeAll' + } + , name; + // loop hash and bind all methods - include layoutID namespacing + for (name in layoutMethods) { + $N.bind("layout"+ name.toLowerCase() +"."+ sID, Instance[ layoutMethods[name] || name ]); + } + + // if this container is another layout's 'pane', then set child/parent pointers + if (isChild) { + // update parent flag + Instance.hasParentLayout = true; + // set pointers to THIS child-layout (Instance) in parent-layout + // NOTE: parent.PANE.child is an ALIAS to parent.children.PANE + parent[pane].child = parent.children[pane] = $N.data("layout"); + } + + // SAVE original container CSS for use in destroy() + if (!$N.data(css)) { + // handle props like overflow different for BODY & HTML - has 'system default' values + if (fullPage) { + CSS = $.extend( elCSS($N, props), { + height: $N.css("height") + , overflow: $N.css("overflow") + , overflowX: $N.css("overflowX") + , overflowY: $N.css("overflowY") + }); + // ALSO SAVE CSS + var $H = $("html"); + $H.data(css, { + height: "auto" // FF would return a fixed px-size! + , overflow: $H.css("overflow") + , overflowX: $H.css("overflowX") + , overflowY: $H.css("overflowY") + }); + } + else // handle props normally for non-body elements + CSS = elCSS($N, props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY"); + + $N.data(css, CSS); + } + + try { // format html/body if this is a full page layout + if (fullPage) { + $("html").css({ + height: "100%" + , overflow: hid + , overflowX: hid + , overflowY: hid + }); + $("body").css({ + position: "relative" + , height: "100%" + , overflow: hid + , overflowX: hid + , overflowY: hid + , margin: 0 + , padding: 0 // TODO: test whether body-padding could be handled? + , border: "none" // a body-border creates problems because it cannot be measured! + }); + + // set current layout-container dimensions + $.extend(sC, elDims( $N )); + } + else { // set required CSS for overflow and position + // ENSURE container will not 'scroll' + CSS = { overflow: hid, overflowX: hid, overflowY: hid } + var + p = $N.css("position") + , h = $N.css("height") + ; + // if this is a NESTED layout, then container/outer-pane ALREADY has position and height + if (!isChild) { + if (!p || !p.match(/fixed|absolute|relative/)) + CSS.position = "relative"; // container MUST have a 'position' + /* + if (!h || h=="auto") + CSS.height = "100%"; // container MUST have a 'height' + */ + } + $N.css( CSS ); + + // set current layout-container dimensions + if ( $N.is(":visible") ) { + $.extend(sC, elDims( $N )); + if (o.showErrorMessages && sC.innerHeight < 1) + _log( lang.errContainerHeight.replace(/CONTAINER/, sC.ref), true ); + } + } + } catch (ex) {} + } + + /** + * Bind layout hotkeys - if options enabled + * + * @see _create() and addPane() + * @param {string=} [panes=""] The edge(s) to process + */ +, initHotkeys = function (panes) { + panes = panes ? panes.split(",") : _c.borderPanes; + // bind keyDown to capture hotkeys, if option enabled for ANY pane + $.each(panes, function (i, pane) { + var o = options[pane]; + if (o.enableCursorHotkey || o.customHotkey) { + $(document).bind("keydown."+ sID, keyDown); // only need to bind this ONCE + return false; // BREAK - binding was done + } + }); + } + + /** + * Build final OPTIONS data + * + * @see _create() + */ +, initOptions = function () { + var data, d, pane, key, val, i, c, o; + + // reprocess user's layout-options to have correct options sub-key structure + opts = $.layout.transformData( opts ); // panes = default subkey + + // auto-rename old options for backward compatibility + opts = $.layout.backwardCompatibility.renameAllOptions( opts ); + + // if user-options has 'panes' key (pane-defaults), process it... + if (!$.isEmptyObject(opts.panes)) { + // REMOVE any pane-defaults that MUST be set per-pane + data = $.layout.optionsMap.noDefault; + for (i=0, c=data.length; i 0) { + z.pane_normal = zo; + z.content_mask = max(zo+1, z.content_mask); // MIN = +1 + z.resizer_normal = max(zo+2, z.resizer_normal); // MIN = +2 + } + + function createFxOptions ( pane ) { + var o = options[pane] + , d = options.panes; + // ensure fxSettings key to avoid errors + if (!o.fxSettings) o.fxSettings = {}; + if (!d.fxSettings) d.fxSettings = {}; + + $.each(["_open","_close","_size"], function (i,n) { + var + sName = "fxName"+ n + , sSpeed = "fxSpeed"+ n + , sSettings = "fxSettings"+ n + // recalculate fxName according to specificity rules + , fxName = o[sName] = + o[sName] // options.west.fxName_open + || d[sName] // options.panes.fxName_open + || o.fxName // options.west.fxName + || d.fxName // options.panes.fxName + || "none" // MEANS $.layout.defaults.panes.fxName == "" || false || null || 0 + ; + // validate fxName to ensure is valid effect - MUST have effect-config data in options.effects + if (fxName === "none" || !$.effects || !$.effects[fxName] || !options.effects[fxName]) + fxName = o[sName] = "none"; // effect not loaded OR unrecognized fxName + + // set vars for effects subkeys to simplify logic + var fx = options.effects[fxName] || {} // effects.slide + , fx_all = fx.all || null // effects.slide.all + , fx_pane = fx[pane] || null // effects.slide.west + ; + // create fxSpeed[_open|_close|_size] + o[sSpeed] = + o[sSpeed] // options.west.fxSpeed_open + || d[sSpeed] // options.west.fxSpeed_open + || o.fxSpeed // options.west.fxSpeed + || d.fxSpeed // options.panes.fxSpeed + || null // DEFAULT - let fxSetting.duration control speed + ; + // create fxSettings[_open|_close|_size] + o[sSettings] = $.extend( + {} + , fx_all // effects.slide.all + , fx_pane // effects.slide.west + , d.fxSettings // options.panes.fxSettings + , o.fxSettings // options.west.fxSettings + , d[sSettings] // options.panes.fxSettings_open + , o[sSettings] // options.west.fxSettings_open + ); + }); + + // DONE creating action-specific-settings for this pane, + // so DELETE generic options - are no longer meaningful + delete o.fxName; + delete o.fxSpeed; + delete o.fxSettings; + } + + // DELETE 'panes' key now that we are done - values were copied to EACH pane + delete options.panes; + } + + /** + * Initialize module objects, styling, size and position for all panes + * + * @see _initElements() + * @param {string} pane The pane to process + */ +, getPane = function (pane) { + var sel = options[pane].paneSelector + if (sel.substr(0,1)==="#") // ID selector + // NOTE: elements selected 'by ID' DO NOT have to be 'children' + return $N.find(sel).eq(0); + else { // class or other selector + var $P = $N.children(sel).eq(0); + // look for the pane nested inside a 'form' element + return $P.length ? $P : $N.children("form:first").children(sel).eq(0); + } + } + +, initPanes = function () { + // NOTE: do north & south FIRST so we can measure their height - do center LAST + $.each(_c.allPanes, function (idx, pane) { + addPane( pane, true ); + }); + + // init the pane-handles NOW in case we have to hide or close the pane below + initHandles(); + + // now that all panes have been initialized and initially-sized, + // make sure there is really enough space available for each pane + $.each(_c.borderPanes, function (i, pane) { + if ($Ps[pane] && state[pane].isVisible) { // pane is OPEN + setSizeLimits(pane); + makePaneFit(pane); // pane may be Closed, Hidden or Resized by makePaneFit() + } + }); + // size center-pane AGAIN in case we 'closed' a border-pane in loop above + sizeMidPanes("center"); + + // Chrome/Webkit sometimes fires callbacks BEFORE it completes resizing! + // Before RC30.3, there was a 10ms delay here, but that caused layout + // to load asynchrously, which is BAD, so try skipping delay for now + + // process pane contents and callbacks, and init/resize child-layout if exists + $.each(_c.allPanes, function (i, pane) { + var o = options[pane]; + if ($Ps[pane]) { + if (state[pane].isVisible) { // pane is OPEN + sizeContent(pane); + // trigger pane.onResize if triggerEventsOnLoad = true + if (o.triggerEventsOnLoad) + _runCallbacks("onresize_end", pane); + else // automatic if onresize called, otherwise call it specifically + // resize child - IF inner-layout already exists (created before this layout) + resizeChildLayout(pane); + } + // init childLayout - even if pane is not visible + if (o.initChildLayout && o.childOptions) + createChildLayout(pane); + } + }); + } + + /** + * Add a pane to the layout - subroutine of initPanes() + * + * @see initPanes() + * @param {string} pane The pane to process + * @param {boolean=} [force=false] Size content after init + */ +, addPane = function (pane, force) { + if (!force && !isInitialized()) return; + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , fx = s.fx + , dir = c.dir + , spacing = o.spacing_open || 0 + , isCenter = (pane === "center") + , CSS = {} + , $P = $Ps[pane] + , size, minSize, maxSize + ; + // if pane-pointer already exists, remove the old one first + if ($P) + removePane( pane, false, true, false ); + else + $Cs[pane] = false; // init + + $P = $Ps[pane] = getPane(pane); + if (!$P.length) { + $Ps[pane] = false; // logic + return; + } + + // SAVE original Pane CSS + if (!$P.data("layoutCSS")) { + var props = "position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border"; + $P.data("layoutCSS", elCSS($P, props)); + } + + // create alias for pane data in Instance - initHandles will add more + Instance[pane] = { name: pane, pane: $Ps[pane], content: $Cs[pane], options: options[pane], state: state[pane], child: children[pane] }; + + // add classes, attributes & events + $P .data({ + parentLayout: Instance // pointer to Layout Instance + , layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + , layoutRole: "pane" + }) + .css(c.cssReq).css("zIndex", options.zIndexes.pane_normal) + .css(o.applyDemoStyles ? c.cssDemo : {}) // demo styles + .addClass( o.paneClass +" "+ o.paneClass+"-"+pane ) // default = "ui-layout-pane ui-layout-pane-west" - may be a dupe of 'paneSelector' + .bind("mouseenter."+ sID, addHover ) + .bind("mouseleave."+ sID, removeHover ) + ; + var paneMethods = { + hide: '' + , show: '' + , toggle: '' + , close: '' + , open: '' + , slideOpen: '' + , slideClose: '' + , slideToggle: '' + , size: 'manualSizePane' + , sizePane: 'manualSizePane' + , sizeContent: '' + , sizeHandles: '' + , enableClosable: '' + , disableClosable: '' + , enableSlideable: '' + , disableSlideable: '' + , enableResizable: '' + , disableResizable: '' + , swapPanes: 'swapPanes' + , swap: 'swapPanes' + , move: 'swapPanes' + , removePane: 'removePane' + , remove: 'removePane' + , createChildLayout: '' + , resizeChildLayout: '' + , resizeAll: 'resizeAll' + , resizeLayout: 'resizeAll' + } + , name; + // loop hash and bind all methods - include layoutID namespacing + for (name in paneMethods) { + $P.bind("layoutpane"+ name.toLowerCase() +"."+ sID, Instance[ paneMethods[name] || name ]); + } + + // see if this pane has a 'scrolling-content element' + initContent(pane, false); // false = do NOT sizeContent() - called later + + if (!isCenter) { + // call _parseSize AFTER applying pane classes & styles - but before making visible (if hidden) + // if o.size is auto or not valid, then MEASURE the pane and use that as its 'size' + size = s.size = _parseSize(pane, o.size); + minSize = _parseSize(pane,o.minSize) || 1; + maxSize = _parseSize(pane,o.maxSize) || 100000; + if (size > 0) size = max(min(size, maxSize), minSize); + + // state for border-panes + s.isClosed = false; // true = pane is closed + s.isSliding = false; // true = pane is currently open by 'sliding' over adjacent panes + s.isResizing= false; // true = pane is in process of being resized + s.isHidden = false; // true = pane is hidden - no spacing, resizer or toggler is visible! + + // array for 'pin buttons' whose classNames are auto-updated on pane-open/-close + if (!s.pins) s.pins = []; + } + // states common to ALL panes + s.tagName = $P[0].tagName; + s.edge = pane; // useful if pane is (or about to be) 'swapped' - easy find out where it is (or is going) + s.noRoom = false; // true = pane 'automatically' hidden due to insufficient room - will unhide automatically + s.isVisible = true; // false = pane is invisible - closed OR hidden - simplify logic + + // set css-position to account for container borders & padding + switch (pane) { + case "north": CSS.top = sC.insetTop; + CSS.left = sC.insetLeft; + CSS.right = sC.insetRight; + break; + case "south": CSS.bottom = sC.insetBottom; + CSS.left = sC.insetLeft; + CSS.right = sC.insetRight; + break; + case "west": CSS.left = sC.insetLeft; // top, bottom & height set by sizeMidPanes() + break; + case "east": CSS.right = sC.insetRight; // ditto + break; + case "center": // top, left, width & height set by sizeMidPanes() + } + + if (dir === "horz") // north or south pane + CSS.height = cssH($P, size); + else if (dir === "vert") // east or west pane + CSS.width = cssW($P, size); + //else if (isCenter) {} + + $P.css(CSS); // apply size -- top, bottom & height will be set by sizeMidPanes + if (dir != "horz") sizeMidPanes(pane, true); // true = skipCallback + + // close or hide the pane if specified in settings + if (o.initClosed && o.closable && !o.initHidden) + close(pane, true, true); // true, true = force, noAnimation + else if (o.initHidden || o.initClosed) + hide(pane); // will be completely invisible - no resizer or spacing + else if (!s.noRoom) + // make the pane visible - in case was initially hidden + $P.css("display","block"); + // ELSE setAsOpen() - called later by initHandles() + + // RESET visibility now - pane will appear IF display:block + $P.css("visibility","visible"); + + // check option for auto-handling of pop-ups & drop-downs + if (o.showOverflowOnHover) + $P.hover( allowOverflow, resetOverflow ); + + // if manually adding a pane AFTER layout initialization, then... + if (state.initialized) { + initHandles( pane ); + initHotkeys( pane ); + resizeAll(); // will sizeContent if pane is visible + if (s.isVisible) { // pane is OPEN + if (o.triggerEventsOnLoad) + _runCallbacks("onresize_end", pane); + else // automatic if onresize called, otherwise call it specifically + // resize child - IF inner-layout already exists (created before this layout) + resizeChildLayout(pane); // a previously existing childLayout + } + if (o.initChildLayout && o.childOptions) + createChildLayout(pane); + } + } + + /** + * Initialize module objects, styling, size and position for all resize bars and toggler buttons + * + * @see _create() + * @param {string=} [panes=""] The edge(s) to process + */ +, initHandles = function (panes) { + panes = panes ? panes.split(",") : _c.borderPanes; + + // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV + $.each(panes, function (i, pane) { + var $P = $Ps[pane]; + $Rs[pane] = false; // INIT + $Ts[pane] = false; + if (!$P) return; // pane does not exist - skip + + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , rClass = o.resizerClass + , tClass = o.togglerClass + , side = c.side.toLowerCase() + , spacing = (s.isVisible ? o.spacing_open : o.spacing_closed) + , _pane = "-"+ pane // used for classNames + , _state = (s.isVisible ? "-open" : "-closed") // used for classNames + , I = Instance[pane] + // INIT RESIZER BAR + , $R = I.resizer = $Rs[pane] = $("
      ") + // INIT TOGGLER BUTTON + , $T = I.toggler = (o.closable ? $Ts[pane] = $("
      ") : false) + ; + + //if (s.isVisible && o.resizable) ... handled by initResizable + if (!s.isVisible && o.slidable) + $R.attr("title", o.sliderTip).css("cursor", o.sliderCursor); + + $R // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-resizer" + .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-resizer" : "")) + .data({ + parentLayout: Instance + , layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + , layoutRole: "resizer" + }) + .css(_c.resizers.cssReq).css("zIndex", options.zIndexes.resizer_normal) + .css(o.applyDemoStyles ? _c.resizers.cssDemo : {}) // add demo styles + .addClass(rClass +" "+ rClass+_pane) + .hover(addHover, removeHover) // ALWAYS add hover-classes, even if resizing is not enabled - handle with CSS instead + .hover(onResizerEnter, onResizerLeave) // ALWAYS NEED resizer.mouseleave to balance toggler.mouseenter + .appendTo($N) // append DIV to container + ; + + if ($T) { + $T // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "#paneLeft-toggler" + .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-toggler" : "")) + .data({ + parentLayout: Instance + , layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + , layoutRole: "toggler" + }) + .css(_c.togglers.cssReq) // add base/required styles + .css(o.applyDemoStyles ? _c.togglers.cssDemo : {}) // add demo styles + .addClass(tClass +" "+ tClass+_pane) + .hover(addHover, removeHover) // ALWAYS add hover-classes, even if toggling is not enabled - handle with CSS instead + .bind("mouseenter", onResizerEnter) // NEED toggler.mouseenter because mouseenter MAY NOT fire on resizer + .appendTo($R) // append SPAN to resizer DIV + ; + // ADD INNER-SPANS TO TOGGLER + if (o.togglerContent_open) // ui-layout-open + $(""+ o.togglerContent_open +"") + .data({ + layoutEdge: pane + , layoutRole: "togglerContent" + }) + .data("layoutRole", "togglerContent") + .data("layoutEdge", pane) + .addClass("content content-open") + .css("display","none") + .appendTo( $T ) + //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-open instead! + ; + if (o.togglerContent_closed) // ui-layout-closed + $(""+ o.togglerContent_closed +"") + .data({ + layoutEdge: pane + , layoutRole: "togglerContent" + }) + .addClass("content content-closed") + .css("display","none") + .appendTo( $T ) + //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-closed instead! + ; + // ADD TOGGLER.click/.hover + enableClosable(pane); + } + + // add Draggable events + initResizable(pane); + + // ADD CLASSNAMES & SLIDE-BINDINGS - eg: class="resizer resizer-west resizer-open" + if (s.isVisible) + setAsOpen(pane); // onOpen will be called, but NOT onResize + else { + setAsClosed(pane); // onClose will be called + bindStartSlidingEvent(pane, true); // will enable events IF option is set + } + + }); + + // SET ALL HANDLE DIMENSIONS + sizeHandles(); + } + + + /** + * Initialize scrolling ui-layout-content div - if exists + * + * @see initPane() - or externally after an Ajax injection + * @param {string} [pane] The pane to process + * @param {boolean=} [resize=true] Size content after init + */ +, initContent = function (pane, resize) { + if (!isInitialized()) return; + var + o = options[pane] + , sel = o.contentSelector + , I = Instance[pane] + , $P = $Ps[pane] + , $C + ; + if (sel) $C = I.content = $Cs[pane] = (o.findNestedContent) + ? $P.find(sel).eq(0) // match 1-element only + : $P.children(sel).eq(0) + ; + if ($C && $C.length) { + $C.data("layoutRole", "content"); + // SAVE original Pane CSS + if (!$C.data("layoutCSS")) + $C.data("layoutCSS", elCSS($C, "height")); + $C.css( _c.content.cssReq ); + if (o.applyDemoStyles) { + $C.css( _c.content.cssDemo ); // add padding & overflow: auto to content-div + $P.css( _c.content.cssDemoPane ); // REMOVE padding/scrolling from pane + } + state[pane].content = {}; // init content state + if (resize !== false) sizeContent(pane); + // sizeContent() is called AFTER init of all elements + } + else + I.content = $Cs[pane] = false; + } + + + /** + * Add resize-bars to all panes that specify it in options + * -dependancy: $.fn.resizable - will skip if not found + * + * @see _create() + * @param {string=} [panes=""] The edge(s) to process + */ +, initResizable = function (panes) { + var draggingAvailable = $.layout.plugins.draggable + , side // set in start() + ; + panes = panes ? panes.split(",") : _c.borderPanes; + + $.each(panes, function (idx, pane) { + var o = options[pane]; + if (!draggingAvailable || !$Ps[pane] || !o.resizable) { + o.resizable = false; + return true; // skip to next + } + + var s = state[pane] + , z = options.zIndexes + , c = _c[pane] + , side = c.dir=="horz" ? "top" : "left" + , opEdge = _c.oppositeEdge[pane] + , masks = pane +",center,"+ opEdge + (c.dir=="horz" ? ",west,east" : "") + , $P = $Ps[pane] + , $R = $Rs[pane] + , base = o.resizerClass + , lastPos = 0 // used when live-resizing + , r, live // set in start because may change + // 'drag' classes are applied to the ORIGINAL resizer-bar while dragging is in process + , resizerClass = base+"-drag" // resizer-drag + , resizerPaneClass = base+"-"+pane+"-drag" // resizer-north-drag + // 'helper' class is applied to the CLONED resizer-bar while it is being dragged + , helperClass = base+"-dragging" // resizer-dragging + , helperPaneClass = base+"-"+pane+"-dragging" // resizer-north-dragging + , helperLimitClass = base+"-dragging-limit" // resizer-drag + , helperPaneLimitClass = base+"-"+pane+"-dragging-limit" // resizer-north-drag + , helperClassesSet = false // logic var + ; + + if (!s.isClosed) + $R.attr("title", o.resizerTip) + .css("cursor", o.resizerCursor); // n-resize, s-resize, etc + + $R.draggable({ + containment: $N[0] // limit resizing to layout container + , axis: (c.dir=="horz" ? "y" : "x") // limit resizing to horz or vert axis + , delay: 0 + , distance: 1 + , grid: o.resizingGrid + // basic format for helper - style it using class: .ui-draggable-dragging + , helper: "clone" + , opacity: o.resizerDragOpacity + , addClasses: false // avoid ui-state-disabled class when disabled + //, iframeFix: o.draggableIframeFix // TODO: consider using when bug is fixed + , zIndex: z.resizer_drag + + , start: function (e, ui) { + // REFRESH options & state pointers in case we used swapPanes + o = options[pane]; + s = state[pane]; + // re-read options + live = o.livePaneResizing; + + // ondrag_start callback - will CANCEL hide if returns false + // TODO: dragging CANNOT be cancelled like this, so see if there is a way? + if (false === _runCallbacks("ondrag_start", pane)) return false; + + s.isResizing = true; // prevent pane from closing while resizing + timer.clear(pane+"_closeSlider"); // just in case already triggered + + // SET RESIZER LIMITS - used in drag() + setSizeLimits(pane); // update pane/resizer state + r = s.resizerPosition; + lastPos = ui.position[ side ] + + $R.addClass( resizerClass +" "+ resizerPaneClass ); // add drag classes + helperClassesSet = false; // reset logic var - see drag() + + // DISABLE TEXT SELECTION (probably already done by resizer.mouseOver) + $('body').disableSelection(); + + // MASK PANES CONTAINING IFRAMES, APPLETS OR OTHER TROUBLESOME ELEMENTS + showMasks( masks ); + } + + , drag: function (e, ui) { + if (!helperClassesSet) { // can only add classes after clone has been added to the DOM + //$(".ui-draggable-dragging") + ui.helper + .addClass( helperClass +" "+ helperPaneClass ) // add helper classes + .css({ right: "auto", bottom: "auto" }) // fix dir="rtl" issue + .children().css("visibility","hidden") // hide toggler inside dragged resizer-bar + ; + helperClassesSet = true; + // draggable bug!? RE-SET zIndex to prevent E/W resize-bar showing through N/S pane! + if (s.isSliding) $Ps[pane].css("zIndex", z.pane_sliding); + } + // CONTAIN RESIZER-BAR TO RESIZING LIMITS + var limit = 0; + if (ui.position[side] < r.min) { + ui.position[side] = r.min; + limit = -1; + } + else if (ui.position[side] > r.max) { + ui.position[side] = r.max; + limit = 1; + } + // ADD/REMOVE dragging-limit CLASS + if (limit) { + ui.helper.addClass( helperLimitClass +" "+ helperPaneLimitClass ); // at dragging-limit + window.defaultStatus = (limit>0 && pane.match(/north|west/)) || (limit<0 && pane.match(/south|east/)) ? lang.maxSizeWarning : lang.minSizeWarning; + } + else { + ui.helper.removeClass( helperLimitClass +" "+ helperPaneLimitClass ); // not at dragging-limit + window.defaultStatus = ""; + } + // DYNAMICALLY RESIZE PANES IF OPTION ENABLED + // won't trigger unless resizer has actually moved! + if (live && Math.abs(ui.position[side] - lastPos) >= o.liveResizingTolerance) { + lastPos = ui.position[side]; + resizePanes(e, ui, pane) + } + } + + , stop: function (e, ui) { + $('body').enableSelection(); // RE-ENABLE TEXT SELECTION + window.defaultStatus = ""; // clear 'resizing limit' message from statusbar + $R.removeClass( resizerClass +" "+ resizerPaneClass ); // remove drag classes from Resizer + s.isResizing = false; + resizePanes(e, ui, pane, true, masks); // true = resizingDone + } + + }); + }); + + /** + * resizePanes + * + * Sub-routine called from stop() - and drag() if livePaneResizing + * + * @param {!Object} evt + * @param {!Object} ui + * @param {string} pane + * @param {boolean=} [resizingDone=false] + */ + var resizePanes = function (evt, ui, pane, resizingDone, masks) { + var dragPos = ui.position + , c = _c[pane] + , o = options[pane] + , s = state[pane] + , resizerPos + ; + switch (pane) { + case "north": resizerPos = dragPos.top; break; + case "west": resizerPos = dragPos.left; break; + case "south": resizerPos = sC.offsetHeight - dragPos.top - o.spacing_open; break; + case "east": resizerPos = sC.offsetWidth - dragPos.left - o.spacing_open; break; + }; + // remove container margin from resizer position to get the pane size + var newSize = resizerPos - sC["inset"+ c.side]; + + // Disable OR Resize Mask(s) created in drag.start + if (!resizingDone) { + // ensure we meet liveResizingTolerance criteria + if (Math.abs(newSize - s.size) < o.liveResizingTolerance) + return; // SKIP resize this time + // resize the pane + manualSizePane(pane, newSize, false, true); // true = noAnimation + sizeMasks(); // resize all visible masks + } + else { // resizingDone + // ondrag_end callback + if (false !== _runCallbacks("ondrag_end", pane)) + manualSizePane(pane, newSize, false, true); // true = noAnimation + hideMasks(); // hide all masks, which include panes with 'content/iframe-masks' + if (s.isSliding && masks) // RE-SHOW only 'object-masks' so objects won't show through sliding pane + showMasks( masks, true ); // true = onlyForObjects + } + }; + } + + /** + * sizeMask + * + * Needed to overlay a DIV over an IFRAME-pane because mask CANNOT be *inside* the pane + * Called when mask created, and during livePaneResizing + */ +, sizeMask = function () { + var $M = $(this) + , pane = $M.data("layoutMask") // eg: "west" + , s = state[pane] + ; + // only masks over an IFRAME-pane need manual resizing + if (s.tagName == "IFRAME" && s.isVisible) // no need to mask closed/hidden panes + $M.css({ + top: s.offsetTop + , left: s.offsetLeft + , width: s.outerWidth + , height: s.outerHeight + }); + /* ALT Method... + var $P = $Ps[pane]; + $M.css( $P.position() ).css({ width: $P[0].offsetWidth, height: $P[0].offsetHeight }); + */ + } +, sizeMasks = function () { + $Ms.each( sizeMask ); // resize all 'visible' masks + } + +, showMasks = function (panes, onlyForObjects) { + var a = panes ? panes.split(",") : $.layout.config.allPanes + , z = options.zIndexes + , o, s; + $.each(a, function(i,p){ + s = state[p]; + o = options[p]; + if (s.isVisible && ( (!onlyForObjects && o.maskContents) || o.maskObjects )) { + getMasks(p).each(function(){ + sizeMask.call(this); + this.style.zIndex = s.isSliding ? z.pane_sliding+1 : z.pane_normal+1 + this.style.display = "block"; + }); + } + }); + } + +, hideMasks = function () { + // ensure no pane is resizing - could be a timing issue + var skip; + $.each( $.layout.config.borderPanes, function(i,p){ + if (state[p].isResizing) { + skip = true; + return false; // BREAK + } + }); + if (!skip) + $Ms.hide(); // hide ALL masks + } + +, getMasks = function (pane) { + var $Masks = $([]) + , $M, i = 0, c = $Ms.length + ; + for (; i CSS + if (sC.tagName === "BODY" && ($N = $("html")).data(css)) // RESET CSS + $N.css( $N.data(css) ).removeData(css); + + // trigger plugins for this layout, if there are any + runPluginCallbacks( Instance, $.layout.onDestroy ); + + // trigger state-management and onunload callback + unload(); + + // clear the Instance of everything except for container & options (so could recreate) + // RE-CREATE: myLayout = myLayout.container.layout( myLayout.options ); + for (n in Instance) + if (!n.match(/^(container|options)$/)) delete Instance[ n ]; + // add a 'destroyed' flag to make it easy to check + Instance.destroyed = true; + + // if this is a child layout, CLEAR the child-pointer in the parent + /* for now the pointer REMAINS, but with only container, options and destroyed keys + if (parentPane) { + var layout = parentPane.pane.data("parentLayout"); + parentPane.child = layout.children[ parentPane.name ] = null; + } + */ + + return Instance; // for coding convenience + } + + /** + * Remove a pane from the layout - subroutine of destroy() + * + * @see destroy() + * @param {string} pane The pane to process + * @param {boolean=} [remove=false] Remove the DOM element? + * @param {boolean=} [skipResize=false] Skip calling resizeAll()? + */ +, removePane = function (evt_or_pane, remove, skipResize, destroyChild) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $P = $Ps[pane] + , $C = $Cs[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + ; + //alert( '$P.length = '+ $P.length ); + // NOTE: elements can still exist even after remove() + // so check for missing data(), which is cleared by removed() + if ($P && $.isEmptyObject( $P.data() )) $P = false; + if ($C && $.isEmptyObject( $C.data() )) $C = false; + if ($R && $.isEmptyObject( $R.data() )) $R = false; + if ($T && $.isEmptyObject( $T.data() )) $T = false; + + if ($P) $P.stop(true, true); + + // check for a child layout + var o = options[pane] + , s = state[pane] + , d = "layout" + , css = "layoutCSS" + , child = children[pane] || ($P ? $P.data(d) : 0) || ($C ? $C.data(d) : 0) || null + , destroy = destroyChild !== undefined ? destroyChild : o.destroyChildLayout + ; + + // FIRST destroy the child-layout(s) + if (destroy && child && !child.destroyed) { + child.destroy(true); // tell child-layout to destroy ALL its child-layouts too + if (child.destroyed) // destroy was successful + child = null; // clear pointer for logic below + } + + if ($P && remove && !child) + $P.remove(); + else if ($P && $P[0]) { + // create list of ALL pane-classes that need to be removed + var root = o.paneClass // default="ui-layout-pane" + , pRoot = root +"-"+ pane // eg: "ui-layout-pane-west" + , _open = "-open" + , _sliding= "-sliding" + , _closed = "-closed" + , classes = [ root, root+_open, root+_closed, root+_sliding, // generic classes + pRoot, pRoot+_open, pRoot+_closed, pRoot+_sliding ] // pane-specific classes + ; + $.merge(classes, getHoverClasses($P, true)); // ADD hover-classes + // remove all Layout classes from pane-element + $P .removeClass( classes.join(" ") ) // remove ALL pane-classes + .removeData("parentLayout") + .removeData("layoutPane") + .removeData("layoutRole") + .removeData("layoutEdge") + .removeData("autoHidden") // in case set + .unbind("."+ sID) // remove ALL Layout events + // TODO: remove these extra unbind commands when jQuery is fixed + //.unbind("mouseenter"+ sID) + //.unbind("mouseleave"+ sID) + ; + // do NOT reset CSS if this pane/content is STILL the container of a nested layout! + // the nested layout will reset its 'container' CSS when/if it is destroyed + if ($C && $C.data(d)) { + // a content-div may not have a specific width, so give it one to contain the Layout + $C.width( $C.width() ); + child.resizeAll(); // now resize the Layout + } + else if ($C) + $C.css( $C.data(css) ).removeData(css).removeData("layoutRole"); + // remove pane AFTER content in case there was a nested layout + if (!$P.data(d)) + $P.css( $P.data(css) ).removeData(css); + } + + // REMOVE pane resizer and toggler elements + if ($T) $T.remove(); + if ($R) $R.remove(); + + // CLEAR all pointers and state data + Instance[pane] = $Ps[pane] = $Cs[pane] = $Rs[pane] = $Ts[pane] = children[pane] = false; + s = { removed: true }; + + if (!skipResize) + resizeAll(); + } + + +/* + * ########################### + * ACTION METHODS + * ########################### + */ + +, _hidePane = function (pane) { + var $P = $Ps[pane] + , o = options[pane] + , s = $P[0].style + ; + if (o.useOffscreenClose) { + if (!$P.data(_c.offscreenReset)) + $P.data(_c.offscreenReset, { left: s.left, right: s.right }); + $P.css( _c.offscreenCSS ); + } + else + $P.hide().removeData(_c.offscreenReset); + } + +, _showPane = function (pane) { + var $P = $Ps[pane] + , o = options[pane] + , off = _c.offscreenCSS + , old = $P.data(_c.offscreenReset) + , s = $P[0].style + ; + $P .show() // ALWAYS show, just in case + .removeData(_c.offscreenReset); + if (o.useOffscreenClose && old) { + if (s.left == off.left) + s.left = old.left; + if (s.right == off.right) + s.right = old.right; + } + } + + + /** + * Completely 'hides' a pane, including its spacing - as if it does not exist + * The pane is not actually 'removed' from the source, so can use 'show' to un-hide it + * + * @param {string} pane The pane being hidden, ie: north, south, east, or west + * @param {boolean=} [noAnimation=false] + */ +, hide = function (evt_or_pane, noAnimation) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + ; + if (!$P || s.isHidden) return; // pane does not exist OR is already hidden + + // onhide_start callback - will CANCEL hide if returns false + if (state.initialized && false === _runCallbacks("onhide_start", pane)) return; + + s.isSliding = false; // just in case + + // now hide the elements + if ($R) $R.hide(); // hide resizer-bar + if (!state.initialized || s.isClosed) { + s.isClosed = true; // to trigger open-animation on show() + s.isHidden = true; + s.isVisible = false; + if (!state.initialized) + _hidePane(pane); // no animation when loading page + sizeMidPanes(_c[pane].dir === "horz" ? "" : "center"); + if (state.initialized || o.triggerEventsOnLoad) + _runCallbacks("onhide_end", pane); + } + else { + s.isHiding = true; // used by onclose + close(pane, false, noAnimation); // adjust all panes to fit + } + } + + /** + * Show a hidden pane - show as 'closed' by default unless openPane = true + * + * @param {string} pane The pane being opened, ie: north, south, east, or west + * @param {boolean=} [openPane=false] + * @param {boolean=} [noAnimation=false] + * @param {boolean=} [noAlert=false] + */ +, show = function (evt_or_pane, openPane, noAnimation, noAlert) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + ; + if (!$P || !s.isHidden) return; // pane does not exist OR is not hidden + + // onshow_start callback - will CANCEL show if returns false + if (false === _runCallbacks("onshow_start", pane)) return; + + s.isSliding = false; // just in case + s.isShowing = true; // used by onopen/onclose + //s.isHidden = false; - will be set by open/close - if not cancelled + + // now show the elements + //if ($R) $R.show(); - will be shown by open/close + if (openPane === false) + close(pane, true); // true = force + else + open(pane, false, noAnimation, noAlert); // adjust all panes to fit + } + + + /** + * Toggles a pane open/closed by calling either open or close + * + * @param {string} pane The pane being toggled, ie: north, south, east, or west + * @param {boolean=} [slide=false] + */ +, toggle = function (evt_or_pane, slide) { + if (!isInitialized()) return; + var evt = evtObj(evt_or_pane) + , pane = evtPane.call(this, evt_or_pane) + , s = state[pane] + ; + if (evt) // called from to $R.dblclick OR triggerPaneEvent + evt.stopImmediatePropagation(); + if (s.isHidden) + show(pane); // will call 'open' after unhiding it + else if (s.isClosed) + open(pane, !!slide); + else + close(pane); + } + + + /** + * Utility method used during init or other auto-processes + * + * @param {string} pane The pane being closed + * @param {boolean=} [setHandles=false] + */ +, _closePane = function (pane, setHandles) { + var + $P = $Ps[pane] + , s = state[pane] + ; + _hidePane(pane); + s.isClosed = true; + s.isVisible = false; + // UNUSED: if (setHandles) setAsClosed(pane, true); // true = force + } + + /** + * Close the specified pane (animation optional), and resize all other panes as needed + * + * @param {string} pane The pane being closed, ie: north, south, east, or west + * @param {boolean=} [force=false] + * @param {boolean=} [noAnimation=false] + * @param {boolean=} [skipCallback=false] + */ +, close = function (evt_or_pane, force, noAnimation, skipCallback) { + var pane = evtPane.call(this, evt_or_pane); + // if pane has been initialized, but NOT the complete layout, close pane instantly + if (!state.initialized && $Ps[pane]) { + _closePane(pane); // INIT pane as closed + return; + } + if (!isInitialized()) return; + + var + $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , c = _c[pane] + , doFX, isShowing, isHiding, wasSliding; + + // QUEUE in case another action/animation is in progress + $N.queue(function( queueNext ){ + + if ( !$P + || (!o.closable && !s.isShowing && !s.isHiding) // invalid request // (!o.resizable && !o.closable) ??? + || (!force && s.isClosed && !s.isShowing) // already closed + ) return queueNext(); + + // onclose_start callback - will CANCEL hide if returns false + // SKIP if just 'showing' a hidden pane as 'closed' + var abort = !s.isShowing && false === _runCallbacks("onclose_start", pane); + + // transfer logic vars to temp vars + isShowing = s.isShowing; + isHiding = s.isHiding; + wasSliding = s.isSliding; + // now clear the logic vars (REQUIRED before aborting) + delete s.isShowing; + delete s.isHiding; + + if (abort) return queueNext(); + + doFX = !noAnimation && !s.isClosed && (o.fxName_close != "none"); + s.isMoving = true; + s.isClosed = true; + s.isVisible = false; + // update isHidden BEFORE sizing panes + if (isHiding) s.isHidden = true; + else if (isShowing) s.isHidden = false; + + if (s.isSliding) // pane is being closed, so UNBIND trigger events + bindStopSlidingEvents(pane, false); // will set isSliding=false + else // resize panes adjacent to this one + sizeMidPanes(_c[pane].dir === "horz" ? "" : "center", false); // false = NOT skipCallback + + // if this pane has a resizer bar, move it NOW - before animation + setAsClosed(pane); + + // CLOSE THE PANE + if (doFX) { // animate the close + // mask panes with objects + var masks = "center"+ (c.dir=="horz" ? ",west,east" : ""); + showMasks( masks, true ); // true = ONLY mask panes with maskObjects=true + lockPaneForFX(pane, true); // need to set left/top so animation will work + $P.hide( o.fxName_close, o.fxSettings_close, o.fxSpeed_close, function () { + lockPaneForFX(pane, false); // undo + if (s.isClosed) close_2(); + queueNext(); + }); + } + else { // hide the pane without animation + _hidePane(pane); + close_2(); + queueNext(); + }; + }); + + // SUBROUTINE + function close_2 () { + s.isMoving = false; + bindStartSlidingEvent(pane, true); // will enable if o.slidable = true + + // if opposite-pane was autoClosed, see if it can be autoOpened now + var altPane = _c.oppositeEdge[pane]; + if (state[ altPane ].noRoom) { + setSizeLimits( altPane ); + makePaneFit( altPane ); + } + + // hide any masks shown while closing + hideMasks(); + + if (!skipCallback && (state.initialized || o.triggerEventsOnLoad)) { + // onclose callback - UNLESS just 'showing' a hidden pane as 'closed' + if (!isShowing) _runCallbacks("onclose_end", pane); + // onhide OR onshow callback + if (isShowing) _runCallbacks("onshow_end", pane); + if (isHiding) _runCallbacks("onhide_end", pane); + } + } + } + + /** + * @param {string} pane The pane just closed, ie: north, south, east, or west + */ +, setAsClosed = function (pane) { + var + $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , side = _c[pane].side.toLowerCase() + , inset = "inset"+ _c[pane].side + , rClass = o.resizerClass + , tClass = o.togglerClass + , _pane = "-"+ pane // used for classNames + , _open = "-open" + , _sliding= "-sliding" + , _closed = "-closed" + ; + $R + .css(side, sC[inset]) // move the resizer + .removeClass( rClass+_open +" "+ rClass+_pane+_open ) + .removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) + .addClass( rClass+_closed +" "+ rClass+_pane+_closed ) + .unbind("dblclick."+ sID) + ; + // DISABLE 'resizing' when closed - do this BEFORE bindStartSlidingEvent? + if (o.resizable && $.layout.plugins.draggable) + $R + .draggable("disable") + .removeClass("ui-state-disabled") // do NOT apply disabled styling - not suitable here + .css("cursor", "default") + .attr("title","") + ; + + // if pane has a toggler button, adjust that too + if ($T) { + $T + .removeClass( tClass+_open +" "+ tClass+_pane+_open ) + .addClass( tClass+_closed +" "+ tClass+_pane+_closed ) + .attr("title", o.togglerTip_closed) // may be blank + ; + // toggler-content - if exists + $T.children(".content-open").hide(); + $T.children(".content-closed").css("display","block"); + } + + // sync any 'pin buttons' + syncPinBtns(pane, false); + + if (state.initialized) { + // resize 'length' and position togglers for adjacent panes + sizeHandles(); + } + } + + /** + * Open the specified pane (animation optional), and resize all other panes as needed + * + * @param {string} pane The pane being opened, ie: north, south, east, or west + * @param {boolean=} [slide=false] + * @param {boolean=} [noAnimation=false] + * @param {boolean=} [noAlert=false] + */ +, open = function (evt_or_pane, slide, noAnimation, noAlert) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , c = _c[pane] + , doFX, isShowing + ; + // QUEUE in case another action/animation is in progress + $N.queue(function( queueNext ){ + + if ( !$P + || (!o.resizable && !o.closable && !s.isShowing) // invalid request + || (s.isVisible && !s.isSliding) // already open + ) return queueNext(); + + // pane can ALSO be unhidden by just calling show(), so handle this scenario + if (s.isHidden && !s.isShowing) { + queueNext(); // call before show() because it needs the queue free + show(pane, true); + return; + } + + if (o.autoResize && s.size != o.size) // resize pane to original size set in options + sizePane(pane, o.size, true, true, true); // true=skipCallback/forceResize/noAnimation + else + // make sure there is enough space available to open the pane + setSizeLimits(pane, slide); + + // onopen_start callback - will CANCEL open if returns false + var cbReturn = _runCallbacks("onopen_start", pane); + + if (cbReturn === "abort") + return queueNext(); + + // update pane-state again in case options were changed in onopen_start + if (cbReturn !== "NC") // NC = "No Callback" + setSizeLimits(pane, slide); + + if (s.minSize > s.maxSize) { // INSUFFICIENT ROOM FOR PANE TO OPEN! + syncPinBtns(pane, false); // make sure pin-buttons are reset + if (!noAlert && o.noRoomToOpenTip) + alert(o.noRoomToOpenTip); + return queueNext(); // ABORT + } + + if (slide) // START Sliding - will set isSliding=true + bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane + else if (s.isSliding) // PIN PANE (stop sliding) - open pane 'normally' instead + bindStopSlidingEvents(pane, false); // UNBIND trigger events - will set isSliding=false + else if (o.slidable) + bindStartSlidingEvent(pane, false); // UNBIND trigger events + + s.noRoom = false; // will be reset by makePaneFit if 'noRoom' + makePaneFit(pane); + + // transfer logic var to temp var + isShowing = s.isShowing; + // now clear the logic var + delete s.isShowing; + + doFX = !noAnimation && s.isClosed && (o.fxName_open != "none"); + s.isMoving = true; + s.isVisible = true; + s.isClosed = false; + // update isHidden BEFORE sizing panes - WHY??? Old? + if (isShowing) s.isHidden = false; + + if (doFX) { // ANIMATE + // mask panes with objects + var masks = "center"+ (c.dir=="horz" ? ",west,east" : ""); + if (s.isSliding) masks += ","+ _c.oppositeEdge[pane]; + showMasks( masks, true ); // true = ONLY mask panes with maskObjects=true + lockPaneForFX(pane, true); // need to set left/top so animation will work + $P.show( o.fxName_open, o.fxSettings_open, o.fxSpeed_open, function() { + lockPaneForFX(pane, false); // undo + if (s.isVisible) open_2(); // continue + queueNext(); + }); + } + else { // no animation + _showPane(pane);// just show pane and... + open_2(); // continue + queueNext(); + }; + }); + + // SUBROUTINE + function open_2 () { + s.isMoving = false; + + // cure iframe display issues + _fixIframe(pane); + + // NOTE: if isSliding, then other panes are NOT 'resized' + if (!s.isSliding) { // resize all panes adjacent to this one + hideMasks(); // remove any masks shown while opening + sizeMidPanes(_c[pane].dir=="vert" ? "center" : "", false); // false = NOT skipCallback + } + + // set classes, position handles and execute callbacks... + setAsOpen(pane); + }; + + } + + /** + * @param {string} pane The pane just opened, ie: north, south, east, or west + * @param {boolean=} [skipCallback=false] + */ +, setAsOpen = function (pane, skipCallback) { + var + $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , o = options[pane] + , s = state[pane] + , side = _c[pane].side.toLowerCase() + , inset = "inset"+ _c[pane].side + , rClass = o.resizerClass + , tClass = o.togglerClass + , _pane = "-"+ pane // used for classNames + , _open = "-open" + , _closed = "-closed" + , _sliding= "-sliding" + ; + $R + .css(side, sC[inset] + getPaneSize(pane)) // move the resizer + .removeClass( rClass+_closed +" "+ rClass+_pane+_closed ) + .addClass( rClass+_open +" "+ rClass+_pane+_open ) + ; + if (s.isSliding) + $R.addClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) + else // in case 'was sliding' + $R.removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) + + if (o.resizerDblClickToggle) + $R.bind("dblclick", toggle ); + removeHover( 0, $R ); // remove hover classes + if (o.resizable && $.layout.plugins.draggable) + $R .draggable("enable") + .css("cursor", o.resizerCursor) + .attr("title", o.resizerTip); + else if (!s.isSliding) + $R.css("cursor", "default"); // n-resize, s-resize, etc + + // if pane also has a toggler button, adjust that too + if ($T) { + $T .removeClass( tClass+_closed +" "+ tClass+_pane+_closed ) + .addClass( tClass+_open +" "+ tClass+_pane+_open ) + .attr("title", o.togglerTip_open); // may be blank + removeHover( 0, $T ); // remove hover classes + // toggler-content - if exists + $T.children(".content-closed").hide(); + $T.children(".content-open").css("display","block"); + } + + // sync any 'pin buttons' + syncPinBtns(pane, !s.isSliding); + + // update pane-state dimensions - BEFORE resizing content + $.extend(s, elDims($P)); + + if (state.initialized) { + // resize resizer & toggler sizes for all panes + sizeHandles(); + // resize content every time pane opens - to be sure + sizeContent(pane, true); // true = remeasure headers/footers, even if 'pane.isMoving' + } + + if (!skipCallback && (state.initialized || o.triggerEventsOnLoad) && $P.is(":visible")) { + // onopen callback + _runCallbacks("onopen_end", pane); + // onshow callback - TODO: should this be here? + if (s.isShowing) _runCallbacks("onshow_end", pane); + + // ALSO call onresize because layout-size *may* have changed while pane was closed + if (state.initialized) + _runCallbacks("onresize_end", pane); + } + + // TODO: Somehow sizePane("north") is being called after this point??? + } + + + /** + * slideOpen / slideClose / slideToggle + * + * Pass-though methods for sliding + */ +, slideOpen = function (evt_or_pane) { + if (!isInitialized()) return; + var evt = evtObj(evt_or_pane) + , pane = evtPane.call(this, evt_or_pane) + , s = state[pane] + , delay = options[pane].slideDelay_open + ; + // prevent event from triggering on NEW resizer binding created below + if (evt) evt.stopImmediatePropagation(); + + if (s.isClosed && evt && evt.type === "mouseenter" && delay > 0) + // trigger = mouseenter - use a delay + timer.set(pane+"_openSlider", open_NOW, delay); + else + open_NOW(); // will unbind events if is already open + + /** + * SUBROUTINE for timed open + */ + function open_NOW () { + if (!s.isClosed) // skip if no longer closed! + bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane + else if (!s.isMoving) + open(pane, true); // true = slide - open() will handle binding + }; + } + +, slideClose = function (evt_or_pane) { + if (!isInitialized()) return; + var evt = evtObj(evt_or_pane) + , pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + , delay = s.isMoving ? 1000 : 300 // MINIMUM delay - option may override + ; + if (s.isClosed || s.isResizing) + return; // skip if already closed OR in process of resizing + else if (o.slideTrigger_close === "click") + close_NOW(); // close immediately onClick + else if (o.preventQuickSlideClose && s.isMoving) + return; // handle Chrome quick-close on slide-open + else if (o.preventPrematureSlideClose && evt && $.layout.isMouseOverElem(evt, $Ps[pane])) + return; // handle incorrect mouseleave trigger, like when over a SELECT-list in IE + else if (evt) // trigger = mouseleave - use a delay + // 1 sec delay if 'opening', else .3 sec + timer.set(pane+"_closeSlider", close_NOW, max(o.slideDelay_close, delay)); + else // called programically + close_NOW(); + + /** + * SUBROUTINE for timed close + */ + function close_NOW () { + if (s.isClosed) // skip 'close' if already closed! + bindStopSlidingEvents(pane, false); // UNBIND trigger events - TODO: is this needed here? + else if (!s.isMoving) + close(pane); // close will handle unbinding + }; + } + + /** + * @param {string} pane The pane being opened, ie: north, south, east, or west + */ +, slideToggle = function (evt_or_pane) { + var pane = evtPane.call(this, evt_or_pane); + toggle(pane, true); + } + + + /** + * Must set left/top on East/South panes so animation will work properly + * + * @param {string} pane The pane to lock, 'east' or 'south' - any other is ignored! + * @param {boolean} doLock true = set left/top, false = remove + */ +, lockPaneForFX = function (pane, doLock) { + var $P = $Ps[pane] + , s = state[pane] + , o = options[pane] + , z = options.zIndexes + ; + if (doLock) { + $P.css({ zIndex: z.pane_animate }); // overlay all elements during animation + if (pane=="south") + $P.css({ top: sC.insetTop + sC.innerHeight - $P.outerHeight() }); + else if (pane=="east") + $P.css({ left: sC.insetLeft + sC.innerWidth - $P.outerWidth() }); + } + else { // animation DONE - RESET CSS + // TODO: see if this can be deleted. It causes a quick-close when sliding in Chrome + $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) }); + if (pane=="south") + $P.css({ top: "auto" }); + // if pane is positioned 'off-screen', then DO NOT screw with it! + else if (pane=="east" && !$P.css("left").match(/\-99999/)) + $P.css({ left: "auto" }); + // fix anti-aliasing in IE - only needed for animations that change opacity + if (browser.msie && o.fxOpacityFix && o.fxName_open != "slide" && $P.css("filter") && $P.css("opacity") == 1) + $P[0].style.removeAttribute('filter'); + } + } + + + /** + * Toggle sliding functionality of a specific pane on/off by adding removing 'slide open' trigger + * + * @see open(), close() + * @param {string} pane The pane to enable/disable, 'north', 'south', etc. + * @param {boolean} enable Enable or Disable sliding? + */ +, bindStartSlidingEvent = function (pane, enable) { + var o = options[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , evtName = o.slideTrigger_open.toLowerCase() + ; + if (!$R || (enable && !o.slidable)) return; + + // make sure we have a valid event + if (evtName.match(/mouseover/)) + evtName = o.slideTrigger_open = "mouseenter"; + else if (!evtName.match(/click|dblclick|mouseenter/)) + evtName = o.slideTrigger_open = "click"; + + $R + // add or remove event + [enable ? "bind" : "unbind"](evtName +'.'+ sID, slideOpen) + // set the appropriate cursor & title/tip + .css("cursor", enable ? o.sliderCursor : "default") + .attr("title", enable ? o.sliderTip : "") + ; + } + + /** + * Add or remove 'mouseleave' events to 'slide close' when pane is 'sliding' open or closed + * Also increases zIndex when pane is sliding open + * See bindStartSlidingEvent for code to control 'slide open' + * + * @see slideOpen(), slideClose() + * @param {string} pane The pane to process, 'north', 'south', etc. + * @param {boolean} enable Enable or Disable events? + */ +, bindStopSlidingEvents = function (pane, enable) { + var o = options[pane] + , s = state[pane] + , c = _c[pane] + , z = options.zIndexes + , evtName = o.slideTrigger_close.toLowerCase() + , action = (enable ? "bind" : "unbind") + , $P = $Ps[pane] + , $R = $Rs[pane] + ; + s.isSliding = enable; // logic + timer.clear(pane+"_closeSlider"); // just in case + + // remove 'slideOpen' event from resizer + // ALSO will raise the zIndex of the pane & resizer + if (enable) bindStartSlidingEvent(pane, false); + + // RE/SET zIndex - increases when pane is sliding-open, resets to normal when not + $P.css("zIndex", enable ? z.pane_sliding : z.pane_normal); + $R.css("zIndex", enable ? z.pane_sliding+2 : z.resizer_normal); // NOTE: mask = pane_sliding+1 + + // make sure we have a valid event + if (!evtName.match(/click|mouseleave/)) + evtName = o.slideTrigger_close = "mouseleave"; // also catches 'mouseout' + + // add/remove slide triggers + $R[action](evtName, slideClose); // base event on resize + // need extra events for mouseleave + if (evtName === "mouseleave") { + // also close on pane.mouseleave + $P[action]("mouseleave."+ sID, slideClose); + // cancel timer when mouse moves between 'pane' and 'resizer' + $R[action]("mouseenter."+ sID, cancelMouseOut); + $P[action]("mouseenter."+ sID, cancelMouseOut); + } + + if (!enable) + timer.clear(pane+"_closeSlider"); + else if (evtName === "click" && !o.resizable) { + // IF pane is not resizable (which already has a cursor and tip) + // then set the a cursor & title/tip on resizer when sliding + $R.css("cursor", enable ? o.sliderCursor : "default"); + $R.attr("title", enable ? o.togglerTip_open : ""); // use Toggler-tip, eg: "Close Pane" + } + + // SUBROUTINE for mouseleave timer clearing + function cancelMouseOut (evt) { + timer.clear(pane+"_closeSlider"); + evt.stopPropagation(); + } + } + + + /** + * Hides/closes a pane if there is insufficient room - reverses this when there is room again + * MUST have already called setSizeLimits() before calling this method + * + * @param {string} pane The pane being resized + * @param {boolean=} [isOpening=false] Called from onOpen? + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [force=false] + */ +, makePaneFit = function (pane, isOpening, skipCallback, force) { + var + o = options[pane] + , s = state[pane] + , c = _c[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , isSidePane = c.dir==="vert" + , hasRoom = false + ; + // special handling for center & east/west panes + if (pane === "center" || (isSidePane && s.noVerticalRoom)) { + // see if there is enough room to display the pane + // ERROR: hasRoom = s.minHeight <= s.maxHeight && (isSidePane || s.minWidth <= s.maxWidth); + hasRoom = (s.maxHeight >= 0); + if (hasRoom && s.noRoom) { // previously hidden due to noRoom, so show now + _showPane(pane); + if ($R) $R.show(); + s.isVisible = true; + s.noRoom = false; + if (isSidePane) s.noVerticalRoom = false; + _fixIframe(pane); + } + else if (!hasRoom && !s.noRoom) { // not currently hidden, so hide now + _hidePane(pane); + if ($R) $R.hide(); + s.isVisible = false; + s.noRoom = true; + } + } + + // see if there is enough room to fit the border-pane + if (pane === "center") { + // ignore center in this block + } + else if (s.minSize <= s.maxSize) { // pane CAN fit + hasRoom = true; + if (s.size > s.maxSize) // pane is too big - shrink it + sizePane(pane, s.maxSize, skipCallback, force, true); // true = noAnimation + else if (s.size < s.minSize) // pane is too small - enlarge it + sizePane(pane, s.minSize, skipCallback, force, true); + // need s.isVisible because new pseudoClose method keeps pane visible, but off-screen + else if ($R && s.isVisible && $P.is(":visible")) { + // make sure resizer-bar is positioned correctly + // handles situation where nested layout was 'hidden' when initialized + var side = c.side.toLowerCase() + , pos = s.size + sC["inset"+ c.side] + ; + if ($.layout.cssNum($R, side) != pos) $R.css( side, pos ); + } + + // if was previously hidden due to noRoom, then RESET because NOW there is room + if (s.noRoom) { + // s.noRoom state will be set by open or show + if (s.wasOpen && o.closable) { + if (o.autoReopen) + open(pane, false, true, true); // true = noAnimation, true = noAlert + else // leave the pane closed, so just update state + s.noRoom = false; + } + else + show(pane, s.wasOpen, true, true); // true = noAnimation, true = noAlert + } + } + else { // !hasRoom - pane CANNOT fit + if (!s.noRoom) { // pane not set as noRoom yet, so hide or close it now... + s.noRoom = true; // update state + s.wasOpen = !s.isClosed && !s.isSliding; + if (s.isClosed){} // SKIP + else if (o.closable) // 'close' if possible + close(pane, true, true); // true = force, true = noAnimation + else // 'hide' pane if cannot just be closed + hide(pane, true); // true = noAnimation + } + } + } + + + /** + * sizePane / manualSizePane + * sizePane is called only by internal methods whenever a pane needs to be resized + * manualSizePane is an exposed flow-through method allowing extra code when pane is 'manually resized' + * + * @param {string} pane The pane being resized + * @param {number} size The *desired* new size for this pane - will be validated + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [noAnimation=false] + */ +, manualSizePane = function (evt_or_pane, size, skipCallback, noAnimation) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , o = options[pane] + , s = state[pane] + // if resizing callbacks have been delayed and resizing is now DONE, force resizing to complete... + , forceResize = o.livePaneResizing && !s.isResizing + ; + // ANY call to manualSizePane disables autoResize - ie, percentage sizing + o.autoResize = false; + // flow-through... + sizePane(pane, size, skipCallback, forceResize, noAnimation); // will animate resize if option enabled + } + + /** + * @param {string} pane The pane being resized + * @param {number} size The *desired* new size for this pane - will be validated + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [force=false] Force resizing even if does not seem necessary + * @param {boolean=} [noAnimation=false] + */ +, sizePane = function (evt_or_pane, size, skipCallback, force, noAnimation) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) // probably NEVER called from event? + , o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , side = _c[pane].side.toLowerCase() + , dimName = _c[pane].sizeType.toLowerCase() + , inset = "inset"+ _c[pane].side + , skipResizeWhileDragging = s.isResizing && !o.triggerEventsDuringLiveResize + , doFX = noAnimation !== true && o.animatePaneSizing + , oldSize, newSize + ; + // QUEUE in case another action/animation is in progress + $N.queue(function( queueNext ){ + // calculate 'current' min/max sizes + setSizeLimits(pane); // update pane-state + oldSize = s.size; + size = _parseSize(pane, size); // handle percentages & auto + size = max(size, _parseSize(pane, o.minSize)); + size = min(size, s.maxSize); + if (size < s.minSize) { // not enough room for pane! + queueNext(); // call before makePaneFit() because it needs the queue free + makePaneFit(pane, false, skipCallback); // will hide or close pane + return; + } + + // IF newSize is same as oldSize, then nothing to do - abort + if (!force && size === oldSize) + return queueNext(); + + // onresize_start callback CANNOT cancel resizing because this would break the layout! + if (!skipCallback && state.initialized && s.isVisible) + _runCallbacks("onresize_start", pane); + + // resize the pane, and make sure its visible + newSize = cssSize(pane, size); + + if (doFX && $P.is(":visible")) { // ANIMATE + var fx = $.layout.effects.size[pane] || $.layout.effects.size.all + , easing = o.fxSettings_size.easing || fx.easing + , z = options.zIndexes + , props = {}; + props[ dimName ] = newSize +'px'; + s.isMoving = true; + // overlay all elements during animation + $P.css({ zIndex: z.pane_animate }) + .show().animate( props, o.fxSpeed_size, easing, function(){ + // reset zIndex after animation + $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) }); + s.isMoving = false; + sizePane_2(); // continue + queueNext(); + }); + } + else { // no animation + $P.css( dimName, newSize ); // resize pane + // if pane is visible, then + if ($P.is(":visible")) + sizePane_2(); // continue + else { + // pane is NOT VISIBLE, so just update state data... + // when pane is *next opened*, it will have the new size + s.size = size; // update state.size + $.extend(s, elDims($P)); // update state dimensions + } + queueNext(); + }; + + }); + + // SUBROUTINE + function sizePane_2 () { + /* Panes are sometimes not sized precisely in some browsers!? + * This code will resize the pane up to 3 times to nudge the pane to the correct size + */ + var actual = dimName==='width' ? $P.outerWidth() : $P.outerHeight() + , tries = [{ + pane: pane + , count: 1 + , target: size + , actual: actual + , correct: (size === actual) + , attempt: size + , cssSize: newSize + }] + , lastTry = tries[0] + , msg = 'Inaccurate size after resizing the '+ pane +'-pane.' + ; + while ( !lastTry.correct ) { + thisTry = { pane: pane, count: lastTry.count+1, target: size }; + + if (lastTry.actual > size) + thisTry.attempt = max(0, lastTry.attempt - (lastTry.actual - size)); + else // lastTry.actual < size + thisTry.attempt = max(0, lastTry.attempt + (size - lastTry.actual)); + + thisTry.cssSize = cssSize(pane, thisTry.attempt); + $P.css( dimName, thisTry.cssSize ); + + thisTry.actual = dimName=='width' ? $P.outerWidth() : $P.outerHeight(); + thisTry.correct = (size === thisTry.actual); + + // if showDebugMessages, log attempts and alert the user of this *non-fatal error* + if (options.showDebugMessages) { + if ( tries.length === 1) { + _log(msg, false); + _log(lastTry, false); + } + _log(thisTry, false); + } + + // after 4 tries, is as close as its gonna get! + if (tries.length > 3) break; + + tries.push( thisTry ); + lastTry = tries[ tries.length - 1 ]; + } + // END TESTING CODE + + // update pane-state dimensions + s.size = size; + $.extend(s, elDims($P)); + + if (s.isVisible && $P.is(":visible")) { + // reposition the resizer-bar + if ($R) $R.css( side, size + sC[inset] ); + // resize the content-div + sizeContent(pane); + } + + if (!skipCallback && !skipResizeWhileDragging && state.initialized && s.isVisible) + _runCallbacks("onresize_end", pane); + + // resize all the adjacent panes, and adjust their toggler buttons + // when skipCallback passed, it means the controlling method will handle 'other panes' + if (!skipCallback) { + // also no callback if live-resize is in progress and NOT triggerEventsDuringLiveResize + if (!s.isSliding) sizeMidPanes(_c[pane].dir=="horz" ? "" : "center", skipResizeWhileDragging, force); + sizeHandles(); + } + + // if opposite-pane was autoClosed, see if it can be autoOpened now + var altPane = _c.oppositeEdge[pane]; + if (size < oldSize && state[ altPane ].noRoom) { + setSizeLimits( altPane ); + makePaneFit( altPane, false, skipCallback ); + } + + // DEBUG - ALERT user/developer so they know there was a sizing problem + if (options.showDebugMessages && tries.length > 1) + _log(msg +'\nSee the Error Console for details.', true); + } + } + + /** + * @see initPanes(), sizePane(), resizeAll(), open(), close(), hide() + * @param {string} panes The pane(s) being resized, comma-delmited string + * @param {boolean=} [skipCallback=false] Should the onresize callback be run? + * @param {boolean=} [force=false] + */ +, sizeMidPanes = function (panes, skipCallback, force) { + panes = (panes ? panes : "east,west,center").split(","); + + $.each(panes, function (i, pane) { + if (!$Ps[pane]) return; // NO PANE - skip + var + o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , isCenter= (pane=="center") + , hasRoom = true + , CSS = {} + , newCenter = calcNewCenterPaneDims() + ; + // update pane-state dimensions + $.extend(s, elDims($P)); + + if (pane === "center") { + if (!force && s.isVisible && newCenter.width === s.outerWidth && newCenter.height === s.outerHeight) + return true; // SKIP - pane already the correct size + // set state for makePaneFit() logic + $.extend(s, cssMinDims(pane), { + maxWidth: newCenter.width + , maxHeight: newCenter.height + }); + CSS = newCenter; + // convert OUTER width/height to CSS width/height + CSS.width = cssW($P, CSS.width); + // NEW - allow pane to extend 'below' visible area rather than hide it + CSS.height = cssH($P, CSS.height); + hasRoom = CSS.width >= 0 && CSS.height >= 0; // height >= 0 = ALWAYS TRUE NOW + // during layout init, try to shrink east/west panes to make room for center + if (!state.initialized && o.minWidth > s.outerWidth) { + var + reqPx = o.minWidth - s.outerWidth + , minE = options.east.minSize || 0 + , minW = options.west.minSize || 0 + , sizeE = state.east.size + , sizeW = state.west.size + , newE = sizeE + , newW = sizeW + ; + if (reqPx > 0 && state.east.isVisible && sizeE > minE) { + newE = max( sizeE-minE, sizeE-reqPx ); + reqPx -= sizeE-newE; + } + if (reqPx > 0 && state.west.isVisible && sizeW > minW) { + newW = max( sizeW-minW, sizeW-reqPx ); + reqPx -= sizeW-newW; + } + // IF we found enough extra space, then resize the border panes as calculated + if (reqPx === 0) { + if (sizeE != minE) + sizePane('east', newE, true, force, true); // true = skipCallback/noAnimation - initPanes will handle when done + if (sizeW != minW) + sizePane('west', newW, true, force, true); + // now start over! + sizeMidPanes('center', skipCallback, force); + return; // abort this loop + } + } + } + else { // for east and west, set only the height, which is same as center height + // set state.min/maxWidth/Height for makePaneFit() logic + if (s.isVisible && !s.noVerticalRoom) + $.extend(s, elDims($P), cssMinDims(pane)) + if (!force && !s.noVerticalRoom && newCenter.height === s.outerHeight) + return true; // SKIP - pane already the correct size + // east/west have same top, bottom & height as center + CSS.top = newCenter.top; + CSS.bottom = newCenter.bottom; + // NEW - allow pane to extend 'below' visible area rather than hide it + CSS.height = cssH($P, newCenter.height); + s.maxHeight = CSS.height; + hasRoom = (s.maxHeight >= 0); // ALWAYS TRUE NOW + if (!hasRoom) s.noVerticalRoom = true; // makePaneFit() logic + } + + if (hasRoom) { + // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized + if (!skipCallback && state.initialized) + _runCallbacks("onresize_start", pane); + + $P.css(CSS); // apply the CSS to pane + sizeHandles(pane); // also update resizer length + if (s.noRoom && !s.isClosed && !s.isHidden) + makePaneFit(pane); // will re-open/show auto-closed/hidden pane + if (s.isVisible) { + $.extend(s, elDims($P)); // update pane dimensions + if (state.initialized) sizeContent(pane); // also resize the contents, if exists + } + } + else if (!s.noRoom && s.isVisible) // no room for pane + makePaneFit(pane); // will hide or close pane + + if (!s.isVisible) + return true; // DONE - next pane + + /* + * Extra CSS for IE6 or IE7 in Quirks-mode - add 'width' to NORTH/SOUTH panes + * Normally these panes have only 'left' & 'right' positions so pane auto-sizes + * ALSO required when pane is an IFRAME because will NOT default to 'full width' + */ + if (pane === "center") { // finished processing midPanes + var b = $.layout.browser; + var fix = b.isIE6 || (b.msie && !$.support.boxModel); + if ($Ps.north && (fix || state.north.tagName=="IFRAME")) + $Ps.north.css("width", cssW($Ps.north, sC.innerWidth)); + if ($Ps.south && (fix || state.south.tagName=="IFRAME")) + $Ps.south.css("width", cssW($Ps.south, sC.innerWidth)); + } + + // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized + if (!skipCallback && state.initialized) + _runCallbacks("onresize_end", pane); + }); + } + + + /** + * @see window.onresize(), callbacks or custom code + */ +, resizeAll = function () { + if (!state.initialized) { + _initLayoutElements(); + return; // no need to resize since we just initialized! + } + var oldW = sC.innerWidth + , oldH = sC.innerHeight + ; + // cannot size layout when 'container' is hidden or collapsed + if (!$N.is(":visible:") ) return; + $.extend( state.container, elDims( $N ) ); // UPDATE container dimensions + if (!sC.outerHeight) return; + + // onresizeall_start will CANCEL resizing if returns false + // state.container has already been set, so user can access this info for calcuations + if (false === _runCallbacks("onresizeall_start")) return false; + + var // see if container is now 'smaller' than before + shrunkH = (sC.innerHeight < oldH) + , shrunkW = (sC.innerWidth < oldW) + , $P, o, s, dir + ; + // NOTE special order for sizing: S-N-E-W + $.each(["south","north","east","west"], function (i, pane) { + if (!$Ps[pane]) return; // no pane - SKIP + s = state[pane]; + o = options[pane]; + dir = _c[pane].dir; + + if (o.autoResize && s.size != o.size) // resize pane to original size set in options + sizePane(pane, o.size, true, true, true); // true=skipCallback/forceResize/noAnimation + else { + setSizeLimits(pane); + makePaneFit(pane, false, true, true); // true=skipCallback/forceResize + } + }); + + sizeMidPanes("", true, true); // true=skipCallback, true=forceResize + sizeHandles(); // reposition the toggler elements + + // trigger all individual pane callbacks AFTER layout has finished resizing + o = options; // reuse alias + $.each(_c.allPanes, function (i, pane) { + $P = $Ps[pane]; + if (!$P) return; // SKIP + if (state[pane].isVisible) // undefined for non-existent panes + _runCallbacks("onresize_end", pane); // callback - if exists + }); + + _runCallbacks("onresizeall_end"); + //_triggerLayoutEvent(pane, 'resizeall'); + } + + /** + * Whenever a pane resizes or opens that has a nested layout, trigger resizeAll + * + * @param {string} pane The pane just resized or opened + */ +, resizeChildLayout = function (evt_or_pane) { + var pane = evtPane.call(this, evt_or_pane); + if (!options[pane].resizeChildLayout) return; + var $P = $Ps[pane] + , $C = $Cs[pane] + , d = "layout" + , P = Instance[pane] + , L = children[pane] + ; + // user may have manually set EITHER instance pointer, so handle that + if (P.child && !L) { + // have to reverse the pointers! + var el = P.child.container; + L = children[pane] = (el ? el.data(d) : 0) || null; // set pointer _directly_ to layout instance + } + + // if a layout-pointer exists, see if child has been destroyed + if (L && L.destroyed) + L = children[pane] = null; // clear child pointers + // no child layout pointer is set - see if there is a child layout NOW + if (!L) L = children[pane] = $P.data(d) || ($C ? $C.data(d) : 0) || null; // set/update child pointers + + // ALWAYS refresh the pane.child alias + P.child = children[pane]; + + if (L) L.resizeAll(); + } + + + /** + * IF pane has a content-div, then resize all elements inside pane to fit pane-height + * + * @param {string=} [panes=""] The pane(s) being resized + * @param {boolean=} [remeasure=false] Should the content (header/footer) be remeasured? + */ +, sizeContent = function (evt_or_panes, remeasure) { + if (!isInitialized()) return; + + var panes = evtPane.call(this, evt_or_panes); + panes = panes ? panes.split(",") : _c.allPanes; + + $.each(panes, function (idx, pane) { + var + $P = $Ps[pane] + , $C = $Cs[pane] + , o = options[pane] + , s = state[pane] + , m = s.content // m = measurements + ; + if (!$P || !$C || !$P.is(":visible")) return true; // NOT VISIBLE - skip + + // if content-element was REMOVED, update OR remove the pointer + if (!$C.length) { + initContent(pane, false); // false = do NOT sizeContent() - already there! + if (!$C) return; // no replacement element found - pointer have been removed + } + + // onsizecontent_start will CANCEL resizing if returns false + if (false === _runCallbacks("onsizecontent_start", pane)) return; + + // skip re-measuring offsets if live-resizing + if ((!s.isMoving && !s.isResizing) || o.liveContentResizing || remeasure || m.top == undefined) { + _measure(); + // if any footers are below pane-bottom, they may not measure correctly, + // so allow pane overflow and re-measure + if (m.hiddenFooters > 0 && $P.css("overflow") === "hidden") { + $P.css("overflow", "visible"); + _measure(); // remeasure while overflowing + $P.css("overflow", "hidden"); + } + } + // NOTE: spaceAbove/Below *includes* the pane paddingTop/Bottom, but not pane.borders + var newH = s.innerHeight - (m.spaceAbove - s.css.paddingTop) - (m.spaceBelow - s.css.paddingBottom); + + if (!$C.is(":visible") || m.height != newH) { + // size the Content element to fit new pane-size - will autoHide if not enough room + setOuterHeight($C, newH, true); // true=autoHide + m.height = newH; // save new height + }; + + if (state.initialized) + _runCallbacks("onsizecontent_end", pane); + + function _below ($E) { + return max(s.css.paddingBottom, (parseInt($E.css("marginBottom"), 10) || 0)); + }; + + function _measure () { + var + ignore = options[pane].contentIgnoreSelector + , $Fs = $C.nextAll().not(ignore || ':lt(0)') // not :lt(0) = ALL + , $Fs_vis = $Fs.filter(':visible') + , $F = $Fs_vis.filter(':last') + ; + m = { + top: $C[0].offsetTop + , height: $C.outerHeight() + , numFooters: $Fs.length + , hiddenFooters: $Fs.length - $Fs_vis.length + , spaceBelow: 0 // correct if no content footer ($E) + } + m.spaceAbove = m.top; // just for state - not used in calc + m.bottom = m.top + m.height; + if ($F.length) + //spaceBelow = (LastFooter.top + LastFooter.height) [footerBottom] - Content.bottom + max(LastFooter.marginBottom, pane.paddingBotom) + m.spaceBelow = ($F[0].offsetTop + $F.outerHeight()) - m.bottom + _below($F); + else // no footer - check marginBottom on Content element itself + m.spaceBelow = _below($C); + }; + }); + } + + + /** + * Called every time a pane is opened, closed, or resized to slide the togglers to 'center' and adjust their length if necessary + * + * @see initHandles(), open(), close(), resizeAll() + * @param {string=} [panes=""] The pane(s) being resized + */ +, sizeHandles = function (evt_or_panes) { + var panes = evtPane.call(this, evt_or_panes) + panes = panes ? panes.split(",") : _c.borderPanes; + + $.each(panes, function (i, pane) { + var + o = options[pane] + , s = state[pane] + , $P = $Ps[pane] + , $R = $Rs[pane] + , $T = $Ts[pane] + , $TC + ; + if (!$P || !$R) return; + + var + dir = _c[pane].dir + , _state = (s.isClosed ? "_closed" : "_open") + , spacing = o["spacing"+ _state] + , togAlign = o["togglerAlign"+ _state] + , togLen = o["togglerLength"+ _state] + , paneLen + , left + , offset + , CSS = {} + ; + + if (spacing === 0) { + $R.hide(); + return; + } + else if (!s.noRoom && !s.isHidden) // skip if resizer was hidden for any reason + $R.show(); // in case was previously hidden + + // Resizer Bar is ALWAYS same width/height of pane it is attached to + if (dir === "horz") { // north/south + //paneLen = $P.outerWidth(); // s.outerWidth || + paneLen = sC.innerWidth; // handle offscreen-panes + s.resizerLength = paneLen; + left = $.layout.cssNum($P, "left") + $R.css({ + width: cssW($R, paneLen) // account for borders & padding + , height: cssH($R, spacing) // ditto + , left: left > -9999 ? left : sC.insetLeft // handle offscreen-panes + }); + } + else { // east/west + paneLen = $P.outerHeight(); // s.outerHeight || + s.resizerLength = paneLen; + $R.css({ + height: cssH($R, paneLen) // account for borders & padding + , width: cssW($R, spacing) // ditto + , top: sC.insetTop + getPaneSize("north", true) // TODO: what if no North pane? + //, top: $.layout.cssNum($Ps["center"], "top") + }); + } + + // remove hover classes + removeHover( o, $R ); + + if ($T) { + if (togLen === 0 || (s.isSliding && o.hideTogglerOnSlide)) { + $T.hide(); // always HIDE the toggler when 'sliding' + return; + } + else + $T.show(); // in case was previously hidden + + if (!(togLen > 0) || togLen === "100%" || togLen > paneLen) { + togLen = paneLen; + offset = 0; + } + else { // calculate 'offset' based on options.PANE.togglerAlign_open/closed + if (isStr(togAlign)) { + switch (togAlign) { + case "top": + case "left": offset = 0; + break; + case "bottom": + case "right": offset = paneLen - togLen; + break; + case "middle": + case "center": + default: offset = round((paneLen - togLen) / 2); // 'default' catches typos + } + } + else { // togAlign = number + var x = parseInt(togAlign, 10); // + if (togAlign >= 0) offset = x; + else offset = paneLen - togLen + x; // NOTE: x is negative! + } + } + + if (dir === "horz") { // north/south + var width = cssW($T, togLen); + $T.css({ + width: width // account for borders & padding + , height: cssH($T, spacing) // ditto + , left: offset // TODO: VERIFY that toggler positions correctly for ALL values + , top: 0 + }); + // CENTER the toggler content SPAN + $T.children(".content").each(function(){ + $TC = $(this); + $TC.css("marginLeft", round((width-$TC.outerWidth())/2)); // could be negative + }); + } + else { // east/west + var height = cssH($T, togLen); + $T.css({ + height: height // account for borders & padding + , width: cssW($T, spacing) // ditto + , top: offset // POSITION the toggler + , left: 0 + }); + // CENTER the toggler content SPAN + $T.children(".content").each(function(){ + $TC = $(this); + $TC.css("marginTop", round((height-$TC.outerHeight())/2)); // could be negative + }); + } + + // remove ALL hover classes + removeHover( 0, $T ); + } + + // DONE measuring and sizing this resizer/toggler, so can be 'hidden' now + if (!state.initialized && (o.initHidden || s.noRoom)) { + $R.hide(); + if ($T) $T.hide(); + } + }); + } + + + /** + * @param {string} pane + */ +, enableClosable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $T = $Ts[pane] + , o = options[pane] + ; + if (!$T) return; + o.closable = true; + $T .bind("click."+ sID, function(evt){ evt.stopPropagation(); toggle(pane); }) + .css("visibility", "visible") + .css("cursor", "pointer") + .attr("title", state[pane].isClosed ? o.togglerTip_closed : o.togglerTip_open) // may be blank + .show(); + } + /** + * @param {string} pane + * @param {boolean=} [hide=false] + */ +, disableClosable = function (evt_or_pane, hide) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $T = $Ts[pane] + ; + if (!$T) return; + options[pane].closable = false; + // is closable is disable, then pane MUST be open! + if (state[pane].isClosed) open(pane, false, true); + $T .unbind("."+ sID) + .css("visibility", hide ? "hidden" : "visible") // instead of hide(), which creates logic issues + .css("cursor", "default") + .attr("title", ""); + } + + + /** + * @param {string} pane + */ +, enableSlidable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + ; + if (!$R || !$R.data('draggable')) return; + options[pane].slidable = true; + if (s.isClosed) + bindStartSlidingEvent(pane, true); + } + /** + * @param {string} pane + */ +, disableSlidable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + ; + if (!$R) return; + options[pane].slidable = false; + if (state[pane].isSliding) + close(pane, false, true); + else { + bindStartSlidingEvent(pane, false); + $R .css("cursor", "default") + .attr("title", ""); + removeHover(null, $R[0]); // in case currently hovered + } + } + + + /** + * @param {string} pane + */ +, enableResizable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + , o = options[pane] + ; + if (!$R || !$R.data('draggable')) return; + o.resizable = true; + $R.draggable("enable"); + if (!state[pane].isClosed) + $R .css("cursor", o.resizerCursor) + .attr("title", o.resizerTip); + } + /** + * @param {string} pane + */ +, disableResizable = function (evt_or_pane) { + if (!isInitialized()) return; + var pane = evtPane.call(this, evt_or_pane) + , $R = $Rs[pane] + ; + if (!$R || !$R.data('draggable')) return; + options[pane].resizable = false; + $R .draggable("disable") + .css("cursor", "default") + .attr("title", ""); + removeHover(null, $R[0]); // in case currently hovered + } + + + /** + * Move a pane from source-side (eg, west) to target-side (eg, east) + * If pane exists on target-side, move that to source-side, ie, 'swap' the panes + * + * @param {string} pane1 The pane/edge being swapped + * @param {string} pane2 ditto + */ +, swapPanes = function (evt_or_pane1, pane2) { + if (!isInitialized()) return; + var pane1 = evtPane.call(this, evt_or_pane1); + // change state.edge NOW so callbacks can know where pane is headed... + state[pane1].edge = pane2; + state[pane2].edge = pane1; + // run these even if NOT state.initialized + if (false === _runCallbacks("onswap_start", pane1) + || false === _runCallbacks("onswap_start", pane2) + ) { + state[pane1].edge = pane1; // reset + state[pane2].edge = pane2; + return; + } + + var + oPane1 = copy( pane1 ) + , oPane2 = copy( pane2 ) + , sizes = {} + ; + sizes[pane1] = oPane1 ? oPane1.state.size : 0; + sizes[pane2] = oPane2 ? oPane2.state.size : 0; + + // clear pointers & state + $Ps[pane1] = false; + $Ps[pane2] = false; + state[pane1] = {}; + state[pane2] = {}; + + // ALWAYS remove the resizer & toggler elements + if ($Ts[pane1]) $Ts[pane1].remove(); + if ($Ts[pane2]) $Ts[pane2].remove(); + if ($Rs[pane1]) $Rs[pane1].remove(); + if ($Rs[pane2]) $Rs[pane2].remove(); + $Rs[pane1] = $Rs[pane2] = $Ts[pane1] = $Ts[pane2] = false; + + // transfer element pointers and data to NEW Layout keys + move( oPane1, pane2 ); + move( oPane2, pane1 ); + + // cleanup objects + oPane1 = oPane2 = sizes = null; + + // make panes 'visible' again + if ($Ps[pane1]) $Ps[pane1].css(_c.visible); + if ($Ps[pane2]) $Ps[pane2].css(_c.visible); + + // fix any size discrepancies caused by swap + resizeAll(); + + // run these even if NOT state.initialized + _runCallbacks("onswap_end", pane1); + _runCallbacks("onswap_end", pane2); + + return; + + function copy (n) { // n = pane + var + $P = $Ps[n] + , $C = $Cs[n] + ; + return !$P ? false : { + pane: n + , P: $P ? $P[0] : false + , C: $C ? $C[0] : false + , state: $.extend(true, {}, state[n]) + , options: $.extend(true, {}, options[n]) + } + }; + + function move (oPane, pane) { + if (!oPane) return; + var + P = oPane.P + , C = oPane.C + , oldPane = oPane.pane + , c = _c[pane] + , side = c.side.toLowerCase() + , inset = "inset"+ c.side + // save pane-options that should be retained + , s = $.extend({}, state[pane]) + , o = options[pane] + // RETAIN side-specific FX Settings - more below + , fx = { resizerCursor: o.resizerCursor } + , re, size, pos + ; + $.each("fxName,fxSpeed,fxSettings".split(","), function (i, k) { + fx[k +"_open"] = o[k +"_open"]; + fx[k +"_close"] = o[k +"_close"]; + fx[k +"_size"] = o[k +"_size"]; + }); + + // update object pointers and attributes + $Ps[pane] = $(P) + .data({ + layoutPane: Instance[pane] // NEW pointer to pane-alias-object + , layoutEdge: pane + }) + .css(_c.hidden) + .css(c.cssReq) + ; + $Cs[pane] = C ? $(C) : false; + + // set options and state + options[pane] = $.extend({}, oPane.options, fx); + state[pane] = $.extend({}, oPane.state); + + // change classNames on the pane, eg: ui-layout-pane-east ==> ui-layout-pane-west + re = new RegExp(o.paneClass +"-"+ oldPane, "g"); + P.className = P.className.replace(re, o.paneClass +"-"+ pane); + + // ALWAYS regenerate the resizer & toggler elements + initHandles(pane); // create the required resizer & toggler + + // if moving to different orientation, then keep 'target' pane size + if (c.dir != _c[oldPane].dir) { + size = sizes[pane] || 0; + setSizeLimits(pane); // update pane-state + size = max(size, state[pane].minSize); + // use manualSizePane to disable autoResize - not useful after panes are swapped + manualSizePane(pane, size, true, true); // true/true = skipCallback/noAnimation + } + else // move the resizer here + $Rs[pane].css(side, sC[inset] + (state[pane].isVisible ? getPaneSize(pane) : 0)); + + + // ADD CLASSNAMES & SLIDE-BINDINGS + if (oPane.state.isVisible && !s.isVisible) + setAsOpen(pane, true); // true = skipCallback + else { + setAsClosed(pane); + bindStartSlidingEvent(pane, true); // will enable events IF option is set + } + + // DESTROY the object + oPane = null; + }; + } + + + /** + * INTERNAL method to sync pin-buttons when pane is opened or closed + * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes + * + * @see open(), setAsOpen(), setAsClosed() + * @param {string} pane These are the params returned to callbacks by layout() + * @param {boolean} doPin True means set the pin 'down', False means 'up' + */ +, syncPinBtns = function (pane, doPin) { + if ($.layout.plugins.buttons) + $.each(state[pane].pins, function (i, selector) { + $.layout.buttons.setPinState(Instance, $(selector), pane, doPin); + }); + } + +; // END var DECLARATIONS + + /** + * Capture keys when enableCursorHotkey - toggle pane if hotkey pressed + * + * @see document.keydown() + */ + function keyDown (evt) { + if (!evt) return true; + var code = evt.keyCode; + if (code < 33) return true; // ignore special keys: ENTER, TAB, etc + + var + PANE = { + 38: "north" // Up Cursor - $.ui.keyCode.UP + , 40: "south" // Down Cursor - $.ui.keyCode.DOWN + , 37: "west" // Left Cursor - $.ui.keyCode.LEFT + , 39: "east" // Right Cursor - $.ui.keyCode.RIGHT + } + , ALT = evt.altKey // no worky! + , SHIFT = evt.shiftKey + , CTRL = evt.ctrlKey + , CURSOR = (CTRL && code >= 37 && code <= 40) + , o, k, m, pane + ; + + if (CURSOR && options[PANE[code]].enableCursorHotkey) // valid cursor-hotkey + pane = PANE[code]; + else if (CTRL || SHIFT) // check to see if this matches a custom-hotkey + $.each(_c.borderPanes, function (i, p) { // loop each pane to check its hotkey + o = options[p]; + k = o.customHotkey; + m = o.customHotkeyModifier; // if missing or invalid, treated as "CTRL+SHIFT" + if ((SHIFT && m=="SHIFT") || (CTRL && m=="CTRL") || (CTRL && SHIFT)) { // Modifier matches + if (k && code === (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches + pane = p; + return false; // BREAK + } + } + }); + + // validate pane + if (!pane || !$Ps[pane] || !options[pane].closable || state[pane].isHidden) + return true; + + toggle(pane); + + evt.stopPropagation(); + evt.returnValue = false; // CANCEL key + return false; + }; + + +/* + * ###################################### + * UTILITY METHODS + * called externally or by initButtons + * ###################################### + */ + + /** + * Change/reset a pane overflow setting & zIndex to allow popups/drop-downs to work + * + * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event + */ + function allowOverflow (el) { + if (!isInitialized()) return; + if (this && this.tagName) el = this; // BOUND to element + var $P; + if (isStr(el)) + $P = $Ps[el]; + else if ($(el).data("layoutRole")) + $P = $(el); + else + $(el).parents().each(function(){ + if ($(this).data("layoutRole")) { + $P = $(this); + return false; // BREAK + } + }); + if (!$P || !$P.length) return; // INVALID + + var + pane = $P.data("layoutEdge") + , s = state[pane] + ; + + // if pane is already raised, then reset it before doing it again! + // this would happen if allowOverflow is attached to BOTH the pane and an element + if (s.cssSaved) + resetOverflow(pane); // reset previous CSS before continuing + + // if pane is raised by sliding or resizing, or its closed, then abort + if (s.isSliding || s.isResizing || s.isClosed) { + s.cssSaved = false; + return; + } + + var + newCSS = { zIndex: (options.zIndexes.resizer_normal + 1) } + , curCSS = {} + , of = $P.css("overflow") + , ofX = $P.css("overflowX") + , ofY = $P.css("overflowY") + ; + // determine which, if any, overflow settings need to be changed + if (of != "visible") { + curCSS.overflow = of; + newCSS.overflow = "visible"; + } + if (ofX && !ofX.match(/visible|auto/)) { + curCSS.overflowX = ofX; + newCSS.overflowX = "visible"; + } + if (ofY && !ofY.match(/visible|auto/)) { + curCSS.overflowY = ofX; + newCSS.overflowY = "visible"; + } + + // save the current overflow settings - even if blank! + s.cssSaved = curCSS; + + // apply new CSS to raise zIndex and, if necessary, make overflow 'visible' + $P.css( newCSS ); + + // make sure the zIndex of all other panes is normal + $.each(_c.allPanes, function(i, p) { + if (p != pane) resetOverflow(p); + }); + + }; + /** + * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event + */ + function resetOverflow (el) { + if (!isInitialized()) return; + if (this && this.tagName) el = this; // BOUND to element + var $P; + if (isStr(el)) + $P = $Ps[el]; + else if ($(el).data("layoutRole")) + $P = $(el); + else + $(el).parents().each(function(){ + if ($(this).data("layoutRole")) { + $P = $(this); + return false; // BREAK + } + }); + if (!$P || !$P.length) return; // INVALID + + var + pane = $P.data("layoutEdge") + , s = state[pane] + , CSS = s.cssSaved || {} + ; + // reset the zIndex + if (!s.isSliding && !s.isResizing) + $P.css("zIndex", options.zIndexes.pane_normal); + + // reset Overflow - if necessary + $P.css( CSS ); + + // clear var + s.cssSaved = false; + }; + +/* + * ##################### + * CREATE/RETURN LAYOUT + * ##################### + */ + + // validate that container exists + var $N = $(this).eq(0); // FIRST matching Container element + if (!$N.length) { + if (options.showErrorMessages) + _log( lang.errContainerMissing, true ); + return null; + }; + + // Users retrieve Instance of a layout with: $N.layout() OR $N.data("layout") + // return the Instance-pointer if layout has already been initialized + if ($N.data("layoutContainer") && $N.data("layout")) + return $N.data("layout"); // cached pointer + + // init global vars + var + $Ps = {} // Panes x5 - set in initPanes() + , $Cs = {} // Content x5 - set in initPanes() + , $Rs = {} // Resizers x4 - set in initHandles() + , $Ts = {} // Togglers x4 - set in initHandles() + , $Ms = $([]) // Masks - up to 2 masks per pane (IFRAME + DIV) + // aliases for code brevity + , sC = state.container // alias for easy access to 'container dimensions' + , sID = state.id // alias for unique layout ID/namespace - eg: "layout435" + ; + + // create Instance object to expose data & option Properties, and primary action Methods + var Instance = { + // layout data + options: options // property - options hash + , state: state // property - dimensions hash + // object pointers + , container: $N // property - object pointers for layout container + , panes: $Ps // property - object pointers for ALL Panes: panes.north, panes.center + , contents: $Cs // property - object pointers for ALL Content: contents.north, contents.center + , resizers: $Rs // property - object pointers for ALL Resizers, eg: resizers.north + , togglers: $Ts // property - object pointers for ALL Togglers, eg: togglers.north + // border-pane open/close + , hide: hide // method - ditto + , show: show // method - ditto + , toggle: toggle // method - pass a 'pane' ("north", "west", etc) + , open: open // method - ditto + , close: close // method - ditto + , slideOpen: slideOpen // method - ditto + , slideClose: slideClose // method - ditto + , slideToggle: slideToggle // method - ditto + // pane actions + , setSizeLimits: setSizeLimits // method - pass a 'pane' - update state min/max data + , _sizePane: sizePane // method -intended for user by plugins only! + , sizePane: manualSizePane // method - pass a 'pane' AND an 'outer-size' in pixels or percent, or 'auto' + , sizeContent: sizeContent // method - pass a 'pane' + , swapPanes: swapPanes // method - pass TWO 'panes' - will swap them + // pane element methods + , initContent: initContent // method - ditto + , addPane: addPane // method - pass a 'pane' + , removePane: removePane // method - pass a 'pane' to remove from layout, add 'true' to delete the pane-elem + , createChildLayout: createChildLayout// method - pass a 'pane' and (optional) layout-options (OVERRIDES options[pane].childOptions + // special pane option setting + , enableClosable: enableClosable // method - pass a 'pane' + , disableClosable: disableClosable // method - ditto + , enableSlidable: enableSlidable // method - ditto + , disableSlidable: disableSlidable // method - ditto + , enableResizable: enableResizable // method - ditto + , disableResizable: disableResizable// method - ditto + // utility methods for panes + , allowOverflow: allowOverflow // utility - pass calling element (this) + , resetOverflow: resetOverflow // utility - ditto + // layout control + , destroy: destroy // method - no parameters + , initPanes: isInitialized // method - no parameters + , resizeAll: resizeAll // method - no parameters + // callback triggering + , runCallbacks: _runCallbacks // method - pass evtName & pane (if a pane-event), eg: trigger("onopen", "west") + // alias collections of options, state and children - created in addPane and extended elsewhere + , hasParentLayout: false // set by initContainer() + , children: children // pointers to child-layouts, eg: Instance.children["west"] + , north: false // alias group: { name: pane, pane: $Ps[pane], options: options[pane], state: state[pane], child: children[pane] } + , south: false // ditto + , west: false // ditto + , east: false // ditto + , center: false // ditto + }; + + // create the border layout NOW + if (_create() === 'cancel') // onload_start callback returned false to CANCEL layout creation + return null; + else // true OR false -- if layout-elements did NOT init (hidden or do not exist), can auto-init later + return Instance; // return the Instance object + +} + + + + +/** + * jquery.layout.state 1.0 + * $Date$ + * + * Copyright (c) 2010 + * Kevin Dalman (http://allpro.net) + * + * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) + * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. + * + * @dependancies: UI Layout 1.3.0.rc30.1 or higher + * @dependancies: $.ui.cookie (above) + * + * @support: http://groups.google.com/group/jquery-ui-layout + */ +/* + * State-management options stored in options.stateManagement, which includes a .cookie hash + * Default options saves ALL KEYS for ALL PANES, ie: pane.size, pane.isClosed, pane.isHidden + * + * // STATE/COOKIE OPTIONS + * @example $(el).layout({ + stateManagement: { + enabled: true + , stateKeys: "east.size,west.size,east.isClosed,west.isClosed" + , cookie: { name: "appLayout", path: "/" } + } + }) + * @example $(el).layout({ stateManagement__enabled: true }) // enable auto-state-management using cookies + * @example $(el).layout({ stateManagement__cookie: { name: "appLayout", path: "/" } }) + * @example $(el).layout({ stateManagement__cookie__name: "appLayout", stateManagement__cookie__path: "/" }) + * + * // STATE/COOKIE METHODS + * @example myLayout.saveCookie( "west.isClosed,north.size,south.isHidden", {expires: 7} ); + * @example myLayout.loadCookie(); + * @example myLayout.deleteCookie(); + * @example var JSON = myLayout.readState(); // CURRENT Layout State + * @example var JSON = myLayout.readCookie(); // SAVED Layout State (from cookie) + * @example var JSON = myLayout.state.stateData; // LAST LOADED Layout State (cookie saved in layout.state hash) + * + * CUSTOM STATE-MANAGEMENT (eg, saved in a database) + * @example var JSON = myLayout.readState( "west.isClosed,north.size,south.isHidden" ); + * @example myLayout.loadState( JSON ); + */ + +/** + * UI COOKIE UTILITY + * + * A $.cookie OR $.ui.cookie namespace *should be standard*, but until then... + * This creates $.ui.cookie so Layout does not need the cookie.jquery.js plugin + * NOTE: This utility is REQUIRED by the layout.state plugin + * + * Cookie methods in Layout are created as part of State Management + */ +if (!$.ui) $.ui = {}; +$.ui.cookie = { + + // cookieEnabled is not in DOM specs, but DOES works in all browsers,including IE6 + acceptsCookies: !!navigator.cookieEnabled + +, read: function (name) { + var + c = document.cookie + , cs = c ? c.split(';') : [] + , pair // loop var + ; + for (var i=0, n=cs.length; i < n; i++) { + pair = $.trim(cs[i]).split('='); // name=value pair + if (pair[0] == name) // found the layout cookie + return decodeURIComponent(pair[1]); + + } + return null; + } + +, write: function (name, val, cookieOpts) { + var + params = '' + , date = '' + , clear = false + , o = cookieOpts || {} + , x = o.expires + ; + if (x && x.toUTCString) + date = x; + else if (x === null || typeof x === 'number') { + date = new Date(); + if (x > 0) + date.setDate(date.getDate() + x); + else { + date.setFullYear(1970); + clear = true; + } + } + if (date) params += ';expires='+ date.toUTCString(); + if (o.path) params += ';path='+ o.path; + if (o.domain) params += ';domain='+ o.domain; + if (o.secure) params += ';secure'; + document.cookie = name +'='+ (clear ? "" : encodeURIComponent( val )) + params; // write or clear cookie + } + +, clear: function (name) { + $.ui.cookie.write(name, '', {expires: -1}); + } + +}; +// if cookie.jquery.js is not loaded, create an alias to replicate it +// this may be useful to other plugins or code dependent on that plugin +if (!$.cookie) $.cookie = function (k, v, o) { + var C = $.ui.cookie; + if (v === null) + C.clear(k); + else if (v === undefined) + return C.read(k); + else + C.write(k, v, o); +}; + + +// tell Layout that the state plugin is available +$.layout.plugins.stateManagement = true; + +// Add State-Management options to layout.defaults +$.layout.config.optionRootKeys.push("stateManagement"); +$.layout.defaults.stateManagement = { + enabled: false // true = enable state-management, even if not using cookies +, autoSave: true // Save a state-cookie when page exits? +, autoLoad: true // Load the state-cookie when Layout inits? + // List state-data to save - must be pane-specific +, stateKeys: "north.size,south.size,east.size,west.size,"+ + "north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+ + "north.isHidden,south.isHidden,east.isHidden,west.isHidden" +, cookie: { + name: "" // If not specified, will use Layout.name, else just "Layout" + , domain: "" // blank = current domain + , path: "" // blank = current page, '/' = entire website + , expires: "" // 'days' to keep cookie - leave blank for 'session cookie' + , secure: false + } +}; +// Set stateManagement as a layout-option, NOT a pane-option +$.layout.optionsMap.layout.push("stateManagement"); + +/* + * State Management methods + */ +$.layout.state = { + + /** + * Get the current layout state and save it to a cookie + * + * myLayout.saveCookie( keys, cookieOpts ) + * + * @param {Object} inst + * @param {(string|Array)=} keys + * @param {Object=} opts + */ + saveCookie: function (inst, keys, cookieOpts) { + var o = inst.options + , oS = o.stateManagement + , oC = $.extend(true, {}, oS.cookie, cookieOpts || null) + , data = inst.state.stateData = inst.readState( keys || oS.stateKeys ) // read current panes-state + ; + $.ui.cookie.write( oC.name || o.name || "Layout", $.layout.state.encodeJSON(data), oC ); + return $.extend(true, {}, data); // return COPY of state.stateData data + } + + /** + * Remove the state cookie + * + * @param {Object} inst + */ +, deleteCookie: function (inst) { + var o = inst.options; + $.ui.cookie.clear( o.stateManagement.cookie.name || o.name || "Layout" ); + } + + /** + * Read & return data from the cookie - as JSON + * + * @param {Object} inst + */ +, readCookie: function (inst) { + var o = inst.options; + var c = $.ui.cookie.read( o.stateManagement.cookie.name || o.name || "Layout" ); + // convert cookie string back to a hash and return it + return c ? $.layout.state.decodeJSON(c) : {}; + } + + /** + * Get data from the cookie and USE IT to loadState + * + * @param {Object} inst + */ +, loadCookie: function (inst) { + var c = $.layout.state.readCookie(inst); // READ the cookie + if (c) { + inst.state.stateData = $.extend(true, {}, c); // SET state.stateData + inst.loadState(c); // LOAD the retrieved state + } + return c; + } + + /** + * Update layout options from the cookie, if one exists + * + * @param {Object} inst + * @param {Object=} stateData + * @param {boolean=} animate + */ +, loadState: function (inst, stateData, animate) { + stateData = $.layout.transformData( stateData ); // panes = default subkey + if ($.isEmptyObject( stateData )) return; + $.extend(true, inst.options, stateData); // update layout options + // if layout has already been initialized, then UPDATE layout state + if (inst.state.initialized) { + var pane, vis, o, s, h, c + , noAnimate = (animate===false) + ; + $.each($.layout.config.borderPanes, function (idx, pane) { + state = inst.state[pane]; + o = stateData[ pane ]; + if (typeof o != 'object') return; // no key, continue + s = o.size; + c = o.initClosed; + h = o.initHidden; + vis = state.isVisible; + // resize BEFORE opening + if (!vis) + inst.sizePane(pane, s, false, false); + if (h === true) inst.hide(pane, noAnimate); + else if (c === false) inst.open (pane, false, noAnimate); + else if (c === true) inst.close(pane, false, noAnimate); + else if (h === false) inst.show (pane, false, noAnimate); + // resize AFTER any other actions + if (vis) + inst.sizePane(pane, s, false, noAnimate); // animate resize if option passed + }); + }; + } + + /** + * Get the *current layout state* and return it as a hash + * + * @param {Object=} inst + * @param {(string|Array)=} keys + */ +, readState: function (inst, keys) { + var + data = {} + , alt = { isClosed: 'initClosed', isHidden: 'initHidden' } + , state = inst.state + , panes = $.layout.config.allPanes + , pair, pane, key, val + ; + if (!keys) keys = inst.options.stateManagement.stateKeys; // if called by user + if ($.isArray(keys)) keys = keys.join(","); + // convert keys to an array and change delimiters from '__' to '.' + keys = keys.replace(/__/g, ".").split(','); + // loop keys and create a data hash + for (var i=0, n=keys.length; i < n; i++) { + pair = keys[i].split("."); + pane = pair[0]; + key = pair[1]; + if ($.inArray(pane, panes) < 0) continue; // bad pane! + val = state[ pane ][ key ]; + if (val == undefined) continue; + if (key=="isClosed" && state[pane]["isSliding"]) + val = true; // if sliding, then *really* isClosed + ( data[pane] || (data[pane]={}) )[ alt[key] ? alt[key] : key ] = val; + } + return data; + } + + /** + * Stringify a JSON hash so can save in a cookie or db-field + */ +, encodeJSON: function (JSON) { + return parse(JSON); + function parse (h) { + var D=[], i=0, k, v, t; // k = key, v = value + for (k in h) { + v = h[k]; + t = typeof v; + if (t == 'string') // STRING - add quotes + v = '"'+ v +'"'; + else if (t == 'object') // SUB-KEY - recurse into it + v = parse(v); + D[i++] = '"'+ k +'":'+ v; + } + return '{'+ D.join(',') +'}'; + }; + } + + /** + * Convert stringified JSON back to a hash object + * @see $.parseJSON(), adding in jQuery 1.4.1 + */ +, decodeJSON: function (str) { + try { return $.parseJSON ? $.parseJSON(str) : window["eval"]("("+ str +")") || {}; } + catch (e) { return {}; } + } + + +, _create: function (inst) { + var _ = $.layout.state; + // ADD State-Management plugin methods to inst + $.extend( inst, { + // readCookie - update options from cookie - returns hash of cookie data + readCookie: function () { return _.readCookie(inst); } + // deleteCookie + , deleteCookie: function () { _.deleteCookie(inst); } + // saveCookie - optionally pass keys-list and cookie-options (hash) + , saveCookie: function (keys, cookieOpts) { return _.saveCookie(inst, keys, cookieOpts); } + // loadCookie - readCookie and use to loadState() - returns hash of cookie data + , loadCookie: function () { return _.loadCookie(inst); } + // loadState - pass a hash of state to use to update options + , loadState: function (stateData, animate) { _.loadState(inst, stateData, animate); } + // readState - returns hash of current layout-state + , readState: function (keys) { return _.readState(inst, keys); } + // add JSON utility methods too... + , encodeJSON: _.encodeJSON + , decodeJSON: _.decodeJSON + }); + + // init state.stateData key, even if plugin is initially disabled + inst.state.stateData = {}; + + // read and load cookie-data per options + var oS = inst.options.stateManagement; + if (oS.enabled) { + if (oS.autoLoad) // update the options from the cookie + inst.loadCookie(); + else // don't modify options - just store cookie data in state.stateData + inst.state.stateData = inst.readCookie(); + } + } + +, _unload: function (inst) { + var oS = inst.options.stateManagement; + if (oS.enabled) { + if (oS.autoSave) // save a state-cookie automatically + inst.saveCookie(); + else // don't save a cookie, but do store state-data in state.stateData key + inst.state.stateData = inst.readState(); + } + } + +}; + +// add state initialization method to Layout's onCreate array of functions +$.layout.onCreate.push( $.layout.state._create ); +$.layout.onUnload.push( $.layout.state._unload ); + + + + +/** + * jquery.layout.buttons 1.0 + * $Date$ + * + * Copyright (c) 2010 + * Kevin Dalman (http://allpro.net) + * + * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) + * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. + * + * @dependancies: UI Layout 1.3.0.rc30.1 or higher + * + * @support: http://groups.google.com/group/jquery-ui-layout + * + * Docs: [ to come ] + * Tips: [ to come ] + */ + +// tell Layout that the state plugin is available +$.layout.plugins.buttons = true; + +// Add buttons options to layout.defaults +$.layout.defaults.autoBindCustomButtons = false; +// Specify autoBindCustomButtons as a layout-option, NOT a pane-option +$.layout.optionsMap.layout.push("autoBindCustomButtons"); + +var lang = $.layout.language; + +/* + * Button methods + */ +$.layout.buttons = { + + /** + * Searches for .ui-layout-button-xxx elements and auto-binds them as layout-buttons + * + * @see _create() + * + * @param {Object} inst Layout Instance object + */ + init: function (inst) { + var pre = "ui-layout-button-" + , layout = inst.options.name || "" + , name; + $.each("toggle,open,close,pin,toggle-slide,open-slide".split(","), function (i, action) { + $.each($.layout.config.borderPanes, function (ii, pane) { + $("."+pre+action+"-"+pane).each(function(){ + // if button was previously 'bound', data.layoutName was set, but is blank if layout has no 'name' + name = $(this).data("layoutName") || $(this).attr("layoutName"); + if (name == undefined || name === layout) + inst.bindButton(this, action, pane); + }); + }); + }); + } + + /** + * Helper function to validate params received by addButton utilities + * + * Two classes are added to the element, based on the buttonClass... + * The type of button is appended to create the 2nd className: + * - ui-layout-button-pin // action btnClass + * - ui-layout-button-pin-west // action btnClass + pane + * - ui-layout-button-toggle + * - ui-layout-button-open + * - ui-layout-button-close + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + * + * @return {Array.} If both params valid, the element matching 'selector' in a jQuery wrapper - otherwise returns null + */ +, get: function (inst, selector, pane, action) { + var $E = $(selector) + , o = inst.options + , err = o.showErrorMessages + ; + if (!$E.length) { // element not found + if (err) $.layout.msg(lang.errButton + lang.selector +": "+ selector, true); + } + else if ($.inArray(pane, $.layout.config.borderPanes) < 0) { // invalid 'pane' sepecified + if (err) $.layout.msg(lang.errButton + lang.pane +": "+ pane, true); + $E = $(""); // NO BUTTON + } + else { // VALID + var btn = o[pane].buttonClass +"-"+ action; + $E .addClass( btn +" "+ btn +"-"+ pane ) + .data("layoutName", o.name); // add layout identifier - even if blank! + } + return $E; + } + + + /** + * NEW syntax for binding layout-buttons - will eventually replace addToggle, addOpen, etc. + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} action + * @param {string} pane + */ +, bind: function (inst, selector, action, pane) { + var _ = $.layout.buttons; + switch (action.toLowerCase()) { + case "toggle": _.addToggle (inst, selector, pane); break; + case "open": _.addOpen (inst, selector, pane); break; + case "close": _.addClose (inst, selector, pane); break; + case "pin": _.addPin (inst, selector, pane); break; + case "toggle-slide": _.addToggle (inst, selector, pane, true); break; + case "open-slide": _.addOpen (inst, selector, pane, true); break; + } + return inst; + } + + /** + * Add a custom Toggler button for a pane + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + * @param {boolean=} slide true = slide-open, false = pin-open + */ +, addToggle: function (inst, selector, pane, slide) { + $.layout.buttons.get(inst, selector, pane, "toggle") + .click(function(evt){ + inst.toggle(pane, !!slide); + evt.stopPropagation(); + }); + return inst; + } + + /** + * Add a custom Open button for a pane + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + * @param {boolean=} slide true = slide-open, false = pin-open + */ +, addOpen: function (inst, selector, pane, slide) { + $.layout.buttons.get(inst, selector, pane, "open") + .attr("title", lang.Open) + .click(function (evt) { + inst.open(pane, !!slide); + evt.stopPropagation(); + }); + return inst; + } + + /** + * Add a custom Close button for a pane + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the button is for: 'north', 'south', etc. + */ +, addClose: function (inst, selector, pane) { + $.layout.buttons.get(inst, selector, pane, "close") + .attr("title", lang.Close) + .click(function (evt) { + inst.close(pane); + evt.stopPropagation(); + }); + return inst; + } + + /** + * Add a custom Pin button for a pane + * + * Four classes are added to the element, based on the paneClass for the associated pane... + * Assuming the default paneClass and the pin is 'up', these classes are added for a west-pane pin: + * - ui-layout-pane-pin + * - ui-layout-pane-west-pin + * - ui-layout-pane-pin-up + * - ui-layout-pane-west-pin-up + * + * @param {Object} inst Layout Instance object + * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button" + * @param {string} pane Name of the pane the pin is for: 'north', 'south', etc. + */ +, addPin: function (inst, selector, pane) { + var _ = $.layout.buttons + , $E = _.get(inst, selector, pane, "pin"); + if ($E.length) { + var s = inst.state[pane]; + $E.click(function (evt) { + _.setPinState(inst, $(this), pane, (s.isSliding || s.isClosed)); + if (s.isSliding || s.isClosed) inst.open( pane ); // change from sliding to open + else inst.close( pane ); // slide-closed + evt.stopPropagation(); + }); + // add up/down pin attributes and classes + _.setPinState(inst, $E, pane, (!s.isClosed && !s.isSliding)); + // add this pin to the pane data so we can 'sync it' automatically + // PANE.pins key is an array so we can store multiple pins for each pane + s.pins.push( selector ); // just save the selector string + } + return inst; + } + + /** + * Change the class of the pin button to make it look 'up' or 'down' + * + * @see addPin(), syncPins() + * + * @param {Object} inst Layout Instance object + * @param {Array.} $Pin The pin-span element in a jQuery wrapper + * @param {string} pane These are the params returned to callbacks by layout() + * @param {boolean} doPin true = set the pin 'down', false = set it 'up' + */ +, setPinState: function (inst, $Pin, pane, doPin) { + var updown = $Pin.attr("pin"); + if (updown && doPin === (updown=="down")) return; // already in correct state + var + pin = inst.options[pane].buttonClass +"-pin" + , side = pin +"-"+ pane + , UP = pin +"-up "+ side +"-up" + , DN = pin +"-down "+side +"-down" + ; + $Pin + .attr("pin", doPin ? "down" : "up") // logic + .attr("title", doPin ? lang.Unpin : lang.Pin) + .removeClass( doPin ? UP : DN ) + .addClass( doPin ? DN : UP ) + ; + } + + /** + * INTERNAL function to sync 'pin buttons' when pane is opened or closed + * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes + * + * @see open(), close() + * + * @param {Object} inst Layout Instance object + * @param {string} pane These are the params returned to callbacks by layout() + * @param {boolean} doPin True means set the pin 'down', False means 'up' + */ +, syncPinBtns: function (inst, pane, doPin) { + // REAL METHOD IS _INSIDE_ LAYOUT - THIS IS HERE JUST FOR REFERENCE + $.each(state[pane].pins, function (i, selector) { + $.layout.buttons.setPinState(inst, $(selector), pane, doPin); + }); + } + + +, _load: function (inst) { + var _ = $.layout.buttons; + // ADD Button methods to Layout Instance + // Note: sel = jQuery Selector string + $.extend( inst, { + bindButton: function (sel, action, pane) { return _.bind(inst, sel, action, pane); } + // DEPRECATED METHODS + , addToggleBtn: function (sel, pane, slide) { return _.addToggle(inst, sel, pane, slide); } + , addOpenBtn: function (sel, pane, slide) { return _.addOpen(inst, sel, pane, slide); } + , addCloseBtn: function (sel, pane) { return _.addClose(inst, sel, pane); } + , addPinBtn: function (sel, pane) { return _.addPin(inst, sel, pane); } + }); + + // init state array to hold pin-buttons + for (var i=0; i<4; i++) { + var pane = $.layout.config.borderPanes[i]; + inst.state[pane].pins = []; + } + + // auto-init buttons onLoad if option is enabled + if ( inst.options.autoBindCustomButtons ) + _.init(inst); + } + +, _unload: function (inst) { + // TODO: unbind all buttons??? + } + +}; + +// add initialization method to Layout's onLoad array of functions +$.layout.onLoad.push( $.layout.buttons._load ); +//$.layout.onUnload.push( $.layout.buttons._unload ); + + + +/** + * jquery.layout.browserZoom 1.0 + * $Date$ + * + * Copyright (c) 2012 + * Kevin Dalman (http://allpro.net) + * + * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) + * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. + * + * @dependancies: UI Layout 1.3.0.rc30.1 or higher + * + * @support: http://groups.google.com/group/jquery-ui-layout + * + * @todo: Extend logic to handle other problematic zooming in browsers + * @todo: Add hotkey/mousewheel bindings to _instantly_ respond to these zoom event + */ + +// tell Layout that the plugin is available +$.layout.plugins.browserZoom = true; + +$.layout.defaults.browserZoomCheckInterval = 1000; +$.layout.optionsMap.layout.push("browserZoomCheckInterval"); + +/* + * browserZoom methods + */ +$.layout.browserZoom = { + + _init: function (inst) { + // abort if browser does not need this check + if ($.layout.browserZoom.ratio() !== false) + $.layout.browserZoom._setTimer(inst); + } + +, _setTimer: function (inst) { + // abort if layout destroyed or browser does not need this check + if (inst.destroyed) return; + var o = inst.options + , s = inst.state + // don't need check if inst has parentLayout, but check occassionally in case parent destroyed! + // MINIMUM 100ms interval, for performance + , ms = inst.hasParentLayout ? 5000 : Math.max( o.browserZoomCheckInterval, 100 ) + ; + // set the timer + setTimeout(function(){ + if (inst.destroyed || !o.resizeWithWindow) return; + var d = $.layout.browserZoom.ratio(); + if (d !== s.browserZoom) { + s.browserZoom = d; + inst.resizeAll(); + } + // set a NEW timeout + $.layout.browserZoom._setTimer(inst); + } + , ms ); + } + +, ratio: function () { + var w = window + , s = screen + , d = document + , dE = d.documentElement || d.body + , b = $.layout.browser + , v = b.version + , r, sW, cW + ; + // we can ignore all browsers that fire window.resize event onZoom + if ((b.msie && v > 8) + || !b.msie + ) return false; // don't need to track zoom + + if (s.deviceXDPI) + return calc(s.deviceXDPI, s.systemXDPI); + // everything below is just for future reference! + if (b.webkit && (r = d.body.getBoundingClientRect)) + return calc((r.left - r.right), d.body.offsetWidth); + if (b.webkit && (sW = w.outerWidth)) + return calc(sW, w.innerWidth); + if ((sW = s.width) && (cW = dE.clientWidth)) + return calc(sW, cW); + return false; // no match, so cannot - or don't need to - track zoom + + function calc (x,y) { return (parseInt(x,10) / parseInt(y,10) * 100).toFixed(); } + } + +}; +// add initialization method to Layout's onLoad array of functions +$.layout.onReady.push( $.layout.browserZoom._init ); + + + +})( jQuery ); \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-anim_basic_16x16.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-anim_basic_16x16.gif new file mode 100644 index 000000000..085ccaeca Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-anim_basic_16x16.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_flat_0_aaaaaa_40x100.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_flat_0_aaaaaa_40x100.png new file mode 100644 index 000000000..5b5dab2ab Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_flat_0_aaaaaa_40x100.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_flat_55_fbec88_40x100.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_flat_55_fbec88_40x100.png new file mode 100644 index 000000000..47acaadd7 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_flat_55_fbec88_40x100.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_glass_75_d0e5f5_1x400.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_glass_75_d0e5f5_1x400.png new file mode 100644 index 000000000..9d149b1c6 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_glass_75_d0e5f5_1x400.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_glass_85_dfeffc_1x400.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_glass_85_dfeffc_1x400.png new file mode 100644 index 000000000..014951529 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_glass_85_dfeffc_1x400.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_glass_95_fef1ec_1x400.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_glass_95_fef1ec_1x400.png new file mode 100644 index 000000000..4443fdc1a Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_glass_95_fef1ec_1x400.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png new file mode 100644 index 000000000..81ecc362d Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png new file mode 100644 index 000000000..4f3faf8aa Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png new file mode 100644 index 000000000..38c38335d Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_217bc0_256x240.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_217bc0_256x240.png new file mode 100644 index 000000000..6f4bd87c0 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_217bc0_256x240.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_2e83ff_256x240.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_2e83ff_256x240.png new file mode 100644 index 000000000..09d1cdc85 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_2e83ff_256x240.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_469bdd_256x240.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_469bdd_256x240.png new file mode 100644 index 000000000..bd2cf079a Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_469bdd_256x240.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_6da8d5_256x240.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_6da8d5_256x240.png new file mode 100644 index 000000000..3d6f567f4 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_6da8d5_256x240.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_cd0a0a_256x240.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_cd0a0a_256x240.png new file mode 100644 index 000000000..2ab019b73 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_cd0a0a_256x240.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_d8e7f3_256x240.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_d8e7f3_256x240.png new file mode 100644 index 000000000..ad2dc6f9d Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_d8e7f3_256x240.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_f9bd01_256x240.png b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_f9bd01_256x240.png new file mode 100644 index 000000000..c7c53cb11 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/images/ui-icons_f9bd01_256x240.png differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/jquery-ui-1.8.2.custom.css b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/jquery-ui-1.8.2.custom.css new file mode 100644 index 000000000..0b1736320 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/theme-redmond/jquery-ui-1.8.2.custom.css @@ -0,0 +1,398 @@ +/* +* jQuery UI CSS Framework +* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) +* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. +*/ + +/* Layout helpers +----------------------------------*/ +.ui-helper-hidden { display: none; } +.ui-helper-hidden-accessible { position: absolute; left: -99999999px; } +.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } +.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } +.ui-helper-clearfix { display: inline-block; } +/* required comment for clearfix to work in Opera \*/ +* html .ui-helper-clearfix { height:1%; } +.ui-helper-clearfix { display:block; } +/* end clearfix */ +.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } + + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { cursor: default !important; } + + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } + + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } + + +/* +* jQuery UI CSS Framework +* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) +* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. +* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Lucida%20Grande,%20Lucida%20Sans,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=5px&bgColorHeader=5c9ccc&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=55&borderColorHeader=4297d7&fcHeader=ffffff&iconColorHeader=d8e7f3&bgColorContent=fcfdfd&bgTextureContent=06_inset_hard.png&bgImgOpacityContent=100&borderColorContent=a6c9e2&fcContent=222222&iconColorContent=469bdd&bgColorDefault=dfeffc&bgTextureDefault=02_glass.png&bgImgOpacityDefault=85&borderColorDefault=c5dbec&fcDefault=2e6e9e&iconColorDefault=6da8d5&bgColorHover=d0e5f5&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=79b7e7&fcHover=1d5987&iconColorHover=217bc0&bgColorActive=f5f8f9&bgTextureActive=06_inset_hard.png&bgImgOpacityActive=100&borderColorActive=79b7e7&fcActive=e17009&iconColorActive=f9bd01&bgColorHighlight=fbec88&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=fad42e&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px +*/ + + +/* Component containers +----------------------------------*/ +.ui-widget { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1.1em; } +.ui-widget .ui-widget { font-size: 1em; } +.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em; } +.ui-widget-content { border: 1px solid #a6c9e2; background: #fcfdfd url(images/ui-bg_inset-hard_100_fcfdfd_1x100.png) 50% bottom repeat-x; color: #222222; } +.ui-widget-content a { color: #222222; } +.ui-widget-header { border: 1px solid #4297d7; background: #5c9ccc url(images/ui-bg_gloss-wave_55_5c9ccc_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } +.ui-widget-header a { color: #ffffff; } + +/* Interaction states +----------------------------------*/ +.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #c5dbec; background: #dfeffc url(images/ui-bg_glass_85_dfeffc_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #2e6e9e; } +.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #2e6e9e; text-decoration: none; } +.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #79b7e7; background: #d0e5f5 url(images/ui-bg_glass_75_d0e5f5_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1d5987; } +.ui-state-hover a, .ui-state-hover a:hover { color: #1d5987; text-decoration: none; } +.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #79b7e7; background: #f5f8f9 url(images/ui-bg_inset-hard_100_f5f8f9_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #e17009; } +.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #e17009; text-decoration: none; } +.ui-widget :active { outline: none; } + +/* Interaction Cues +----------------------------------*/ +.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fad42e; background: #fbec88 url(images/ui-bg_flat_55_fbec88_40x100.png) 50% 50% repeat-x; color: #363636; } +.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; } +.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; } +.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; } +.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; } +.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } +.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } +.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_469bdd_256x240.png); } +.ui-widget-content .ui-icon {background-image: url(images/ui-icons_469bdd_256x240.png); } +.ui-widget-header .ui-icon {background-image: url(images/ui-icons_d8e7f3_256x240.png); } +.ui-state-default .ui-icon { background-image: url(images/ui-icons_6da8d5_256x240.png); } +.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_217bc0_256x240.png); } +.ui-state-active .ui-icon {background-image: url(images/ui-icons_f9bd01_256x240.png); } +.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); } +.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); } + +/* positioning */ +.ui-icon-carat-1-n { background-position: 0 0; } +.ui-icon-carat-1-ne { background-position: -16px 0; } +.ui-icon-carat-1-e { background-position: -32px 0; } +.ui-icon-carat-1-se { background-position: -48px 0; } +.ui-icon-carat-1-s { background-position: -64px 0; } +.ui-icon-carat-1-sw { background-position: -80px 0; } +.ui-icon-carat-1-w { background-position: -96px 0; } +.ui-icon-carat-1-nw { background-position: -112px 0; } +.ui-icon-carat-2-n-s { background-position: -128px 0; } +.ui-icon-carat-2-e-w { background-position: -144px 0; } +.ui-icon-triangle-1-n { background-position: 0 -16px; } +.ui-icon-triangle-1-ne { background-position: -16px -16px; } +.ui-icon-triangle-1-e { background-position: -32px -16px; } +.ui-icon-triangle-1-se { background-position: -48px -16px; } +.ui-icon-triangle-1-s { background-position: -64px -16px; } +.ui-icon-triangle-1-sw { background-position: -80px -16px; } +.ui-icon-triangle-1-w { background-position: -96px -16px; } +.ui-icon-triangle-1-nw { background-position: -112px -16px; } +.ui-icon-triangle-2-n-s { background-position: -128px -16px; } +.ui-icon-triangle-2-e-w { background-position: -144px -16px; } +.ui-icon-arrow-1-n { background-position: 0 -32px; } +.ui-icon-arrow-1-ne { background-position: -16px -32px; } +.ui-icon-arrow-1-e { background-position: -32px -32px; } +.ui-icon-arrow-1-se { background-position: -48px -32px; } +.ui-icon-arrow-1-s { background-position: -64px -32px; } +.ui-icon-arrow-1-sw { background-position: -80px -32px; } +.ui-icon-arrow-1-w { background-position: -96px -32px; } +.ui-icon-arrow-1-nw { background-position: -112px -32px; } +.ui-icon-arrow-2-n-s { background-position: -128px -32px; } +.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } +.ui-icon-arrow-2-e-w { background-position: -160px -32px; } +.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } +.ui-icon-arrowstop-1-n { background-position: -192px -32px; } +.ui-icon-arrowstop-1-e { background-position: -208px -32px; } +.ui-icon-arrowstop-1-s { background-position: -224px -32px; } +.ui-icon-arrowstop-1-w { background-position: -240px -32px; } +.ui-icon-arrowthick-1-n { background-position: 0 -48px; } +.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } +.ui-icon-arrowthick-1-e { background-position: -32px -48px; } +.ui-icon-arrowthick-1-se { background-position: -48px -48px; } +.ui-icon-arrowthick-1-s { background-position: -64px -48px; } +.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } +.ui-icon-arrowthick-1-w { background-position: -96px -48px; } +.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } +.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } +.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } +.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } +.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } +.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } +.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } +.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } +.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } +.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } +.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } +.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } +.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } +.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } +.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } +.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } +.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } +.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } +.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } +.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } +.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } +.ui-icon-arrow-4 { background-position: 0 -80px; } +.ui-icon-arrow-4-diag { background-position: -16px -80px; } +.ui-icon-extlink { background-position: -32px -80px; } +.ui-icon-newwin { background-position: -48px -80px; } +.ui-icon-refresh { background-position: -64px -80px; } +.ui-icon-shuffle { background-position: -80px -80px; } +.ui-icon-transfer-e-w { background-position: -96px -80px; } +.ui-icon-transferthick-e-w { background-position: -112px -80px; } +.ui-icon-folder-collapsed { background-position: 0 -96px; } +.ui-icon-folder-open { background-position: -16px -96px; } +.ui-icon-document { background-position: -32px -96px; } +.ui-icon-document-b { background-position: -48px -96px; } +.ui-icon-note { background-position: -64px -96px; } +.ui-icon-mail-closed { background-position: -80px -96px; } +.ui-icon-mail-open { background-position: -96px -96px; } +.ui-icon-suitcase { background-position: -112px -96px; } +.ui-icon-comment { background-position: -128px -96px; } +.ui-icon-person { background-position: -144px -96px; } +.ui-icon-print { background-position: -160px -96px; } +.ui-icon-trash { background-position: -176px -96px; } +.ui-icon-locked { background-position: -192px -96px; } +.ui-icon-unlocked { background-position: -208px -96px; } +.ui-icon-bookmark { background-position: -224px -96px; } +.ui-icon-tag { background-position: -240px -96px; } +.ui-icon-home { background-position: 0 -112px; } +.ui-icon-flag { background-position: -16px -112px; } +.ui-icon-calendar { background-position: -32px -112px; } +.ui-icon-cart { background-position: -48px -112px; } +.ui-icon-pencil { background-position: -64px -112px; } +.ui-icon-clock { background-position: -80px -112px; } +.ui-icon-disk { background-position: -96px -112px; } +.ui-icon-calculator { background-position: -112px -112px; } +.ui-icon-zoomin { background-position: -128px -112px; } +.ui-icon-zoomout { background-position: -144px -112px; } +.ui-icon-search { background-position: -160px -112px; } +.ui-icon-wrench { background-position: -176px -112px; } +.ui-icon-gear { background-position: -192px -112px; } +.ui-icon-heart { background-position: -208px -112px; } +.ui-icon-star { background-position: -224px -112px; } +.ui-icon-link { background-position: -240px -112px; } +.ui-icon-cancel { background-position: 0 -128px; } +.ui-icon-plus { background-position: -16px -128px; } +.ui-icon-plusthick { background-position: -32px -128px; } +.ui-icon-minus { background-position: -48px -128px; } +.ui-icon-minusthick { background-position: -64px -128px; } +.ui-icon-close { background-position: -80px -128px; } +.ui-icon-closethick { background-position: -96px -128px; } +.ui-icon-key { background-position: -112px -128px; } +.ui-icon-lightbulb { background-position: -128px -128px; } +.ui-icon-scissors { background-position: -144px -128px; } +.ui-icon-clipboard { background-position: -160px -128px; } +.ui-icon-copy { background-position: -176px -128px; } +.ui-icon-contact { background-position: -192px -128px; } +.ui-icon-image { background-position: -208px -128px; } +.ui-icon-video { background-position: -224px -128px; } +.ui-icon-script { background-position: -240px -128px; } +.ui-icon-alert { background-position: 0 -144px; } +.ui-icon-info { background-position: -16px -144px; } +.ui-icon-notice { background-position: -32px -144px; } +.ui-icon-help { background-position: -48px -144px; } +.ui-icon-check { background-position: -64px -144px; } +.ui-icon-bullet { background-position: -80px -144px; } +.ui-icon-radio-off { background-position: -96px -144px; } +.ui-icon-radio-on { background-position: -112px -144px; } +.ui-icon-pin-w { background-position: -128px -144px; } +.ui-icon-pin-s { background-position: -144px -144px; } +.ui-icon-play { background-position: 0 -160px; } +.ui-icon-pause { background-position: -16px -160px; } +.ui-icon-seek-next { background-position: -32px -160px; } +.ui-icon-seek-prev { background-position: -48px -160px; } +.ui-icon-seek-end { background-position: -64px -160px; } +.ui-icon-seek-start { background-position: -80px -160px; } +/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ +.ui-icon-seek-first { background-position: -80px -160px; } +.ui-icon-stop { background-position: -96px -160px; } +.ui-icon-eject { background-position: -112px -160px; } +.ui-icon-volume-off { background-position: -128px -160px; } +.ui-icon-volume-on { background-position: -144px -160px; } +.ui-icon-power { background-position: 0 -176px; } +.ui-icon-signal-diag { background-position: -16px -176px; } +.ui-icon-signal { background-position: -32px -176px; } +.ui-icon-battery-0 { background-position: -48px -176px; } +.ui-icon-battery-1 { background-position: -64px -176px; } +.ui-icon-battery-2 { background-position: -80px -176px; } +.ui-icon-battery-3 { background-position: -96px -176px; } +.ui-icon-circle-plus { background-position: 0 -192px; } +.ui-icon-circle-minus { background-position: -16px -192px; } +.ui-icon-circle-close { background-position: -32px -192px; } +.ui-icon-circle-triangle-e { background-position: -48px -192px; } +.ui-icon-circle-triangle-s { background-position: -64px -192px; } +.ui-icon-circle-triangle-w { background-position: -80px -192px; } +.ui-icon-circle-triangle-n { background-position: -96px -192px; } +.ui-icon-circle-arrow-e { background-position: -112px -192px; } +.ui-icon-circle-arrow-s { background-position: -128px -192px; } +.ui-icon-circle-arrow-w { background-position: -144px -192px; } +.ui-icon-circle-arrow-n { background-position: -160px -192px; } +.ui-icon-circle-zoomin { background-position: -176px -192px; } +.ui-icon-circle-zoomout { background-position: -192px -192px; } +.ui-icon-circle-check { background-position: -208px -192px; } +.ui-icon-circlesmall-plus { background-position: 0 -208px; } +.ui-icon-circlesmall-minus { background-position: -16px -208px; } +.ui-icon-circlesmall-close { background-position: -32px -208px; } +.ui-icon-squaresmall-plus { background-position: -48px -208px; } +.ui-icon-squaresmall-minus { background-position: -64px -208px; } +.ui-icon-squaresmall-close { background-position: -80px -208px; } +.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } +.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } +.ui-icon-grip-solid-vertical { background-position: -32px -224px; } +.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } +.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } +.ui-icon-grip-diagonal-se { background-position: -80px -224px; } + + +/* Misc visuals +----------------------------------*/ + +/* Corner radius */ +.ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; } +.ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } +.ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } +.ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } + +/* Overlays */ +.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); } +.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* Resizable +----------------------------------*/ +.ui-resizable { position: relative;} +.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;} +.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } +.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; } +.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; } +.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; } +.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; } +.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } +.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } +.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } +.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/* Selectable +----------------------------------*/ +.ui-selectable-helper { border:1px dotted black } +/* Autocomplete +----------------------------------*/ +.ui-autocomplete { position: absolute; cursor: default; } +.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } + +/* workarounds */ +* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */ + +/* Menu +----------------------------------*/ +.ui-menu { + list-style:none; + padding: 2px; + margin: 0; + display:block; +} +.ui-menu .ui-menu { + margin-top: -3px; +} +.ui-menu .ui-menu-item { + margin:0; + padding: 0; + zoom: 1; + float: left; + clear: left; + width: 100%; +} +.ui-menu .ui-menu-item a { + text-decoration:none; + display:block; + padding:.2em .4em; + line-height:1.5; + zoom:1; +} +.ui-menu .ui-menu-item a.ui-state-hover, +.ui-menu .ui-menu-item a.ui-state-active { + font-weight: normal; + margin: -1px; +} +/* Button +----------------------------------*/ + +.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */ +.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */ +button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */ +.ui-button-icons-only { width: 3.4em; } +button.ui-button-icons-only { width: 3.7em; } + +/*button text element */ +.ui-button .ui-button-text { display: block; line-height: 1.4; } +.ui-button-text-only .ui-button-text { padding: .4em 1em; } +.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; } +.ui-button-text-icon .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; } +.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } +/* no icon support for input elements, provide padding by default */ +input.ui-button { padding: .4em 1em; } + +/*button icon element(s) */ +.ui-button-icon-only .ui-icon, .ui-button-text-icon .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; } +.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; } +.ui-button-text-icon .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; } +.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } + +/*button sets*/ +.ui-buttonset { margin-right: 7px; } +.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; } + +/* workarounds */ +button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */ + + + + + +/* Dialog +----------------------------------*/ +.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; } +.ui-dialog .ui-dialog-titlebar { padding: .5em 1em .3em; position: relative; } +.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .2em 0; } +.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } +.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } +.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } +.ui-dialog .ui-dialog-content { border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; } +.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } +.ui-dialog .ui-dialog-buttonpane button { float: right; margin: .5em .4em .5em 0; cursor: pointer; padding: .2em .6em .3em .6em; line-height: 1.4em; width:auto; overflow:visible; } +.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } +.ui-draggable .ui-dialog-titlebar { cursor: move; } +/* Tabs +----------------------------------*/ +.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ +.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } +.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } +.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } +.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; } +.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } +.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ +.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; } +.ui-tabs .ui-tabs-hide { display: none !important; } diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/file.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/file.gif new file mode 100644 index 000000000..bd4f96549 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/file.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/folder-closed.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/folder-closed.gif new file mode 100644 index 000000000..be6b59c2b Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/folder-closed.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/folder.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/folder.gif new file mode 100644 index 000000000..be6b59c2b Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/folder.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-black-line.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-black-line.gif new file mode 100644 index 000000000..e5496877a Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-black-line.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-black.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-black.gif new file mode 100644 index 000000000..d549b9fc5 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-black.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-default-line.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-default-line.gif new file mode 100644 index 000000000..37114d306 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-default-line.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-default.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-default.gif new file mode 100644 index 000000000..a12ac52ff Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-default.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-famfamfam-line.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-famfamfam-line.gif new file mode 100644 index 000000000..6e289cecc Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-famfamfam-line.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-famfamfam.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-famfamfam.gif new file mode 100644 index 000000000..0cb178e89 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-famfamfam.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-gray-line.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-gray-line.gif new file mode 100644 index 000000000..37600447d Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-gray-line.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-gray.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-gray.gif new file mode 100644 index 000000000..cfb8a2f09 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-gray.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-red-line.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-red-line.gif new file mode 100644 index 000000000..df9e749a8 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-red-line.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-red.gif b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-red.gif new file mode 100644 index 000000000..3bbb3a157 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/images/treeview-red.gif differ diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/jquery.treeview.css b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/jquery.treeview.css new file mode 100644 index 000000000..d7e2c002a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/jquery.treeview.css @@ -0,0 +1,85 @@ +.treeview, .treeview ul { + padding: 0; + margin: 0; + list-style: none; +} + +.treeview ul { + background-color: white; + margin-top: 4px; +} + +.treeview .hitarea { + background: url(images/treeview-default.gif) -64px -25px no-repeat; + height: 16px; + width: 16px; + margin-left: -16px; + float: left; + cursor: pointer; +} +/* fix for IE6 */ +* html .hitarea { + display: inline; + float:none; +} + +.treeview li { + margin: 0; + padding: 3px 0 3px 16px; +} + +.treeview a.selected { + background-color: #eee; +} + +#treecontrol { margin: 1em 0; display: none; } + +.treeview .hover { color: red; cursor: pointer; } + +.treeview li { background: url(images/treeview-default-line.gif) 0 0 no-repeat; } +.treeview li.collapsable, .treeview li.expandable { background-position: 0 -176px; } + +.treeview .expandable-hitarea { background-position: -80px -3px; } + +.treeview li.last { background-position: 0 -1766px } +.treeview li.lastCollapsable, .treeview li.lastExpandable { background-image: url(images/treeview-default.gif); } +.treeview li.lastCollapsable { background-position: 0 -111px } +.treeview li.lastExpandable { background-position: -32px -67px } + +.treeview div.lastCollapsable-hitarea, .treeview div.lastExpandable-hitarea { background-position: 0; } + +.treeview-red li { background-image: url(images/treeview-red-line.gif); } +.treeview-red .hitarea, .treeview-red li.lastCollapsable, .treeview-red li.lastExpandable { background-image: url(images/treeview-red.gif); } + +.treeview-black li { background-image: url(images/treeview-black-line.gif); } +.treeview-black .hitarea, .treeview-black li.lastCollapsable, .treeview-black li.lastExpandable { background-image: url(images/treeview-black.gif); } + +.treeview-gray li { background-image: url(images/treeview-gray-line.gif); } +.treeview-gray .hitarea, .treeview-gray li.lastCollapsable, .treeview-gray li.lastExpandable { background-image: url(images/treeview-gray.gif); } + +.treeview-famfamfam li { background-image: url(images/treeview-famfamfam-line.gif); } +.treeview-famfamfam .hitarea, .treeview-famfamfam li.lastCollapsable, .treeview-famfamfam li.lastExpandable { background-image: url(images/treeview-famfamfam.gif); } + + +.filetree li { padding: 3px 0 2px 16px; } +.filetree span.folder, .filetree span.file { padding: 1px 0 1px 16px; display: block; } +.filetree span.folder { background: url(images/folder.gif) 0 0 no-repeat; } +.filetree li.expandable span.folder { background: url(images/folder-closed.gif) 0 0 no-repeat; } +.filetree span.file { background: url(images/file.gif) 0 0 no-repeat; } + +html, body {height:100%; margin: 0; padding: 0; } + +/* +html>body { + font-size: 16px; + font-size: 68.75%; +} Reset Base Font Size */ + /* +body { + font-family: Verdana, helvetica, arial, sans-serif; + font-size: 68.75%; + background: #fff; + color: #333; +} */ + +a img { border: none; } \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/jquery.treeview.min.js b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/jquery.treeview.min.js new file mode 100644 index 000000000..f9b490d3e --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/jquery/treeview/jquery.treeview.min.js @@ -0,0 +1,16 @@ +/* + * Treeview 1.4 - jQuery plugin to hide and show branches of a tree + * + * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ + * http://docs.jquery.com/Plugins/Treeview + * + * Copyright (c) 2007 Jörn Zaefferer + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Revision: $Id$ + * kasunbg: changed the cookieid name + * + */;(function($){$.extend($.fn,{swapClass:function(c1,c2){var c1Elements=this.filter('.'+c1);this.filter('.'+c2).removeClass(c2).addClass(c1);c1Elements.removeClass(c1).addClass(c2);return this;},replaceClass:function(c1,c2){return this.filter('.'+c1).removeClass(c1).addClass(c2).end();},hoverClass:function(className){className=className||"hover";return this.hover(function(){$(this).addClass(className);},function(){$(this).removeClass(className);});},heightToggle:function(animated,callback){animated?this.animate({height:"toggle"},animated,callback):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();if(callback)callback.apply(this,arguments);});},heightHide:function(animated,callback){if(animated){this.animate({height:"hide"},animated,callback);}else{this.hide();if(callback)this.each(callback);}},prepareBranches:function(settings){if(!settings.prerendered){this.filter(":last-child:not(ul)").addClass(CLASSES.last);this.filter((settings.collapsed?"":"."+CLASSES.closed)+":not(."+CLASSES.open+")").find(">ul").hide();}return this.filter(":has(>ul)");},applyClasses:function(settings,toggler){this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event){toggler.apply($(this).next());}).add($("a",this)).hoverClass();if(!settings.prerendered){this.filter(":has(>ul:hidden)").addClass(CLASSES.expandable).replaceClass(CLASSES.last,CLASSES.lastExpandable);this.not(":has(>ul:hidden)").addClass(CLASSES.collapsable).replaceClass(CLASSES.last,CLASSES.lastCollapsable);this.prepend("
      ").find("div."+CLASSES.hitarea).each(function(){var classes="";$.each($(this).parent().attr("class").split(" "),function(){classes+=this+"-hitarea ";});$(this).addClass(classes);});}this.find("div."+CLASSES.hitarea).click(toggler);},treeview:function(settings){if(typeof(window.treeCookieId) === 'undefined' || window.treeCookieId === ""){treeCookieId = "treeview";} settings=$.extend({cookieId: treeCookieId},settings);if(settings.add){return this.trigger("add",[settings.add]);}if(settings.toggle){var callback=settings.toggle;settings.toggle=function(){return callback.apply($(this).parent()[0],arguments);};}function treeController(tree,control){function handler(filter){return function(){toggler.apply($("div."+CLASSES.hitarea,tree).filter(function(){return filter?$(this).parent("."+filter).length:true;}));return false;};}$("a:eq(0)",control).click(handler(CLASSES.collapsable));$("a:eq(1)",control).click(handler(CLASSES.expandable));$("a:eq(2)",control).click(handler());}function toggler(){$(this).parent().find(">.hitarea").swapClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).swapClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().swapClass(CLASSES.collapsable,CLASSES.expandable).swapClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightToggle(settings.animated,settings.toggle);if(settings.unique){$(this).parent().siblings().find(">.hitarea").replaceClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).replaceClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().replaceClass(CLASSES.collapsable,CLASSES.expandable).replaceClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightHide(settings.animated,settings.toggle);}}function serialize(){function binary(arg){return arg?1:0;}var data=[];branches.each(function(i,e){data[i]=$(e).is(":has(>ul:visible)")?1:0;});$.cookie(settings.cookieId,data.join(""));}function deserialize(){var stored=$.cookie(settings.cookieId);if(stored){var data=stored.split("");branches.each(function(i,e){$(e).find(">ul")[parseInt(data[i])?"show":"hide"]();});}}this.addClass("treeview");var branches=this.find("li").prepareBranches(settings);switch(settings.persist){case"cookie":var toggleCallback=settings.toggle;settings.toggle=function(){serialize();if(toggleCallback){toggleCallback.apply(this,arguments);}};deserialize();break;case"location":var current=this.find("a").filter(function(){return this.href.toLowerCase()==location.href.toLowerCase();});if(current.length){current.addClass("selected").parents("ul, li").add(current.next()).show();}break;}branches.applyClasses(settings,toggler);if(settings.control){treeController(this,settings.control);$(settings.control).show();}return this.bind("add",function(event,branches){$(branches).prev().removeClass(CLASSES.last).removeClass(CLASSES.lastCollapsable).removeClass(CLASSES.lastExpandable).find(">.hitarea").removeClass(CLASSES.lastCollapsableHitarea).removeClass(CLASSES.lastExpandableHitarea);$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings,toggler);});}});var CLASSES=$.fn.treeview.classes={open:"open",closed:"closed",expandable:"expandable",expandableHitarea:"expandable-hitarea",lastExpandableHitarea:"lastExpandable-hitarea",collapsable:"collapsable",collapsableHitarea:"collapsable-hitarea",lastCollapsableHitarea:"lastCollapsable-hitarea",lastCollapsable:"lastCollapsable",lastExpandable:"lastExpandable",last:"last",hitarea:"hitarea"};$.fn.Treeview=$.fn.treeview;})(jQuery); \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/common/main.js b/xs/src/avrdude/atmel-docs/EDBG/common/main.js new file mode 100644 index 000000000..96b6a86c6 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/common/main.js @@ -0,0 +1,282 @@ +/** + * Miscellaneous js functions for WebHelp + * Kasun Gajasinghe, http://kasunbg.blogspot.com + * David Cramer, http://www.thingbag.net + * + */ + +//Turn ON and OFF the animations for Show/Hide Sidebar. Extend this to other anime as well if any. +var noAnimations=false; + +$(document).ready(function() { + + /* Local addition */ + $("a").filter(function() { + return this.hostname && this.hostname !== location.hostname; + }).addClass('external'); + + // When you click on a link to an anchor, scroll down + // 105 px to cope with the fact that the banner + // hides the top 95px or so of the page. + // This code deals with the problem when + // you click on a link within a page. + $('a[href*=#]').click(function() { + if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') + && location.hostname == this.hostname) { + var $target = $(this.hash); + $target = $target.length && $target + || $('[name=' + this.hash.slice(1) +']'); + if (!(this.hash == "#searchDiv" || this.hash == "#treeDiv" || this.hash == "") && $target.length) { + var targetOffset = $target.offset().top - 120; + $('html,body') + .animate({scrollTop: targetOffset}, 200); + return false; + } + } + }); + + // $("#showHideHighlight").button(); //add jquery button styling to 'Go' button + //Generate tabs in nav-pane with JQuery + $(function() { + $("#tabs").tabs({ + cookie: { + expires: 2 // store cookie for 2 days. + } + }); + }); + + //Generate the tree + $("#ulTreeDiv").attr("style", ""); + $("#tree").treeview({ + collapsed: true, + animated: "medium", + control: "#sidetreecontrol", + persist: "cookie" + }); + + //after toc fully styled, display it. Until loading, a 'loading' image will be displayed + $("#tocLoading").attr("style", "display:none;"); + // $("#ulTreeDiv").attr("style","display:block;"); + + //.searchButton is the css class applied to 'Go' button + $(function() { + $("button", ".searchButton").button(); + + $("button", ".searchButton").click(function() { + return false; + }); + }); + + //'ui-tabs-1' is the cookie name which is used for the persistence of the tabs.(Content/Search tab) + if ($.cookie('ui-tabs-1') === '1') { //search tab is active + if ($.cookie('textToSearch') != undefined && $.cookie('textToSearch').length > 0) { + document.getElementById('textToSearch').value = $.cookie('textToSearch'); + Verifie('searchForm'); + searchHighlight($.cookie('textToSearch')); + $("#showHideHighlight").css("display", "block"); + } + } + + syncToc(); //Synchronize the toc tree with the content pane, when loading the page. + //$("#doSearch").button(); //add jquery button styling to 'Go' button + + // When you click on a link to an anchor, scroll down + // 120 px to cope with the fact that the banner + // hides the top 95px or so of the page. + // This code deals with the problem when + // you click on a link from another page. + var hash = window.location.hash; + if(hash){ + var targetOffset = $(hash).offset().top - 120; + $('html,body').animate({scrollTop: targetOffset}, 200); + return false; + } +}); + + +/** + * If an user moved to another page by clicking on a toc link, and then clicked on #searchDiv, + * search should be performed if the cookie textToSearch is not empty. + */ +function doSearch() { +//'ui-tabs-1' is the cookie name which is used for the persistence of the tabs.(Content/Search tab) + if ($.cookie('textToSearch') != undefined && $.cookie('textToSearch').length > 0) { + document.getElementById('textToSearch').value = $.cookie('textToSearch'); + Verifie('searchForm'); + } +} + +/** + * Synchronize with the tableOfContents + */ +function syncToc() { + var a = document.getElementById("webhelp-currentid"); + if (a != undefined) { + //Expanding the child sections of the selected node. + var nodeClass = a.getAttribute("class"); + if (nodeClass != null && !nodeClass.match(/collapsable/)) { + a.setAttribute("class", "collapsable"); + //remove display:none; css style from
        block in the selected node. + var ulNode = a.getElementsByTagName("ul")[0]; + if (ulNode != undefined) { + if (ulNode.hasAttribute("style")) { + ulNode.setAttribute("style", "display: block; background-color: #D8D8D8 !important;"); + } else { + var ulStyle = document.createAttribute("style"); + ulStyle.nodeValue = "display: block; background-color: #D8D8D8 !important;"; + ulNode.setAttributeNode(ulStyle); + } } + //adjust tree's + sign to - + var divNode = a.getElementsByTagName("div")[0]; + if (divNode != undefined) { + if (divNode.hasAttribute("class")) { + divNode.setAttribute("class", "hitarea collapsable-hitarea"); + } else { + var divClass = document.createAttribute("class"); + divClass.nodeValue = "hitarea collapsable-hitarea"; + divNode.setAttributeNode(divClass); + } } + //set persistence cookie when a node is auto expanded + // setCookieForExpandedNode("webhelp-currentid"); + } + var b = a.getElementsByTagName("a")[0]; + + if (b != undefined) { + //Setting the background for selected node. + var style = a.getAttribute("style", 2); + if (style != null && !style.match(/background-color: Background;/)) { + a.setAttribute("style", "background-color: #D8D8D8; " + style); + b.setAttribute("style", "color: black;"); + } else if (style != null) { + a.setAttribute("style", "background-color: #D8D8D8; " + style); + b.setAttribute("style", "color: black;"); + } else { + a.setAttribute("style", "background-color: #D8D8D8; "); + b.setAttribute("style", "color: black;"); + } + } + + //shows the node related to current content. + //goes a recursive call from current node to ancestor nodes, displaying all of them. + while (a.parentNode && a.parentNode.nodeName) { + var parentNode = a.parentNode; + var nodeName = parentNode.nodeName; + + if (nodeName.toLowerCase() == "ul") { + parentNode.setAttribute("style", "display: block;"); + } else if (nodeName.toLocaleLowerCase() == "li") { + parentNode.setAttribute("class", "collapsable"); + parentNode.firstChild.setAttribute("class", "hitarea collapsable-hitarea "); + } + a = parentNode; +} } } +/* + function setCookieForExpandedNode(nodeName) { + var tocDiv = document.getElementById("tree"); //get table of contents Div + var divs = tocDiv.getElementsByTagName("div"); + var matchedDivNumber; + var i; + for (i = 0; i < divs.length; i++) { //1101001 + var div = divs[i]; + var liNode = div.parentNode; + } +//create a new cookie if a treeview does not exist + if ($.cookie(treeCookieId) == null || $.cookie(treeCookieId) == "") { + var branches = $("#tree").find("li");//.prepareBranches(treesettings); + var data = []; + branches.each(function(i, e) { + data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0; + }); + $.cookie(treeCookieId, data.join("")); + + } + + if (i < divs.length) { + var treeviewCookie = $.cookie(treeCookieId); + var tvCookie1 = treeviewCookie.substring(0, i); + var tvCookie2 = treeviewCookie.substring(i + 1); + var newTVCookie = tvCookie1 + "1" + tvCookie2; + $.cookie(treeCookieId, newTVCookie); + } + } */ + +/** + * Code for Show/Hide TOC + * + */ +function showHideToc() { + var showHideButton = $("#showHideButton"); + var leftNavigation = $("#sidebar"); //hide the parent div of leftnavigation, ie sidebar + var content = $("#content"); + var animeTime=75 + + if (showHideButton != undefined && showHideButton.hasClass("pointLeft")) { + //Hide TOC + showHideButton.removeClass('pointLeft').addClass('pointRight'); + + if(noAnimations) { + leftNavigation.css("display", "none"); + content.css("margin", "125px 0 0 0"); + } else { + leftNavigation.hide(animeTime); + content.animate( { "margin-left": 0 }, animeTime); + } + showHideButton.attr("title", "Show Sidebar"); + } else { + //Show the TOC + showHideButton.removeClass('pointRight').addClass('pointLeft'); + if(noAnimations) { + content.css("margin", "125px 0 0 280px"); + leftNavigation.css("display", "block"); + } else { + content.animate( { "margin-left": '280px' }, animeTime); + leftNavigation.show(animeTime); + } + showHideButton.attr("title", "Hide Sidebar"); + } +} + +/** + * Code for search highlighting + */ +var highlightOn = true; +function searchHighlight(searchText) { + highlightOn = true; + if (searchText != undefined) { + var wList; + var sList = new Array(); //stem list + //Highlight the search terms + searchText = searchText.toLowerCase().replace(/<\//g, "_st_").replace(/\$_/g, "_di_").replace(/\.|%2C|%3B|%21|%3A|@|\/|\*/g, " ").replace(/(%20)+/g, " ").replace(/_st_/g, " + + + +EDBG interface overview - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch01s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch01s02.html new file mode 100644 index 000000000..d59bf2d5e --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch01s02.html @@ -0,0 +1,234 @@ + + + + +Atmel EDBG-based tool implementations - - Atmel EDBG-based Tools Protocols

        The protocol-set described in this document is intended for use on EDBG platforms as well + as standalone debuggers. The JTAGICE3 firmware version 3 upgrades that tool to support SAMD20, + and implements parts of the protocol-set described here. EDBG implementations are very limited + subsets os this protocol which support the particular Atmel controller mounted on that board.


        Note that capability of each implementation should be queried from the tool itself rather than based upon the lists here.

        Future Atmel standalone debuggers will also implement the same CMSIS-DAP based protocol as + described here.

        JTAGICE3 (FW version 2 and earlier) implements a custom USB interface which is no + longer supported.

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s01.html new file mode 100644 index 000000000..234c40886 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s01.html @@ -0,0 +1,212 @@ + + + + +CMSIS-DAP protocol - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02.html new file mode 100644 index 000000000..1ae5aac6a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02.html @@ -0,0 +1,213 @@ + + + + +CMSIS-DAP vendor commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s01.html new file mode 100644 index 000000000..ab2191d46 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s01.html @@ -0,0 +1,211 @@ + + + + +AVR-target specific vendor commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s02.html new file mode 100644 index 000000000..0396afd8b --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s02.html @@ -0,0 +1,211 @@ + + + + +ARM-target specific vendor commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s02s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s02s01.html new file mode 100644 index 000000000..94e442177 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s02s01.html @@ -0,0 +1,212 @@ + + + + +Erase pin - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s02s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s02s02.html new file mode 100644 index 000000000..443f008f0 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s02s02.html @@ -0,0 +1,211 @@ + + + + +Serial trace - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03.html new file mode 100644 index 000000000..ce86f07b8 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03.html @@ -0,0 +1,211 @@ + + + + +EDBG-specific vendor commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s01.html new file mode 100644 index 000000000..666fa6f3b --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s01.html @@ -0,0 +1,211 @@ + + + + +Get configuration - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s02.html new file mode 100644 index 000000000..f513f9656 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s02.html @@ -0,0 +1,211 @@ + + + + +Set configuration - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s03.html new file mode 100644 index 000000000..feb2e2aff --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s03.html @@ -0,0 +1,211 @@ + + + + +EDBG GET request - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s04.html new file mode 100644 index 000000000..0ad83b637 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s02s03s04.html @@ -0,0 +1,211 @@ + + + + +EDBG SET request - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s01.html new file mode 100644 index 000000000..69c34b0a0 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s01.html @@ -0,0 +1,214 @@ + + + + +Set transport mode - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s02.html new file mode 100644 index 000000000..df5f82436 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s02.html @@ -0,0 +1,214 @@ + + + + +Set capture mode - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s03.html new file mode 100644 index 000000000..60e231822 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s03.html @@ -0,0 +1,212 @@ + + + + +Set baud rate - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s04.html new file mode 100644 index 000000000..ca57b115e --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s04.html @@ -0,0 +1,212 @@ + + + + +Start - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s05.html new file mode 100644 index 000000000..8fdf2a10a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s05.html @@ -0,0 +1,212 @@ + + + + +Stop - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s06.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s06.html new file mode 100644 index 000000000..b18020202 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s06.html @@ -0,0 +1,216 @@ + + + + +Get data - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s07.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s07.html new file mode 100644 index 000000000..3f894396e --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s07.html @@ -0,0 +1,214 @@ + + + + +Get status - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s08.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s08.html new file mode 100644 index 000000000..01fda3281 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s08.html @@ -0,0 +1,211 @@ + + + + +Get buffer size - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s09.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s09.html new file mode 100644 index 000000000..7508ace3f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s03s09.html @@ -0,0 +1,211 @@ + + + + +Signon - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04.html new file mode 100644 index 000000000..7f0e6c37a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04.html @@ -0,0 +1,216 @@ + + + + +Enveloped AVR commands, responses & events - - Atmel EDBG-based Tools Protocols

        In order to support programing and debugging AVR devices over the same interface as + ARM-based devices, three vendor commands are used. Commands are send using the AVR_CMD vendor + command. All commands are synchronous and result in one and only one response. The response is + however buffered on the tool and must be polled for using the AVR_RSP vendor command. Events + occur asynchronously to commands, and must be periodically polled for using the AVR_EVT vendor + command.

        The AVR command set is described in AVR communication protocol.

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04s01.html new file mode 100644 index 000000000..410b1cd2d --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04s01.html @@ -0,0 +1,216 @@ + + + + +Wrapping AVR commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04s02.html new file mode 100644 index 000000000..16c752df3 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04s02.html @@ -0,0 +1,218 @@ + + + + +Unwrapping AVR responses - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04s03.html new file mode 100644 index 000000000..012c91dcb --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch02s04s03.html @@ -0,0 +1,214 @@ + + + + +Unwrapping AVR events - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01.html new file mode 100644 index 000000000..6bd694495 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01.html @@ -0,0 +1,211 @@ + + + + +Protocol commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s01.html new file mode 100644 index 000000000..1a5e37f0a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s01.html @@ -0,0 +1,215 @@ + + + + +QUERY - - Atmel EDBG-based Tools Protocols diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s01.html~ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s01.html~ new file mode 100644 index 000000000..20b5c4514 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s01.html~ @@ -0,0 +1,215 @@ + + + + +QUERY - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s02.html new file mode 100644 index 000000000..dbb58ccee --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s02.html @@ -0,0 +1,216 @@ + + + + +SET - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s03.html new file mode 100644 index 000000000..04fb2403d --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s03.html @@ -0,0 +1,216 @@ + + + + +GET - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s03s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s03s01.html new file mode 100644 index 000000000..37174b6cc --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s01s03s01.html @@ -0,0 +1,211 @@ + + + + +SET/GET parameters - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02.html new file mode 100644 index 000000000..2716e63a4 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02.html @@ -0,0 +1,211 @@ + + + + +Responses - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s01.html new file mode 100644 index 000000000..11e766ec2 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s01.html @@ -0,0 +1,211 @@ + + + + +OK - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s02.html new file mode 100644 index 000000000..fee95a4d4 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s02.html @@ -0,0 +1,211 @@ + + + + +LIST - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s03.html new file mode 100644 index 000000000..a5f5ea0ae --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s03.html @@ -0,0 +1,212 @@ + + + + +DATA - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s04.html new file mode 100644 index 000000000..be4e8e65a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch03s02s04.html @@ -0,0 +1,211 @@ + + + + +FAILED - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s01.html new file mode 100644 index 000000000..661b07998 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s01.html @@ -0,0 +1,212 @@ + + + + +Overview - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s02.html new file mode 100644 index 000000000..928910efc --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s02.html @@ -0,0 +1,228 @@ + + + + +Framing - - Atmel EDBG-based Tools Protocols

        This section outlines the general frame format used by all sub-protocols.

        The protocol handler ID field identifies which sub-protocol to decode the packet + by, and this which command handler to forward the packet to.

        In general, ID == 0x00 is used as a “query” function in order for + the host to “discover” the feature set of the tool.

        +


        +

        +


        +

        +


        +

        The protocol handler ID field identifies which sub-protocol to decode the packet + by, and this which command handler to forward the packet to.

        In general, ID == 0x00 is used as a “query” function in order for + the host to “discover” the feature set of the tool.

        If there is a condition where the EDBG AVR command handler expects more data + for a command than is available, then the next incoming command will be rejected and an + error response (RSP_FAILED with failure code + FAILURE_USB_PREVIOUS_UNDERRUN) will be returned . Note that such an + underrun situation will result in unknown values for the parameters of the failing + command and the host will have to do the necessary cleanup to undo any undesired + behaviour. The underrun error reporting is done by transport layer and is independent of + the sub-protocol being used.

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s03.html new file mode 100644 index 000000000..4fd01391c --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s03.html @@ -0,0 +1,218 @@ + + + + +Protocol sub-set overview - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04.html new file mode 100644 index 000000000..0a5ee21bf --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04.html @@ -0,0 +1,212 @@ + + + + +Discovery Protocol Definition - - Atmel EDBG-based Tools Protocols

        The discovery handler only supports the QUERY command. It is used to interrogate + the tool for its supported functionality and other fixed information.

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s01.html new file mode 100644 index 000000000..5604043c7 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s01.html @@ -0,0 +1,215 @@ + + + + +CMD: QUERY - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s03.html new file mode 100644 index 000000000..c2eb3844f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s03.html @@ -0,0 +1,211 @@ + + + + +RSP: LIST - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s04.html new file mode 100644 index 000000000..0dc44a78d --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s04.html @@ -0,0 +1,211 @@ + + + + +RSP: FAILED - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s05.html new file mode 100644 index 000000000..6b10f7ebe --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s04s05.html @@ -0,0 +1,236 @@ + + + + +Discovery Protocol ID definitions - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05.html new file mode 100644 index 000000000..70efa405c --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05.html @@ -0,0 +1,213 @@ + + + + +Housekeeping Protocol - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s01.html new file mode 100644 index 000000000..3f46ac85c --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s01.html @@ -0,0 +1,215 @@ + + + + +CMD: QUERY - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s03.html new file mode 100644 index 000000000..713c57c0c --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s03.html @@ -0,0 +1,216 @@ + + + + +CMD: SET - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s04.html new file mode 100644 index 000000000..adb176dd9 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s04.html @@ -0,0 +1,216 @@ + + + + +CMD: GET - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06.html new file mode 100644 index 000000000..254c04931 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06.html @@ -0,0 +1,211 @@ + + + + +Housekeeping Commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s02.html new file mode 100644 index 000000000..9a01e3c48 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s02.html @@ -0,0 +1,213 @@ + + + + +End Session - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s03.html new file mode 100644 index 000000000..8278b2627 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s03.html @@ -0,0 +1,213 @@ + + + + +Firmware Upgrade - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s04.html new file mode 100644 index 000000000..75f289697 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s04.html @@ -0,0 +1,217 @@ + + + + +JTAG scan-chain detection - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s05.html new file mode 100644 index 000000000..3bf798fb6 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s06s05.html @@ -0,0 +1,217 @@ + + + + +Calibrate Oscillator - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07.html new file mode 100644 index 000000000..df1d7fef4 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07.html @@ -0,0 +1,211 @@ + + + + +Housekeeping Responses - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s01.html new file mode 100644 index 000000000..ddd7e13ed --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s01.html @@ -0,0 +1,211 @@ + + + + +OK - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s02.html new file mode 100644 index 000000000..1f18a73d0 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s02.html @@ -0,0 +1,211 @@ + + + + +LIST - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s03.html new file mode 100644 index 000000000..92b8b3f50 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s03.html @@ -0,0 +1,213 @@ + + + + +DATA - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s04.html new file mode 100644 index 000000000..19fc5eb04 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s07s04.html @@ -0,0 +1,211 @@ + + + + +FAILED - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08.html new file mode 100644 index 000000000..f0efdf9b8 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08.html @@ -0,0 +1,211 @@ + + + + +Events - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08s01.html new file mode 100644 index 000000000..91fbfb8ed --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08s01.html @@ -0,0 +1,213 @@ + + + + +Event: power - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08s02.html new file mode 100644 index 000000000..395e3a4ae --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08s02.html @@ -0,0 +1,214 @@ + + + + +Event: sleep - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08s03.html new file mode 100644 index 000000000..128c2b8c8 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s08s03.html @@ -0,0 +1,211 @@ + + + + +Event: external reset - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s09.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s09.html new file mode 100644 index 000000000..3588ca655 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s09.html @@ -0,0 +1,220 @@ + + + + +Hints and tips - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s10.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s10.html new file mode 100644 index 000000000..80f23e797 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch04s05s10.html @@ -0,0 +1,310 @@ + + + + +Housekeeping ID definitions - - Atmel EDBG-based Tools Protocols
        enum Jtagice3HousekeepingCommands {
        +                    
        +    // Basics
        +    CMD_HOUSEKEEPING_QUERY                  = 0x00, //! Capability discovery 
        +    CMD_HOUSEKEEPING_SET                    = 0x01, //! Set parameters
        +    CMD_HOUSEKEEPING_GET                    = 0x02, //! Get parameters
        +    
        +    // Session
        +    CMD_HOUSEKEEPING_START_SESSION          = 0x10, //! Start a session
        +    CMD_HOUSEKEEPING_END_SESSION            = 0x11, //! Terminate a session
        +    
        +    // Misc target-related
        +    CMD_HOUSEKEEPING_JTAG_DETECT            = 0x30, //! Scan for JTAG devices
        +    CMD_HOUSEKEEPING_CAL_OSC                = 0x31, //! Oscillator calibration 
        +    
        +    // Internal commands
        +    CMD_HOUSEKEEPING_FW_UPGRADE             = 0x50, //! Enter upgrade mode
        +};
        +
        +enum Jtagice3HousekeepingResponses {
        +    RSP_HOUSEKEEPING_OK                     = 0x80, //! All OK
        +    RSP_HOUSEKEEPING_LIST                   = 0x81, //! List of items returned
        +    RSP_HOUSEKEEPING_DATA                   = 0x84, //! Data returned
        +    RSP_HOUSEKEEPING_FAILED                 = 0xA0, //! Command failed to execute
        +    RSP_HOUSEKEEPING_FAILED_WITH_DATA       = 0xA1  //! Failed with more info
        +
        +};
        +
        +enum Jtagice3HousekeepingEvents {
        +    EVT_HOUSEKEEPING_POWER                  = 0x10, //! Power event occurred
        +    EVT_HOUSEKEEPING_SLEEP                  = 0x11, //! Sleep event detected
        +    EVT_HOUSEKEEPING_EXT_RESET              = 0x12, //! External reset event
        +};
        +
        +
        +enum Jtagice3HousekeepingFailureCodes {
        +    HOUSEKEEPING_FAILED_OK                              = 0x00, //! All OK
        +    HOUSEKEEPING_FAILED_NOT_SUPPORTED                   = 0x10, //! Not supported
        +    HOUSEKEEPING_FAILED_INVALID_KEY                     = 0x11, //! Wrong key
        +    HOUSEKEEPING_FAILED_INVALID_PARAMETER               = 0x12, //! Wrong parameter
        +    HOUSEKEEPING_FAILED_INVALID_PARAMETER_VALUE         = 0x13, //! Wrong value
        +
        +    HOUSEKEEPING_FAILED_JTAG_DETECT_NO_DEVICES          = 0x30, //! No devices
        +    HOUSEKEEPING_FAILED_JTAG_DETECT_TOO_MANY_DEVICES    = 0x31, //! Too many devices
        +    HOUSEKEEPING_FAILED_JTAG_DETECT_JTAGM_INIT_ERROR    = 0x32, //! Init failed
        +    HOUSEKEEPING_FAILED_JTAG_DETECT_JTAGM_ERROR         = 0x33, //! JTAGM error
        +    
        +    HOUSEKEEPING_FAILED_NO_TARGET_POWER                 = 0x38, //! Apply power
        +    
        +    HOUSEKEEPING_FAILED_OSCCAL_INVALID_MODE             = 0x40, //! Wrong mode
        +    HOUSEKEEPING_FAILED_OSCCAL_INVALID_PHYSICAL         = 0x41, //! Wrong phy
        +    HOUSEKEEPING_FAILED_OSCCAL_FW_ERROR                 = 0x42, //! Firmware error
        +    HOUSEKEEPING_FAILED_OSCCAL_FAILED                   = 0x43, //! OSCCAL error
        +};
        +
        +enum Jtagice3SetGetFailureCodes {
        +    SETGET_FAILURE_OK                                   = 0x00, //! All OK
        +    SETGET_FAILURE_NOT_IMPLEMENTED                      = 0x10, //! Command not implented
        +    SETGET_FAILURE_NOT_SUPPORTED                        = 0x11, //! Parameter not supported
        +    SETGET_FAILURE_INVALID_CLOCK_SPEED                  = 0x20, //! Clock out of range
        +    SETGET_FAILURE_ILLEGAL_STATE                        = 0x21, //! Wrong state to access the parameter
        +    SETGET_FAILURE_JTAGM_INIT_ERROR                     = 0x22, //! JTAG initialisation error
        +    SETGET_FAILURE_INVALID_VALUE                        = 0x23  //! Value out of range
        +};
        +
        +
        +enum Jtagice3HousekeepingQueryContexts {
        +    HK_QUERY_COMMANDS                                   = 0x00  //! Supported command list
        +};
        +
        +enum Jtagice3HousekeepingSetGetContexts {
        +    HK_CONTEXT_CONFIG                                   = 0x00, //! Config parameter
        +    HK_CONTEXT_ANALOG                                   = 0x01, //! Analog parameters
        +};
        +
        +enum Jtagice3HousekeepingConfigContextParameters {
        +    HOUSEKEEPING_CONFIG_HWREV               = 0x00, //! Hardware revision 
        +    HOUSEKEEPING_CONFIG_FWREV_MAJ           = 0x01, //! Firmware revision high
        +    HOUSEKEEPING_CONFIG_FWREV_MIN           = 0x02, //! Firmware revision low
        +    HOUSEKEEPING_CONFIG_BUILD               = 0x03, //! Firmware build number
        +};
        +
        +enum Jtagice3HousekeepingAnalogContextParameters {
        +    HOUSEKEEPING_ANALOG_VTREF               = 0x00  //! Target reference voltage
        +};
        +
        +enum Jtagice3HousekeepingPowerEvents {
        +    HOUSEKEEPING_POWER_OFF                  = 0x00, //! Power went off
        +    HOUSEKEEPING_POWER_ON                   = 0x01  //! Power went on
        +};
        +
        +enum Jtagice3HousekeepingSleepEvents {
        +    HOUSEKEEPING_AWAKE                      = 0x00, //! Target woke up
        +    HOUSEKEEPING_SLEEP                      = 0x01  //! Target fell asleep
        +};
        +
        +enum Jtagice3HousekeepingResetEvents {
        +    HOUSEKEEPING_RESET_RELEASED             = 0x00, //! External reset released
        +    HOUSEKEEPING_RESET_APPLIED              = 0x01  //! External reset applied
        +};
        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01.html new file mode 100644 index 000000000..3cb080a26 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01.html @@ -0,0 +1,211 @@ + + + + +Protocol commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s01.html new file mode 100644 index 000000000..4e07d5716 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s01.html @@ -0,0 +1,215 @@ + + + + +QUERY - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s02.html new file mode 100644 index 000000000..51d7f260d --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s02.html @@ -0,0 +1,216 @@ + + + + +SET - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s03.html new file mode 100644 index 000000000..0a8ae1f5a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s03.html @@ -0,0 +1,216 @@ + + + + +GET - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s04.html new file mode 100644 index 000000000..aa8419adc --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s04.html @@ -0,0 +1,216 @@ + + + + +Activate Physical - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s05.html new file mode 100644 index 000000000..53c5b4661 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s05.html @@ -0,0 +1,213 @@ + + + + +Deactivate Physical - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s06.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s06.html new file mode 100644 index 000000000..7cd708933 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s06.html @@ -0,0 +1,215 @@ + + + + +Get ID - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s07.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s07.html new file mode 100644 index 000000000..0c8fd69cf --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s07.html @@ -0,0 +1,213 @@ + + + + +Erase - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s08.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s08.html new file mode 100644 index 000000000..33458079f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s08.html @@ -0,0 +1,213 @@ + + + + +Halt - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s09.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s09.html new file mode 100644 index 000000000..5b1a92485 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s09.html @@ -0,0 +1,214 @@ + + + + +Reset - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s10.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s10.html new file mode 100644 index 000000000..c34fdc8f9 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s10.html @@ -0,0 +1,213 @@ + + + + +Step - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s11.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s11.html new file mode 100644 index 000000000..d0e20a1f4 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s11.html @@ -0,0 +1,214 @@ + + + + +Read - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s12.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s12.html new file mode 100644 index 000000000..9a083c7fc --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s12.html @@ -0,0 +1,214 @@ + + + + +Write - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s13.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s13.html new file mode 100644 index 000000000..d7f9e2899 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s13.html @@ -0,0 +1,215 @@ + + + + +TAP - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s14.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s14.html new file mode 100644 index 000000000..07d724a3b --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s14.html @@ -0,0 +1,217 @@ + + + + +Is protected - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s15.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s15.html new file mode 100644 index 000000000..75d4fc8ea --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s01s15.html @@ -0,0 +1,216 @@ + + + + +Erase Section - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02.html new file mode 100644 index 000000000..d7ecd1244 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02.html @@ -0,0 +1,211 @@ + + + + +Responses - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s01.html new file mode 100644 index 000000000..ca3957a18 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s01.html @@ -0,0 +1,211 @@ + + + + +OK - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s02.html new file mode 100644 index 000000000..53534183b --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s02.html @@ -0,0 +1,211 @@ + + + + +LIST - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s03.html new file mode 100644 index 000000000..cc729e727 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s03.html @@ -0,0 +1,211 @@ + + + + +ID - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s04.html new file mode 100644 index 000000000..be920ef5d --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s04.html @@ -0,0 +1,211 @@ + + + + +PC - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s05.html new file mode 100644 index 000000000..a08bf7070 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s05.html @@ -0,0 +1,212 @@ + + + + +DATA - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s06.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s06.html new file mode 100644 index 000000000..6f64eee57 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s02s06.html @@ -0,0 +1,211 @@ + + + + +FAILED - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03.html new file mode 100644 index 000000000..7d02558fa --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03.html @@ -0,0 +1,211 @@ + + + + +Hints and tips - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03s01.html new file mode 100644 index 000000000..0097735a7 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03s01.html @@ -0,0 +1,219 @@ + + + + +Configuration - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03s02.html new file mode 100644 index 000000000..635e4d02c --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03s02.html @@ -0,0 +1,224 @@ + + + + +Activate and deactivate physical - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03s03.html new file mode 100644 index 000000000..88856f5b8 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s03s03.html @@ -0,0 +1,214 @@ + + + + +Programming and debugging commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s04.html new file mode 100644 index 000000000..4294de672 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch05s04.html @@ -0,0 +1,360 @@ + + + + +AVR32GENERIC ID definitions - - Atmel EDBG-based Tools Protocols

        + This sections includes the header file defining the different command and + response IDs for the AVR32 protocol. It also defines the different possible failure codes. +

        enum Avr32GenericCommands {
        +    AVR32_CMD_QUERY                 = 0x00, //! Capability discovery 
        +    AVR32_CMD_SET                   = 0x01, //! Set parameters
        +    AVR32_CMD_GET                   = 0x02, //! Get parameters
        +    AVR32_CMD_ACTIVATE_PHYSICAL     = 0x03, //! Connect physically
        +    AVR32_CMD_DEACTIVATE_PHYSICAL   = 0x04, //! Disconnect physically
        +    AVR32_CMD_GET_ID                = 0x10, //! Read the ID
        +    AVR32_CMD_ERASE                 = 0x11, //! Erase the device
        +    AVR32_CMD_HALT                  = 0x12, //! Stop or start execution
        +    AVR32_CMD_RESET                 = 0x13, //! Apply or release reset
        +    AVR32_CMD_STEP                  = 0x14, //! Single step
        +    AVR32_CMD_READ                  = 0x15, //! Read memory
        +    AVR32_CMD_WRITE                 = 0x16, //! Write memory
        +    AVR32_CMD_TAP                   = 0x17, //! Low-level JTAG commands
        +    AVR32_CMD_IS_PROTECTED          = 0x18, //! Check protected bit
        +    AVR32_CMD_ERASE_SECTION         = 0x19  //! Partial erase
        +};
        +
        +enum Avr32GenericResponses {
        +    AVR32_RSP_FAILED                = 0xA0, //! Execution failed
        +    AVR32_RSP_OK                    = 0x80, //! All OK
        +    AVR32_RSP_LIST                  = 0x81, //! List of items returned
        +    AVR32_RSP_ID                    = 0x82, //! ID value returned
        +    AVR32_RSP_PC                    = 0x83, //! PC value returned
        +    AVR32_RSP_DATA                  = 0x84  //! Data returned
        +};
        +
        +enum Avr32GenericQueryContexts {
        +    AVR32_QUERY_COMMANDS             = 0x00, //! Supported command list
        +    AVR32_QUERY_CONFIGURATION        = 0x05, //! Supported configuration list
        +    AVR32_QUERY_READ_MEMTYPES        = 0x06, //! Supported read memtypes list
        +    AVR32_QUERY_WRITE_MEMTYPES       = 0x07, //! Supported write memtypes list
        +    AVR32_QUERY_COMMAND_VERSIONS     = 0x08  //! Version map of command list
        +};
        + 
        +enum Avr32GenericSetGetContexts {
        +    AVR32_CTXT_USB                  = 0x03, //! Transport-related settings
        +    AVR32_CTXT_SESSION              = 0x04, //! Session-related settings
        +    AVR32_CTXT_PHYSICAL             = 0x80, //! Physical interface related
        +    AVR32_CTXT_DEVICE                = 0x82, //! Device specific settings
        +};
        +
        +enum Avr32GenericSessionContextParameters {
        +    AVR32_SESS_RUN_LED              = 0x00, //! Control the LED
        +};
        +
        +enum Avr32GenericUsbContextParameters {
        +    AVR32_USB_MAX_READ              = 0x00, //! Read payload size
        +    AVR32_USB_MAX_WRITE             = 0x01  //! Write payload size
        +};
        +
        +enum Avr32GenericPhysicalContextParameters {
        +    AVR32_PHY_PHYSICAL              = 0x00, //! Physical interface selector
        +    AVR32_PHYL_JTAG_CLOCK           = 0x01, //! JTAG clock value
        +    AVR32_PHY_AW_MAXBAUD            = 0x02, //! Maximum aWire baud
        +    AVR32_PHY_DAISY                 = 0x03, //! JTAG daisy chain settings
        +    AVR32_PHY_AWIRE_BAUD            = 0x04, //! Current aWire baud
        +    AVR32_PHY_AWIRE_VERSION         = 0x05, //! aWire slave version
        +    AVR32_PHY_EXT_RESET             = 0x0C, //! External reset control
        +};
        +
        +enum Avr32GenericDeviceContext {
        +    AVR32_FLASH_CTRL_BASE           = 0x02, //! Flash controller base address
        +    AVR32_FLASH_PAGEBYTES           = 0x06, //! Number of bytes in one flash page
        +    AVR32_RESET_DOMAINS         = 0x0A, //! Number of reset domains
        +    AVR32_FLASH_PAGES               = 0x0B, //! Number of pages in the flash block
        +    AVR32_AWIRE_BASE                = 0x10  //! Base address for aWire module
        +};
        +
        +enum Avr32GenericMemoryTypes {
        +    AVR32_MEMTYPE_SAB               = 0x80, //! Service Access Bus (SAB) word access
        +    AVR32_MEMTYPE_NEXUS             = 0x81, //! Nexus mode access to SAB
        +    AVR32_MEMTYPE_MEMORY_SERVICE    = 0x82, //! Memory Service mode access to SAB
        +    AVR32_MEMTYPE_BLOCK             = 0x83, //! Block access to SAB
        +    AVR32_MEMTYPE_BYTE              = 0x84, //! 8-bit access to SAB
        +    AVR32_MEMTYPE_HALF_WORD         = 0x85, //! 16-bit access to SAB
        +    AVR32_MEMTYPE_INTERNAL_FLASH    = 0x90, //! Write access to internal FLASH
        +    AVR32_MEMTYPE_SYSREG            = 0x91, //! Access to system registers
        +    AVR32_MEMTYPE_REGFILE           = 0x92, //! Access to register file
        +    AVR32_MEMTYPE_USER_PAGE         = 0x93  //! Access to User Page in flash
        +};
        +
        +enum Avr32GenericPhysicalInterfaces {
        +    AVR32_PHYSICAL_INTERFACE_NONE   = 0x00, //! No physical
        +    AVR32_PHYSICAL_INTERFACE_JTAG   = 0x04, //! JTAG physical
        +    AVR32_PHYSICAL_INTERFACE_AWIRE  = 0x07  //! aWire physical
        +};
        +
        +enum Avr32TapCommands {
        +    AVR32_TAP_IR                    = 0x00, //! JTAG Instruction Register access
        +    AVR32_TAP_DR                    = 0x01  //! JTAG Data Register access
        +};
        +
        +enum Avr32GenericFailureCodes {
        +    AVR32_FAILURE_OK                        = 0x00, //! All OK
        +    AVR32_FAILURE_NACK                      = 0x01, //! NACK received from target
        +    AVR32_FAILURE_LENGTH                    = 0x02, //! Incorrect packet length
        +    AVR32_FAILURE_RECEIVE_TIMEOUT           = 0x03, //! Receive function timeout
        +    AVR32_FAILURE_RECEIVE_SYNC              = 0x04, //! Receive did not sync
        +    AVR32_FAILURE_RECEIVE_LENGTH            = 0x05, //! Incorrect packet length
        +    AVR32_FAILURE_TRANSMIT_OVERFLOW         = 0x06, //! Transmit buffer overflow
        +    AVR32_FAILURE_INVALID_MEMTYPE           = 0x07, //! Invalid memtype given
        +    AVR32_FAILURE_WRITE_ERROR               = 0x08, //! A write error occurred 
        +    AVR32_FAILURE_WRITE_BUSY                = 0x09, //! Busy signal received
        +    AVR32_FAILURE_READ_SHORT                = 0x0A, //! Short-packet received
        +    AVR32_FAILURE_ERASE_TIMEOUT             = 0x0B, //! Erase command timeout 
        +    AVR32_FAILURE_FLASHREADY_TIMEOUT        = 0x0C, //! Flash controller busy
        +    AVR32_FAILURE_ILLEGAL_STATE             = 0x0D, //! Illegal state specified
        +    AVR32_FAILURE_NOT_SUPPORTED             = 0x0E, //! Feature not supported
        +    AVR32_FAILURE_PROGE                     = 0x0F, //! Programming error
        +    AVR32_FAILURE_LOCKE                     = 0x10, //! Lock error
        +    AVR32_FAILURE_STEP_TIMEOUT              = 0x11, //! Single stepping timeout
        +    AVR32_FAILURE_READ_BUSY                 = 0x12, //! Busy bit was set
        +    AVR32_FAILURE_READ_ERROR                = 0x13, //! Error bit was set
        +    AVR32_FAILURE_HARDWARE_ERROR            = 0x14, //! aWire hardware init error
        +    AVR32_FAILURE_NO_CONTACT                = 0x15, //! No response from aWire 
        +    AVR32_FAILURE_NO_TARGET_POWER           = 0x16, //! No target power 
        +    AVR32_FAILURE_NOT_IMPLEMENTED           = 0x17, //! Command not implemented
        +    AVR32_FAILURE_UNSUPPORTED_HARDWARE      = 0x18, //! Hardware not supported
        +    AVR32_FAILURE_JTAGM_INIT_ERROR          = 0x19, //! JTAG master init error
        +    AVR32_FAILURE_NO_DEVICE_FOUND           = 0x1A, //! devices == 0!    
        +    AVR32_FAILURE_JTAGM_ERROR               = 0x1B, //! JTAG master error
        +    AVR32_FAILURE_INVALID_SIZE              = 0x1D, //! Too many or too few bytes
        +    AVR32_FAILURE_INVALID_ADDRESS           = 0x1E, //! Bad address requested
        +    AVR32_FAILURE_AWIRE_SET_BAUD_ERROR      = 0x1F, //! Failure setting baud   
        +    AVR32_FAILURE_INVALID_DATA              = 0x20, //! Data invalid, discard it
        +    AVR32_FAILURE_INVALID_PHYSICAL_MODE     = 0x21, //! Physical mode not valid  
        +    AVR32_FAILURE_INVALID_CLOCK_SPEED       = 0x22, //! The clock is not valid
        +    AVR32_FAILURE_AWIRE_ERROR_RESPONSE      = 0x23, //! Error response received
        +    AVR32_FAILURE_AWIRE_OVERFLOW            = 0x24, //! Overflow data RX overflow
        +    AVR32_FAILURE_AWM_ERROR                 = 0x24, //! aWire master error
        +    AVR32_FAILURE_AWIRE_CRC                 = 0x25, //! aWire CRC error
        +    AVR32_FAILURE_AWIRE_TUNE                = 0x26, //! aWire TUNE error
        +    AVR32_FAILURE_JTAGM_WAS_BUSY            = 0x29, //! JTAG master busy 
        +    AVR32_FAILURE_JTAGM_TIMEOUT             = 0x2A, //! JTAG master timeout
        +    AVR32_FAILURE_BAD_VALUE                 = 0x2B, //! Invalid parameter value
        +    AVR32_FAILURE_ERASE_ERROR               = 0x2C, //! Erase error
        +    AVR32_FAILURE_CONFIG_ERROR              = 0x2D, //! Insufficient config info
        +    AVR32_FAILURE_INVALID_EMULATOR_MODE     = 0x2E, //! Mode is not valid 
        +    AVR32_FAILURE_CPU_DIRTY_TIMEOUT         = 0x2F, //! CPU wait timeout
        +    AVR32_FAILURE_CPU_MODE                  = 0x30, //! CPU not in debug mode 
        +    AVR32_FAILURE_CPU_DEBUG_MODE_TIMEOUT    = 0x31, //! CPU debug mode timeout
        +    AVR32_FAILURE_AWIRE_RW_STATUS           = 0x32, //! Unexpected status
        +    AVR32_FAILURE_TRANSMIT_TIMEOUT          = 0x33, //! Data TX timeout
        +    AVR32_FAILURE_INTERNAL_RESPONSE_ERROR   = 0xFE, //! Near disaster
        +    AVR32_FAILURE_UNKNOWN                   = 0xFF, //! Disaster
        +};
        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01.html new file mode 100644 index 000000000..e1c6693ce --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01.html @@ -0,0 +1,211 @@ + + + + +Protocol Commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s01.html new file mode 100644 index 000000000..160dad9d2 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s01.html @@ -0,0 +1,215 @@ + + + + +QUERY - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s02.html new file mode 100644 index 000000000..566a0e63f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s02.html @@ -0,0 +1,216 @@ + + + + +SET - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s03.html new file mode 100644 index 000000000..b93f1df0d --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s03.html @@ -0,0 +1,216 @@ + + + + +GET - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s04.html new file mode 100644 index 000000000..4bb7f0dec --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s04.html @@ -0,0 +1,217 @@ + + + + +Activate Physical - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s05.html new file mode 100644 index 000000000..91c248e1a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s05.html @@ -0,0 +1,213 @@ + + + + +Deactivate Physical - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s06.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s06.html new file mode 100644 index 000000000..f6d33e77b --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s06.html @@ -0,0 +1,215 @@ + + + + +Get ID - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s07.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s07.html new file mode 100644 index 000000000..a315297c1 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s07.html @@ -0,0 +1,213 @@ + + + + +Attach - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s08.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s08.html new file mode 100644 index 000000000..e72779d9b --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s08.html @@ -0,0 +1,213 @@ + + + + +Detach - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s09.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s09.html new file mode 100644 index 000000000..d2fc1967d --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s09.html @@ -0,0 +1,215 @@ + + + + +Reset - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s10.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s10.html new file mode 100644 index 000000000..d3f4e9525 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s10.html @@ -0,0 +1,214 @@ + + + + +Stop - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s11.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s11.html new file mode 100644 index 000000000..9838850fb --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s11.html @@ -0,0 +1,213 @@ + + + + +Run - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s12.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s12.html new file mode 100644 index 000000000..3c82c435c --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s12.html @@ -0,0 +1,215 @@ + + + + +Run To - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s13.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s13.html new file mode 100644 index 000000000..361df065f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s13.html @@ -0,0 +1,216 @@ + + + + +Step - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s14.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s14.html new file mode 100644 index 000000000..ea3525247 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s14.html @@ -0,0 +1,213 @@ + + + + +PC read - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s15.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s15.html new file mode 100644 index 000000000..c9c76a1f0 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s15.html @@ -0,0 +1,213 @@ + + + + +PC write - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s16.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s16.html new file mode 100644 index 000000000..fe394e6ba --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s16.html @@ -0,0 +1,213 @@ + + + + +Prog Mode Enter - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s17.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s17.html new file mode 100644 index 000000000..939388d18 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s17.html @@ -0,0 +1,217 @@ + + + + +Prog Mode Leave - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s18.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s18.html new file mode 100644 index 000000000..64ff30f74 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s18.html @@ -0,0 +1,215 @@ + + + + +Disable debugWIRE - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s19.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s19.html new file mode 100644 index 000000000..48853cb9b --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s19.html @@ -0,0 +1,220 @@ + + + + +Erase - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s20.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s20.html new file mode 100644 index 000000000..0be622a45 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s20.html @@ -0,0 +1,216 @@ + + + + +CRC - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s21.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s21.html new file mode 100644 index 000000000..a7d6b7d95 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s21.html @@ -0,0 +1,214 @@ + + + + +Memory Read - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s22.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s22.html new file mode 100644 index 000000000..857cfaeb8 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s22.html @@ -0,0 +1,215 @@ + + + + +Memory Read masked - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s23.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s23.html new file mode 100644 index 000000000..66ef8e9e8 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s23.html @@ -0,0 +1,215 @@ + + + + +Memory Write - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s24.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s24.html new file mode 100644 index 000000000..08ac0851d --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s24.html @@ -0,0 +1,214 @@ + + + + +Page Erase - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s25.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s25.html new file mode 100644 index 000000000..ffcd1f490 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s25.html @@ -0,0 +1,213 @@ + + + + +Hardware Breakpoint Set - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s26.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s26.html new file mode 100644 index 000000000..568f099f5 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s26.html @@ -0,0 +1,213 @@ + + + + +Hardware Breakpoint Clear - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s27.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s27.html new file mode 100644 index 000000000..3567113c7 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s27.html @@ -0,0 +1,216 @@ + + + + +Software Breakpoint Set - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s28.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s28.html new file mode 100644 index 000000000..90793d9e6 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s28.html @@ -0,0 +1,216 @@ + + + + +Software Breakpoint Clear - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s29.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s29.html new file mode 100644 index 000000000..05c04de12 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s01s29.html @@ -0,0 +1,214 @@ + + + + +Software Breakpoint Clear All - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02.html new file mode 100644 index 000000000..762bf9846 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02.html @@ -0,0 +1,211 @@ + + + + +Responses - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s01.html new file mode 100644 index 000000000..25b97f941 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s01.html @@ -0,0 +1,211 @@ + + + + +OK - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s02.html new file mode 100644 index 000000000..0004271e5 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s02.html @@ -0,0 +1,211 @@ + + + + +LIST - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s03.html new file mode 100644 index 000000000..bac30cb2f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s03.html @@ -0,0 +1,211 @@ + + + + +PC - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s04.html new file mode 100644 index 000000000..8ac473d49 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s04.html @@ -0,0 +1,211 @@ + + + + +DATA - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s05.html new file mode 100644 index 000000000..0d39d303b --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s02s05.html @@ -0,0 +1,211 @@ + + + + +FAILED - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s03.html new file mode 100644 index 000000000..1dd6d123a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s03.html @@ -0,0 +1,211 @@ + + + + +Events - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s03s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s03s01.html new file mode 100644 index 000000000..0381d127f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s03s01.html @@ -0,0 +1,213 @@ + + + + +Event: Break - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s03s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s03s02.html new file mode 100644 index 000000000..fbd7f8852 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s03s02.html @@ -0,0 +1,211 @@ + + + + +Event: IDR message - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s04s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s04s01.html new file mode 100644 index 000000000..6be4d4417 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s04s01.html @@ -0,0 +1,213 @@ + + + + +debugWIRE memtypes - - Atmel EDBG-based Tools Protocols

        Table 135. debugWIRE memtypes

        IDProg AccessDebug AccessUsage / Rules
        MEMTYPE_FLASH_PAGE-RW
        • Used for writing FLASH before a debug session, and reading FLASH during a debug session.

        • Only FULL PAGE access is allowed.

        • If the number of bytes requested does not match the flash page size, an error is returned (AVR8_FAILURE_INVALID_SIZE).

        • Software breakpoints are NOT filtered out.

        +
        MEMTYPE_SIGNATURE-R
        • Used to read the device signature stored in the debugWIRE module itself.

        • This signature may differ from the signature stored in FLASH and accessed through SPI programming interface.

        • A read MUST be for exactly 3 bytes from address 0x00.

        • Violating this will results in an error (AVR8_FAILURE_INVALID_SIZE / AVR8_FAILURE_INVALID_ADDRESS).

        • Byte 2 will always read 0x1E.

        MEMTYPE_SRAM-RW
        • Accesses SRAM and IO space during debugging.

        • If used in programming mode, an error is returned (AVR8_FAILURE_ILLEGAL_STATE)

        • If a read attempts to read an area containing the OCDR register, an error is returned (AVR8_FAILURE_INVALID_ADDRESS).

        • A masked read must be used in this case.

        • Any number of bytes (within payload restrictions) can be written or read in one operation.

        MEMTYPE_EEPROM-RW
        • Used to read and write EEPROM during a debug session.

        • Any number of bytes can be written or read in one operation.

        • Uses monitor code heavily - may take some time to complete, depending proportionally upon the number of bytes being accessed.

        MEMTYPE_SPM-R
        • Used to access small amounts of FLASH during a debug session.

        • If an odd number of bytes is requested, an error is returned + [a].

        • This memtype is efficient for reading full pages, or single words from FLASH.

        • Multiple word requests are inefficient and may take time to complete.

        • Software breakpoints are filtered out.

        [a] AVR8_FAILURE_ILLEGAL_MEMORY_RANGE


        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s04s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s04s02.html new file mode 100644 index 000000000..9437fc24a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s04s02.html @@ -0,0 +1,219 @@ + + + + +megaAVR (JTAG) OCD memtypes - - Atmel EDBG-based Tools Protocols

        Table 136. megaAVR (JTAG) OCD memtypes

        IDProg AccessDebug AccessUsage / Rules
        MEMTYPE_FLASH_PAGERW- +
        • Used for reading and writing FLASH pages in programming mode.

        • Writing it restricted to single full FLASH pages.

        • Reading is restricted to multiple full FLASH pages.

        • If access is attempted outside of programming mode, an error is returned. + [a]

        +
        MEMTYPE_EEPROM_PAGERW-
        • Used to read and write EEPROM in programming mode.

        • Writing is restricted to single full pages.

        • Reading is restricted to multiple full pages.

        • If access is attempted outside of programming mode, an error is returned[a]

        MEMTYPE_FUSESRW-
        • Used to read and write FUSES in programming mode.

        • Up to 3 fuses can be written/read in one operation. More than 3 results in an error + [b]

        • Up to address 0x02 can be accessed. Outside of this range results in an error + [c]

        • If access is attempted outside of programming mode, an error is returned[a]

        MEMTYPE_LOCKBITSRW-
        • Used to read and write LOCKBITS in programming mode.

        • Only a single lockbit is available to read, at address 0.

        • Violating this results in an error + [b][c]

        • If access is attempted outside of programming mode, an error is returned[a]

        MEMTYPE_SIGNATURER-
        • Used to read the device SIGNATURE in programming mode.

        • Up to 3 signature bytes can be read in one operation. More than 3 results in an error[b]

        • Up to address 0x02 can be accessed. Outside of this range results in an error[c]

        • If access is attempted outside of programming mode, an error is returned[a]

        MEMTYPE_OSCCALR-
        • Used to read the device OSCCAL VALUES in programming mode.

        • Up to 4 bytes can be read in one operation. More than 4 results in an error[b]

        • Up to address 0x03 can be accessed. Outside of this range results in an error[c]

        • If access is attempted outside of programming mode, an error is returned[a]

        MEMTYPE_SRAM-RW
        • Accesses SRAM and IO space during debugging.

        • If used in programming mode, an error is returned[a]

        • If a read attempts to read an area containing the OCDR register, an error is returned[c].

        • A masked read must be used in this case.

        • Any number of bytes (within payload restrictions) can be written or read in one operation.

        MEMTYPE_EEPROM-RW
        • Used to read and write EEPROM during a debug session.

        • Any number of bytes can be written or read in one operation.

        • Uses monitor code heavily - may take some time to complete, depending proportionally upon the number of bytes being accessed

        MEMTYPE_SPM-R
        • Used to read FLASH during a debug session.

        • If an odd number of bytes is requested, an error is returned + [d].

        • If a mal-aligned address is requested, an error is returned + [e].

        • Software breakpoints are filtered out.

        MEMTYPE_USER_SIGNATURERWRW
        • Used to read/write the USER SIGNATURE in programming mode. NB: applies to ATmegaxxxRFR2 devices only!

        • Writing it restricted to single full FLASH pages.

        • Reading is restricted to multiple full FLASH pages.

        [a] AVR8_FAILURE_ILLEGAL_STATE

        [b] AVR8_FAILURE_INVALID_SIZE

        [c] AVR8_FAILURE_INVALID_ADDRESS

        [d] AVR8_FAILURE_ILLEGAL_MEMORY_RANGE

        [e] AVR8_FAILURE_INVALID_ALIGNMENT


        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s04s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s04s03.html new file mode 100644 index 000000000..908842f76 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s04s03.html @@ -0,0 +1,211 @@ + + + + +AVR XMEGA memtypes - - Atmel EDBG-based Tools Protocols

        Table 137. AVR XMEGA memtypes

        IDProg AccessDebug AccessUsage / Rules
        MEMTYPE_APPL_FLASHRWR
        MEMTYPE_BOOT_FLASHRWR
        MEMTYPE_APPL_FLASH_ATOMICW-
        • Used to write a full FLASH page in the application section in programming mode

        • The page is automatically erased before writing

        • Address is from base 0x000000, provided that APPL_BASE_ADDR is configured correctly (the section called “Device context: AVR XMEGA targets”).

        • Writes are restricted to full pages only.

        MEMTYPE_BOOT_FLASH_ATOMICW-
        • Used to write a full FLASH page in the boot section in programming mode

        • The page is automatically erased before writing

        • Address is from base 0x000000, provided that BOOT_BASE_ADDR is configured correctly (the section called “Device context: AVR XMEGA targets”).

        • Writes are restricted to full pages only.

        MEMTYPE_EEPROM_ATOMICWW
        • Used to write a full EEPROM page in programming or debugging mode

        • The page is automatically erased before writing

        • Address is from base 0x000000, provided that EEPROM_BASE_ADDR is configured correctly (the section called “Device context: AVR XMEGA targets”).

        • Writes are restricted to full pages only.

        MEMTYPE_EEPROMRWRW
        MEMTYPE_FUSESRW-
        MEMTYPE_LOCK_BITSRWR
        MEMTYPE_SIGNATURERR
        MEMTYPE_USER_SIGNATURERWRW
        MEMTYPE_CALIBRATION_SIGNATURERR
        MEMTYPE_REGFILE-RW
        • Used to read/write the general purpose registers in debugging mode

        • Address is from base 0x00

        • Any number of bytes can be accessed

        MEMTYPE_SRAM-RW

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05.html new file mode 100644 index 000000000..698298a23 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05.html @@ -0,0 +1,211 @@ + + + + +Hints and tips: - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s01.html new file mode 100644 index 000000000..a44f60f4b --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s01.html @@ -0,0 +1,227 @@ + + + + +Configuration - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s02.html new file mode 100644 index 000000000..f6077325d --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s02.html @@ -0,0 +1,231 @@ + + + + +Activate and deactivate physical - - Atmel EDBG-based Tools Protocols

        Once configuration is complete, the host requests that the tool makes + a connection to the target by calling the “activate physical” command. In many + interfaces, the physical can be disabled by default or overridden by user code, + which implies that the external reset must be applied in order to gain access. In + other cases, the external reset may not be used, for example when attaching to a + running process. The use of external reset must be specified in the command + parameter.

        Activating the physical must be followed by device ID validation, to + ensure that the session is capable of starting with the device that is + expected. For this reason, the activation command returns a DATA packet + containing the device ID of the target, as read directly from the target. If + no valid device is detected, the command will return FAILED. Device ID + return format is given here:

        +


        +

        The Get ID command can also be used to retrieve this value at any stage + during the session. It is read out on demand and not cached, so be aware + that the IR value will be altered during this process when using JTAG.

        On completion of a session, the physical must be deactivated. The tool + disconnects from the target at this point. In order to re-connect, the + physical must be activated again.

        Commands for leaving programming mode or detaching from a debug session + may implicitly require that the physical is deactivated. If this is the + case, the deactivation should be performed as usual. To start a new session, + the physical should be activated again.

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s03.html new file mode 100644 index 000000000..3ac632e84 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s03.html @@ -0,0 +1,219 @@ + + + + +Programming session control - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s04.html new file mode 100644 index 000000000..a68ec01e3 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s04.html @@ -0,0 +1,220 @@ + + + + +Debug session control - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s05.html new file mode 100644 index 000000000..cbbca98bd --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s05s05.html @@ -0,0 +1,231 @@ + + + + +Flow control - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s06.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s06.html new file mode 100644 index 000000000..237404283 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch06s06.html @@ -0,0 +1,423 @@ + + + + +AVR8GENERIC ID definitions - - Atmel EDBG-based Tools Protocols

        + This section includes the header file defining the different command, + response and event IDs for the AVR8 protocol. It also defines the different possible failure codes. +

        enum Avr8GenericCommands {
        +    CMD_AVR8_QUERY                      = 0x00, //! Capability discovery 
        +    CMD_AVR8_SET                        = 0x01, //! Set parameters
        +    CMD_AVR8_GET                        = 0x02, //! Get parameters
        +    CMD_AVR8_ACTIVATE_PHYSICAL          = 0x10, //! Connect physically
        +    CMD_AVR8_DEACTIVATE_PHYSICAL        = 0x11, //! Disconnect physically
        +    CMD_AVR8_GET_ID                     = 0x12, //! Read the ID
        +    CMD_AVR8_ATTACH                     = 0x13, //! Attach to OCD module
        +    CMD_AVR8_DETACH                     = 0x14, //! Detach from OCD module
        +    CMD_AVR8_PROG_MODE_ENTER            = 0x15, //! Enter programming mode
        +    CMD_AVR8_PROG_MODE_LEAVE            = 0x16, //! Leave programming mode
        +    CMD_AVR8_DISABLE_DEBUGWIRE          = 0x17, //! Disable debugWIRE interface
        +    CMD_AVR8_ERASE                      = 0x20, //! Erase the chip
        +    CMD_AVR8_MEMORY_READ                = 0x21, //! Read memory
        +    CMD_AVR8_MEMORY_READ_MASKED         = 0x22, //! Read memory while via a mask
        +    CMD_AVR8_MEMORY_WRITE               = 0x23, //! Write memory
        +    CMD_AVR8_CRC                        = 0x24, //! Calculate CRC
        +    CMD_AVR8_RESET                      = 0x30, //! Reset the MCU
        +    CMD_AVR8_STOP                       = 0x31, //! Stop the MCU
        +    CMD_AVR8_RUN                        = 0x32, //! Resume execution
        +    CMD_AVR8_RUN_TO_ADDRESS             = 0x33, //! Resume with breakpoint 
        +    CMD_AVR8_STEP                       = 0x34, //! Single step
        +    CMD_AVR8_PC_READ                    = 0x35, //! Read PC
        +    CMD_AVR8_PC_WRITE                   = 0x36, //! Write PC
        +    CMD_AVR8_HW_BREAK_SET               = 0x40, //! Set breakpoints
        +    CMD_AVR8_HW_BREAK_CLEAR             = 0x41, //! Clear breakpoints
        +    CMD_AVR8_SW_BREAK_SET               = 0x43, //! Set software breakpoints
        +    CMD_AVR8_SW_BREAK_CLEAR             = 0x44, //! Clear software breakpoints
        +    CMD_AVR8_SW_BREAK_CLEAR_ALL         = 0x45, //! Clear all software breakpoints
        +    CMD_AVR8_PAGE_ERASE                 = 0x50  //! Erase page
        +};
        +
        +// Protocol responses
        +enum Avr8GenericResponses {
        +    RSP_AVR8_OK                         = 0x80, //! All OK
        +    RSP_AVR8_LIST                       = 0x81, //! List of items returned
        +    RSP_AVR8_DATA                       = 0x84, //! Data returned
        +    RSP_AVR8_PC                         = 0x83, //! PC value returned
        +    RSP_AVR8_FAILED                     = 0xA0  //! Command failed to execute
        +};
        +
        +// Protocol events
        +enum Avr8GenericEvents {
        +    EVT_AVR8_BREAK                      = 0x40, //! Break message
        +    EVT_AVR8_IDR                        = 0x41  //! IO Data Register message
        +};
        +
        +// Failure response codes (RSP_FAILED)
        +enum Avr8GenericFailureCodes {
        +    AVR8_FAILURE_OK                      = 0x00, //! All OK
        +    AVR8_FAILURE_DW_PHY_ERROR            = 0x10, //! debugWIRE physical error
        +    AVR8_FAILURE_JTAGM_INIT_ERROR        = 0x11, //! JTAGM failed to initialise
        +    AVR8_FAILURE_JTAGM_ERROR             = 0x12, //! JTAGM did something strange
        +    AVR8_FAILURE_JTAG_ERROR              = 0x13, //! JTAG low level error
        +    AVR8_FAILURE_JTAGM_VERSION           = 0x14, //! Unsupported version of JTAGM
        +    AVR8_FAILURE_JTAGM_TIMEOUT           = 0x15, //! JTAG master timed out
        +    AVR8_FAILURE_JTAG_BIT_BANGER_TIMEOUT = 0x16, //! JTAG bit banger timed out
        +    AVR8_FAILURE_PARITY_ERROR            = 0x17, //! Parity error in received data
        +    AVR8_FAILURE_EB_ERROR                = 0x18, //! Did not receive EMPTY byte
        +    AVR8_FAILURE_PDI_TIMEOUT             = 0x19, //! PDI physical timed out
        +    AVR8_FAILURE_COLLISION               = 0x1A, //! Collision on physical level
        +    AVR8_FAILURE_PDI_ENABLE              = 0x1B, //! PDI enable failed
        +    AVR8_FAILURE_NO_DEVICE_FOUND         = 0x20, //! devices == 0!
        +    AVR8_FAILURE_CLOCK_ERROR             = 0x21, //! Failure when increasing baud
        +    AVR8_FAILURE_NO_TARGET_POWER         = 0x22, //! Target power not detected
        +    AVR8_FAILURE_NOT_ATTACHED            = 0x23, //! Must run attach command first
        +    AVR8_FAILURE_INVALID_PHYSICAL_STATE  = 0x31, //! Physical not activated
        +    AVR8_FAILURE_ILLEGAL_STATE           = 0x32, //! Illegal run / stopped state
        +    AVR8_FAILURE_INVALID_CONFIG          = 0x33, //! Invalid config for activate phy
        +    AVR8_FAILURE_INVALID_MEMTYPE         = 0x34, //! Not a valid memtype
        +    AVR8_FAILURE_INVALID_SIZE            = 0x35, //! Too many or too few bytes
        +    AVR8_FAILURE_INVALID_ADDRESS         = 0x36, //! Asked for a bad address
        +    AVR8_FAILURE_INVALID_ALIGNMENT       = 0x37, //! Asked for badly aligned data
        +    AVR8_FAILURE_ILLEGAL_MEMORY_RANGE    = 0x38, //! Address not within legal range
        +    AVR8_FAILURE_ILLEGAL_VALUE           = 0x39, //! Illegal value given
        +    AVR8_FAILURE_ILLEGAL_ID              = 0x3A, //! Illegal target ID
        +    AVR8_FAILURE_INVALID_CLOCK_SPEED     = 0x3B, //! Clock value out of range
        +    AVR8_FAILURE_TIMEOUT                 = 0x3C, //! A timeout occurred
        +    AVR8_FAILURE_ILLEGAL_OCD_STATUS      = 0x3D, //! Read an illegal OCD status 
        +    AVR8_FAILURE_NVM_ENABLE              = 0x40, //! NVM failed to be enabled
        +    AVR8_FAILURE_NVM_DISABLE             = 0x41, //! NVM failed to be disabled
        +    AVR8_FAILURE_CS_ERROR                = 0x42, //! Illegal control/status bits 
        +    AVR8_FAILURE_CRC_FAILURE             = 0x43, //! CRC mismatch
        +    AVR8_FAILURE_OCD_LOCKED              = 0x44, //! Failed to enable OCD
        +    AVR8_FAILURE_NO_OCD_CONTROL          = 0x50, //! Device is not under control
        +    AVR8_FAILURE_PC_READ_FAILED          = 0x60, //! Error when reading PC
        +    AVR8_FAILURE_REGISTER_READ_FAILED    = 0x61, //! Error when reading register
        +    AVR8_FAILURE_READ_ERROR              = 0x70, //! Error while reading
        +    AVR8_FAILURE_WRITE_ERROR             = 0x71, //! Error while writing
        +    AVR8_FAILURE_WRITE_TIMEOUT           = 0x72, //! Timeout while reading
        +    AVR8_FAILURE_ILLEGAL_BREAKPOINT      = 0x80, //! Invalid breakpoint configuration
        +    AVR8_FAILURE_TOO_MANY_BREAKPOINTS    = 0x81, //! Not enough available resources
        +    AVR8_FAILURE_NOT_SUPPORTED           = 0x90, //! This feature is not available
        +    AVR8_FAILURE_NOT_IMPLEMENTED         = 0x91, //! Command has not been implemented
        +    AVR8_FAILURE_UNKNOWN                 = 0xFF  //! Disaster.
        +};
        +
        +// QUERY types on this protocol
        +enum Avr8GenericQueryContexts {
        +    AVR8_QUERY_COMMANDS                 = 0x00, //! Supported command list
        +    AVR8_QUERY_CONFIGURATION            = 0x05, //! Supported configuration list
        +    AVR8_QUERY_READ_MEMTYPES            = 0x07, //! Supported read memtypes list
        +    AVR8_QUERY_WRITE_MEMTYPES           = 0x08  //! Supported write memtypes list
        +};
        +
        +// Context definitions 
        +enum Avr8GenericSetGetContexts {
        +    AVR8_CTXT_CONFIG                    = 0x00, //! Configuration
        +    AVR8_CTXT_PHYSICAL                  = 0x01, //! Physical interface related
        +    AVR8_CTXT_DEVICE                    = 0x02, //! Device specific settings
        +    AVR8_CTXT_OPTIONS                   = 0x03, //! Option-related settings
        +    AVR8_CTXT_SESSION                   = 0x04, //! Session-related settings
        +};
        +
        +enum Avr8GenericConfigContextParameters {
        +    AVR8_CONFIG_VARIANT                 = 0x00, //! Device family/variant
        +    AVR8_CONFIG_FUNCTION                = 0x01  //! Functional intent
        +};
        +
        +enum Avr8GenericPhysicalContextParameters {
        +    AVR8_PHY_INTERFACE                  = 0x00, //! Physical interface selector
        +    AVR8_PHY_JTAG_DAISY                 = 0x01, //! JTAG daisy chain settings
        +    AVR8_PHY_DW_CLK_DIV                 = 0x10, //! debugWIRE clock divide ratio
        +    AVR8_PHY_MEGA_PRG_CLK               = 0x20, //! Clock for programming megaAVR
        +    AVR8_PHY_MEGA_DBG_CLK               = 0x21, //! Clock for debugging megaAVR
        +    AVR8_PHY_XM_JTAG_CLK                = 0x30, //! JTAG clock for AVR XMEGA
        +    AVR8_PHY_XM_PDI_CLK                 = 0x31  //! PDI clock for AVR XMEGA
        +};
        +
        +enum Avr8GenericOptionsContextParameters {
        +    AVR8_OPT_RUN_TIMERS                 = 0x00, //! Keep timers running when stopped
        +    AVR8_OPT_DISABLE_DBP                = 0x01, //! No data breaks during reset
        +    AVR8_OPT_ENABLE_IDR                 = 0x03, //! Relay IDR messages
        +    AVR8_OPT_POLL_INT                   = 0x04  //! Configure polling speed
        +};
        +
        +enum Avr8GenericSessionContextParameters {
        +    AVR8_SESS_MAIN_PC                   = 0x00  //! Address of main() function
        +};
        +
        +enum Avr8GenericConfigTestParameters {
        +    AVR8_TEST_TGT_RUNNING               = 0x00  //! Is target running?
        +};
        +
        +enum Avr8GenericVariantValues {
        +    AVR8_VARIANT_LOOPBACK               = 0x00, //! Dummy device
        +    AVR8_VARIANT_TINYOCD                = 0x01, //! tinyAVR or megaAVR with debugWIRE
        +    AVR8_VARIANT_MEGAOCD                = 0x02, //! megaAVR with JTAG
        +    AVR8_VARIANT_XMEGA                  = 0x03, //! AVR XMEGA
        +    AVR8_VARIANT_NONE                   = 0xFF  //! No device
        +};
        +
        +enum Avr8GenericFunctionValues {
        +    AVR8_FUNC_NONE                      = 0x00, //! Not configured
        +    AVR8_FUNC_PROGRAMMING               = 0x01, //! I want to program only
        +    AVR8_FUNC_DEBUGGING                 = 0x02  //! I want a debug session
        +};
        +
        +// Physical modes
        +enum Avr8GenericPhysicalInterfaces {
        +    AVR8_PHY_INTF_NONE                  = 0x00, //! Not configured
        +    AVR8_PHY_INTF_JTAG                  = 0x04, //! JTAG
        +    AVR8_PHY_INTF_DW                    = 0x05, //! debugWIRE
        +    AVR8_PHY_INTF_PDI                   = 0x06  //! PDI
        +};
        +
        +
        +enum Avr8GenericMegaBreakpointTypes {        
        +    AVR8_HWBP_PROG_BP               = 0x01  //! Program breaks
        +
        +};
        +
        +enum Avr8GenericMegaBreakCauses {
        +    AVR8_BREAK_CAUSE_UNKNOWN        = 0x00, //! Unspecified
        +    AVR8_BREAK_CAUSE_PROGRAM        = 0x01  //! Program break
        +
        +};
        +
        +    
        +enum Avr8GenericXmegaEraseModes {
        +    XMEGA_ERASE_CHIP                = 0x00, //! Erase entire chip 
        +    XMEGA_ERASE_APP                 = 0x01, //! Erase application section only
        +    XMEGA_ERASE_BOOT                = 0x02, //! Erase boot section only
        +    XMEGA_ERASE_EEPROM              = 0x03, //! Erase EEPROM section only
        +    XMEGA_ERASE_APP_PAGE            = 0x04, //! Erase a single app section page
        +    XMEGA_ERASE_BOOT_PAGE           = 0x05, //! Erase a single boot section page
        +    XMEGA_ERASE_EEPROM_PAGE         = 0x06, //! Erase a single EEPROM page
        +    XMEGA_ERASE_USERSIG             = 0x07  //! Erase the user signature section
        +};
        +
        +// Memory types
        +enum Avr8GenericMemtypes {
        +    MEMTYPE_SRAM                    = 0x20, //! SRAM
        +    MEMTYPE_EEPROM                  = 0x22, //! EEPROM memory
        +    MEMTYPE_SPM                     = 0xA0, //! Flash memory in a debug session
        +    MEMTYPE_FLASH_PAGE              = 0xB0, //! Flash memory programming
        +    MEMTYPE_EEPROM_PAGE             = 0xB1, //! EEPROM memory pages
        +    MEMTYPE_FUSES                   = 0xB2, //! Fuse memory
        +    MEMTYPE_LOCKBITS                = 0xB3, //! Lock bits
        +    MEMTYPE_SIGNATURE               = 0xB4, //! Device signature
        +    MEMTYPE_OSCCAL                  = 0xB5, //! Oscillator calibration values
        +    MEMTYPE_REGFILE                 = 0xB8, //! Register file
        +    MEMTYPE_APPL_FLASH              = 0xC0, //! Application section flash
        +    MEMTYPE_BOOT_FLASH              = 0xC1, //! Boot section flash
        +    MEMTYPE_APPL_FLASH_ATOMIC       = 0xC2, //! Application page with auto-erase
        +    MEMTYPE_BOOT_FLASH_ATOMIC       = 0xC3, //! Boot page with auto-erase
        +    MEMTYPE_EEPROM_ATOMIC           = 0xC4, //! EEPROM page with auto-erase
        +    MEMTYPE_USER_SIGNATURE          = 0xC5, //! User signature secion
        +    MEMTYPE_CALIBRATION_SIGNATURE   = 0xC6  //! Calibration section
        +    };
        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01.html new file mode 100644 index 000000000..979b8fb37 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01.html @@ -0,0 +1,211 @@ + + + + +SPI programming protocol commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s01.html new file mode 100644 index 000000000..70756cf66 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s01.html @@ -0,0 +1,211 @@ + + + + +SPI Load Address - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s02.html new file mode 100644 index 000000000..3f9e3a398 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s02.html @@ -0,0 +1,211 @@ + + + + +SPI Set Baud - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s03.html new file mode 100644 index 000000000..64b8e2452 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s03.html @@ -0,0 +1,211 @@ + + + + +SPI Get Baud - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s04.html new file mode 100644 index 000000000..be105b8c2 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s04.html @@ -0,0 +1,211 @@ + + + + +SPI Enter Programming Mode - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s05.html new file mode 100644 index 000000000..5355bee9f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s05.html @@ -0,0 +1,211 @@ + + + + +SPI Leave Programming Mode - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s06.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s06.html new file mode 100644 index 000000000..9fef3f72b --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s06.html @@ -0,0 +1,212 @@ + + + + +SPI Chip Erase - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s07.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s07.html new file mode 100644 index 000000000..ad752fcee --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s07.html @@ -0,0 +1,231 @@ + + + + +SPI Program Flash - - Atmel EDBG-based Tools Protocols

        Programs data into flash memory using SPI programming


        *Mode byte: The mode parameter is essential for how this command works. The bits + in the mode byte have the following meanings:


        The Word/Page Modebit selects if the device supports page programming or not. The + command bytes are different for word and page mode. In word mode, the SPI commands + Write Program Memory and Read Program Memory are used. In page mode, Load Page, Write + Program Memory Page and Read Program Memory are used. The read instruction is used if + Value Polling is specified in the mode bit. The Low/High byte selection bit (3rd bit + in the Load Page, Write Program Memory commands) is handled by EDBG automatically, so leave + this bit cleared.

        + According to the mode, different termination methods are selected – Timed delay, + Value polling or RDY/BSY polling.

        + For paged operation, the Write pagebit decides if a Write Program Memory Page + command should be issued after the data has been loaded into the page buffer. For + devices with page size bigger than what can be transferred to EDBG in one + command, several SPI_CMD_PROGRAM_FLASH commands must be issued. In + such a case, only the last command should have the Write Page mode bit set.

        + NOTE: Only bit 0-6 are set in the XML file, because bit 7 is not constant and must be controlled + by the PC software.

        + When value polling is used to determine when a programming operation is complete, + poll1 must be supplied. This value indicates which value will be read from the device + until the programmed value is read. This indicates end of programming. poll2 is used + only for EEPROM programming.

        Response:


        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s08.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s08.html new file mode 100644 index 000000000..4f76886e8 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s08.html @@ -0,0 +1,211 @@ + + + + +SPI Read Flash - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s09.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s09.html new file mode 100644 index 000000000..8baeae716 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s09.html @@ -0,0 +1,211 @@ + + + + +SPI Program EEPROM - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s10.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s10.html new file mode 100644 index 000000000..38bf91143 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s10.html @@ -0,0 +1,211 @@ + + + + +SPI Read EEPROM - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s11.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s11.html new file mode 100644 index 000000000..5044b87fc --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s11.html @@ -0,0 +1,211 @@ + + + + +SPI Program Fuse - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s12.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s12.html new file mode 100644 index 000000000..d36aeaf66 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s12.html @@ -0,0 +1,212 @@ + + + + +SPI Read Fuse - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s13.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s13.html new file mode 100644 index 000000000..5d314e462 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s13.html @@ -0,0 +1,211 @@ + + + + +SPI Program Lock - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s14.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s14.html new file mode 100644 index 000000000..98dc07000 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s14.html @@ -0,0 +1,211 @@ + + + + +SPI Read Lock - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s15.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s15.html new file mode 100644 index 000000000..b116fcda6 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s15.html @@ -0,0 +1,211 @@ + + + + +SPI Read Signature - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s16.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s16.html new file mode 100644 index 000000000..fdc2d8ece --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s16.html @@ -0,0 +1,211 @@ + + + + +SPI Read OSCCAL - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s17.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s17.html new file mode 100644 index 000000000..e0a212842 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s01s17.html @@ -0,0 +1,211 @@ + + + + +SPI Multi - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s02.html new file mode 100644 index 000000000..6dc0922fd --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s02.html @@ -0,0 +1,211 @@ + + + + +SPI programming protocol responses - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s03.html new file mode 100644 index 000000000..080363476 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch07s03.html @@ -0,0 +1,253 @@ + + + + +ID definitions - - Atmel EDBG-based Tools Protocols

        + This sections includes the header file defining the different command, + response and event IDs for the AVRISP protocol. It also defines the different possible failure codes. +

        enum SpiProgrammingProtocolCommands {
        +    //**********************************************************
        +    // Protocol commands
        +    //**********************************************************
        +    SPI_CMD_LOAD_ADDRESS                    = 0x06, //! Load address
        +    SPI_CMD_ENTER_PROGMODE                  = 0x10, //! Enter programming mode
        +    SPI_CMD_LEAVE_PROGMODE                  = 0x11, //! Leave programming mode
        +    SPI_CMD_CHIP_ERASE                      = 0x12, //! Erase device
        +    SPI_CMD_PROGRAM_FLASH                   = 0x13, //! Program flash data
        +    SPI_CMD_READ_FLASH                      = 0x14, //! Read flash data
        +    SPI_CMD_PROGRAM_EEPROM                  = 0x15, //! Program EEPROM data
        +    SPI_CMD_READ_EEPROM                     = 0x16, //! Read EEPROM data
        +    SPI_CMD_PROGRAM_FUSE                    = 0x17, //! Program a fuse byte
        +    SPI_CMD_READ_FUSE                       = 0x18, //! Read a fuse byte
        +    SPI_CMD_PROGRAM_LOCK                    = 0x19, //! Program lock bits
        +    SPI_CMD_READ_LOCK                       = 0x1A, //! Read lock bits
        +    SPI_CMD_READ_SIGNATURE                  = 0x1B, //! Read a signature byte
        +    SPI_CMD_READ_OSCCAL                     = 0x1C, //! Read an OSCCAL byte
        +    SPI_CMD_SET_BAUD                        = 0x1D, //! Set baud rate
        +    SPI_CMD_GET_BAUD                        = 0x1E  //! Read baud rate
        +};
        +
        +enum SpiProgrammingProtocolResponses {
        +    //**********************************************************
        +    // Protocol responses
        +    //**********************************************************
        +    // Success
        +    SPI_STATUS_CMD_OK                       = 0x00, //! All OK
        +
        +    // Warnings
        +    SPI_STATUS_CMD_TOUT                     = 0x80, //! Command timeout
        +    SPI_STATUS_RDY_BSY_TOUT                 = 0x81, //! Device busy
        +
        +    // Errors
        +    SPI_STATUS_CMD_FAILED                   = 0xC0, //! Command failed
        +    SPI_STATUS_CMD_UNKNOWN                  = 0xC9, //! Unknown error
        +    SPI_STATUS_PHY_ERROR                    = 0xCB, //! Physical error
        +    SPI_STATUS_CLOCK_ERROR                  = 0xCC, //! Speed error
        +    SPI_STATUS_BAUD_INVALID                 = 0xCD  //! Baud value error
        +};
        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01.html new file mode 100644 index 000000000..cffed6d67 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01.html @@ -0,0 +1,211 @@ + + + + +TPI protocol commands - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s01.html new file mode 100644 index 000000000..896cd5abd --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s01.html @@ -0,0 +1,211 @@ + + + + +TPI Enter Programming Mode - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s02.html new file mode 100644 index 000000000..b3aaba663 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s02.html @@ -0,0 +1,211 @@ + + + + +TPI Leave Programming Mode - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s03.html new file mode 100644 index 000000000..48757b5d2 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s03.html @@ -0,0 +1,211 @@ + + + + +TPI Set Parameter - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s04.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s04.html new file mode 100644 index 000000000..fc6f8a8ae --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s04.html @@ -0,0 +1,211 @@ + + + + +TPI Erase - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s05.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s05.html new file mode 100644 index 000000000..fe082b12c --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s05.html @@ -0,0 +1,211 @@ + + + + +TPI Write Memory - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s06.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s06.html new file mode 100644 index 000000000..dbcda2ca7 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s01s06.html @@ -0,0 +1,211 @@ + + + + +TPI Read Memory - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s02.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s02.html new file mode 100644 index 000000000..0b1a19b5f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s02.html @@ -0,0 +1,211 @@ + + + + +TPI programming protocol responses - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s03.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s03.html new file mode 100644 index 000000000..fb6afa569 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/ch08s03.html @@ -0,0 +1,240 @@ + + + + +ID definitions - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/document.revisions.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/document.revisions.html new file mode 100644 index 000000000..5e2418811 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/document.revisions.html @@ -0,0 +1,209 @@ + + + + +Document Revisions - - Atmel EDBG-based Tools Protocols

        +

        Document revisionDateComment
        42197A09.10.2013Preliminary (internal) release.
        42197B28.01.2014Preliminary (beta) release.

        +

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/index.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/index.html new file mode 100644 index 000000000..7d4c0901c --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/index.html @@ -0,0 +1,227 @@ + + + + +Atmel EDBG-based Tools Protocols -
        Atmel Corporation

        © 2014 Atmel Corporation. All rights reserved. / Rev.: 42197AX-MCU-10/2014

        Atmel®, Atmel logo and combinations thereof, Enabling Unlimited Possibilities®, AVR®, and others are registered trademarks or trademarks of Atmel Corporation in U.S. and other countries. Windows® is a registered trademark of Microsoft Corporation in U.S. and or other countries. ARM® is a registered trademark of ARM Ltd. Other terms and product names may be trademarks of others.

        + Disclaimer: The information in this + document is provided in connection with Atmel products. No license, express or implied, by estoppel + or otherwise, to any intellectual property right is granted by this document or in connection with + the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED + ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR + STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE + LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, + WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) + ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the + accuracy or completeness of the contents of this document and reserves the right to make changes to + specifications and products descriptions at any time without notice. Atmel does not make any + commitment to update the information contained herein. Unless specifically provided otherwise, Atmel + products are not suitable for, and shall not be used in, automotive applications. Atmel products are + not intended, authorized, or warranted for use as components in applications intended to support or + sustain life. +


        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/pr01.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/pr01.html new file mode 100644 index 000000000..53f993d3f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/pr01.html @@ -0,0 +1,213 @@ + + + + +Preface - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.Introduction.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.Introduction.html new file mode 100644 index 000000000..c0ff81420 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.Introduction.html @@ -0,0 +1,209 @@ + + + + +Introduction - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avr32protocol.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avr32protocol.html new file mode 100644 index 000000000..e5f43a972 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avr32protocol.html @@ -0,0 +1,212 @@ + + + + +AVR32 generic protocol - - Atmel EDBG-based Tools Protocols

        The AVR32GENERIC protocol is the single protocol for programming and debugging + Atmel AVR UC3 32-bit microcontrollers using all relevant tools.

        UC3 devices are big endian meaning that byte address 0 is most significant byte. The + AVR32GENERIC protocol is little endian, i.e. least significant byte is sent first. Words are + sent in ascending order, i.e. lowest word address first.

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avr8protocol.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avr8protocol.html new file mode 100644 index 000000000..a93a23c7f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avr8protocol.html @@ -0,0 +1,211 @@ + + + + +AVR8 generic protocol - - Atmel EDBG-based Tools Protocols

        The AVR8 generic protocol is the single protocol for programming and debugging + 8-bit AVR devices on all NEW tools (JTAGICE3 and newer). +

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avrispprotocol.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avrispprotocol.html new file mode 100644 index 000000000..660b1e669 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avrispprotocol.html @@ -0,0 +1,219 @@ + + + + +AVR ISP protocol - - Atmel EDBG-based Tools Protocols

        The AVR ISP protocol is based upon the communication protocol used by all Atmel + AVR tools as far back as the STK500. It is used for programming tinyAVR and megaAVR devices + using the SPI interface

        Timing parameter + values are extracted from XML files and included in the protocol command function + calls.

        Note

        This protocol is also described in the Application Note AVR069: AVRISP mkII + Communication Protocol, although not all commands are supported. The + SPI_MULTI command is not supported by this implementation.

        The protocol commands are put in the payload of EDBG commands with the handler + set to SPI. The responses are also sent as the payload of EDBG commands.

        Note that the SPI protocol has no CMD_ACTIVATE_PHYSICAL. The ENTER_PROGMODE command will + enable the physical and LEAVE_PROGMODE will deactivate it.

        The SPI_MULTI command is not supported by this implementation.

        In addition to the SPI commands the general CMD_LOAD_ADDRESS from the STK500 communication + protocol is supported. This command is used to set the start address for the following write + or read command. This command is described below.

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avrprotocol.Overview.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avrprotocol.Overview.html new file mode 100644 index 000000000..599ac4895 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.avrprotocol.Overview.html @@ -0,0 +1,209 @@ + + + + +AVR communication protocol - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.cmsis_dap.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.cmsis_dap.html new file mode 100644 index 000000000..828c6d2e7 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.cmsis_dap.html @@ -0,0 +1,209 @@ + + + + +CMSIS-DAP - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.edbg_ctrl_protocol.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.edbg_ctrl_protocol.html new file mode 100644 index 000000000..5d8211df7 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.edbg_ctrl_protocol.html @@ -0,0 +1,210 @@ + + + + +EDBG Control Protocol - - Atmel EDBG-based Tools Protocols

        The EDBG Control protocol is used to query and configure parameters relevant to EDBG + and the board in which EDBG is embedded.

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.tpiprotocol.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.tpiprotocol.html new file mode 100644 index 000000000..442c2b337 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/protocoldocs.tpiprotocol.html @@ -0,0 +1,213 @@ + + + + +TPI Protocol - - Atmel EDBG-based Tools Protocols

        The TPI protocol is based upon the communication protocol used by STK600 and + AVRISP mkII. In those tools it is used for programming tinyAVR using TPI interface as well + as AVR XMEGA devices using PDI and/or JTAG. This implementation supports only programming of + tinyAVR devices using the TPI interface.

        All multi-byte values (e.g. address and length fields) are big endian.

        The protocol commands are put in the payload of EDBG commands with the handler set to TPIPROTOCOL. The responses are also sent as the payload of EDBG commands.

        Note that the TPIPROTOCOL has no CMD_ACTIVATE_PHYSICAL. The ENTER_PROGMODE command will + enable the physical and LEAVE_PROGMODE will deactivate it.

        \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/htmlFileInfoList.js b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/htmlFileInfoList.js new file mode 100644 index 000000000..d1d8fbc2c --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/htmlFileInfoList.js @@ -0,0 +1,392 @@ +var doStem = true; +//List of indexed files. +fl = new Array(); +fl["0"]= "ch01s01.html"; +fl["1"]= "ch01s02.html"; +fl["2"]= "ch02s01.html"; +fl["3"]= "ch02s02.html"; +fl["4"]= "ch02s02s01.html"; +fl["5"]= "ch02s02s02.html"; +fl["6"]= "ch02s02s02s01.html"; +fl["7"]= "ch02s02s02s02.html"; +fl["8"]= "ch02s02s03.html"; +fl["9"]= "ch02s02s03s01.html"; +fl["10"]= "ch02s02s03s02.html"; +fl["11"]= "ch02s02s03s03.html"; +fl["12"]= "ch02s02s03s04.html"; +fl["13"]= "ch02s03s01.html"; +fl["14"]= "ch02s03s02.html"; +fl["15"]= "ch02s03s03.html"; +fl["16"]= "ch02s03s04.html"; +fl["17"]= "ch02s03s05.html"; +fl["18"]= "ch02s03s06.html"; +fl["19"]= "ch02s03s07.html"; +fl["20"]= "ch02s03s08.html"; +fl["21"]= "ch02s03s09.html"; +fl["22"]= "ch02s04.html"; +fl["23"]= "ch02s04s01.html"; +fl["24"]= "ch02s04s02.html"; +fl["25"]= "ch02s04s03.html"; +fl["26"]= "ch03s01.html"; +fl["27"]= "ch03s01s01.html"; +fl["28"]= "ch03s01s02.html"; +fl["29"]= "ch03s01s03.html"; +fl["30"]= "ch03s01s03s01.html"; +fl["31"]= "ch03s02.html"; +fl["32"]= "ch03s02s01.html"; +fl["33"]= "ch03s02s02.html"; +fl["34"]= "ch03s02s03.html"; +fl["35"]= "ch03s02s04.html"; +fl["36"]= "ch04s01.html"; +fl["37"]= "ch04s02.html"; +fl["38"]= "ch04s03.html"; +fl["39"]= "ch04s04.html"; +fl["40"]= "ch04s04s01.html"; +fl["41"]= "ch04s04s03.html"; +fl["42"]= "ch04s04s04.html"; +fl["43"]= "ch04s04s05.html"; +fl["44"]= "ch04s05.html"; +fl["45"]= "ch04s05s01.html"; +fl["46"]= "ch04s05s03.html"; +fl["47"]= "ch04s05s04.html"; +fl["48"]= "ch04s05s06.html"; +fl["49"]= "ch04s05s06s02.html"; +fl["50"]= "ch04s05s06s03.html"; +fl["51"]= "ch04s05s06s04.html"; +fl["52"]= "ch04s05s06s05.html"; +fl["53"]= "ch04s05s07.html"; +fl["54"]= "ch04s05s07s01.html"; +fl["55"]= "ch04s05s07s02.html"; +fl["56"]= "ch04s05s07s03.html"; +fl["57"]= "ch04s05s07s04.html"; +fl["58"]= "ch04s05s08.html"; +fl["59"]= "ch04s05s08s01.html"; +fl["60"]= "ch04s05s08s02.html"; +fl["61"]= "ch04s05s08s03.html"; +fl["62"]= "ch04s05s09.html"; +fl["63"]= "ch04s05s10.html"; +fl["64"]= "ch05s01.html"; +fl["65"]= "ch05s01s01.html"; +fl["66"]= "ch05s01s02.html"; +fl["67"]= "ch05s01s03.html"; +fl["68"]= "ch05s01s04.html"; +fl["69"]= "ch05s01s05.html"; +fl["70"]= "ch05s01s06.html"; +fl["71"]= "ch05s01s07.html"; +fl["72"]= "ch05s01s08.html"; +fl["73"]= "ch05s01s09.html"; +fl["74"]= "ch05s01s10.html"; +fl["75"]= "ch05s01s11.html"; +fl["76"]= "ch05s01s12.html"; +fl["77"]= "ch05s01s13.html"; +fl["78"]= "ch05s01s14.html"; +fl["79"]= "ch05s01s15.html"; +fl["80"]= "ch05s02.html"; +fl["81"]= "ch05s02s01.html"; +fl["82"]= "ch05s02s02.html"; +fl["83"]= "ch05s02s03.html"; +fl["84"]= "ch05s02s04.html"; +fl["85"]= "ch05s02s05.html"; +fl["86"]= "ch05s02s06.html"; +fl["87"]= "ch05s03.html"; +fl["88"]= "ch05s03s01.html"; +fl["89"]= "ch05s03s02.html"; +fl["90"]= "ch05s03s03.html"; +fl["91"]= "ch05s04.html"; +fl["92"]= "ch06s01.html"; +fl["93"]= "ch06s01s01.html"; +fl["94"]= "ch06s01s02.html"; +fl["95"]= "ch06s01s03.html"; +fl["96"]= "ch06s01s04.html"; +fl["97"]= "ch06s01s05.html"; +fl["98"]= "ch06s01s06.html"; +fl["99"]= "ch06s01s07.html"; +fl["100"]= "ch06s01s08.html"; +fl["101"]= "ch06s01s09.html"; +fl["102"]= "ch06s01s10.html"; +fl["103"]= "ch06s01s11.html"; +fl["104"]= "ch06s01s12.html"; +fl["105"]= "ch06s01s13.html"; +fl["106"]= "ch06s01s14.html"; +fl["107"]= "ch06s01s15.html"; +fl["108"]= "ch06s01s16.html"; +fl["109"]= "ch06s01s17.html"; +fl["110"]= "ch06s01s18.html"; +fl["111"]= "ch06s01s19.html"; +fl["112"]= "ch06s01s20.html"; +fl["113"]= "ch06s01s21.html"; +fl["114"]= "ch06s01s22.html"; +fl["115"]= "ch06s01s23.html"; +fl["116"]= "ch06s01s24.html"; +fl["117"]= "ch06s01s25.html"; +fl["118"]= "ch06s01s26.html"; +fl["119"]= "ch06s01s27.html"; +fl["120"]= "ch06s01s28.html"; +fl["121"]= "ch06s01s29.html"; +fl["122"]= "ch06s02.html"; +fl["123"]= "ch06s02s01.html"; +fl["124"]= "ch06s02s02.html"; +fl["125"]= "ch06s02s03.html"; +fl["126"]= "ch06s02s04.html"; +fl["127"]= "ch06s02s05.html"; +fl["128"]= "ch06s03.html"; +fl["129"]= "ch06s03s01.html"; +fl["130"]= "ch06s03s02.html"; +fl["131"]= "ch06s04s01.html"; +fl["132"]= "ch06s04s02.html"; +fl["133"]= "ch06s04s03.html"; +fl["134"]= "ch06s05.html"; +fl["135"]= "ch06s05s01.html"; +fl["136"]= "ch06s05s02.html"; +fl["137"]= "ch06s05s03.html"; +fl["138"]= "ch06s05s04.html"; +fl["139"]= "ch06s05s05.html"; +fl["140"]= "ch06s06.html"; +fl["141"]= "ch07s01.html"; +fl["142"]= "ch07s01s01.html"; +fl["143"]= "ch07s01s02.html"; +fl["144"]= "ch07s01s03.html"; +fl["145"]= "ch07s01s04.html"; +fl["146"]= "ch07s01s05.html"; +fl["147"]= "ch07s01s06.html"; +fl["148"]= "ch07s01s07.html"; +fl["149"]= "ch07s01s08.html"; +fl["150"]= "ch07s01s09.html"; +fl["151"]= "ch07s01s10.html"; +fl["152"]= "ch07s01s11.html"; +fl["153"]= "ch07s01s12.html"; +fl["154"]= "ch07s01s13.html"; +fl["155"]= "ch07s01s14.html"; +fl["156"]= "ch07s01s15.html"; +fl["157"]= "ch07s01s16.html"; +fl["158"]= "ch07s01s17.html"; +fl["159"]= "ch07s02.html"; +fl["160"]= "ch07s03.html"; +fl["161"]= "ch08s01.html"; +fl["162"]= "ch08s01s01.html"; +fl["163"]= "ch08s01s02.html"; +fl["164"]= "ch08s01s03.html"; +fl["165"]= "ch08s01s04.html"; +fl["166"]= "ch08s01s05.html"; +fl["167"]= "ch08s01s06.html"; +fl["168"]= "ch08s02.html"; +fl["169"]= "ch08s03.html"; +fl["170"]= "document.revisions.html"; +fl["171"]= "index.html"; +fl["172"]= "pr01.html"; +fl["173"]= "protocoldocs.avr32protocol.html"; +fl["174"]= "protocoldocs.avr8protocol.html"; +fl["175"]= "protocoldocs.avrispprotocol.html"; +fl["176"]= "protocoldocs.avrprotocol.Overview.html"; +fl["177"]= "protocoldocs.cmsis_dap.html"; +fl["178"]= "protocoldocs.edbg_ctrl_protocol.html"; +fl["179"]= "protocoldocs.Introduction.html"; +fl["180"]= "protocoldocs.tpiprotocol.html"; +fl["181"]= "section_avr32_memtypes.html"; +fl["182"]= "section_avr32_setget_params.html"; +fl["183"]= "section_avr8_memtypes.html"; +fl["184"]= "section_avr8_query_contexts.html"; +fl["185"]= "section_avr8_setget_params.html"; +fl["186"]= "section_edbg_ctrl_setget_params.html"; +fl["187"]= "section_edbg_query_contexts.html"; +fl["188"]= "section_housekeeping_start_session.html"; +fl["189"]= "section_i5v_3yz_rl.html"; +fl["190"]= "section_jdx_m11_sl.html"; +fl["191"]= "section_qhb_x1c_sl.html"; +fl["192"]= "section_serial_trace.html"; +fl["193"]= "section_t1f_hb1_sl.html"; +fil = new Array(); +fil["0"]= "ch01s01.html@@@EDBG interface overview@@@null"; +fil["1"]= "ch01s02.html@@@Atmel EDBG-based tool implementations@@@null"; +fil["2"]= "ch02s01.html@@@CMSIS-DAP protocol@@@null"; +fil["3"]= "ch02s02.html@@@CMSIS-DAP vendor commands@@@null"; +fil["4"]= "ch02s02s01.html@@@AVR-target specific vendor commands@@@null"; +fil["5"]= "ch02s02s02.html@@@ARM-target specific vendor commands@@@null"; +fil["6"]= "ch02s02s02s01.html@@@Erase pin@@@null"; +fil["7"]= "ch02s02s02s02.html@@@Serial trace@@@null"; +fil["8"]= "ch02s02s03.html@@@EDBG-specific vendor commands@@@null"; +fil["9"]= "ch02s02s03s01.html@@@Get configuration@@@null"; +fil["10"]= "ch02s02s03s02.html@@@Set configuration@@@null"; +fil["11"]= "ch02s02s03s03.html@@@EDBG GET request@@@null"; +fil["12"]= "ch02s02s03s04.html@@@EDBG SET request@@@null"; +fil["13"]= "ch02s03s01.html@@@Set transport mode@@@null"; +fil["14"]= "ch02s03s02.html@@@Set capture mode@@@null"; +fil["15"]= "ch02s03s03.html@@@Set baud rate@@@null"; +fil["16"]= "ch02s03s04.html@@@Start@@@null"; +fil["17"]= "ch02s03s05.html@@@Stop@@@null"; +fil["18"]= "ch02s03s06.html@@@Get data@@@null"; +fil["19"]= "ch02s03s07.html@@@Get status@@@null"; +fil["20"]= "ch02s03s08.html@@@Get buffer size@@@null"; +fil["21"]= "ch02s03s09.html@@@Signon@@@null"; +fil["22"]= "ch02s04.html@@@Enveloped AVR commands, responses & events@@@null"; +fil["23"]= "ch02s04s01.html@@@Wrapping AVR commands@@@null"; +fil["24"]= "ch02s04s02.html@@@Unwrapping AVR responses@@@null"; +fil["25"]= "ch02s04s03.html@@@Unwrapping AVR events@@@null"; +fil["26"]= "ch03s01.html@@@Protocol commands@@@null"; +fil["27"]= "ch03s01s01.html@@@QUERY@@@null"; +fil["28"]= "ch03s01s02.html@@@SET@@@null"; +fil["29"]= "ch03s01s03.html@@@GET@@@null"; +fil["30"]= "ch03s01s03s01.html@@@SET/GET parameters@@@null"; +fil["31"]= "ch03s02.html@@@Responses@@@null"; +fil["32"]= "ch03s02s01.html@@@OK@@@null"; +fil["33"]= "ch03s02s02.html@@@LIST@@@null"; +fil["34"]= "ch03s02s03.html@@@DATA@@@null"; +fil["35"]= "ch03s02s04.html@@@FAILED@@@null"; +fil["36"]= "ch04s01.html@@@Overview@@@null"; +fil["37"]= "ch04s02.html@@@Framing@@@null"; +fil["38"]= "ch04s03.html@@@Protocol sub-set overview@@@null"; +fil["39"]= "ch04s04.html@@@Discovery Protocol Definition@@@null"; +fil["40"]= "ch04s04s01.html@@@CMD: QUERY@@@null"; +fil["41"]= "ch04s04s03.html@@@RSP: LIST@@@null"; +fil["42"]= "ch04s04s04.html@@@RSP: FAILED@@@null"; +fil["43"]= "ch04s04s05.html@@@Discovery Protocol ID definitions@@@null"; +fil["44"]= "ch04s05.html@@@Housekeeping Protocol@@@null"; +fil["45"]= "ch04s05s01.html@@@CMD: QUERY@@@null"; +fil["46"]= "ch04s05s03.html@@@CMD: SET@@@null"; +fil["47"]= "ch04s05s04.html@@@CMD: GET@@@null"; +fil["48"]= "ch04s05s06.html@@@Housekeeping Commands@@@null"; +fil["49"]= "ch04s05s06s02.html@@@End Session@@@null"; +fil["50"]= "ch04s05s06s03.html@@@Firmware Upgrade@@@null"; +fil["51"]= "ch04s05s06s04.html@@@JTAG scan-chain detection@@@null"; +fil["52"]= "ch04s05s06s05.html@@@Calibrate Oscillator@@@null"; +fil["53"]= "ch04s05s07.html@@@Housekeeping Responses@@@null"; +fil["54"]= "ch04s05s07s01.html@@@OK@@@null"; +fil["55"]= "ch04s05s07s02.html@@@LIST@@@null"; +fil["56"]= "ch04s05s07s03.html@@@DATA@@@null"; +fil["57"]= "ch04s05s07s04.html@@@FAILED@@@null"; +fil["58"]= "ch04s05s08.html@@@Events@@@null"; +fil["59"]= "ch04s05s08s01.html@@@Event: power@@@null"; +fil["60"]= "ch04s05s08s02.html@@@Event: sleep@@@null"; +fil["61"]= "ch04s05s08s03.html@@@Event: external reset@@@null"; +fil["62"]= "ch04s05s09.html@@@Hints and tips@@@null"; +fil["63"]= "ch04s05s10.html@@@Housekeeping ID definitions@@@null"; +fil["64"]= "ch05s01.html@@@Protocol commands@@@null"; +fil["65"]= "ch05s01s01.html@@@QUERY@@@null"; +fil["66"]= "ch05s01s02.html@@@SET@@@null"; +fil["67"]= "ch05s01s03.html@@@GET@@@null"; +fil["68"]= "ch05s01s04.html@@@Activate Physical@@@null"; +fil["69"]= "ch05s01s05.html@@@Deactivate Physical@@@null"; +fil["70"]= "ch05s01s06.html@@@Get ID@@@null"; +fil["71"]= "ch05s01s07.html@@@Erase@@@null"; +fil["72"]= "ch05s01s08.html@@@Halt@@@null"; +fil["73"]= "ch05s01s09.html@@@Reset@@@null"; +fil["74"]= "ch05s01s10.html@@@Step@@@null"; +fil["75"]= "ch05s01s11.html@@@Read@@@null"; +fil["76"]= "ch05s01s12.html@@@Write@@@null"; +fil["77"]= "ch05s01s13.html@@@TAP@@@null"; +fil["78"]= "ch05s01s14.html@@@Is protected@@@null"; +fil["79"]= "ch05s01s15.html@@@Erase Section@@@null"; +fil["80"]= "ch05s02.html@@@Responses@@@null"; +fil["81"]= "ch05s02s01.html@@@OK@@@null"; +fil["82"]= "ch05s02s02.html@@@LIST@@@null"; +fil["83"]= "ch05s02s03.html@@@ID@@@null"; +fil["84"]= "ch05s02s04.html@@@PC@@@null"; +fil["85"]= "ch05s02s05.html@@@DATA@@@null"; +fil["86"]= "ch05s02s06.html@@@FAILED@@@null"; +fil["87"]= "ch05s03.html@@@Hints and tips@@@null"; +fil["88"]= "ch05s03s01.html@@@Configuration@@@null"; +fil["89"]= "ch05s03s02.html@@@Activate and deactivate physical@@@null"; +fil["90"]= "ch05s03s03.html@@@Programming and debugging commands@@@null"; +fil["91"]= "ch05s04.html@@@AVR32GENERIC ID definitions@@@null"; +fil["92"]= "ch06s01.html@@@Protocol Commands@@@null"; +fil["93"]= "ch06s01s01.html@@@QUERY@@@null"; +fil["94"]= "ch06s01s02.html@@@SET@@@null"; +fil["95"]= "ch06s01s03.html@@@GET@@@null"; +fil["96"]= "ch06s01s04.html@@@Activate Physical@@@null"; +fil["97"]= "ch06s01s05.html@@@Deactivate Physical@@@null"; +fil["98"]= "ch06s01s06.html@@@Get ID@@@null"; +fil["99"]= "ch06s01s07.html@@@Attach@@@null"; +fil["100"]= "ch06s01s08.html@@@Detach@@@null"; +fil["101"]= "ch06s01s09.html@@@Reset@@@null"; +fil["102"]= "ch06s01s10.html@@@Stop@@@null"; +fil["103"]= "ch06s01s11.html@@@Run@@@null"; +fil["104"]= "ch06s01s12.html@@@Run To@@@null"; +fil["105"]= "ch06s01s13.html@@@Step@@@null"; +fil["106"]= "ch06s01s14.html@@@PC read@@@null"; +fil["107"]= "ch06s01s15.html@@@PC write@@@null"; +fil["108"]= "ch06s01s16.html@@@Prog Mode Enter@@@null"; +fil["109"]= "ch06s01s17.html@@@Prog Mode Leave@@@null"; +fil["110"]= "ch06s01s18.html@@@Disable debugWIRE@@@null"; +fil["111"]= "ch06s01s19.html@@@Erase@@@null"; +fil["112"]= "ch06s01s20.html@@@CRC@@@null"; +fil["113"]= "ch06s01s21.html@@@Memory Read@@@null"; +fil["114"]= "ch06s01s22.html@@@Memory Read masked@@@null"; +fil["115"]= "ch06s01s23.html@@@Memory Write@@@null"; +fil["116"]= "ch06s01s24.html@@@Page Erase@@@null"; +fil["117"]= "ch06s01s25.html@@@Hardware Breakpoint Set@@@null"; +fil["118"]= "ch06s01s26.html@@@Hardware Breakpoint Clear@@@null"; +fil["119"]= "ch06s01s27.html@@@Software Breakpoint Set@@@null"; +fil["120"]= "ch06s01s28.html@@@Software Breakpoint Clear@@@null"; +fil["121"]= "ch06s01s29.html@@@Software Breakpoint Clear All@@@null"; +fil["122"]= "ch06s02.html@@@Responses@@@null"; +fil["123"]= "ch06s02s01.html@@@OK@@@null"; +fil["124"]= "ch06s02s02.html@@@LIST@@@null"; +fil["125"]= "ch06s02s03.html@@@PC@@@null"; +fil["126"]= "ch06s02s04.html@@@DATA@@@null"; +fil["127"]= "ch06s02s05.html@@@FAILED@@@null"; +fil["128"]= "ch06s03.html@@@Events@@@null"; +fil["129"]= "ch06s03s01.html@@@Event: Break@@@null"; +fil["130"]= "ch06s03s02.html@@@Event: IDR message@@@null"; +fil["131"]= "ch06s04s01.html@@@debugWIRE memtypes@@@null"; +fil["132"]= "ch06s04s02.html@@@megaAVR (JTAG) OCD memtypes@@@null"; +fil["133"]= "ch06s04s03.html@@@AVR XMEGA memtypes@@@null"; +fil["134"]= "ch06s05.html@@@Hints and tips:@@@null"; +fil["135"]= "ch06s05s01.html@@@Configuration@@@null"; +fil["136"]= "ch06s05s02.html@@@Activate and deactivate physical@@@null"; +fil["137"]= "ch06s05s03.html@@@Programming session control@@@null"; +fil["138"]= "ch06s05s04.html@@@Debug session control@@@null"; +fil["139"]= "ch06s05s05.html@@@Flow control@@@null"; +fil["140"]= "ch06s06.html@@@AVR8GENERIC ID definitions@@@null"; +fil["141"]= "ch07s01.html@@@SPI programming protocol commands@@@null"; +fil["142"]= "ch07s01s01.html@@@SPI Load Address@@@null"; +fil["143"]= "ch07s01s02.html@@@SPI Set Baud@@@null"; +fil["144"]= "ch07s01s03.html@@@SPI Get Baud@@@null"; +fil["145"]= "ch07s01s04.html@@@SPI Enter Programming Mode@@@null"; +fil["146"]= "ch07s01s05.html@@@SPI Leave Programming Mode@@@null"; +fil["147"]= "ch07s01s06.html@@@SPI Chip Erase@@@null"; +fil["148"]= "ch07s01s07.html@@@SPI Program Flash@@@null"; +fil["149"]= "ch07s01s08.html@@@SPI Read Flash@@@null"; +fil["150"]= "ch07s01s09.html@@@SPI Program EEPROM@@@null"; +fil["151"]= "ch07s01s10.html@@@SPI Read EEPROM@@@null"; +fil["152"]= "ch07s01s11.html@@@SPI Program Fuse@@@null"; +fil["153"]= "ch07s01s12.html@@@SPI Read Fuse@@@null"; +fil["154"]= "ch07s01s13.html@@@SPI Program Lock@@@null"; +fil["155"]= "ch07s01s14.html@@@SPI Read Lock@@@null"; +fil["156"]= "ch07s01s15.html@@@SPI Read Signature@@@null"; +fil["157"]= "ch07s01s16.html@@@SPI Read OSCCAL@@@null"; +fil["158"]= "ch07s01s17.html@@@SPI Multi@@@null"; +fil["159"]= "ch07s02.html@@@SPI programming protocol responses@@@null"; +fil["160"]= "ch07s03.html@@@ID definitions@@@null"; +fil["161"]= "ch08s01.html@@@TPI protocol commands@@@null"; +fil["162"]= "ch08s01s01.html@@@TPI Enter Programming Mode@@@null"; +fil["163"]= "ch08s01s02.html@@@TPI Leave Programming Mode@@@null"; +fil["164"]= "ch08s01s03.html@@@TPI Set Parameter@@@null"; +fil["165"]= "ch08s01s04.html@@@TPI Erase@@@null"; +fil["166"]= "ch08s01s05.html@@@TPI Write Memory@@@null"; +fil["167"]= "ch08s01s06.html@@@TPI Read Memory@@@null"; +fil["168"]= "ch08s02.html@@@TPI programming protocol responses@@@null"; +fil["169"]= "ch08s03.html@@@ID definitions@@@null"; +fil["170"]= "document.revisions.html@@@Document Revisions@@@null"; +fil["171"]= "index.html@@@Atmel EDBG-based Tools Protocols@@@null"; +fil["172"]= "pr01.html@@@Preface@@@null"; +fil["173"]= "protocoldocs.avr32protocol.html@@@AVR32 generic protocol@@@null"; +fil["174"]= "protocoldocs.avr8protocol.html@@@AVR8 generic protocol@@@null"; +fil["175"]= "protocoldocs.avrispprotocol.html@@@AVR ISP protocol@@@null"; +fil["176"]= "protocoldocs.avrprotocol.Overview.html@@@AVR communication protocol@@@null"; +fil["177"]= "protocoldocs.cmsis_dap.html@@@CMSIS-DAP@@@null"; +fil["178"]= "protocoldocs.edbg_ctrl_protocol.html@@@EDBG Control Protocol@@@null"; +fil["179"]= "protocoldocs.Introduction.html@@@Introduction@@@null"; +fil["180"]= "protocoldocs.tpiprotocol.html@@@TPI Protocol@@@null"; +fil["181"]= "section_avr32_memtypes.html@@@Memory Types@@@null"; +fil["182"]= "section_avr32_setget_params.html@@@SET/GET parameters@@@null"; +fil["183"]= "section_avr8_memtypes.html@@@Memory Types@@@null"; +fil["184"]= "section_avr8_query_contexts.html@@@AVR8 QUERY contexts@@@null"; +fil["185"]= "section_avr8_setget_params.html@@@SET/GET parameters@@@null"; +fil["186"]= "section_edbg_ctrl_setget_params.html@@@EDBGCTRL ID definitions@@@null"; +fil["187"]= "section_edbg_query_contexts.html@@@EDBG QUERY contexts@@@null"; +fil["188"]= "section_housekeeping_start_session.html@@@Start session@@@null"; +fil["189"]= "section_i5v_3yz_rl.html@@@Housekeeping QUERY contexts@@@null"; +fil["190"]= "section_jdx_m11_sl.html@@@Discovery QUERY contexts@@@null"; +fil["191"]= "section_qhb_x1c_sl.html@@@AVR32 QUERY contexts@@@null"; +fil["192"]= "section_serial_trace.html@@@Serial trace commands@@@null"; +fil["193"]= "section_t1f_hb1_sl.html@@@Housekeeping SET/GET parameters@@@null"; diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/index-1.js b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/index-1.js new file mode 100644 index 000000000..c708ea8c9 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/index-1.js @@ -0,0 +1,851 @@ +var indexerLanguage="en"; +//Auto generated index for searching by xsl-webhelpindexer for DocBook Webhelp.# Kasun Gajasinghe, University of Moratuwa +w["-"]="0*2,1*2,2*2,3*2,4*2,5*2,6*2,7*2,8*2,9*2,10*2,11*2,12*2,13*2,14*2,15*2,16*2,17*2,18*2,19*2,20*2,21*2,22*2,23*2,24*2,25*2,26*2,27*2,28*2,29*2,30*2,31*2,32*2,33*2,34*2,35*2,36*2,37*2,38*2,39*2,40*2,41*2,42*2,43*2,44*2,45*2,46*2,47*2,48*2,49*2,50*2,51*2,52*2,53*2,54*2,55*2,56*2,57*2,58*2,59*2,60*2,61*2,62*2,63*2,64*2,65*2,66*2,67*2,68*2,69*2,70*3,71*2,72*2,73*2,74*2,75*2,76*2,77*2,78*2,79*2,80*2,81*2,82*2,83*2,84*2,85*2,86*2,87*2,88*2,89*2,90*2,91*2,92*2,93*2,94*2,95*2,96*2,97*2,98*2,99*2,100*2,101*2,102*2,103*2,104*2,105*2,106*2,107*2,108*2,109*2,110*2,111*4,112*2,113*2,114*2,115*2,116*2,117*2,118*2,119*2,120*2,121*2,122*2,123*2,124*2,125*2,126*2,127*2,128*2,129*2,130*2,131*8,132*12,133*7,134*2,135*2,136*2,137*2,138*2,139*2,140*2,141*2,142*2,143*2,144*2,145*2,146*2,147*2,148*2,149*2,150*2,151*2,152*2,153*2,154*2,155*2,156*2,157*2,158*2,159*2,160*2,161*2,162*2,163*2,164*2,165*2,166*3,167*2,168*2,169*2,170*2,171*1,173*2,174*2,175*2,176*2,177*2,178*2,179*2,180*2,181*2,182*2,183*2,184*2,185*2,186*2,187*2,188*2,189*2,190*2,191*2,192*2,193*2"; +w["-board"]="172*1"; +w["-chip"]="1*2"; +w["."]="22*1,30*1,37*3,52*1,62*1,77*2,96*1,109*1,119*1,120*1,131*4,132*3,133*12,135*1,139*2,148*2,171*1,172*1,174*1,175*1,180*1"; +w[".e."]="173*2"; +w["0"]="21*1,34*5,49*1,51*1,56*6,85*5,91*3,114*1,119*1,120*1,126*5,132*1,140*3,145*1,147*1,148*3,169*1,173*1,181*1,182*1,185*1,186*1"; +w["0-6"]="148*1"; +w["0."]="132*1"; +w["00"]="136*2"; +w["01"]="78*1,170*1"; +w["05"]="136*1"; +w["09"]="136*2,170*1"; +w["09.10.2013"]="170*1"; +w["0:"]="18*1"; +w["0x00"]="6*1,9*1,10*1,13*4,14*2,16*1,17*1,23*1,24*2,27*2,28*1,29*1,30*3,32*1,33*1,34*1,35*1,37*6,38*1,40*2,41*1,42*1,43*3,45*2,46*1,47*1,49*1,50*1,51*1,52*1,54*1,55*1,56*1,57*1,59*2,60*2,61*2,63*10,65*2,66*1,67*1,68*2,69*1,71*1,72*2,73*1,74*1,75*1,76*1,77*1,78*1,79*1,81*1,82*1,83*1,84*1,85*2,86*1,91*8,93*2,94*1,95*1,96*2,97*1,98*1,99*2,100*1,101*1,102*1,103*1,104*1,105*2,106*1,107*1,108*1,109*1,110*1,111*2,112*2,113*1,114*1,115*2,116*1,117*1,118*1,119*1,120*1,121*1,123*1,124*1,125*1,126*1,127*1,129*2,130*1,131*1,133*1,140*14,160*1,182*2,185*4,186*10,188*1"; +w["0x00."]="131*1"; +w["0x0000"]="25*1"; +w["0x000000"]="133*12"; +w["0x00:"]="6*1,9*1,10*1,13*2,14*2,16*1,17*1,23*1,24*1,30*3,68*1,72*1,96*1,105*1"; +w["0x01"]="6*1,13*1,14*2,23*1,24*1,28*1,30*3,34*1,38*1,46*1,56*1,59*1,60*1,61*1,63*6,66*1,68*1,72*1,85*1,91*5,94*1,96*1,99*1,101*1,102*1,105*2,111*1,112*1,115*1,117*1,126*1,129*1,140*10,169*1,182*3,185*1,186*7"; +w["0x01:"]="6*1,13*1,23*1,24*1,30*3,68*1,72*1,96*1,101*1,102*1,105*2,117*1,182*2"; +w["0x02"]="14*1,15*2,29*1,47*1,63*2,67*1,91*4,95*1,101*1,102*1,105*2,111*1,112*1,132*2,140*5,169*1,185*2,186*5"; +w["0x02:"]="14*1,101*1,102*1,105*2"; +w["0x03"]="16*2,63*1,91*4,111*1,112*1,117*1,132*1,140*4,169*2,186*3"; +w["0x03:"]="117*1"; +w["0x04"]="17*2,91*5,111*1,140*4,169*2,182*1,185*1,186*2"; +w["0x05"]="91*3,111*1,140*3,169*1,186*1"; +w["0x06"]="91*3,111*1,140*2,160*1,185*2,186*1"; +w["0x07"]="91*3,111*1,140*2,169*1,182*1,186*1"; +w["0x08"]="18*2,91*2,140*1,185*1,186*2"; +w["0x09"]="19*2,91*1,186*2"; +w["0x0a"]="20*2,91*2,185*2,186*2"; +w["0x0b"]="91*2,186*1"; +w["0x0c"]="91*2,185*1,186*1"; +w["0x0d"]="91*1,186*1"; +w["0x0e"]="37*3,91*1,185*2,186*1"; +w["0x0f"]="21*2,91*1,186*2"; +w["0x10"]="43*1,63*4,91*3,140*3,160*1,185*3,186*5"; +w["0x11"]="38*1,63*4,91*2,140*2,160*1,186*3"; +w["0x12"]="38*1,63*2,91*2,140*2,160*1,185*2,186*2"; +w["0x13"]="38*1,63*1,91*2,140*2,160*1,185*2,186*2"; +w["0x14"]="38*1,91*2,140*2,160*1,185*1,186*2"; +w["0x15"]="91*2,140*2,160*1,186*2"; +w["0x16"]="91*2,140*2,160*1,186*2"; +w["0x17"]="91*2,140*2,160*1,186*2"; +w["0x18"]="91*2,140*1,160*1,185*3,186*1"; +w["0x19"]="91*2,140*1,160*1,185*2,186*1"; +w["0x1a"]="91*1,140*1,160*1,185*2"; +w["0x1b"]="91*1,140*1,160*1,185*2"; +w["0x1c"]="160*1,185*3"; +w["0x1d"]="91*1,160*1,185*2"; +w["0x1e"]="91*1,131*1,160*1,185*2"; +w["0x1e."]="131*1"; +w["0x1f"]="91*1"; +w["0x20"]="38*1,63*1,91*1,140*4,185*1,186*3"; +w["0x21"]="63*1,91*1,140*3"; +w["0x2111"]="1*1"; +w["0x2140"]="1*1"; +w["0x2141"]="1*1"; +w["0x2145"]="1*1"; +w["0x22"]="63*1,91*1,140*3"; +w["0x23"]="63*1,91*1,140*2"; +w["0x24"]="91*2,140*1,185*1"; +w["0x25"]="91*1"; +w["0x26"]="91*1,185*1"; +w["0x28"]="185*1"; +w["0x29"]="91*1"; +w["0x2a"]="91*1,185*1"; +w["0x2b"]="91*1,185*1"; +w["0x2c"]="91*1"; +w["0x2d"]="91*1,185*1"; +w["0x2e"]="91*1"; +w["0x2f"]="91*1"; +w["0x30"]="63*2,91*1,140*2,186*1"; +w["0x31"]="63*2,91*1,140*3"; +w["0x32"]="63*1,91*1,140*2"; +w["0x33"]="63*1,91*1,140*2"; +w["0x34"]="140*2"; +w["0x35"]="140*2"; +w["0x36"]="140*2"; +w["0x37"]="140*1"; +w["0x38"]="63*1,140*1"; +w["0x39"]="140*1"; +w["0x3a"]="140*1"; +w["0x3b"]="140*1"; +w["0x3c"]="140*1"; +w["0x3d"]="140*1"; +w["0x40"]="63*1,140*3"; +w["0x41"]="63*1,140*3"; +w["0x42"]="63*1,140*1"; +w["0x43"]="63*1,140*2"; +w["0x44"]="140*2"; +w["0x45"]="140*1"; +w["0x50"]="63*1,140*2"; +w["0x53"]="145*1"; +w["0x60"]="140*1"; +w["0x61"]="140*1"; +w["0x70"]="140*1"; +w["0x71"]="140*1"; +w["0x72"]="140*1"; +w["0x80"]="3*1,4*1,23*2,43*1,63*1,91*3,140*2,160*1,186*1"; +w["0x81"]="3*1,4*1,24*2,43*2,63*1,91*2,140*2,160*1,186*1"; +w["0x82"]="3*1,4*1,25*2,43*1,91*3"; +w["0x83"]="3*1,9*2,91*2,140*1"; +w["0x84"]="3*1,10*2,63*1,91*2,140*1,186*1"; +w["0x85"]="3*1,91*1"; +w["0x86"]="3*1,6*2"; +w["0x87"]="3*1,13*2,14*2,15*2,16*2,17*2,18*2,19*2,20*2,21*2,192*1"; +w["0x88"]="3*1"; +w["0x89"]="3*1"; +w["0x90"]="91*1,140*1"; +w["0x91"]="91*1,140*1"; +w["0x92"]="91*1"; +w["0x93"]="91*1"; +w["0xa0"]="43*1,63*1,91*1,140*2,186*1"; +w["0xa1"]="63*1"; +w["0xb0"]="140*1"; +w["0xb1"]="140*1"; +w["0xb2"]="140*1"; +w["0xb3"]="140*1"; +w["0xb4"]="140*1"; +w["0xb5"]="140*1"; +w["0xb8"]="140*1"; +w["0xc0"]="140*1,160*1"; +w["0xc1"]="140*1"; +w["0xc2"]="140*1"; +w["0xc3"]="140*1"; +w["0xc4"]="140*1"; +w["0xc5"]="140*1"; +w["0xc6"]="140*1"; +w["0xc9"]="160*1"; +w["0xcb"]="160*1"; +w["0xcc"]="160*1"; +w["0xcd"]="160*1"; +w["0xe0"]="43*1"; +w["0xfe"]="91*1"; +w["0xff"]="13*1,14*1,16*1,17*1,35*1,42*1,43*1,57*1,86*1,91*1,127*1,140*2,186*1"; +w["0xff:"]="13*1,14*1,16*1,17*1"; +w["1"]="6*3,9*8,10*5,13*6,14*6,15*4,16*5,17*5,18*4,19*6,20*4,21*4,23*4,24*3,25*2,27*3,28*5,29*5,30*3,32*2,33*2,34*3,35*3,37*8,40*3,41*2,42*3,45*3,46*5,47*5,49*3,50*2,51*4,52*2,54*2,55*2,56*3,57*3,59*3,60*3,61*3,65*3,66*5,67*5,68*3,69*2,70*2,71*2,72*3,73*3,74*2,75*3,76*3,77*4,78*2,79*4,81*2,82*2,83*2,84*2,85*10,86*3,93*3,94*5,95*5,96*3,97*2,98*2,99*3,100*2,101*3,102*3,103*2,104*2,105*4,106*2,107*2,108*2,109*2,110*2,111*3,112*3,113*3,114*5,115*4,116*2,117*6,118*4,119*2,120*2,121*2,123*2,124*2,125*2,126*3,127*3,129*3,130*3,142*3,143*3,144*3,145*15,146*5,147*11,148*15,149*7,152*8,153*11,162*3,163*3,164*5,165*4,166*6,167*6,169*3,181*1,182*7,185*27,186*1,188*2,193*3"; +w["1-4"]="164*1"; +w["1."]="149*1"; +w["10"]="170*1,171*1,185*1,186*1"; +w["100"]="185*1"; +w["100."]="185*1"; +w["1024"]="181*1"; +w["11"]="186*1"; +w["12"]="186*1"; +w["120"]="52*1"; +w["13"]="186*1"; +w["14"]="18*1,186*2"; +w["14:"]="18*1"; +w["15"]="18*1,186*2"; +w["15:"]="18*1"; +w["16"]="91*3,181*1,182*1,185*1"; +w["16-bit"]="91*3"; +w["1:"]="19*1"; +w["1byte"]="185*2"; +w["1e"]="136*2"; +w["2"]="1*1,9*1,18*1,19*1,23*1,24*1,25*1,37*3,79*1,117*2,118*2,129*1,131*1,143*1,144*1,145*1,147*1,148*4,149*1,152*1,153*1,166*1,167*1,169*2,181*1,182*4,185*15,186*1,193*2"; +w["20"]="185*1"; +w["2013"]="170*1"; +w["2014"]="170*1,171*3"; +w["24"]="182*1,185*1"; +w["256"]="167*1"; +w["28"]="170*1"; +w["28.01.2014"]="170*1"; +w["2^max_read"]="182*1"; +w["2^max_writ"]="182*1"; +w["3"]="1*2,21*1,117*2,118*2,131*1,132*4,145*2,147*1,148*2,149*1,152*1,153*1,169*1,186*1"; +w["300ms"]="6*1"; +w["300ms."]="6*1"; +w["32"]="38*1,51*1,52*1,68*1,70*1,173*1"; +w["32-bit"]="38*1,51*1,68*1,70*1,173*1"; +w["32.120"]="52*1"; +w["3f"]="136*2"; +w["3rd"]="148*1"; +w["4"]="15*2,20*1,23*2,50*1,75*1,76*1,79*1,83*1,84*1,104*1,107*1,111*1,112*2,113*2,114*2,115*2,116*1,117*1,119*1,120*1,125*1,129*1,132*2,142*1,145*1,147*1,148*1,152*1,153*1,164*1,165*1,166*1,167*1,169*2,181*6,182*3,185*17,186*1"; +w["4-bit"]="23*1"; +w["42197a"]="170*1"; +w["42197ax"]="171*1"; +w["42197ax-mcu-10"]="171*1"; +w["42197b"]="170*1"; +w["5"]="75*1,76*1,148*1,169*1,182*1,185*1,186*1"; +w["50"]="185*1"; +w["508"]="18*1"; +w["512"]="166*1"; +w["6"]="19*1,148*2"; +w["6:"]="19*1"; +w["7"]="19*1,148*2,186*1,192*1"; +w["74"]="136*2"; +w["7:"]="19*1"; +w["8"]="18*1,77*1,91*3,114*1,174*1,182*1,185*1,186*1"; +w["8-bit"]="91*3,174*1"; +w["8..0"]="18*1"; +w["8..0:"]="18*1"; +w["9"]="18*1,169*1,186*2"; +w["94"]="136*1"; +w["9:"]="18*1"; +w[":"]="23*2,24*1,25*1"; +w["_byte"]="185*1"; +w["abil"]="139*1"; +w["about"]="6*1"; +w["acc"]="30*1,181*1,182*1,193*1"; +w["access"]="0*3,6*1,7*1,63*3,75*1,76*1,79*1,89*1,91*39,104*1,113*4,114*4,115*4,131*7,132*13,133*12,135*1,136*1,137*1,139*2,181*11,185*1"; +w["access."]="89*1,113*3,114*3,115*3,136*1"; +w["accessed."]="131*1,132*3,133*2"; +w["accord"]="9*1,23*1,111*1,148*2"; +w["accur"]="172*1"; +w["accuraci"]="171*1"; +w["achiev"]="15*1"; +w["action"]="49*1,72*1,73*1"; +w["activ"]="52*1,62*1,64*1,68*43,69*1,70*1,87*1,88*2,89*44,92*1,96*43,97*1,98*1,134*1,135*2,136*45,138*1,140*6,182*1,185*3"; +w["actual"]="15*1,60*1"; +w["add"]="139*1"; +w["addit"]="156*1,157*1,175*1"; +w["addr"]="185*3"; +w["address"]="28*2,29*2,46*2,47*2,66*2,67*2,75*2,76*2,79*3,91*9,94*2,95*2,101*1,104*3,106*1,107*1,111*5,112*7,113*3,114*3,115*3,116*3,117*3,119*3,120*3,129*1,131*1,132*5,133*13,139*1,140*9,141*1,142*54,145*1,153*1,160*3,165*4,166*2,167*2,172*1,173*2,175*1,180*1,181*19,182*3,185*38"; +w["address."]="75*1,139*1"; +w["adjust"]="139*1,185*1"; +w["advanc"]="171*100,172*1"; +w["advis"]="171*1"; +w["after"]="69*1,97*1,99*1,138*4,148*1,159*1,168*1,182*3,185*2"; +w["afterward"]="138*1"; +w["afterwards."]="138*1"; +w["again"]="89*1,136*1"; +w["again."]="89*1,136*2"; +w["aka"]="62*1"; +w["aka:"]="62*1"; +w["al"]="136*1"; +w["align"]="132*1,140*3,181*1"; +w["all"]="1*6,22*1,28*1,29*1,37*3,46*1,47*1,62*2,63*9,66*1,67*1,79*2,91*6,92*1,94*1,95*1,121*47,139*3,140*9,160*3,171*1,172*2,173*1,174*1,175*2,180*1,192*1"; +w["all:"]="139*1"; +w["alloc"]="117*1"; +w["allow"]="131*1,185*1"; +w["allowed."]="131*1"; +w["along"]="18*1"; +w["also"]="1*1,79*1,89*1,91*1,136*1,140*1,160*1,169*1,175*2,180*1,186*1"; +w["alter"]="114*1,136*1"; +w["altern"]="59*1"; +w["although"]="172*1,175*1"; +w["alway"]="109*1,131*1"; +w["amount"]="131*1"; +w["analog"]="63*3"; +w["ani"]="0*1,37*1,51*1,52*1,62*2,70*1,89*1,98*1,104*1,111*1,115*1,131*2,132*2,133*10,135*1,136*1,171*5"; +w["anoth"]="69*1,97*1"; +w["api"]="7*1"; +w["app"]="136*1,140*3"; +w["appear"]="59*1"; +w["appl_base_addr"]="133*2,185*1"; +w["appli"]="51*3,61*1,63*6,68*1,89*1,91*3,96*1,112*1,113*1,114*3,115*2,116*1,119*1,120*1,132*1,182*1"; +w["applic"]="111*1,112*1,133*2,140*9,165*1,171*2,175*1,185*4"; +w["applications."]="185*1"; +w["applicaton"]="111*1"; +w["appnot"]="52*1"; +w["area"]="79*1,131*1,132*1,139*1,165*1"; +w["aris"]="171*1"; +w["arm"]="0*1,2*1,3*4,5*41,7*1,22*1,171*2,192*1"; +w["arm-bas"]="22*1,192*1"; +w["arm-target"]="3*1,5*41"; +w["arm."]="2*1"; +w["armjtag"]="186*3"; +w["array"]="135*1"; +w["ascend"]="173*1"; +w["ase"]="3*1"; +w["ask"]="140*6"; +w["asleep"]="60*1,63*3"; +w["assum"]="139*1,171*1"; +w["asynchron"]="22*1,105*1,115*2"; +w["asynchronously."]="105*1"; +w["ate"]="171*1"; +w["atmegaxxxrfr2"]="132*1"; +w["atmel"]="0*4,1*59,2*1,3*1,4*1,5*1,6*1,7*1,8*1,9*1,10*1,11*1,12*1,13*1,14*1,15*1,16*1,17*1,18*1,19*1,20*1,21*1,22*1,23*1,24*1,25*1,26*1,27*1,28*1,29*1,30*1,31*1,32*1,33*1,34*1,35*1,36*1,37*1,38*1,39*1,40*1,41*1,42*1,43*1,44*1,45*1,46*1,47*1,48*1,49*1,50*1,51*2,52*1,53*1,54*1,55*1,56*1,57*1,58*1,59*1,60*1,61*1,62*1,63*1,64*1,65*1,66*1,67*1,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,80*1,81*1,82*1,83*1,84*1,85*1,86*1,87*1,88*1,89*1,90*1,91*1,92*1,93*1,94*1,95*1,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,122*1,123*1,124*1,125*1,126*1,127*1,128*1,129*1,130*1,131*1,132*1,133*1,134*1,135*1,136*1,137*1,138*1,139*1,140*1,141*1,142*1,143*1,144*1,145*1,146*1,147*1,148*1,149*1,150*1,151*1,152*1,153*1,154*1,155*1,156*1,157*1,158*1,159*1,160*1,161*1,162*1,163*1,164*1,165*1,166*1,167*1,168*1,169*1,170*1,171*167,172*5,173*2,174*1,175*2,176*1,177*1,178*1,179*2,180*1,181*1,182*1,183*1,184*1,185*1,186*1,187*1,188*1,189*1,190*1,191*1,192*1,193*1"; +w["atmel-ic"]="1*1"; +w["atmel."]="51*1"; +w["attach"]="92*1,99*42,109*1,136*1,138*2,140*6"; +w["attachin"]="89*1"; +w["attempt"]="131*1,132*7"; +w["author"]="171*1"; +w["auto"]="51*1,62*2,140*9"; +w["auto-detect"]="62*2"; +w["auto-eras"]="140*9"; +w["automat"]="109*1,111*1,133*3,148*1,182*1"; +w["automot"]="171*1"; +w["avail"]="19*1,20*1,24*1,25*1,36*1,37*1,43*3,132*1,140*6,185*1,192*1"; +w["avr"]="0*1,1*4,3*7,4*44,22*54,23*44,24*44,25*43,36*1,37*1,38*1,52*1,90*1,111*1,112*1,117*1,118*1,133*53,140*9,145*1,171*3,173*1,174*1,175*53,176*51,177*1,180*1,183*1,185*34"; +w["avr-specif"]="4*3"; +w["avr-target"]="3*1,4*41"; +w["avr053"]="52*1"; +w["avr069"]="175*1"; +w["avr069:"]="175*1"; +w["avr1606"]="52*1"; +w["avr32"]="65*1,91*1,171*1,173*51,191*36"; +w["avr32_awire_bas"]="91*1,182*1"; +w["avr32_cmd_activate_phys"]="68*1,91*1"; +w["avr32_cmd_deactivate_phys"]="69*1,91*1"; +w["avr32_cmd_eras"]="71*1,91*1"; +w["avr32_cmd_erase_sect"]="79*1,91*1"; +w["avr32_cmd_get"]="91*1"; +w["avr32_cmd_get_id"]="70*1,91*1"; +w["avr32_cmd_halt"]="72*1,91*1"; +w["avr32_cmd_is_protect"]="78*1,91*1"; +w["avr32_cmd_queri"]="91*1"; +w["avr32_cmd_read"]="75*1,91*1"; +w["avr32_cmd_reset"]="73*1,91*1"; +w["avr32_cmd_set"]="91*1"; +w["avr32_cmd_step"]="74*1,91*1"; +w["avr32_cmd_tap"]="77*1,91*1"; +w["avr32_cmd_writ"]="76*1,91*1"; +w["avr32_ctxt_devic"]="91*1,182*1"; +w["avr32_ctxt_phys"]="91*1,182*1"; +w["avr32_ctxt_sess"]="91*1,182*1"; +w["avr32_ctxt_usb"]="91*1,182*1"; +w["avr32_failure_awire_crc"]="91*1"; +w["avr32_failure_awire_error_respons"]="91*1"; +w["avr32_failure_awire_overflow"]="91*1"; +w["avr32_failure_awire_rw_status"]="91*1"; +w["avr32_failure_awire_set_baud_error"]="91*1"; +w["avr32_failure_awire_tun"]="91*1"; +w["avr32_failure_awm_error"]="91*1"; +w["avr32_failure_bad_valu"]="91*1"; +w["avr32_failure_config_error"]="91*1"; +w["avr32_failure_cpu_debug_mode_timeout"]="91*1"; +w["avr32_failure_cpu_dirty_timeout"]="91*1"; +w["avr32_failure_cpu_mod"]="91*1"; +w["avr32_failure_erase_error"]="91*1"; +w["avr32_failure_erase_timeout"]="91*1"; +w["avr32_failure_flashready_timeout"]="91*1"; +w["avr32_failure_hardware_error"]="91*1"; +w["avr32_failure_illegal_st"]="91*1"; +w["avr32_failure_internal_response_error"]="91*1"; +w["avr32_failure_invalid_address"]="91*1"; +w["avr32_failure_invalid_clock_spe"]="91*1"; +w["avr32_failure_invalid_data"]="91*1"; +w["avr32_failure_invalid_emulator_mod"]="91*1"; +w["avr32_failure_invalid_memtyp"]="91*1"; +w["avr32_failure_invalid_physical_mod"]="91*1"; +w["avr32_failure_invalid_s"]="91*1"; +w["avr32_failure_jtagm_error"]="91*1"; +w["avr32_failure_jtagm_init_error"]="91*1"; +w["avr32_failure_jtagm_timeout"]="91*1"; +w["avr32_failure_jtagm_was_busi"]="91*1"; +w["avr32_failure_length"]="91*1"; +w["avr32_failure_lock"]="91*1"; +w["avr32_failure_nack"]="91*1"; +w["avr32_failure_no_contact"]="91*1"; +w["avr32_failure_no_device_found"]="91*1"; +w["avr32_failure_no_target_pow"]="91*1"; +w["avr32_failure_not_impl"]="91*1"; +w["avr32_failure_not_support"]="91*1"; +w["avr32_failure_ok"]="91*1"; +w["avr32_failure_prog"]="91*1"; +w["avr32_failure_read_busi"]="91*1"; +w["avr32_failure_read_error"]="91*1"; +w["avr32_failure_read_short"]="91*1"; +w["avr32_failure_receive_length"]="91*1"; +w["avr32_failure_receive_sync"]="91*1"; +w["avr32_failure_receive_timeout"]="91*1"; +w["avr32_failure_step_timeout"]="91*1"; +w["avr32_failure_transmit_overflow"]="91*1"; +w["avr32_failure_transmit_timeout"]="91*1"; +w["avr32_failure_unknown"]="91*1"; +w["avr32_failure_unsupported_hardwar"]="91*1"; +w["avr32_failure_write_busi"]="91*1"; +w["avr32_failure_write_error"]="91*1"; +w["avr32_flash_ctrl_bas"]="91*1,182*1"; +w["avr32_flash_pag"]="91*1,182*1"; +w["avr32_flash_pagebyt"]="91*1,182*1"; +w["avr32_memtype_block"]="91*1,181*1"; +w["avr32_memtype_byt"]="91*1,181*1"; +w["avr32_memtype_half_word"]="91*1,181*1"; +w["avr32_memtype_internal_flash"]="91*1,181*1"; +w["avr32_memtype_memory_servic"]="91*1,181*1"; +w["avr32_memtype_nexus"]="91*1,181*1"; +w["avr32_memtype_regfil"]="91*1,181*1"; +w["avr32_memtype_sab"]="91*1,181*1"; +w["avr32_memtype_sysreg"]="91*1,181*1"; +w["avr32_memtype_user_pag"]="91*1,181*1"; +w["avr32_phy_aw_maxbaud"]="91*1,182*1"; +w["avr32_phy_awire_baud"]="91*1"; +w["avr32_phy_awire_vers"]="91*1"; +w["avr32_phy_daisi"]="91*1,182*1"; +w["avr32_phy_ext_reset"]="91*1,182*1"; +w["avr32_phy_jtag_clock"]="182*1"; +w["avr32_phy_phys"]="91*1,182*1"; +w["avr32_phyl_jtag_clock"]="91*1"; +w["avr32_physical_interface_awir"]="91*1"; +w["avr32_physical_interface_jtag"]="91*1"; +w["avr32_physical_interface_non"]="91*1"; +w["avr32_query_command"]="91*1,191*1"; +w["avr32_query_command_vers"]="91*1"; +w["avr32_query_configur"]="91*1,191*1"; +w["avr32_query_read_memtyp"]="91*1,191*1"; +w["avr32_query_write_memtyp"]="91*1,191*1"; +w["avr32_reset_domain"]="91*1,182*1"; +w["avr32_rsp_data"]="85*2,91*1"; +w["avr32_rsp_fail"]="86*1,91*1"; +w["avr32_rsp_id"]="83*1,91*1"; +w["avr32_rsp_list"]="82*1,91*1"; +w["avr32_rsp_ok"]="81*1,91*1"; +w["avr32_rsp_pc"]="84*1,91*1"; +w["avr32_sess_run_l"]="91*1,182*1"; +w["avr32_tap_dr"]="77*1,91*1"; +w["avr32_tap_ir"]="77*1,91*1"; +w["avr32_usb_max_read"]="91*1,182*1"; +w["avr32_usb_max_writ"]="91*1,182*1"; +w["avr32gener"]="38*1,91*46,173*3"; +w["avr32genericcommand"]="91*1"; +w["avr32genericdevicecontext"]="91*1"; +w["avr32genericfailurecod"]="91*1"; +w["avr32genericmemorytyp"]="91*1"; +w["avr32genericphysicalcontextparamet"]="91*1"; +w["avr32genericphysicalinterfac"]="91*1"; +w["avr32genericquerycontext"]="91*1"; +w["avr32genericrespons"]="91*1"; +w["avr32genericsessioncontextparamet"]="91*1"; +w["avr32genericsetgetcontext"]="91*1"; +w["avr32genericusbcontextparamet"]="91*1"; +w["avr32tapcommand"]="91*1"; +w["avr8"]="93*1,135*1,140*1,171*1,174*52,184*36"; +w["avr8_break_cause_program"]="140*1"; +w["avr8_break_cause_unknown"]="140*1"; +w["avr8_config_funct"]="140*1,185*1"; +w["avr8_config_vari"]="140*1,185*1"; +w["avr8_ctxt_config"]="140*1,185*1"; +w["avr8_ctxt_devic"]="140*1,185*1"; +w["avr8_ctxt_opt"]="140*1,185*1"; +w["avr8_ctxt_phys"]="140*1,185*1"; +w["avr8_ctxt_sess"]="140*1,185*1"; +w["avr8_ctxt_test"]="185*1"; +w["avr8_failure_clock_error"]="140*1"; +w["avr8_failure_collis"]="140*1"; +w["avr8_failure_crc_failur"]="140*1"; +w["avr8_failure_cs_error"]="140*1"; +w["avr8_failure_dw_phy_error"]="140*1"; +w["avr8_failure_eb_error"]="140*1"; +w["avr8_failure_illegal_breakpoint"]="140*1"; +w["avr8_failure_illegal_id"]="140*1"; +w["avr8_failure_illegal_memory_rang"]="131*1,132*1,140*1"; +w["avr8_failure_illegal_ocd_status"]="140*1"; +w["avr8_failure_illegal_st"]="131*1,132*1,140*1"; +w["avr8_failure_illegal_valu"]="140*1"; +w["avr8_failure_invalid_address"]="131*4,132*1,140*1"; +w["avr8_failure_invalid_align"]="132*1,140*1"; +w["avr8_failure_invalid_clock_spe"]="140*1"; +w["avr8_failure_invalid_config"]="140*1"; +w["avr8_failure_invalid_memtyp"]="140*1"; +w["avr8_failure_invalid_physical_st"]="140*1"; +w["avr8_failure_invalid_s"]="131*3,132*1,140*1"; +w["avr8_failure_jtag_bit_banger_timeout"]="140*1"; +w["avr8_failure_jtag_error"]="140*1"; +w["avr8_failure_jtagm_error"]="140*1"; +w["avr8_failure_jtagm_init_error"]="140*1"; +w["avr8_failure_jtagm_timeout"]="140*1"; +w["avr8_failure_jtagm_vers"]="140*1"; +w["avr8_failure_no_device_found"]="140*1"; +w["avr8_failure_no_ocd_control"]="140*1"; +w["avr8_failure_no_target_pow"]="140*1"; +w["avr8_failure_not_attach"]="140*1"; +w["avr8_failure_not_impl"]="140*1"; +w["avr8_failure_not_support"]="140*1"; +w["avr8_failure_nvm_dis"]="140*1"; +w["avr8_failure_nvm_en"]="140*1"; +w["avr8_failure_ocd_lock"]="140*1"; +w["avr8_failure_ok"]="140*1"; +w["avr8_failure_parity_error"]="140*1"; +w["avr8_failure_pc_read_fail"]="140*1"; +w["avr8_failure_pdi_en"]="140*1"; +w["avr8_failure_pdi_timeout"]="140*1"; +w["avr8_failure_read_error"]="140*1"; +w["avr8_failure_register_read_fail"]="140*1"; +w["avr8_failure_timeout"]="140*1"; +w["avr8_failure_too_many_breakpoint"]="140*1"; +w["avr8_failure_unknown"]="140*1"; +w["avr8_failure_write_error"]="140*1"; +w["avr8_failure_write_timeout"]="140*1"; +w["avr8_func_debug"]="140*1,185*1"; +w["avr8_func_non"]="140*1,185*1"; +w["avr8_func_program"]="140*1,185*1"; +w["avr8_hwbp_prog_bp"]="140*1"; +w["avr8_opt_disable_dbp"]="140*1,185*1"; +w["avr8_opt_enable_idr"]="140*1,185*1"; +w["avr8_opt_poll_int"]="140*1,185*1"; +w["avr8_opt_run_tim"]="140*1,185*1"; +w["avr8_phy_dw_clk_div"]="140*1,185*1"; +w["avr8_phy_interfac"]="140*1"; +w["avr8_phy_intf_dw"]="140*1,185*1"; +w["avr8_phy_intf_jtag"]="140*1,185*1"; +w["avr8_phy_intf_non"]="140*1,185*1"; +w["avr8_phy_intf_pdi"]="140*1,185*1"; +w["avr8_phy_jtag_daisi"]="140*1,185*1"; +w["avr8_phy_mega_dbg_clk"]="140*1,185*1"; +w["avr8_phy_mega_prg_clk"]="140*1,185*1"; +w["avr8_phy_phys"]="185*1"; +w["avr8_phy_xm_jtag_clk"]="140*1,185*1"; +w["avr8_phy_xm_pdi_clk"]="140*1,185*1"; +w["avr8_query_command"]="140*1,184*1"; +w["avr8_query_configur"]="140*1,184*1"; +w["avr8_query_read_memtyp"]="140*1,184*1"; +w["avr8_query_write_memtyp"]="140*1,184*1"; +w["avr8_rsp_list"]="124*1"; +w["avr8_sess_main_pc"]="140*1,185*1"; +w["avr8_test_tgt_run"]="140*1,185*1"; +w["avr8_variant_loopback"]="140*1,185*1"; +w["avr8_variant_megaocd"]="140*1,185*1"; +w["avr8_variant_non"]="140*1,185*1"; +w["avr8_variant_tinyocd"]="140*1,185*1"; +w["avr8_variant_xmega"]="140*1,185*1"; +w["avr8gener"]="38*1,140*46,174*1"; +w["avr8genericcommand"]="140*1"; +w["avr8genericconfigcontextparamet"]="140*1"; +w["avr8genericconfigtestparamet"]="140*1"; +w["avr8genericev"]="140*1"; +w["avr8genericfailurecod"]="140*1"; +w["avr8genericfunctionvalu"]="140*1"; +w["avr8genericmegabreakcaus"]="140*1"; +w["avr8genericmegabreakpointtyp"]="140*1"; +w["avr8genericmemtyp"]="140*1"; +w["avr8genericoptionscontextparamet"]="140*1"; +w["avr8genericphysicalcontextparamet"]="140*1"; +w["avr8genericphysicalinterfac"]="140*1"; +w["avr8genericquerycontext"]="140*1"; +w["avr8genericrespons"]="140*1"; +w["avr8genericsessioncontextparamet"]="140*1"; +w["avr8genericsetgetcontext"]="140*1"; +w["avr8genericvariantvalu"]="140*1"; +w["avr8genericxmegaerasemod"]="140*1"; +w["avr_cmd"]="3*1,4*1,22*1,23*12"; +w["avr_evt"]="3*1,4*1,22*1,25*13"; +w["avr_rsp"]="3*1,4*1,22*1,23*1,24*13"; +w["avrisp"]="38*2,160*1,175*1,180*1"; +w["avrjtag"]="186*3"; +w["aw"]="186*3"; +w["awak"]="60*1"; +w["awar"]="136*1"; +w["awir"]="1*4,38*1,70*1,78*1,88*3,90*1,91*30,182*3"; +w["awire_baud_max"]="88*1"; +w["awire_baud_max:"]="88*1"; +w["awireid"]="68*1"; +w["b"]="3*1,132*5,182*1"; +w["back"]="175*1"; +w["bad"]="91*3,140*6"; +w["banger"]="140*3"; +w["base"]="0*1,1*54,2*1,3*1,4*1,5*1,6*1,7*1,8*1,9*1,10*1,11*1,12*1,13*1,14*1,15*1,16*1,17*1,18*1,19*1,20*1,21*1,22*2,23*1,24*1,25*1,26*1,27*1,28*1,29*1,30*1,31*1,32*1,33*1,34*1,35*1,36*2,37*1,38*2,39*1,40*1,41*1,42*1,43*1,44*1,45*1,46*1,47*1,48*1,49*1,50*1,51*1,52*1,53*1,54*1,55*1,56*1,57*1,58*1,59*1,60*1,61*1,62*1,63*1,64*1,65*1,66*1,67*1,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,80*1,81*1,82*1,83*1,84*1,85*1,86*1,87*1,88*1,89*1,90*1,91*7,92*1,93*1,94*1,95*1,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,122*1,123*1,124*1,125*1,126*1,127*1,128*1,129*1,130*1,131*1,132*1,133*14,134*1,135*1,136*1,137*1,138*1,139*2,140*1,141*1,142*1,143*1,144*1,145*1,146*1,147*1,148*1,149*1,150*1,151*1,152*1,153*1,154*1,155*1,156*1,157*1,158*1,159*1,160*1,161*1,162*1,163*1,164*1,165*1,166*1,167*1,168*1,169*1,170*1,171*51,172*1,173*1,174*1,175*2,176*1,177*1,178*1,179*2,180*2,181*1,182*3,183*1,184*1,185*4,186*1,187*1,188*1,189*1,190*1,191*1,192*2,193*1"; +w["basic"]="63*3,186*3"; +w["baud"]="15*57,18*1,19*1,88*1,91*9,140*3,141*2,143*53,144*53,159*1,160*9,182*2,192*1"; +w["baud-rat"]="15*1"; +w["be"]="38*1,131*1,132*1,135*1"; +w["becaus"]="148*1"; +w["been"]="18*1,19*1,59*1,61*2,105*1,109*1,140*3,148*1,171*1"; +w["befor"]="24*1,62*1,79*1,88*2,111*1,131*1,133*3,135*2,182*3,185*3"; +w["behaviour"]="37*1,109*1"; +w["behaviour."]="37*1"; +w["bei"]="37*1"; +w["belong"]="2*1"; +w["below"]="38*1,185*1"; +w["below."]="175*1"; +w["beta"]="170*1"; +w["between"]="0*1,1*1,145*1"; +w["bidirect"]="0*1"; +w["big"]="173*1,180*1"; +w["bigger"]="148*1"; +w["bit"]="18*4,19*3,23*1,38*1,51*1,68*1,70*1,73*1,77*5,78*1,91*15,114*1,140*9,148*9,149*2,154*1,155*1,160*6,165*1,173*1,174*1,182*2,185*3"; +w["bit."]="148*1"; +w["ble"]="160*1"; +w["block"]="91*6,181*1,182*1"; +w["board"]="0*1,1*5,3*2,9*1,10*1,172*1,178*1"; +w["board."]="1*1"; +w["boolean"]="79*1"; +w["boot"]="101*1,111*2,112*1,133*2,140*12,185*4"; +w["boot_base_addr"]="133*2,185*1"; +w["boot_byt"]="185*1"; +w["boot_section_start"]="185*2"; +w["both"]="77*1"; +w["break"]="99*2,101*1,102*1,104*1,105*1,109*1,117*2,119*1,128*1,129*47,138*1,139*1,140*12,185*1"; +w["breakpoint"]="92*5,104*3,117*51,118*51,119*48,120*48,121*47,129*1,131*2,132*1,139*6,140*21"; +w["breakpoint."]="104*1"; +w["breakpoints."]="117*2,118*2,139*1,185*1"; +w["bsi"]="147*1,148*3"; +w["buffer"]="18*1,19*1,20*54,22*1,91*3,148*1,153*1,192*1"; +w["buffer."]="148*1"; +w["build"]="15*1,63*3,193*2"; +w["bulk"]="0*1"; +w["bus"]="91*3"; +w["busi"]="91*12,160*3,171*1"; +w["but"]="59*1,62*1,70*1,98*1,150*1,151*1,154*1,155*1,156*1,157*1,171*1,182*1"; +w["byte"]="6*3,9*12,10*7,13*6,14*6,15*6,16*5,17*5,18*8,19*8,20*5,21*5,23*7,24*6,25*5,27*3,28*8,29*7,30*3,32*2,33*3,34*4,35*3,37*17,40*3,41*3,42*3,43*3,45*3,46*8,47*7,49*2,50*3,51*3,52*2,54*2,55*3,56*4,57*3,59*3,60*3,61*3,65*3,66*8,67*7,68*3,69*2,70*2,71*2,72*3,73*3,74*2,75*7,76*8,77*5,78*2,79*6,81*2,82*3,83*3,84*3,85*7,86*3,91*6,93*3,94*8,95*7,96*3,97*2,98*2,99*3,100*2,101*3,102*3,103*2,104*3,105*4,106*2,107*3,108*2,109*2,110*2,111*5,112*7,113*8,114*10,115*10,116*4,117*6,118*3,119*4,120*4,121*2,123*2,124*3,125*3,126*4,127*3,129*5,130*3,131*7,132*6,133*10,140*6,142*4,143*4,144*4,145*20,146*5,147*13,148*24,149*10,152*11,153*17,156*1,157*2,160*12,162*3,163*3,164*5,165*5,166*9,167*8,173*3,180*1,181*18,182*15,184*4,185*85,187*1,188*2,189*1,190*3,191*4,193*5"; +w["byte."]="173*1"; +w["byte:"]="145*1,148*1"; +w["bytedelay"]="145*2"; +w["bytedelay."]="145*1"; +w["bytes."]="75*1,76*1"; +w["c"]="132*6,171*1"; +w["c0"]="136*2"; +w["cach"]="70*1,98*1,136*1"; +w["cached."]="89*1"; +w["calcul"]="112*1,139*1,140*3"; +w["calibr"]="48*1,52*38,63*3,133*1,140*6"; +w["call"]="7*1,15*1,27*1,28*2,29*2,40*1,45*1,46*2,47*2,52*1,65*1,66*2,67*2,75*1,76*1,79*1,88*2,89*1,93*1,94*2,95*2,113*1,114*1,115*1,133*12,135*2,136*1,175*1"; +w["called."]="78*1"; +w["calls."]="175*1"; +w["cannot"]="104*1"; +w["capabl"]="1*3,27*1,36*1,40*1,43*3,45*1,63*3,65*1,89*1,91*3,93*1,136*1,140*3"; +w["captur"]="3*1,14*53,15*1,16*1,17*1,18*1,77*1,192*4"; +w["capture_off"]="186*1"; +w["capture_uart"]="186*1"; +w["cas"]="59*1"; +w["case"]="89*1,131*1,132*1,135*1,136*2,137*1,138*1,148*1"; +w["case."]="131*1,132*1,137*1"; +w["caus"]="110*1,129*1"; +w["cdc"]="0*2,1*2,186*3"; +w["ceas"]="49*1"; +w["ceil"]="182*1"; +w["chain"]="48*1,51*42,62*2,88*2,91*3,140*3,182*1,185*1"; +w["chang"]="135*1,171*1,172*1"; +w["channel."]="188*1"; +w["check"]="21*1,62*1,78*1,91*3"; +w["checksum"]="112*1"; +w["chip"]="1*2,71*1,111*2,140*6,141*1,147*52,165*1"; +w["chop"]="23*1"; +w["cleanup"]="37*1"; +w["clear"]="92*3,118*48,120*48,121*46,139*3,140*9,148*1,165*2"; +w["clear:"]="139*2"; +w["cleared."]="148*1"; +w["clock"]="52*1,63*3,78*2,88*1,91*6,135*2,140*18,143*1,144*1,159*1,182*1,185*6"; +w["cmd"]="24*1,39*1,40*41,44*3,45*41,46*41,47*41"; +w["cmd-rsp"]="24*1"; +w["cmd1"]="145*1,147*1,148*1,149*1,152*1,153*1"; +w["cmd2"]="145*1,147*1,148*1,152*1,153*1"; +w["cmd3"]="145*1,147*1,148*1,152*1,153*1"; +w["cmd4"]="145*1,147*1,152*1,153*1"; +w["cmd:"]="39*1,40*41,44*3,45*41,46*41,47*41"; +w["cmd_activate_phys"]="175*1,180*1"; +w["cmd_activate_physical."]="175*1,180*1"; +w["cmd_avr8_activate_phys"]="140*1"; +w["cmd_avr8_attach"]="99*1,140*1"; +w["cmd_avr8_crc"]="112*1,140*1"; +w["cmd_avr8_deactivate_phys"]="97*1,140*1"; +w["cmd_avr8_detach"]="100*1,140*1"; +w["cmd_avr8_disable_debugwir"]="110*1,140*1"; +w["cmd_avr8_eras"]="111*1,140*1"; +w["cmd_avr8_get"]="140*1"; +w["cmd_avr8_get_id"]="98*1,140*1"; +w["cmd_avr8_hw_break_clear"]="140*1"; +w["cmd_avr8_hw_break_clr"]="118*1"; +w["cmd_avr8_hw_break_set"]="117*1,140*1"; +w["cmd_avr8_memory_read"]="113*1,114*1,140*1"; +w["cmd_avr8_memory_read_mask"]="140*1"; +w["cmd_avr8_memory_writ"]="115*1,140*1"; +w["cmd_avr8_page_eras"]="116*1,140*1"; +w["cmd_avr8_pc_read"]="106*1,140*1"; +w["cmd_avr8_pc_writ"]="107*1,140*1"; +w["cmd_avr8_prog_mode_ent"]="108*1,140*1"; +w["cmd_avr8_prog_mode_leav"]="109*1,140*1"; +w["cmd_avr8_queri"]="140*1"; +w["cmd_avr8_reset"]="101*1,140*1"; +w["cmd_avr8_run"]="103*1,140*1"; +w["cmd_avr8_run_to_address"]="104*1,140*1"; +w["cmd_avr8_set"]="140*1"; +w["cmd_avr8_step"]="105*1,140*1"; +w["cmd_avr8_stop"]="102*1,140*1"; +w["cmd_avr8_sw_break_clear"]="140*1"; +w["cmd_avr8_sw_break_clear_al"]="140*1"; +w["cmd_avr8_sw_break_set"]="140*1"; +w["cmd_avr8_sw_breakpoint_clr"]="120*1"; +w["cmd_avr8_sw_breakpoint_clr_al"]="121*1"; +w["cmd_avr8_sw_breakpoint_set"]="119*1"; +w["cmd_edbg_get"]="186*1"; +w["cmd_edbg_queri"]="186*1"; +w["cmd_edbg_set"]="186*1"; +w["cmd_end_sess"]="62*1"; +w["cmd_housekeeping_cal_osc"]="52*1,63*1"; +w["cmd_housekeeping_end_sess"]="49*1,63*1"; +w["cmd_housekeeping_fw_upgrad"]="50*1,63*1"; +w["cmd_housekeeping_get"]="63*1"; +w["cmd_housekeeping_jtag_detect"]="51*1,63*1"; +w["cmd_housekeeping_queri"]="63*1"; +w["cmd_housekeeping_set"]="63*1"; +w["cmd_housekeeping_start_sess"]="63*1,88*1,135*1,188*1"; +w["cmd_load_address"]="175*1"; +w["cmd_queri"]="43*1"; +w["cmd_start_sess"]="62*1"; +w["cmdexedelay"]="145*2"; +w["cmdexedelay."]="145*1"; +w["cmsis"]="0*4,1*1,2*47,3*47,24*1,171*1,177*53"; +w["cmsis-dap"]="0*4,1*1,2*47,3*47,24*1,171*1,177*53"; +w["co"]="1*1"; +w["code"]="13*1,14*1,16*1,17*1,34*1,35*2,37*1,42*2,43*3,52*1,56*2,57*2,85*1,86*2,89*1,91*1,126*1,127*2,131*1,132*1,135*1,136*1,137*1,140*4,160*1,169*3,186*4"; +w["code."]="56*1,135*1"; +w["codes."]="91*1,140*1,160*1,169*1,186*1"; +w["collis"]="140*3,168*1"; +w["com"]="0*3,1*2,172*1"; +w["combin"]="171*1"; +w["command"]="0*1,3*62,4*48,5*41,6*5,7*1,8*41,9*5,10*5,22*54,23*43,24*2,26*46,27*2,28*2,29*2,32*1,35*1,37*6,38*3,39*1,40*2,42*1,43*9,44*1,45*2,46*2,47*2,48*41,49*7,50*7,51*7,52*8,54*1,57*1,63*12,64*46,65*2,66*2,67*2,68*7,69*8,70*7,71*7,72*7,73*2,74*7,75*7,76*7,77*9,78*8,79*9,81*1,86*1,87*1,88*1,89*5,90*42,91*16,92*46,93*2,94*2,95*2,96*7,97*8,98*7,99*7,100*7,101*7,102*7,103*7,104*7,105*7,106*7,107*7,108*7,109*8,110*7,111*7,112*8,113*7,114*7,115*7,116*7,117*7,118*7,119*8,120*8,121*7,123*1,127*1,130*5,135*1,136*6,137*1,138*5,139*2,140*13,141*46,142*8,143*7,144*7,145*13,146*7,147*12,148*18,149*8,150*1,151*1,152*11,153*11,154*1,155*1,156*2,157*2,158*1,159*5,160*10,161*46,162*7,163*7,164*7,165*7,166*7,167*7,168*3,169*4,172*1,173*1,174*1,175*12,177*3,178*1,180*4,184*1,186*4,187*1,188*7,189*1,190*1,191*1,192*48"; +w["command."]="22*3,39*1,69*1,70*1,89*1,97*1,98*1,136*1,138*2,139*1,142*1,145*1,159*1,168*1,175*1"; +w["command_handl"]="190*1"; +w["commandpacket"]="23*1"; +w["commands."]="88*1,135*1,175*1,180*1"; +w["comment"]="170*1"; +w["commit"]="171*1"; +w["communic"]="22*3,36*1,50*1,139*1,171*1,172*1,175*3,176*51,180*1"; +w["complet"]="89*2,105*1,131*2,132*1,135*1,136*2,138*1,146*1,148*1,163*1,171*1,181*1"; +w["complete."]="131*1"; +w["compon"]="171*1,172*1"; +w["composit"]="0*1"; +w["comput"]="13*1"; +w["computer."]="13*1"; +w["con"]="79*1"; +w["condit"]="37*1"; +w["config"]="9*2,63*3,91*3,109*1,135*2,140*3"; +w["configid"]="9*2,10*1"; +w["configpacket"]="9*1"; +w["configur"]="3*2,8*2,9*54,10*49,38*2,87*1,88*43,89*1,91*3,133*12,134*1,135*44,136*1,138*1,140*18,165*1,178*1,182*1,184*1,186*6,191*1,192*1"; +w["confus"]="23*1"; +w["connect"]="0*1,69*1,89*2,91*3,97*1,136*2,140*3,145*1,171*2"; +w["consequenti"]="171*1"; +w["consist"]="0*1"; +w["constant"]="148*1"; +w["contact"]="68*1,96*1"; +w["contain"]="3*1,38*1,68*1,89*1,131*1,132*1,136*1,153*1,171*1"; +w["content"]="3*5,5*5,8*5,22*5,26*5,27*5,29*5,31*5,39*5,44*5,48*5,53*5,58*5,64*5,65*5,67*5,76*5,80*5,87*5,92*5,93*5,95*5,122*5,128*5,134*5,141*5,161*5,171*6,172*1,173*5,174*5,175*5,176*5,177*5,178*5,179*5,180*5,183*5,185*5,192*5"; +w["context"]="27*3,28*3,29*3,30*1,39*1,40*2,44*1,45*2,46*3,47*3,65*3,66*3,67*3,93*3,94*3,95*3,109*1,133*12,135*3,140*3,182*1,184*41,185*110,187*41,189*46,190*46,191*41,193*1"; +w["context."]="28*1,29*1,46*1,47*1,66*1,67*1,94*1,95*1"; +w["context:"]="133*12,185*108"; +w["contigu"]="79*1"; +w["continu"]="88*1,99*1,135*1,138*1,185*1"; +w["control"]="3*1,38*1,62*1,79*1,90*1,91*12,110*2,119*1,120*1,134*3,137*41,138*41,139*45,140*6,148*1,171*1,178*52,182*1,185*2"; +w["core"]="185*1"; +w["core."]="185*1"; +w["coresight"]="0*1"; +w["corpor"]="171*4"; +w["corporation."]="171*1"; +w["correct"]="133*12,135*1"; +w["could"]="59*1"; +w["count"]="9*1,10*1"; +w["counter"]="84*2,107*1,125*2,129*1,139*1,185*1"; +w["countries."]="171*2"; +w["cpu"]="91*9"; +w["crc"]="91*3,92*1,112*44,139*2,140*6"; +w["crc:"]="139*1"; +w["current"]="13*1,14*1,91*3,144*1"; +w["custom"]="0*1,1*1,3*1"; +w["cyc"]="110*1"; +w["d"]="132*2,148*1"; +w["daisi"]="88*2,91*3,140*3,182*1,185*1"; +w["damag"]="171*3"; +w["damages."]="171*1"; +w["dap"]="0*4,1*1,2*47,3*47,24*1,171*1,177*53"; +w["data"]="0*2,1*1,9*5,10*2,13*2,14*2,15*1,16*1,17*1,18*55,24*1,25*1,28*2,29*1,31*1,33*3,34*45,37*4,41*3,46*2,47*1,53*1,55*3,56*40,63*3,66*2,67*1,68*1,75*1,76*2,77*5,78*1,80*1,82*3,85*47,91*15,94*2,95*1,96*1,98*1,112*1,113*1,114*1,115*1,122*1,124*3,126*45,133*2,135*1,136*1,140*15,148*4,149*3,150*1,151*1,153*2,160*12,166*3,167*3,185*4,192*3"; +w["data."]="15*1"; +w["data_base_addr"]="133*1,185*1"; +w["datasheet"]="83*1"; +w["datatyp"]="9*2"; +w["date"]="43*3,170*1,190*1"; +w["dbg_en"]="186*3"; +w["de"]="69*1,97*1"; +w["de-activ"]="69*1,97*1"; +w["deactiv"]="64*1,69*41,87*1,89*42,92*1,97*41,109*1,134*1,136*44,137*2,175*1,180*1"; +w["deactivated."]="89*1,136*2,137*1"; +w["debounc"]="59*1"; +w["debug"]="0*4,1*6,22*1,30*1,38*3,87*1,90*42,91*6,99*1,100*1,109*2,116*1,131*6,132*4,133*12,134*1,135*1,136*1,138*43,139*1,140*9,172*1,173*1,174*1,185*3"; +w["debugg"]="0*1,1*2,69*1,90*1,97*1,109*1,172*1,185*1"; +w["debuggers."]="1*1"; +w["debugging."]="131*1,132*1"; +w["debugwir"]="1*2,38*1,92*1,110*49,111*1,117*1,118*1,131*42,136*1,140*15,183*1,185*37"; +w["decid"]="148*1"; +w["decod"]="37*2"; +w["default"]="13*1,14*1,89*1,136*1"; +w["defin"]="0*1,3*1,91*2,140*2,160*2,169*21,172*1,186*2"; +w["definit"]="28*1,29*1,39*47,43*41,44*1,63*41,91*46,140*49,160*46,169*46,173*1,174*1,175*1,176*1,178*1,180*1,186*46"; +w["delay"]="145*3,146*2,147*2,148*6"; +w["delay."]="148*1"; +w["demand"]="89*1,136*1"; +w["depend"]="9*1,36*1,73*1,75*1,76*1,96*1,131*1,132*1"; +w["deploy"]="135*1"; +w["deprec"]="101*1,102*1,105*3,185*1"; +w["des"]="109*1"; +w["describ"]="1*3,9*1,22*1,25*1,52*1,90*1,159*1,168*1,175*2,192*1"; +w["descript"]="3*1,4*1,6*2,9*3,10*2,13*2,14*2,15*2,16*2,17*2,18*2,19*2,20*2,21*2,23*2,24*2,25*2,27*1,28*1,29*1,30*1,32*1,33*1,34*1,35*1,38*1,40*1,41*1,42*1,45*1,46*1,47*1,49*1,50*1,51*1,52*1,54*1,55*1,56*1,57*1,59*1,60*1,61*1,65*1,66*1,67*1,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,81*1,82*1,83*1,84*1,85*2,86*1,93*1,94*1,95*1,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,123*1,124*1,125*1,126*1,127*1,129*1,130*1,142*2,143*2,144*2,145*2,146*2,147*2,148*3,149*2,152*2,153*2,159*1,162*2,163*2,164*2,165*3,166*2,167*2,168*1,171*1,181*1,182*1,184*1,185*4,187*1,188*1,189*1,190*1,191*1,193*1"; +w["destin"]="37*1"; +w["detach"]="92*1,100*41,136*1,138*1,140*3"; +w["detail"]="7*1,23*1,172*1"; +w["detect"]="48*1,51*43,62*4,63*3,68*1,89*1,96*1,135*1,136*1,140*3,168*1"; +w["detected."]="135*1"; +w["determin"]="148*1"; +w["develop"]="172*1"; +w["devic"]="0*2,1*8,6*2,7*1,10*1,18*1,22*2,30*1,38*1,51*4,63*9,68*2,70*1,73*2,78*1,79*1,83*3,89*4,90*1,91*9,96*1,113*1,114*1,115*1,131*1,132*3,133*1,135*4,136*5,140*21,148*3,153*1,160*6,173*1,174*1,175*1,180*2,182*3,185*96,192*1"; +w["device-specif"]="135*1"; +w["device."]="73*1,182*1"; +w["device:"]="135*1"; +w["devices."]="51*1"; +w["dgi"]="0*2"; +w["dgi."]="0*1"; +w["did"]="91*3,140*6,159*1"; +w["differ"]="1*1,91*2,131*1,140*2,148*3,160*2,169*2,186*2"; +w["direct"]="11*1,12*1,62*1,79*1,89*1,136*1,171*1"; +w["directly."]="62*1,79*1"; +w["disabl"]="18*2,19*2,30*6,89*1,92*1,110*42,136*1,140*6,185*1"; +w["disast"]="91*6,140*3"; +w["disaster."]="140*3"; +w["discard"]="91*3"; +w["disclaim"]="171*2"; +w["disclaimer:"]="171*1"; +w["disconnect"]="69*1,89*1,91*3,97*1,136*1,140*3"; +w["discov"]="27*1,38*1,40*1,45*1,65*1,93*1"; +w["discoveri"]="38*1,39*49,43*44,63*3,91*3,140*3,176*1,190*41"; +w["discovery_command_handl"]="43*1"; +w["discovery_failed_not_support"]="43*1"; +w["discovery_mnf_d"]="43*1"; +w["discovery_serial_numb"]="43*1"; +w["discovery_tool_nam"]="43*1"; +w["divid"]="140*3"; +w["divis"]="185*1"; +w["do"]="37*1,135*1"; +w["document"]="1*1,90*1,170*52,171*5,172*3"; +w["document."]="90*1"; +w["doe"]="0*1,51*1,56*1,111*1,131*1,137*1,171*1"; +w["domain"]="73*1,91*3,182*1"; +w["done"]="28*1,29*1,37*1,46*1,47*1,62*1,66*1,67*1,69*1,79*1,90*2,94*1,95*1,97*1,101*1,116*1,138*2"; +w["dor"]="22*1"; +w["down"]="0*1"; +w["dr"]="77*2"; +w["dummi"]="140*3"; +w["dure"]="68*1,78*1,88*1,89*1,96*1,109*1,115*1,116*1,131*4,132*3,135*2,136*2,138*1,140*3,185*1"; +w["dw"]="186*3"; +w["dwen"]="110*1"; +w["e"]="132*2,136*1,153*1,173*1,180*1"; +w["e.g."]="180*1"; +w["earlier"]="1*1"; +w["echo"]="37*1"; +w["edbg"]="0*53,1*55,2*1,3*12,4*1,5*1,6*2,7*1,8*44,9*2,10*1,11*37,12*37,13*1,14*1,15*1,16*1,17*1,18*1,19*1,20*1,21*1,22*1,23*2,24*2,25*2,26*1,27*2,28*1,29*1,30*1,31*1,32*1,33*1,34*1,35*1,36*2,37*2,38*3,39*1,40*1,41*1,42*1,43*1,44*1,45*1,46*1,47*1,48*1,49*1,50*1,51*1,52*1,53*1,54*1,55*1,56*1,57*1,58*1,59*1,60*1,61*1,62*1,63*1,64*1,65*1,66*1,67*1,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,80*1,81*1,82*1,83*1,84*1,85*1,86*1,87*1,88*1,89*1,90*1,91*1,92*1,93*1,94*1,95*1,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,122*1,123*1,124*1,125*1,126*1,127*1,128*1,129*1,130*1,131*1,132*1,133*1,134*1,135*1,136*1,137*1,138*1,139*1,140*1,141*1,142*1,143*1,144*1,145*1,146*1,147*1,148*3,149*1,150*1,151*1,152*1,153*1,154*1,155*1,156*1,157*1,158*1,159*1,160*1,161*1,162*1,163*1,164*1,165*1,166*1,167*1,168*1,169*1,170*1,171*152,172*6,173*1,174*1,175*3,176*1,177*1,178*55,179*3,180*3,181*1,182*1,183*1,184*1,185*1,186*7,187*37,188*1,189*1,190*1,191*1,192*1,193*1"; +w["edbg-b"]="3*1"; +w["edbg-bas"]="0*1,1*52,2*1,3*1,4*1,5*1,6*1,7*1,8*1,9*1,10*1,11*1,12*1,13*1,14*1,15*1,16*1,17*1,18*1,19*1,20*1,21*1,22*1,23*1,24*1,25*1,26*1,27*1,28*1,29*1,30*1,31*1,32*1,33*1,34*1,35*1,36*1,37*1,38*1,39*1,40*1,41*1,42*1,43*1,44*1,45*1,46*1,47*1,48*1,49*1,50*1,51*1,52*1,53*1,54*1,55*1,56*1,57*1,58*1,59*1,60*1,61*1,62*1,63*1,64*1,65*1,66*1,67*1,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,80*1,81*1,82*1,83*1,84*1,85*1,86*1,87*1,88*1,89*1,90*1,91*1,92*1,93*1,94*1,95*1,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,122*1,123*1,124*1,125*1,126*1,127*1,128*1,129*1,130*1,131*1,132*1,133*1,134*1,135*1,136*1,137*1,138*1,139*1,140*1,141*1,142*1,143*1,144*1,145*1,146*1,147*1,148*1,149*1,150*1,151*1,152*1,153*1,154*1,155*1,156*1,157*1,158*1,159*1,160*1,161*1,162*1,163*1,164*1,165*1,166*1,167*1,168*1,169*1,170*1,171*51,173*1,174*1,175*1,176*1,177*1,178*1,179*2,180*1,181*1,182*1,183*1,184*1,185*1,186*1,187*1,188*1,189*1,190*1,191*1,192*1,193*1"; +w["edbg-specif"]="3*1,8*41"; +w["edbg."]="0*2,38*1,172*1"; +w["edbg@atmel"]="172*1"; +w["edbg@atmel.com"]="172*1"; +w["edbg_config_board_nam"]="186*1"; +w["edbg_config_board_typ"]="186*1"; +w["edbg_config_dgi_gpio_map"]="186*1"; +w["edbg_config_extension_curr"]="186*1"; +w["edbg_config_extension_manufactur"]="186*1"; +w["edbg_config_extension_map"]="186*1"; +w["edbg_config_extension_max_voltag"]="186*1"; +w["edbg_config_extension_min_voltag"]="186*1"; +w["edbg_config_extension_product"]="186*1"; +w["edbg_config_extension_revis"]="186*1"; +w["edbg_config_extension_seri"]="186*1"; +w["edbg_config_extension_status"]="186*1"; + diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/index-2.js b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/index-2.js new file mode 100644 index 000000000..b929f20ac --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/index-2.js @@ -0,0 +1,850 @@ +//Auto generated index for searching by xsl-webhelpindexer for DocBook Webhelp.# Kasun Gajasinghe, University of Moratuwa +w["edbg_config_family_nam"]="186*1"; +w["edbg_config_interfac"]="186*1"; +w["edbg_config_kit_data"]="186*1"; +w["edbg_config_manufacturer_nam"]="186*1"; +w["edbg_config_serial_numb"]="186*1"; +w["edbg_config_target_chipid"]="186*1"; +w["edbg_config_target_jtagid"]="186*1"; +w["edbg_config_target_nam"]="186*1"; +w["edbg_config_target_signatur"]="186*1"; +w["edbg_config_tv"]="186*1"; +w["edbg_config_usb_id"]="186*1"; +w["edbg_config_vers"]="186*1"; +w["edbg_config_version_minor"]="186*1"; +w["edbg_configtype_array"]="186*1"; +w["edbg_configtype_bit"]="186*1"; +w["edbg_configtype_char"]="186*1"; +w["edbg_configtype_short"]="186*1"; +w["edbg_configtype_str"]="186*1"; +w["edbg_configtype_word"]="186*1"; +w["edbg_context_config0"]="186*1"; +w["edbg_context_config1"]="186*1"; +w["edbg_context_control"]="186*1"; +w["edbg_control_ext_prog"]="186*1"; +w["edbg_control_led_usag"]="186*1"; +w["edbg_control_target_pow"]="186*1"; +w["edbg_ctrl"]="38*1"; +w["edbg_ctrl_ext_prog"]="30*1"; +w["edbg_ctrl_led_usag"]="30*1"; +w["edbg_ctrl_target_pow"]="30*1"; +w["edbg_ctxt_ctrl"]="30*1"; +w["edbg_failed_flash_writ"]="186*1"; +w["edbg_failed_illegal_act"]="186*1"; +w["edbg_failed_illegal_flag"]="186*1"; +w["edbg_failed_illegal_frequ"]="186*1"; +w["edbg_failed_illegal_gpio_mod"]="186*1"; +w["edbg_failed_illegal_gpio_pin"]="186*1"; +w["edbg_failed_illegal_interv"]="186*1"; +w["edbg_failed_illegal_max_threshold"]="186*1"; +w["edbg_failed_illegal_min_threshold"]="186*1"; +w["edbg_failed_illegal_mod"]="186*1"; +w["edbg_failed_illegal_voltage_rang"]="186*1"; +w["edbg_failed_not_support"]="186*1"; +w["edbg_failed_ok"]="186*1"; +w["edbg_failed_overflow"]="186*1"; +w["edbg_failed_unknown"]="186*1"; +w["edbg_get"]="11*1"; +w["edbg_if_cdc"]="186*1"; +w["edbg_if_dbg_armjtag"]="186*1"; +w["edbg_if_dbg_avrjtag"]="186*1"; +w["edbg_if_dbg_aw"]="186*1"; +w["edbg_if_dbg_dw"]="186*1"; +w["edbg_if_dbg_en"]="186*1"; +w["edbg_if_dbg_isp"]="186*1"; +w["edbg_if_dbg_pdi"]="186*1"; +w["edbg_if_dbg_swd"]="186*1"; +w["edbg_if_dgi_gpio"]="186*1"; +w["edbg_if_dgi_spi"]="186*1"; +w["edbg_if_dgi_twi"]="186*1"; +w["edbg_if_dgi_uart"]="186*1"; +w["edbg_if_dgi_usart"]="186*1"; +w["edbg_if_erase_pin"]="186*1"; +w["edbg_query_command"]="186*1,187*1"; +w["edbg_rsp_data"]="34*1"; +w["edbg_rsp_fail"]="35*1"; +w["edbg_rsp_list"]="33*1"; +w["edbg_rsp_ok"]="32*1"; +w["edbg_set"]="12*1"; +w["edbgcommand"]="186*1"; +w["edbgconfigtag"]="186*1"; +w["edbgconfigtyp"]="186*1"; +w["edbgcontrolcontextparamet"]="186*1"; +w["edbgctrl"]="11*1,12*1,178*1,186*47"; +w["edbgfailurecod"]="186*1"; +w["edbginterfac"]="186*1"; +w["edbgquerycontext"]="186*1"; +w["edbgrespons"]="186*1"; +w["edbgsetgetcontext"]="186*1"; +w["edg"]="61*2"; +w["eear"]="185*8"; +w["eearh"]="185*2"; +w["eearh_addr"]="185*2"; +w["eearl"]="185*2"; +w["eearl_addr"]="185*2"; +w["eecr"]="185*2"; +w["eecr_addr"]="185*2"; +w["eedr"]="185*2"; +w["eedr_addr"]="185*2"; +w["eeprom"]="111*2,131*1,132*2,133*2,140*15,141*2,148*1,150*42,151*42,160*6,185*7"; +w["eeprom_base_addr"]="133*2,185*1"; +w["eeprom_page_s"]="185*3"; +w["eeprom_s"]="185*3"; +w["effici"]="131*1"; +w["effort"]="172*1"; +w["eg"]="135*1"; +w["eg:"]="135*1"; +w["element"]="88*1,135*1"; +w["els"]="68*1"; +w["embed"]="0*2,172*2,178*1"; +w["embedded."]="0*1,172*1,178*1"; +w["ement"]="139*1"; +w["ement-level"]="139*1"; +w["empti"]="140*3"; +w["enabl"]="30*6,50*1,51*3,140*9,171*1,175*1,180*1,185*2"; +w["encod"]="18*1,19*1"; +w["encount"]="115*1"; +w["end"]="48*1,49*36,112*1,135*1,148*1"; +w["endian"]="173*2"; +w["endian."]="180*1"; +w["endpoints."]="0*1"; +w["enough"]="18*1,19*1,140*3"; +w["ensur"]="89*1,136*1,147*1"; +w["enter"]="60*1,63*3,92*1,99*1,108*47,140*3,141*1,145*52,160*3,161*1,162*52,185*2"; +w["enter_progmod"]="175*1,180*1"; +w["entered."]="185*1"; +w["enterprogmod"]="145*2"; +w["entir"]="79*1,112*1,140*3"; +w["enum"]="43*5,63*12,91*12,140*18,160*2,186*13"; +w["envelop"]="3*5,4*3,22*46,23*2,24*1,25*1,177*1"; +w["equival"]="136*1"; +w["equivalent."]="90*1"; +w["eras"]="3*1,5*1,6*42,64*2,71*42,79*50,91*12,92*2,111*54,116*48,133*3,139*2,140*39,141*1,147*53,160*3,161*1,165*62,169*3"; +w["erase."]="79*1"; +w["erase:"]="139*1"; +w["erase_pin"]="3*1,6*2"; +w["erasedelay"]="147*2"; +w["erasedelay."]="147*1"; +w["error"]="13*1,14*1,16*1,17*1,18*3,19*3,37*2,43*3,52*1,62*1,63*12,91*36,115*1,131*5,132*17,140*21,159*2,160*15,169*3,172*1"; +w["error_overflow"]="186*1"; +w["error_receiv"]="186*1"; +w["es"]="59*1"; +w["es."]="59*1"; +w["especi"]="185*1"; +w["essenti"]="148*1"; +w["estoppel"]="171*1"; +w["etc"]="62*1,137*1"; +w["etc."]="62*1,137*1"; +w["even"]="24*1,171*1,185*1"; +w["event"]="3*1,4*1,22*48,25*47,44*1,58*44,59*45,60*44,61*43,63*9,101*1,102*1,104*1,105*1,109*1,128*48,129*48,130*43,139*1,140*4,160*1,169*1,171*1,174*1,177*1,185*1,188*2"; +w["event:"]="58*3,59*36,60*36,61*36,128*2,129*41,130*41"; +w["events."]="49*1"; +w["everi"]="24*1"; +w["evt_avr8_break"]="129*1,140*1"; +w["evt_avr8_idr"]="130*1,140*1"; +w["evt_housekeeping_ext_reset"]="61*1,63*1"; +w["evt_housekeeping_pow"]="59*1,63*1"; +w["evt_housekeeping_sleep"]="60*1,63*1"; +w["exact"]="131*1"; +w["exampl"]="89*1,114*1,136*2,185*1"; +w["except"]="171*1"; +w["exclus"]="62*1"; +w["execut"]="27*1,32*1,35*1,40*1,42*1,43*3,45*1,54*1,57*1,62*1,63*3,65*1,81*1,86*1,91*6,93*1,102*1,103*1,104*1,123*1,127*1,137*1,138*3,139*1,140*6,145*1,159*2,168*2"; +w["execute."]="137*1"; +w["executed."]="119*1,120*1,138*1"; +w["exist"]="85*1"; +w["exists:"]="85*1"; +w["exit"]="60*1,109*1"; +w["expect"]="37*1,89*1,136*1"; +w["expected."]="89*1,136*1"; +w["explicit"]="78*1"; +w["express"]="171*2"; +w["extend"]="129*1,172*1"; +w["extern"]="30*3,51*2,58*1,61*39,63*9,68*2,89*3,91*3,96*2,136*3"; +w["extract"]="175*1"; +w["fact"]="34*1,56*1,85*1,126*1"; +w["factor"]="185*1"; +w["fail"]="6*1,9*1,10*1,27*1,28*1,29*1,31*1,35*42,37*1,39*1,40*1,42*42,43*3,45*1,46*1,47*1,49*1,50*1,51*1,52*1,53*1,57*37,63*9,65*1,66*1,67*1,68*2,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,80*1,86*42,89*1,91*3,93*1,94*1,95*1,96*2,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,122*1,127*42,140*18,160*3,168*1,188*1"; +w["failed."]="89*1,136*1"; +w["failur"]="35*2,37*1,42*2,43*6,57*2,78*1,86*2,91*4,127*2,139*1,140*7,160*1,169*1,186*4"; +w["failure_ok"]="43*1"; +w["failure_unknown"]="43*1"; +w["failure_usb_previous_underrun"]="37*1,43*1"; +w["fall"]="61*1"; +w["famili"]="0*1,51*1,139*1,140*3,185*1"; +w["families."]="0*1"; +w["family."]="111*1"; +w["far"]="175*1"; +w["fast"]="18*1,19*1"; +w["featur"]="37*2,38*1,91*3,140*3"; +w["fell"]="63*3"; +w["few"]="43*3,91*3,140*3"; +w["field"]="6*2,9*3,10*2,13*2,14*2,15*2,16*2,17*2,18*2,19*2,20*2,21*2,23*3,24*2,25*2,27*1,28*2,29*2,32*1,33*1,34*1,35*1,37*5,38*2,40*1,41*1,42*1,45*1,46*2,47*2,49*1,50*1,51*1,52*1,54*1,55*1,56*1,57*1,59*1,60*1,61*1,65*1,66*2,67*2,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,81*1,82*1,83*1,84*1,85*2,86*1,93*1,94*2,95*2,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,123*1,124*1,125*1,126*1,127*1,129*1,130*1,142*2,143*2,144*2,145*2,146*2,147*2,148*2,149*2,152*2,153*2,162*2,163*2,164*2,165*2,166*2,167*2,180*1,188*1"; +w["fifo"]="114*1"; +w["file"]="91*4,135*1,140*4,148*1,160*1,169*1,175*1,181*2,186*1"; +w["filter"]="131*2,132*1"; +w["finish"]="147*1"; +w["firmwar"]="1*1,48*1,50*36,63*12,149*1,193*3"; +w["firmware."]="149*1"; +w["first"]="9*1,15*2,18*1,19*1,20*1,23*1,24*1,25*1,37*3,77*1,79*1,112*1,115*2,140*3,142*1,148*1,149*1"; +w["first."]="173*2"; +w["fit"]="171*1"; +w["fix"]="39*1,60*1"; +w["flag"]="79*1,109*4"; +w["flash"]="79*7,91*18,111*1,112*2,116*1,119*1,120*1,131*6,132*6,133*4,139*1,140*12,141*2,148*58,149*53,150*1,151*1,160*6,181*2,182*3,185*9"; +w["flash."]="112*1,131*1"; +w["flash_bas"]="185*2"; +w["flash_byt"]="185*2"; +w["flash_page_byt"]="185*3"; +w["fli"]="135*1"; +w["flow"]="119*1,120*1,134*1,139*44"; +w["foll"]="175*1"; +w["follow"]="24*1,38*1,88*1,89*1,115*1,135*1,136*1,138*1,139*1,148*1"; +w["forgotten"]="121*1"; +w["form"]="190*1"; +w["format"]="9*6,32*5,33*5,34*5,35*5,37*16,38*1,41*5,42*5,49*5,50*5,51*5,52*5,54*5,55*5,56*5,57*5,59*5,60*5,61*5,68*5,69*5,70*5,71*5,72*5,74*5,75*5,76*5,77*5,78*5,79*5,81*5,82*5,83*5,84*5,85*10,86*5,96*5,97*5,98*5,99*5,100*5,101*5,102*5,103*5,104*5,105*5,106*5,107*5,108*5,109*5,110*5,111*5,112*5,113*5,114*5,115*5,116*5,117*5,118*5,119*5,120*5,121*5,123*5,124*5,125*5,126*5,127*5,129*5,130*5,136*7,142*10,143*5,144*5,145*5,146*5,147*5,148*5,149*5,152*5,153*5,162*5,163*5,164*5,165*5,166*5,167*5,188*5"; +w["format."]="38*2"; +w["forth"]="171*1"; +w["forward"]="37*2,192*1"; +w["forwarding."]="192*1"; +w["found"]="2*1,51*1"; +w["fragment"]="23*4,24*1"; +w["fragmentcod"]="23*1"; +w["fragmentinfo"]="23*1,24*2"; +w["frame"]="18*1,19*1,37*62,38*2,176*1"; +w["free"]="3*1"; +w["freeli"]="135*1"; +w["frequenc"]="88*1,143*1,144*1,182*1,185*8"; +w["frequency."]="60*1"; +w["from"]="0*1,1*1,7*1,13*1,14*1,18*1,24*1,25*1,37*2,60*1,69*1,70*1,89*2,91*6,97*1,98*1,113*1,120*1,130*2,131*3,133*13,135*1,136*3,139*1,140*3,148*1,149*2,151*1,153*1,167*3,175*2,185*3"; +w["front"]="135*1"; +w["front-end"]="135*1"; +w["full"]="23*1,24*1,131*2,132*6,133*6,181*2"; +w["functi"]="0*1"; +w["function"]="3*1,24*1,36*1,37*2,38*1,39*1,43*3,62*2,90*1,91*3,111*1,135*1,137*1,138*1,139*2,140*6,175*1,185*1"; +w["function."]="138*1"; +w["function:"]="135*1"; +w["functionality."]="62*1"; +w["functionl"]="111*1"; +w["functions."]="3*1"; +w["further"]="2*1,50*1"; +w["fuse"]="110*1,132*2,133*1,138*1,140*3,141*2,152*52,153*52,154*1,155*1,156*1,157*1,160*6,185*1"; +w["fuse_base_addr"]="133*1,185*1"; +w["futur"]="1*1"; +w["fw"]="1*2"; +w["fwrev_maj"]="193*1"; +w["fwrev_min"]="193*1"; +w["g"]="52*1,89*1,138*1,180*1"; +w["gain"]="6*1,89*1,136*1"; +w["gateway"]="0*1,1*1"; +w["general"]="37*3,133*1,175*1"; +w["generat"]="60*1,105*1"; +w["generic"]="43*3,171*2,173*51,174*52"; +w["get"]="3*1,8*2,9*41,11*36,18*41,19*41,20*41,26*1,28*1,29*48,30*41,44*2,46*2,47*48,63*3,64*2,66*2,67*49,70*41,88*1,91*3,92*2,94*2,95*49,98*41,135*1,136*1,140*3,141*1,144*51,182*41,185*41,192*3,193*46"; +w["get_buffer_s"]="20*2"; +w["get_config"]="3*1,9*2"; +w["get_data"]="18*2"; +w["get_id"]="89*1"; +w["get_request"]="3*1"; +w["get_status"]="19*2"; +w["given"]="3*1,38*1,83*1,91*3,104*1,136*1,140*3,185*1"; +w["gone"]="59*1"; +w["gpio"]="186*3"; +w["grant"]="171*1"; +w["ground"]="182*1"; +w["had"]="43*3"; +w["half"]="181*1"; +w["half-word"]="181*1"; +w["halt"]="64*1,72*43"; +w["handl"]="148*1,149*1"; +w["handler"]="37*11,38*2,39*1,43*3,62*1,175*1,180*1,190*1"; +w["handler."]="62*1"; +w["hardwar"]="13*1,20*1,21*1,63*3,91*6,92*2,117*45,118*45,139*2,159*1,192*1,193*1"; +w["hardware."]="15*1,20*1,21*1"; +w["header"]="91*1,140*1,160*1,169*1,186*1"; +w["heavili"]="131*1,132*1"; +w["held"]="137*2"; +w["help"]="51*1"; +w["here"]="1*3,3*1,9*1,136*1,172*1"; +w["here."]="1*3,172*1"; +w["here:"]="3*1,9*1,136*1"; +w["herein"]="171*1"; +w["herein."]="171*1"; +w["hhb"]="3*1,10*1"; +w["hid"]="0*1,13*2,23*1"; +w["high"]="6*1,63*3,148*1,149*1"; +w["hint"]="44*1,62*41,87*46,134*46,173*1,174*1"; +w["hk"]="38*1"; +w["hk_context_analog"]="63*1,193*1"; +w["hk_context_config"]="63*1,193*1"; +w["hk_query_command"]="63*1,189*1"; +w["hold"]="101*1,135*1"; +w["host"]="0*1,13*2,37*3,88*1,89*1,90*1,130*1,135*2,136*1,188*1"; +w["host."]="130*1"; +w["housekeep"]="38*2,44*51,48*41,53*41,62*6,63*41,176*1,189*41,193*41"; +w["housekeeping_analog_vtref"]="63*1"; +w["housekeeping_awak"]="63*1"; +w["housekeeping_config_build"]="63*1"; +w["housekeeping_config_fwrev_maj"]="63*1"; +w["housekeeping_config_fwrev_min"]="63*1"; +w["housekeeping_config_hwrev"]="63*1"; +w["housekeeping_failed_invalid_key"]="63*1"; +w["housekeeping_failed_invalid_paramet"]="63*1"; +w["housekeeping_failed_invalid_parameter_valu"]="63*1"; +w["housekeeping_failed_jtag_detect_jtagm_error"]="63*1"; +w["housekeeping_failed_jtag_detect_jtagm_init_error"]="63*1"; +w["housekeeping_failed_jtag_detect_no_devic"]="63*1"; +w["housekeeping_failed_jtag_detect_too_many_devic"]="63*1"; +w["housekeeping_failed_no_target_pow"]="63*1"; +w["housekeeping_failed_not_support"]="63*1"; +w["housekeeping_failed_ok"]="63*1"; +w["housekeeping_failed_osccal_fail"]="63*1"; +w["housekeeping_failed_osccal_fw_error"]="63*1"; +w["housekeeping_failed_osccal_invalid_mod"]="63*1"; +w["housekeeping_failed_osccal_invalid_phys"]="63*1"; +w["housekeeping_power_off"]="63*1"; +w["housekeeping_power_on"]="63*1"; +w["housekeeping_reset_appli"]="63*1"; +w["housekeeping_reset_releas"]="63*1"; +w["housekeeping_sleep"]="63*1"; +w["how"]="148*1,185*1,192*2"; +w["howev"]="22*1,137*1"; +w["hwrev"]="193*1"; +w["ice"]="1*1"; +w["id"]="3*1,4*1,9*2,10*1,27*1,28*3,29*3,30*1,32*1,33*1,34*1,35*1,37*14,38*3,39*1,40*1,41*1,42*1,43*41,44*1,45*1,46*2,47*2,49*1,50*1,51*2,52*1,54*1,55*1,56*1,57*1,59*1,60*1,61*1,63*41,64*1,65*1,66*2,67*2,68*3,69*1,70*52,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,80*1,81*1,82*1,83*45,84*1,85*2,86*1,89*3,91*53,92*1,93*1,94*2,95*2,96*2,97*1,98*49,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,123*1,124*1,125*1,126*1,127*1,129*1,130*1,131*1,132*1,133*1,136*6,140*53,142*2,143*2,144*2,145*2,146*2,147*2,148*2,149*2,152*2,153*2,160*47,162*2,163*2,164*3,165*2,166*2,167*2,169*47,173*1,174*1,175*1,178*1,180*1,181*1,182*1,184*1,185*1,186*47,187*1,188*1,189*1,190*1,191*1,193*1"; +w["ident"]="150*1,151*1,154*1,155*1,156*1,157*1"; +w["identifi"]="37*2"; +w["idr"]="128*1,130*47,140*3,185*1"; +w["ie"]="24*1,25*1"; +w["ie:"]="24*1,25*1"; +w["if"]="30*2,37*1,51*2,68*2,78*1,79*1,89*1,96*4,109*3,121*1,131*4,132*10,135*1,136*2,137*3,138*2,148*3,171*1,185*4"; +w["ignor"]="24*1,25*1,111*1,165*1,166*1"; +w["ignored."]="24*1,25*1,111*1"; +w["illeg"]="91*3,140*15"; +w["immedi"]="102*1,121*1,138*1,139*1"; +w["immediately."]="121*1"; +w["implement"]="0*4,1*56,38*2,59*1,91*3,114*1,140*3,153*1,158*1,175*1,179*1,180*1,192*1"; +w["implementation."]="158*1,175*2"; +w["implent"]="63*3"; +w["impli"]="89*1,136*1,171*3"; +w["implicit"]="69*1,97*1,136*1"; +w["inabl"]="171*1"; +w["incident"]="171*1"; +w["includ"]="62*1,91*1,140*1,160*1,169*1,171*2,175*1,186*1"; +w["incom"]="14*1,37*2"; +w["incorrect"]="91*6,135*1"; +w["increas"]="140*3"; +w["increment"]="37*2"; +w["independ"]="37*1,62*1"; +w["index"]="181*2"; +w["indic"]="23*1,24*1,25*1,34*1,56*1,59*1,60*1,61*1,79*1,85*1,126*1,129*1,139*1,148*2,153*1,182*1"; +w["indirect"]="171*1"; +w["ineffici"]="131*1"; +w["info"]="63*3,91*3,129*1"; +w["inform"]="2*1,9*1,18*1,19*1,135*1,171*3"; +w["information."]="9*1,18*1,19*1,39*1,135*1"; +w["infringement."]="171*1"; +w["init"]="63*3,91*6"; +w["initialis"]="63*3,140*3,164*1,185*1"; +w["initiated."]="105*1"; +w["input"]="0*1"; +w["insert"]="119*2,139*1"; +w["instanc"]="35*1,42*1,57*1,86*1,127*1"; +w["instruct"]="74*1,78*1,91*3,105*1,139*3,148*1"; +w["instruction-level"]="139*1"; +w["insuffici"]="91*3"; +w["intellectu"]="171*1"; +w["intend"]="1*1,171*2,172*1"; +w["intent"]="140*3"; +w["interact"]="172*1"; +w["interfac"]="0*53,1*2,22*1,23*1,30*3,62*3,68*3,69*1,88*2,89*1,91*6,96*4,97*1,110*1,131*1,135*2,136*2,140*9,153*2,164*1,175*1,179*1,180*1,182*1,192*1"; +w["interface."]="68*1,96*1,110*1,131*1,180*1"; +w["interface:"]="88*1"; +w["interfaces:"]="0*1"; +w["intern"]="63*3,91*3,104*1,170*1,185*1"; +w["interrog"]="39*1"; +w["interrupt"]="171*1,185*1"; +w["interv"]="185*1"; +w["into"]="38*1,77*1,78*1,105*1,137*2,138*1,139*1,148*2,150*1,166*1"; +w["introduct"]="171*1,179*51"; +w["invalid"]="91*9,140*6"; +w["invok"]="50*1"; +w["io"]="131*1,132*1,140*3"; +w["ir"]="77*1,78*1,136*1,182*2,185*2"; +w["ir-bit"]="182*2,185*2"; +w["ir."]="78*1"; +w["ire"]="109*1"; +w["isp"]="171*1,175*52,186*3"; +w["isprotect"]="78*1"; +w["iss"]="148*1"; +w["issu"]="24*1,148*1"; +w["issued."]="24*1"; +w["it"]="38*1,39*1,171*1"; +w["ite"]="137*1"; +w["item"]="43*3,63*3,91*3,140*3"; +w["iter"]="15*1"; +w["itm"]="7*1"; +w["itself"]="1*1,23*1,131*1,185*3"; +w["itself."]="131*1"; +w["jtag"]="1*6,38*2,48*1,51*41,62*3,63*6,77*1,78*1,88*4,90*1,91*30,111*1,116*1,117*1,118*1,132*46,136*4,140*21,180*1,182*3,183*1,185*35,192*1"; +w["jtag."]="51*1,136*1,180*1"; +w["jtag_clock"]="88*1"; +w["jtag_clock:"]="88*1"; +w["jtag_daisi"]="88*1"; +w["jtag_daisy:"]="88*1"; +w["jtagice3"]="1*3,174*1"; +w["jtagice3discoveri"]="43*1"; +w["jtagice3discoverycommand"]="43*1"; +w["jtagice3discoveryfailurecod"]="43*1"; +w["jtagice3discoveryrespons"]="43*1"; +w["jtagice3failurecod"]="43*1"; +w["jtagice3housekeepinganalogcontextparamet"]="63*1"; +w["jtagice3housekeepingcommand"]="63*1"; +w["jtagice3housekeepingconfigcontextparamet"]="63*1"; +w["jtagice3housekeepingev"]="63*1"; +w["jtagice3housekeepingfailurecod"]="63*1"; +w["jtagice3housekeepingpowerev"]="63*1"; +w["jtagice3housekeepingquerycontext"]="63*1"; +w["jtagice3housekeepingresetev"]="63*1"; +w["jtagice3housekeepingrespons"]="63*1"; +w["jtagice3housekeepingsetgetcontext"]="63*1"; +w["jtagice3housekeepingsleepev"]="63*1"; +w["jtagice3setgetfailurecod"]="63*1"; +w["jtagid"]="68*1,70*1"; +w["jtagm"]="63*3,140*9"; +w["k"]="96*1"; +w["kbit"]="143*1,144*1"; +w["kbps"]="182*1"; +w["keep"]="140*3,172*1"; +w["keil"]="0*1,2*1"; +w["key"]="50*2,63*3"; +w["khz"]="52*1,88*1,182*1,185*4"; +w["kit"]="1*1,172*1"; +w["l"]="171*1,182*1"; +w["l."]="182*1"; +w["larg"]="23*1"; +w["last"]="112*1,148*1"; +w["later"]="1*1"; +w["layer"]="37*1"; +w["le"]="192*1"; +w["least"]="37*3,173*1"; +w["leav"]="90*1,92*1,109*47,136*1,137*1,140*3,141*1,146*52,148*1,160*3,161*1,163*52"; +w["leave."]="109*1"; +w["leave_progmod"]="175*1,180*1"; +w["led"]="30*3,91*3"; +w["legal"]="140*3"; +w["length"]="91*6,96*1,166*1,167*1,180*1"; +w["less"]="185*1"; +w["level"]="74*1,77*1,91*3,101*1,102*1,105*3,139*3,140*6"; +w["liabil"]="171*1"; +w["liabl"]="171*1"; +w["licens"]="171*1"; +w["lie"]="136*1"; +w["life."]="171*1"; +w["limit"]="1*1,171*2,185*3"; +w["line"]="182*2"; +w["line:"]="182*1"; +w["ling"]="110*1"; +w["link"]="0*1"; +w["list"]="1*1,27*2,28*1,29*1,31*1,33*42,38*1,39*1,40*2,41*42,43*6,45*2,46*1,47*1,51*1,53*1,55*37,63*6,65*2,66*1,67*1,80*1,82*42,91*18,93*2,94*1,95*1,119*1,120*1,122*1,124*42,140*15,184*8,187*2,189*2,190*2,191*8"; +w["littl"]="90*1,173*1"; +w["load"]="141*1,142*52,148*4,160*3"; +w["locat"]="104*1,114*5,171*1"; +w["location."]="104*1"; +w["lock"]="91*3,140*3,141*2,154*42,155*42,160*6,185*1"; +w["lockbit"]="132*2,133*1,165*1"; +w["lockbit_base_addr"]="133*1,185*1"; +w["logo"]="171*1"; +w["longer"]="1*1,110*1"; +w["loop"]="145*1"; +w["loss"]="171*2"; +w["low"]="63*3,74*1,77*1,91*3,139*1,140*3,148*1,149*1,182*1"; +w["low-level"]="91*3,139*1"; +w["lower"]="159*1"; +w["lowest"]="173*1"; +w["lsb"]="77*1"; +w["ltd"]="171*1"; +w["ltd."]="171*1"; +w["m"]="23*3,24*2"; +w["made"]="172*1"; +w["main"]="38*2,101*1,140*3,185*1"; +w["maintain"]="185*1"; +w["major"]="193*1"; +w["make"]="68*1,89*1,96*1,136*1,171*3"; +w["mal"]="132*1"; +w["mal-align"]="132*1"; +w["mani"]="63*3,89*1,91*3,136*1,140*3"; +w["manner"]="25*1"; +w["manual"]="62*1"; +w["manufactur"]="43*3,51*1,190*1"; +w["map"]="11*1,12*1,91*3"; +w["market"]="135*1"; +w["mask"]="92*1,114*49,131*1,132*1,140*3"; +w["mask."]="114*1"; +w["master"]="91*15,140*3"; +w["match"]="131*1"; +w["max_sw_break"]="119*1,120*1"; +w["maximum"]="88*1,91*3,182*3"; +w["may"]="36*2,38*1,69*1,97*1,131*3,132*1,135*2,136*2,171*1,188*1"; +w["mcu"]="130*1,140*6,171*101"; +w["mean"]="24*1,148*1,173*1"; +w["meanings:"]="148*1"; +w["means."]="104*1"; +w["medbg"]="0*1,1*1"; +w["mega"]="185*5"; +w["mega48"]="135*1"; +w["megaavr"]="38*2,52*1,111*2,116*1,117*2,118*2,132*41,140*12,175*1,183*1,185*33"; +w["memori"]="75*5,76*6,79*2,91*9,92*3,113*46,114*46,115*46,137*1,139*4,140*27,148*10,149*2,150*1,151*1,161*2,166*53,167*54,169*3,174*1,181*37,183*46"; +w["memory-typ"]="139*1"; +w["memory_word_access"]="78*1"; +w["memtyp"]="91*9,131*47,132*46,133*46,140*9,181*5,183*3,184*2,191*2"; +w["memtype_appl_flash"]="133*1,140*1"; +w["memtype_appl_flash_atom"]="133*1,140*1"; +w["memtype_boot_flash"]="133*1,140*1"; +w["memtype_boot_flash_atom"]="133*1,140*1"; +w["memtype_calibration_signatur"]="133*1,140*1"; +w["memtype_eeprom"]="131*1,132*1,133*1,140*1"; +w["memtype_eeprom_atom"]="133*1,140*1"; +w["memtype_eeprom_pag"]="132*1,140*1"; +w["memtype_flash_pag"]="131*1,132*1,140*1"; +w["memtype_fus"]="132*1,133*1,140*1"; +w["memtype_lock_bit"]="133*1"; +w["memtype_lockbit"]="132*1,140*1"; +w["memtype_oscc"]="132*1,140*1"; +w["memtype_regfil"]="133*1,140*1"; +w["memtype_signatur"]="131*1,132*1,133*1,140*1"; +w["memtype_spm"]="131*1,132*1,140*1"; +w["memtype_sram"]="131*1,132*1,133*1,140*1"; +w["memtype_user_signatur"]="132*1,133*1,140*1"; +w["merchant"]="171*1"; +w["messag"]="60*1,128*1,130*49,140*9,185*3"; +w["messages."]="185*1"; +w["method"]="147*1,148*1"; +w["method:"]="147*1"; +w["microcontrol"]="38*1,173*1"; +w["microsoft"]="171*1"; +w["might"]="75*1,76*1"; +w["mini"]="1*1"; +w["minor"]="193*1"; +w["misc"]="63*3"; +w["mismatch"]="140*3"; +w["mkii"]="175*1,180*1"; +w["mkii."]="180*1"; +w["mnf_date"]="190*1"; +w["mode"]="13*54,14*54,50*2,63*6,88*2,91*18,92*2,99*1,105*1,108*47,109*48,111*4,112*1,113*1,114*1,115*1,116*2,117*1,131*1,132*14,133*13,136*1,137*3,138*2,139*3,140*9,141*2,145*52,146*52,148*27,160*6,161*2,162*52,163*52,165*8,166*1,169*3,185*2,192*2"; +w["mode."]="50*1,88*1,113*1,114*1,115*1,132*7,137*1,138*1,148*1,185*3"; +w["modebit"]="148*1"; +w["modifi"]="107*1"; +w["modul"]="91*3,110*2,117*1,118*1,131*1,135*1,138*1,140*6,182*1,185*1"; +w["module."]="117*1,118*1,138*1"; +w["monitor"]="131*1,132*1,138*1"; +w["more"]="7*1,23*1,24*1,37*1,38*1,63*3,132*3"; +w["most"]="173*1"; +w["motor"]="185*1"; +w["mount"]="1*3"; +w["ms"]="145*4,146*2,147*1"; +w["ms."]="185*1"; +w["msb"]="9*1,15*2,18*1,19*1,20*1,23*1,24*1,25*1,142*1,148*1,149*1"; +w["multi"]="141*1,158*41,180*1"; +w["multi-byt"]="180*1"; +w["multipl"]="28*1,29*1,46*1,47*1,66*1,67*1,94*1,95*1,131*1,132*3"; +w["must"]="22*2,23*1,24*3,25*1,52*1,62*2,88*4,89*6,131*2,132*1,135*4,136*5,139*1,140*3,148*3,156*1,157*1,165*1,181*1,182*1,185*2"; +w["mv"]="193*1"; +w["n"]="9*2,10*1,18*1,23*4,24*3,25*1,28*1,33*1,34*1,37*3,41*1,46*1,55*1,56*1,66*1,76*1,77*3,82*1,85*2,94*1,114*1,115*1,119*4,120*4,124*1,126*1,129*1,138*1,148*1,166*1,181*1,184*4,187*1,189*1,190*3,191*4"; +w["nack"]="91*3"; +w["name"]="38*1,43*3,135*1,171*1,185*3,190*1"; +w["name."]="135*1"; +w["nativ"]="0*1,172*1"; +w["natur"]="24*1"; +w["nb"]="132*1"; +w["nb:"]="132*1"; +w["nbsi"]="159*1"; +w["near"]="91*3"; +w["necessari"]="37*1,68*1,96*1,135*1"; +w["necessarili"]="51*1"; +w["need"]="135*2"; +w["new"]="136*1,174*1"; +w["newer"]="174*2"; +w["next"]="23*1,37*1,102*1,119*1,120*1,139*2,142*1"; +w["next."]="23*1"; +w["nexus"]="91*3,181*3"; +w["ng"]="37*1"; +w["nibbl"]="23*1"; +w["no"]="1*1,24*1,25*1,43*3,49*1,50*1,51*1,63*3,68*2,69*1,89*1,91*9,96*2,97*1,110*1,117*1,118*1,136*1,140*6,145*1,171*4,175*1,180*1"; +w["non"]="171*1"; +w["non-infring"]="171*1"; +w["non-infringement."]="171*1"; +w["none"]="182*1"; +w["normal"]="137*1,138*1"; +w["note"]="0*40,1*2,18*1,24*1,28*1,29*1,37*1,46*1,47*1,52*1,56*1,59*1,60*1,66*1,67*1,69*1,75*1,76*1,79*1,88*1,94*1,95*1,97*1,111*3,112*1,115*1,116*1,117*3,118*3,119*1,120*1,135*2,148*1,153*1,175*42,180*1,182*1,185*6,192*1"; +w["note:"]="28*1,29*1,46*1,47*1,56*1,59*1,60*1,66*1,67*1,69*1,79*1,94*1,95*1,97*1,111*3,112*1,115*1,116*1,117*3,118*3,119*1,120*1,148*1,153*1,185*4"; +w["notic"]="171*1,172*1"; +w["notice."]="171*1,172*1"; +w["now"]="60*2,188*1"; +w["ntroller"]="1*1"; +w["number"]="9*2,10*1,18*1,19*1,23*3,24*1,25*1,28*1,29*1,43*3,46*1,47*1,60*1,63*3,66*1,67*1,73*1,75*2,76*2,77*1,79*1,91*9,94*1,95*1,113*1,114*1,115*1,117*2,118*2,131*5,132*4,133*10,145*1,148*1,149*1,166*1,167*1,182*3,190*1,193*1"; +w["numbyt"]="9*1,148*1,149*1"; +w["nvm"]="140*6,185*1"; +w["nvm_base"]="133*1,185*1"; +w["o"]="38*1,96*1"; +w["occur"]="22*1,59*1,63*3,91*3,140*3"; +w["occurred."]="59*1"; +w["ocd"]="117*1,118*1,132*46,135*2,138*1,139*1,140*12,183*1,185*3"; +w["ocd_rev"]="185*2"; +w["ocdr"]="131*1,132*1,185*2"; +w["ocdr_addr"]="185*2"; +w["odd"]="131*1,132*1"; +w["off"]="13*1,14*1,49*1,59*1,62*2,63*3"; +w["offer"]="172*1"; +w["offset"]="185*9"; +w["often"]="185*1"; +w["ok"]="13*1,14*1,16*1,17*1,21*1,28*1,31*1,32*41,46*1,49*1,50*1,52*1,53*1,54*36,63*9,66*1,69*1,71*1,72*1,73*1,76*1,79*1,80*1,81*41,91*6,94*1,96*1,97*1,99*1,100*1,101*1,102*1,103*1,104*1,105*2,107*1,108*1,109*1,110*1,111*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,122*1,123*41,140*6,159*1,160*3,168*1,188*1"; +w["ok."]="34*1,56*1,85*1,126*1"; +w["on"]="0*1"; +w["onc"]="89*1,105*2,136*1"; +w["ondit"]="171*1"; +w["one"]="22*2,24*3,28*1,29*1,38*2,46*1,47*1,66*1,67*1,74*1,91*3,94*1,95*1,131*2,132*5,148*1,153*1,182*1,185*4"; +w["onli"]="1*2,3*1,10*1,13*1,14*1,22*1,24*1,28*1,29*1,39*1,46*1,47*1,66*1,67*1,77*1,94*1,95*1,111*1,112*1,113*1,114*1,115*1,116*2,119*1,120*1,131*1,132*2,133*3,135*1,139*2,140*12,148*3,180*1,181*1,185*4,192*2"; +w["only."]="6*1,9*1,133*3,139*1"; +w["onto"]="188*1"; +w["oper"]="34*1,56*1,85*1,126*1,131*2,132*5,137*1,148*2"; +w["operation."]="78*1,131*2,132*5"; +w["option"]="135*2,140*3,185*2"; +w["option-rel"]="140*3"; +w["options:"]="135*1"; +w["order"]="22*1,37*2,89*2,135*1,136*2,173*1"; +w["origin"]="139*1"; +w["os"]="1*1"; +w["osccal"]="63*3,132*1,141*1,157*43,160*3,185*2"; +w["osccal_addr"]="185*2"; +w["oscil"]="48*1,52*42,63*3,140*3"; +w["oth"]="171*1"; +w["other"]="9*1,10*1,39*1,62*1,89*1,104*1,136*1,165*1,171*4,172*1"; +w["others."]="171*1"; +w["otherwis"]="79*1,171*1"; +w["out"]="19*1,20*1,24*1,63*6,77*1,78*1,89*1,96*1,105*1,131*2,132*1,135*1,136*1,140*12,145*1,153*1,159*3,168*1,171*1,192*1"; +w["out."]="77*1,131*2,132*1"; +w["outlin"]="37*1"; +w["output"]="0*1,7*1,77*1,185*1,192*1"; +w["outsid"]="132*9"; +w["over"]="22*1,24*1,105*1"; +w["overflow"]="91*9"; +w["overridden"]="89*1,136*1"; +w["overrun"]="18*1,19*1"; +w["overview"]="0*46,36*46,38*46,113*1,114*1,115*1,176*2,179*1"; +w["owe"]="175*1"; +w["own"]="38*1,172*2"; +w["p"]="78*1"; +w["packet"]="9*10,10*1,23*6,24*3,25*2,37*6,89*1,91*9,136*1,159*1,168*1"; +w["packet_numb"]="23*1"; +w["page"]="79*5,91*9,92*1,111*4,116*43,131*3,132*7,133*9,140*24,148*21,166*1,181*4,182*2,185*6"; +w["page-eras"]="116*1"; +w["page."]="182*1"; +w["pagebit"]="148*1"; +w["pages."]="132*6"; +w["pair"]="0*3"; +w["paramet"]="9*3,10*1,28*4,29*5,30*41,37*1,38*1,44*1,46*5,47*5,51*1,63*21,66*5,67*6,88*1,91*9,94*5,95*6,111*2,136*1,138*1,140*6,148*1,161*1,164*55,168*1,169*3,175*1,178*1,182*41,184*1,185*41,191*1,193*46"; +w["parameter."]="89*1,136*1"; +w["parameters."]="10*1,38*1,111*1"; +w["paramt"]="28*1,29*1,46*1,47*1,66*1,67*1,94*1,95*1"; +w["pariti"]="140*3"; +w["part"]="1*1,3*1,185*2"; +w["partial"]="91*3"; +w["particular"]="1*1,171*1"; +w["pattern"]="78*1"; +w["payload"]="37*3,38*1,91*6,113*1,114*1,115*2,119*1,120*1,131*1,132*1,175*2,180*2,182*2"; +w["pc"]="0*1,13*1,74*1,80*1,84*42,91*3,92*2,106*43,107*43,122*1,125*42,129*1,139*1,140*12,148*1"; +w["pdi"]="1*4,38*1,136*1,140*12,180*1,185*10,186*3"; +w["peb01"]="78*1"; +w["per"]="114*1,139*1"; +w["perform"]="3*2,51*1,52*1,62*1,71*1,74*1,105*1,111*1,116*1,136*1,139*5,147*1,165*1,192*1"; +w["performed."]="79*1"; +w["period"]="22*1"; +w["phi"]="63*3,140*3"; +w["physic"]="36*1,52*1,62*1,64*2,68*47,69*47,70*1,87*1,88*6,89*46,91*24,92*2,96*47,97*47,98*1,109*1,134*1,135*4,136*48,137*2,138*2,140*27,160*3,168*1,175*1,180*1,182*2,185*1"; +w["physical."]="109*1,182*1,185*1"; +w["physical:"]="135*1"; +w["pid"]="1*1"; +w["pin"]="0*2,3*1,5*1,6*42,7*1,110*2,145*1,159*1,192*2"; +w["pin."]="110*1,192*1"; +w["place"]="88*1,135*1,138*1"; +w["platform"]="1*1"; +w["point"]="137*2"; +w["point."]="89*1,136*1"; +w["pointer"]="114*1"; +w["poll"]="3*2,4*2,22*2,24*1,25*1,60*1,138*2,140*3,145*1,147*1,148*10,185*3"; +w["poll1"]="148*2"; +w["poll2"]="148*2"; +w["pollindex"]="145*2,153*1"; +w["pollindex."]="145*1,153*1"; +w["polling."]="148*1"; +w["pollmethod"]="147*2"; +w["pollmethod."]="147*1"; +w["pollvalu"]="145*2"; +w["pollvalue."]="145*1"; +w["port"]="0*3,1*2"; +w["port."]="0*1"; +w["possi"]="160*1"; +w["possibl"]="91*1,96*1,137*1,140*1,169*1,171*2,185*1,186*1"; +w["possible."]="138*1"; +w["post"]="146*1"; +w["post-delay"]="146*1"; +w["postdelay"]="146*2"; +w["postdelay."]="146*1"; +w["power"]="30*4,58*1,59*39,63*12,91*3,110*1,140*3"; +w["pre"]="146*1"; +w["pre-delay"]="146*1"; +w["predelay"]="146*2"; +w["predelay."]="146*1"; +w["prefac"]="171*1,172*50"; +w["preliminari"]="170*2"; +w["present"]="30*2"; +w["present."]="30*2"; +w["preserv"]="24*1"; +w["prevent"]="114*1,135*1,185*1"; +w["previous"]="43*3,70*1,98*1"; +w["prior"]="172*1"; +w["pro"]="1*1"; +w["process"]="23*1,24*1,89*1,90*1,136*1,138*3"; +w["process."]="89*1,136*1"; +w["prod_sign_base_addr"]="133*1,185*1"; +w["product"]="171*7,185*1"; +w["products."]="171*2"; +w["profit"]="171*1"; +w["prog"]="92*2,108*41,109*42,131*1,132*1,133*1"; +w["program"]="0*3,1*4,22*1,38*5,84*2,87*1,90*42,91*3,107*1,108*1,109*2,111*1,116*1,117*2,125*2,129*2,131*2,132*14,133*11,134*1,135*1,136*1,137*45,138*2,139*3,140*21,141*52,142*1,143*1,144*1,145*53,146*53,148*73,149*2,150*44,151*1,152*53,153*1,154*44,155*1,156*1,157*1,159*46,160*18,161*2,162*53,163*53,166*1,167*1,168*46,172*1,173*1,174*1,175*3,180*3,185*4"; +w["programmin"]="138*1"; +w["programming."]="111*1,148*2"; +w["properti"]="171*1"; +w["proport"]="131*1,132*1"; +w["protect"]="64*1,78*47,91*3"; +w["protocol"]="0*1,1*5,2*48,3*5,4*4,5*1,6*1,7*2,8*1,9*1,10*1,11*2,12*2,13*1,14*1,15*1,16*1,17*1,18*1,19*1,20*1,21*1,22*4,23*1,24*1,25*1,26*47,27*1,28*1,29*1,30*1,31*1,32*1,33*1,34*1,35*1,36*3,37*14,38*50,39*48,40*1,41*1,42*1,43*42,44*47,45*1,46*1,47*1,48*1,49*1,50*1,51*1,52*2,53*1,54*1,55*1,56*1,57*1,58*1,59*1,60*1,61*1,62*4,63*1,64*47,65*1,66*1,67*1,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,80*1,81*1,82*1,83*1,84*1,85*1,86*1,87*1,88*1,89*1,90*2,91*2,92*47,93*1,94*1,95*1,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,122*1,123*1,124*1,125*1,126*1,127*1,128*1,129*1,130*1,131*1,132*1,133*1,134*1,135*1,136*1,137*1,138*1,139*2,140*11,141*47,142*1,143*1,144*1,145*1,146*1,147*1,148*1,149*1,150*1,151*1,152*1,153*1,154*1,155*1,156*1,157*1,158*1,159*47,160*8,161*47,162*1,163*1,164*1,165*1,166*1,167*1,168*47,169*1,170*1,171*157,172*3,173*56,174*55,175*62,176*55,177*2,178*54,179*1,180*57,181*1,182*1,183*1,184*2,185*1,186*11,187*2,188*1,189*2,190*2,191*2,192*1,193*1"; +w["protocol-set"]="1*2"; +w["protocol."]="62*1,91*1,140*1,160*1,186*1"; +w["protocol:"]="62*1"; +w["protocols."]="37*1"; +w["provid"]="0*1,7*1,133*12,135*1,139*3,171*2,172*1"; +w["provided."]="165*1"; +w["publish"]="49*1,188*1"; +w["pull"]="182*2"; +w["puls"]="6*1"; +w["punit"]="171*1"; +w["pure"]="109*1"; +w["purpos"]="133*1,135*1,137*1,171*1"; +w["put"]="38*1,75*1,76*1,121*1,138*1,139*1,175*1,180*1"; +w["pwm"]="185*1"; +w["quarter"]="185*1"; +w["queri"]="1*1,26*1,27*47,39*3,40*46,43*9,44*2,45*46,64*1,65*47,88*1,92*1,93*47,135*1,140*3,178*1,184*41,186*3,187*41,189*46,190*46,191*41"; +w["question"]="172*1"; +w["r"]="38*1,131*2,132*3,133*7,182*2,185*1,193*5"; +w["rang"]="63*6,79*1,112*1,132*3,140*6,159*1"; +w["rapid"]="60*1"; +w["rate"]="15*55,18*1,19*1,88*1,143*1,159*1,160*6,182*1,192*1"; +w["rather"]="1*1,135*1"; +w["ratio"]="140*3"; +w["raw"]="192*1"; +w["rdi"]="147*1,148*3,159*1"; +w["re"]="70*1,89*2,98*1,136*1"; +w["re-connect"]="89*1,136*1"; +w["re-read"]="70*1,98*1"; +w["rea"]="148*1"; +w["reach"]="104*1"; +w["read"]="18*1,19*3,20*1,24*1,29*1,34*1,47*1,56*1,62*1,64*1,67*1,70*2,75*43,76*1,85*1,89*2,91*12,92*3,95*1,96*1,98*2,106*47,113*47,114*51,126*1,131*11,132*21,133*10,135*2,136*2,137*1,139*4,140*30,141*6,144*1,148*5,149*55,151*43,153*53,155*43,156*44,157*44,160*21,161*1,167*55,175*1,182*1,192*1,193*1"; +w["read."]="75*1,76*1,148*1"; +w["readabl"]="184*1,191*1"; +w["reading."]="114*1"; +w["reason"]="89*1,136*1"; +w["receiv"]="18*4,19*3,20*1,23*1,24*2,25*1,78*1,91*18,139*1,140*6,145*1"; +w["received."]="78*1"; +w["receiver_dis"]="186*1"; +w["refer"]="52*1,63*3,135*1"; +w["regain"]="110*1"; +w["region"]="79*2"; +w["regist"]="0*1,72*1,73*6,77*2,91*12,131*1,132*1,133*1,140*9,171*3,181*4,185*5"; +w["reject"]="37*1"; +w["rela"]="171*1"; +w["relat"]="63*3,91*9,140*9"; +w["relationship"]="23*1"; +w["relationship:"]="23*1"; +w["relay"]="140*3"; +w["releas"]="61*1,63*3,91*3,109*1,135*1,170*2,182*3"; +w["release."]="170*2"; +w["relev"]="135*2,173*1,178*1"; +w["remov"]="120*1,121*1,139*2"; +w["repetit"]="139*1"; +w["repli"]="115*2"; +w["report"]="37*1,115*1"; +w["report_s"]="23*1"; +w["report_size."]="23*1"; +w["represent"]="171*1"; +w["reprogram"]="138*1"; +w["request"]="8*2,11*36,12*36,15*1,79*2,89*1,91*3,131*3,132*2,136*1"; +w["requir"]="6*1,23*1,24*1,88*1,111*1,135*4,136*1,138*2"; +w["required."]="50*1,135*1"; +w["required:"]="88*1,135*1"; +w["reserv"]="171*1,172*1"; +w["reserved."]="171*1"; +w["reset"]="3*2,49*2,51*4,58*1,61*44,63*9,64*1,68*3,73*49,89*2,91*9,92*1,96*3,101*45,109*1,110*3,135*1,136*3,137*2,139*3,140*6,182*5,185*1"; +w["reset."]="101*1,182*1"; +w["reset:"]="139*1"; +w["resetting."]="185*1"; +w["resourc"]="117*2,118*2,139*1,140*3"; +w["resources."]="117*1,118*1"; +w["respect"]="171*1"; +w["respond"]="23*1"; +w["respons"]="3*1,4*1,6*6,9*6,10*6,13*6,14*6,15*6,16*6,17*6,18*6,19*6,20*6,21*6,22*48,23*1,24*50,25*2,27*1,28*1,29*1,31*46,32*7,33*7,34*7,35*7,37*1,38*1,40*1,41*7,42*7,44*1,45*1,46*1,47*1,49*1,50*1,51*1,52*1,53*41,54*7,55*7,56*7,57*7,65*1,66*1,67*1,68*2,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,80*46,81*7,82*7,83*7,84*7,85*14,86*7,91*7,93*1,94*1,95*1,96*2,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,122*46,123*7,124*7,125*7,126*7,127*7,140*7,142*6,143*6,144*6,145*6,146*6,147*6,148*6,149*6,152*6,153*6,159*52,160*4,162*6,163*6,164*6,165*6,166*6,167*6,168*52,169*1,173*1,174*1,175*2,177*1,178*1,180*2,182*1,184*1,186*7,187*1,188*1,189*1,190*1,191*1"; +w["response."]="22*1,77*1"; +w["response:"]="6*1,9*1,10*1,13*1,14*1,15*1,16*1,17*1,18*1,19*1,20*1,21*1,142*1,143*1,144*1,145*1,146*1,147*1,148*1,149*1,152*1,153*1,162*1,163*1,164*1,165*1,166*1,167*1"; +w["responses."]="25*1"; +w["responses:"]="27*1,28*1,29*1,40*1,45*1,46*1,47*1,49*1,50*1,51*1,52*1,65*1,66*1,67*1,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,93*1,94*1,95*1,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,188*1"; +w["rest"]="24*1,25*1"; +w["restor"]="59*1,137*1,139*1"; +w["restrict"]="62*1,75*1,76*1,113*1,114*1,115*2,119*1,120*1,131*1,132*7,133*3,181*1"; +w["result"]="22*1,24*1,37*1,131*1,132*7"; +w["resum"]="72*1,103*1,104*1,140*6"; +w["retaddr"]="153*2"; +w["retri"]="159*1"; +w["retried."]="51*1"; +w["retriev"]="3*1,4*1,9*2,18*2,70*1,89*1,98*1,136*1"; +w["return"]="9*1,33*2,34*3,37*1,41*2,43*3,52*1,55*2,56*3,63*6,68*2,70*1,77*1,78*2,82*2,84*1,85*4,89*2,91*12,96*3,98*1,105*1,124*2,125*1,126*3,131*4,132*10,136*3,139*1,140*9,153*2"; +w["returned."]="34*1,52*1,68*1,85*1,96*2,132*1"; +w["rev."]="171*1"; +w["rev.:"]="171*1"; +w["revis"]="63*9,170*52,171*1,185*2"; +w["right"]="171*3,172*1"; +w["ring"]="153*1"; +w["rise"]="61*1"; +w["risk"]="172*1"; +w["risk."]="172*1"; +w["rout"]="185*1"; +w["routin"]="185*1"; +w["rsp"]="24*1,39*2,41*41,42*41"; +w["rsp:"]="39*2,41*41,42*41"; +w["rsp_avr8_activate_phys"]="96*1"; +w["rsp_avr8_data"]="126*1,140*1"; +w["rsp_avr8_fail"]="127*1,140*1"; +w["rsp_avr8_list"]="140*1"; +w["rsp_avr8_ok"]="123*1,140*1"; +w["rsp_avr8_pc"]="125*1,140*1"; +w["rsp_discovery_fail"]="43*1"; +w["rsp_discovery_list"]="43*1"; +w["rsp_edbg_data"]="186*1"; +w["rsp_edbg_fail"]="186*1"; +w["rsp_edbg_list"]="186*1"; +w["rsp_edbg_ok"]="186*1"; +w["rsp_fail"]="37*1,42*1,140*3,186*3"; +w["rsp_housekeeping_data"]="56*2,63*1"; +w["rsp_housekeeping_fail"]="57*1,63*1"; +w["rsp_housekeeping_failed_with_data"]="63*1"; +w["rsp_housekeeping_list"]="55*1,63*1"; +w["rsp_housekeeping_ok"]="54*1,63*1"; +w["rsp_list"]="41*1"; +w["rt"]="1*1"; +w["rule"]="131*1,132*1,133*1,139*1"; +w["run"]="24*1,89*1,92*2,99*1,103*41,104*42,109*3,135*1,136*1,137*1,138*3,139*3,140*12,182*2,185*6"; +w["run:"]="139*1"; +w["runaway"]="135*1"; +w["runnin"]="52*1"; +w["rw"]="30*3,131*3,132*8,133*10,181*8,182*4,185*1"; +w["rwise"]="171*1"; + diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/index-3.js b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/index-3.js new file mode 100644 index 000000000..88d71a25a --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/index-3.js @@ -0,0 +1,846 @@ +//Auto generated index for searching by xsl-webhelpindexer for DocBook Webhelp.# Kasun Gajasinghe, University of Moratuwa +w["rx"]="0*1,91*3"; +w["rx-tx"]="0*1"; +w["s"]="7*1,78*1,140*1,143*1,144*1,171*2,173*1,185*2"; +w["sab"]="75*1,76*1,91*18,181*7"; +w["sale"]="171*2"; +w["sam"]="6*1"; +w["sam3"]="1*2"; +w["sam4"]="1*2"; +w["samd"]="1*2"; +w["samd20"]="1*1"; +w["same"]="1*1,22*1,25*1,28*1,29*1,46*1,47*1,60*1,66*1,67*1,70*1,94*1,95*1,98*1"; +w["samp"]="192*1"; +w["sampl"]="14*1,15*1,159*1"; +w["save"]="30*2"; +w["scale"]="0*1"; +w["scaled-down"]="0*1"; +w["scan"]="48*1,51*42,62*2,63*3,77*1"; +w["scan-chain"]="48*1,51*41,62*2"; +w["secion"]="140*3"; +w["section"]="3*2,7*1,27*1,28*1,29*1,37*1,40*1,45*1,46*1,47*1,64*1,65*1,66*1,67*1,75*1,76*1,79*50,88*1,91*1,93*1,94*1,95*1,111*2,112*2,113*1,114*1,115*1,133*16,135*1,140*28,160*1,165*1,169*1,185*4,186*1,192*1"; +w["secured."]="6*1"; +w["see"]="7*1,27*1,28*1,29*1,40*1,45*1,46*1,47*1,65*1,66*1,67*1,75*1,76*1,79*1,88*1,93*1,94*1,95*1,113*1,114*1,115*1,135*1,185*1"; +w["select"]="62*1,68*1,96*1,148*3,149*1,182*1"; +w["selector"]="91*3,140*3"; +w["self"]="38*1"; +w["self-contain"]="38*1"; +w["send"]="4*1,13*1,22*1,23*2,24*1,25*1"; +w["sent"]="14*1,24*1,25*1,37*3,101*1,102*1,104*1,109*1,173*2,175*1,180*1,185*1"; +w["sequenc"]="3*1,37*3,51*1,79*1,89*1"; +w["serial"]="3*1,5*1,7*37,21*1,43*3,177*1,190*1,192*50"; +w["serial_numb"]="190*1"; +w["serial_trac"]="3*1,13*2,14*2,15*2,16*2,17*2,18*2,19*2,20*2,21*2"; +w["serialtracecommand"]="186*1"; +w["serialtraceerrorbit"]="186*1"; +w["serialtracetransportmod"]="186*2"; +w["servic"]="91*6,181*1,185*1"; +w["sessio"]="138*1"; +w["session"]="48*2,49*41,62*1,63*9,88*2,89*3,90*1,91*3,100*1,109*1,131*4,132*2,134*2,135*6,136*5,137*42,138*43,139*1,140*9,188*41"; +w["session-rel"]="91*3,140*3"; +w["session."]="89*1,90*1,109*1,131*3,132*2,135*1,136*1,139*1"; +w["set"]="0*1,1*2,3*2,8*2,10*37,12*36,13*42,14*42,15*42,22*1,26*1,28*48,29*3,30*41,37*2,38*52,44*2,46*49,47*3,63*3,64*1,66*48,67*3,78*1,88*1,89*1,91*24,92*3,94*48,95*3,109*3,117*47,119*47,120*1,135*2,137*1,139*2,140*21,141*1,143*52,148*1,160*3,161*1,164*52,171*1,175*2,176*1,180*1,182*44,185*42,192*3,193*46"; +w["set."]="78*1,109*1,135*1,148*1,182*1"; +w["set_baud"]="15*2"; +w["set_capture_mod"]="14*2"; +w["set_config"]="3*1,10*2"; +w["set_request"]="3*1"; +w["set_transport_mod"]="13*2"; +w["setget_failure_illegal_st"]="63*1"; +w["setget_failure_invalid_clock_spe"]="63*1"; +w["setget_failure_invalid_valu"]="63*1"; +w["setget_failure_jtagm_init_error"]="63*1"; +w["setget_failure_not_impl"]="63*1"; +w["setget_failure_not_support"]="63*1"; +w["setget_failure_ok"]="63*1"; +w["sever"]="59*1,148*1"; +w["shal"]="171*1"; +w["shall"]="171*1"; +w["shift"]="77*5"; +w["short"]="91*3"; +w["short-packet"]="91*3"; +w["should"]="1*1,136*2,138*3,148*2"; +w["sign"]="49*1,62*2,188*1"; +w["signal"]="77*1,91*3,192*1"; +w["signal."]="192*1"; +w["signatur"]="111*1,131*3,132*3,133*3,140*9,141*1,156*43,160*3,185*3"; +w["signature_offset"]="133*1,185*1"; +w["signific"]="37*3,173*2"; +w["signon"]="21*44,192*1"; +w["silicon"]="185*3"; +w["simpl"]="0*1,96*1"; +w["simpli"]="138*1"; +w["sinc"]="153*1"; +w["singl"]="74*1,91*6,105*1,131*1,132*4,139*1,140*12,173*1,174*1"; +w["situat"]="37*1"; +w["size"]="6*2,9*3,10*2,13*2,14*2,15*2,16*2,17*2,18*2,19*2,20*56,21*2,23*3,24*3,25*4,27*1,28*1,29*1,30*1,32*1,33*1,34*1,35*1,37*3,40*1,41*1,42*1,45*1,46*1,47*1,49*1,50*1,51*1,52*1,54*1,55*1,56*1,57*1,59*1,60*1,61*1,65*1,66*1,67*1,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,81*1,82*1,83*1,84*1,85*2,86*1,91*6,93*1,94*1,95*1,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,123*1,124*1,125*1,126*1,127*1,129*1,130*1,131*1,142*2,143*2,144*2,145*2,146*2,147*2,148*3,149*2,152*2,153*2,162*2,163*2,164*2,165*2,166*2,167*2,181*2,182*1,185*17,188*1,192*1,193*1"; +w["skip"]="114*2"; +w["slave"]="91*3"; +w["sleep"]="58*1,60*38,63*3"; +w["small"]="131*1"; +w["sof"]="37*3"; +w["softwar"]="92*3,119*42,120*42,121*42,131*2,132*1,139*4,140*9,148*1,172*1"; +w["software."]="148*1"; +w["some"]="6*1,59*1,112*1,114*1,131*1,132*1,185*1,192*1"; +w["someth"]="140*3"; +w["sourc"]="37*2"; +w["space"]="131*1,132*1,133*1"; +w["special"]="0*1,3*1,171*1"; +w["specif"]="3*3,4*44,5*41,8*41,73*1,91*3,135*1,139*2,140*3,171*2,185*1"; +w["specifi"]="73*1,77*1,88*4,89*1,91*3,135*2,136*1,137*2,138*1,148*1"; +w["specific."]="139*1"; +w["specification."]="139*1"; +w["speed"]="140*3,160*3"; +w["spi"]="1*2,38*1,131*1,141*63,142*42,143*42,144*42,145*42,146*42,147*41,148*43,149*42,150*43,151*43,152*42,153*44,154*43,155*43,156*44,157*44,158*41,159*47,175*6,186*3"; +w["spi-bas"]="38*1"; +w["spi."]="175*1"; +w["spi_cmd_chip_eras"]="147*2,160*1"; +w["spi_cmd_enter_progmod"]="145*2,146*1,160*1"; +w["spi_cmd_get_baud"]="144*2,160*1"; +w["spi_cmd_leave_progmod"]="146*1,160*1"; +w["spi_cmd_load_address"]="142*2,160*1"; +w["spi_cmd_program_eeprom"]="150*1,160*1"; +w["spi_cmd_program_flash"]="148*3,160*1"; +w["spi_cmd_program_fus"]="152*2,160*1"; +w["spi_cmd_program_lock"]="154*1,160*1"; +w["spi_cmd_read_eeprom"]="151*1,160*1"; +w["spi_cmd_read_flash"]="149*2,160*1"; +w["spi_cmd_read_fus"]="153*2,160*1"; +w["spi_cmd_read_lock"]="155*1,160*1"; +w["spi_cmd_read_oscc"]="157*1,160*1"; +w["spi_cmd_read_osccal."]="157*1"; +w["spi_cmd_read_signatur"]="156*1,160*1"; +w["spi_cmd_read_signature."]="156*1"; +w["spi_cmd_set_baud"]="143*2,160*1"; +w["spi_multi"]="158*1,175*2"; +w["spi_status_baud_invalid"]="143*1,159*1,160*1"; +w["spi_status_clock_error"]="159*1,160*1"; +w["spi_status_cmd_fail"]="159*1,160*1"; +w["spi_status_cmd_ok"]="142*1,143*1,144*1,145*1,146*1,147*1,148*1,149*2,152*1,153*2,159*1,160*1"; +w["spi_status_cmd_tout"]="145*1,147*1,148*1,159*1,160*1"; +w["spi_status_cmd_unknown"]="159*1,160*1"; +w["spi_status_fail"]="145*1"; +w["spi_status_phy_error"]="159*1,160*1"; +w["spi_status_rdy_bsy_tout"]="148*1,149*1,152*1,153*1,159*1,160*1"; +w["spiprogrammingprotocolcommand"]="160*1"; +w["spiprogrammingprotocolrespons"]="160*1"; +w["spmcr"]="185*2"; +w["spmcr_addr"]="185*2"; +w["sram"]="131*1,132*1,133*1,140*3,185*3"; +w["sram_start"]="185*2"; +w["st_get_buffer_s"]="186*1"; +w["st_get_data"]="186*1"; +w["st_get_status"]="186*1"; +w["st_set_baud"]="186*1"; +w["st_set_capture_mod"]="186*1"; +w["st_set_transport_mod"]="186*1"; +w["st_signon"]="186*1"; +w["st_start"]="186*1"; +w["st_stop"]="186*1"; +w["stabdelay"]="145*2"; +w["stabdelay."]="145*1"; +w["stabil"]="145*1"; +w["stage"]="89*1,136*1"; +w["standalon"]="1*2"; +w["start"]="9*1,16*44,28*1,29*1,46*1,47*1,48*1,63*3,66*1,67*1,79*3,89*1,91*3,94*1,95*1,111*1,112*1,113*1,114*1,115*1,116*1,136*2,137*1,138*2,142*1,145*2,162*1,167*1,175*1,185*4,188*36,192*1"; +w["stat"]="139*1"; +w["state"]="59*1,60*3,61*1,63*3,91*3,110*2,138*1,139*2,140*3,185*2"; +w["state."]="139*1,185*2"; +w["statement"]="105*1"; +w["status"]="6*1,9*1,10*1,13*2,14*2,16*2,17*2,18*3,19*54,34*2,56*3,60*1,61*1,85*2,91*3,126*2,140*6,142*1,143*1,144*1,145*1,146*1,147*1,148*1,149*1,152*1,162*1,163*1,164*1,165*1,166*1,167*1,192*1"; +w["status."]="60*1"; +w["status1"]="149*1,153*1"; +w["status2"]="153*1"; +w["statutori"]="171*1"; +w["step"]="64*1,74*42,91*6,92*1,105*49,139*4,140*3"; +w["step:"]="139*1"; +w["stepping."]="139*1"; +w["still"]="59*1"; +w["stitut"]="79*1"; +w["stk500"]="175*2"; +w["stk500."]="175*1"; +w["stk600"]="180*1"; +w["stop"]="17*44,91*3,92*1,101*3,102*44,109*1,113*1,114*1,115*1,129*1,138*1,139*7,140*9,182*1,185*4,192*1"; +w["stop:"]="139*1"; +w["stopped."]="101*1,102*1"; +w["storag"]="192*1"; +w["store"]="131*2,135*1"; +w["strang"]="140*3"; +w["stream"]="0*1,18*1"; +w["string"]="21*1,190*3"; +w["studio"]="172*1"; +w["studio."]="172*1"; +w["sub"]="36*1,37*7,38*52,176*1"; +w["sub-protocol"]="36*1,37*7,38*1"; +w["sub-protocols."]="37*1"; +w["sub-set"]="38*51,176*1"; +w["subset"]="1*1"; +w["success"]="6*1,9*1,10*1,32*1,54*1,81*1,105*1,123*1,139*1,159*1,160*3"; +w["such"]="37*1,148*1,171*1"; +w["suffix"]="3*1"; +w["suffix."]="10*1"; +w["suitabl"]="171*1"; +w["summari"]="3*6"; +w["supoort"]="21*1"; +w["suppli"]="148*1,156*1,157*1"; +w["supplied."]="148*1,156*1,157*1"; +w["suppo"]="1*1"; +w["support"]="0*4,1*4,15*1,22*1,39*2,62*1,63*9,91*18,111*2,117*2,118*2,139*1,140*12,148*1,158*1,171*1,172*2,175*4,180*1,184*2,187*1,189*1,190*1,191*2"; +w["supported."]="1*1,13*1,14*1,175*2"; +w["supported:"]="139*1"; +w["sustain"]="171*1"; +w["swd"]="1*2,186*3,192*1"; +w["swo"]="7*1,192*1"; +w["symbol"]="102*1"; +w["sync"]="91*3"; +w["synchloop"]="145*2"; +w["synchloops."]="145*1"; +w["synchron"]="22*1,24*1,145*1"; +w["system"]="91*3,181*2"; +w["t"]="0*1"; +w["tabl"]="1*5,3*10,4*5,5*5,6*10,8*5,9*15,10*10,13*10,14*10,15*11,16*10,17*10,18*10,19*10,20*10,21*10,22*5,23*10,24*10,25*10,26*5,27*10,28*5,29*10,30*5,31*5,32*5,33*5,34*5,35*5,37*15,38*6,39*5,40*5,41*5,42*5,44*5,45*5,46*5,47*5,48*5,49*5,50*5,51*5,52*5,53*5,54*5,55*5,56*5,57*5,58*5,59*5,60*5,61*5,64*5,65*10,66*5,67*10,68*5,69*5,70*5,71*5,72*5,73*5,74*5,75*5,76*10,77*5,78*5,79*5,80*5,81*5,82*5,83*5,84*5,85*10,86*5,87*5,92*5,93*10,94*5,95*10,96*5,97*5,98*5,99*5,100*5,101*5,102*5,103*5,104*5,105*5,106*5,107*5,108*5,109*5,110*5,111*5,112*5,113*5,114*5,115*5,116*5,117*5,118*5,119*5,120*5,121*5,122*5,123*5,124*5,125*5,126*5,127*5,128*5,129*5,130*5,131*5,132*5,133*5,134*5,136*5,139*1,141*5,142*10,143*10,144*10,145*10,146*10,147*10,148*15,149*10,152*10,153*10,159*5,161*5,162*10,163*10,164*10,165*15,166*10,167*10,168*5,171*5,173*5,174*5,175*5,176*5,177*5,178*5,179*5,180*5,181*5,182*5,183*5,184*5,185*26,187*5,188*5,189*5,190*5,191*5,192*5,193*5"; +w["tag"]="186*6"; +w["take"]="88*1,131*2,132*1,135*1"; +w["tap"]="64*1,77*43"; +w["target"]="3*2,4*41,5*41,14*1,18*1,30*1,52*2,59*1,60*4,61*1,62*1,63*12,68*1,69*1,70*2,71*1,72*1,73*6,88*1,89*3,91*6,96*1,97*1,98*2,99*1,100*1,101*2,102*2,103*1,104*2,105*1,106*1,107*1,108*1,109*3,110*1,111*2,112*2,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,129*1,130*1,133*12,135*4,136*4,137*4,138*4,139*8,140*9,182*1,185*116,193*1"; +w["target-rel"]="63*3"; +w["target."]="14*1,52*1,69*2,70*2,89*1,97*2,98*2,100*1,102*1,105*1,106*1,107*1,108*1,109*1,111*1,113*1,115*1,116*1,119*1,120*1,136*1,139*2"; +w["targets."]="112*1"; +w["tdo"]="192*1"; +w["temporarili"]="110*1"; +w["term"]="38*1,171*2"; +w["termin"]="63*3,100*1,148*2"; +w["th"]="136*1,192*1"; +w["than"]="1*1,37*1,132*3,135*1,148*1,185*1"; +w["that"]="1*5,18*1,21*1,24*4,25*1,37*1,52*1,75*1,76*1,88*1,89*4,129*1,133*12,135*2,136*6,137*1,139*1,147*1,173*1,175*1,180*1,182*1,185*2,192*1"; +w["their"]="139*1,172*1"; +w["them"]="114*1"; +w["them."]="114*1,121*1"; +w["then"]="37*1,38*1,96*1,115*2"; +w["there"]="37*1"; +w["thereof"]="171*1"; +w["these"]="185*1"; +w["those"]="180*1"; +w["three"]="0*1,22*1"; +w["through"]="131*1"; +w["time"]="131*2,132*1,140*9,145*1,148*3,159*2,168*1,171*1,175*1"; +w["time-out"]="145*1"; +w["time."]="18*1"; +w["timeout"]="91*21,140*6,145*2,160*3"; +w["timeout."]="145*1"; +w["timer"]="140*3,185*3"; +w["ting"]="171*1"; +w["tinyavr"]="38*3,52*1,111*1,117*1,118*1,140*3,175*1,180*2"; +w["tinyocd"]="135*1"; +w["tip"]="44*1,62*41,87*46,134*46,173*1,174*1"; +w["tips:"]="134*46,174*1"; +w["token"]="78*1"; +w["too"]="43*3,63*3,91*6,140*6"; +w["tool"]="0*1,1*55,2*1,3*2,4*1,5*1,6*1,7*1,8*1,9*1,10*1,11*1,12*1,13*2,14*1,15*1,16*1,17*1,18*1,19*1,20*1,21*1,22*2,23*1,24*1,25*1,26*1,27*2,28*2,29*2,30*1,31*1,32*1,33*1,34*1,35*1,36*2,37*3,38*2,39*2,40*2,41*1,42*1,43*10,44*1,45*2,46*2,47*2,48*1,49*4,50*1,51*1,52*1,53*1,54*1,55*1,56*1,57*1,58*1,59*1,60*1,61*1,62*1,63*1,64*1,65*2,66*2,67*2,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,80*1,81*1,82*1,83*1,84*1,85*1,86*1,87*1,88*1,89*3,90*1,91*1,92*1,93*2,94*2,95*2,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,122*1,123*1,124*1,125*1,126*1,127*1,128*1,129*1,130*1,131*1,132*1,133*1,134*1,135*2,136*3,137*1,138*1,139*2,140*1,141*1,142*1,143*1,144*1,145*1,146*1,147*1,148*1,149*1,150*1,151*1,152*1,153*1,154*1,155*1,156*1,157*1,158*1,159*1,160*1,161*1,162*1,163*1,164*1,165*1,166*1,167*1,168*1,169*1,170*1,171*51,172*1,173*2,174*2,175*2,176*1,177*1,178*1,179*2,180*2,181*1,182*1,183*1,184*1,185*1,186*1,187*1,188*3,189*1,190*2,191*1,192*4,193*1"; +w["tool."]="27*1,28*1,36*1,37*2,40*1,45*1,49*1,65*1,93*1,139*1,188*1,192*1"; +w["tool.."]="29*1,46*1,47*1,66*1,67*1,94*1,95*1"; +w["tool_nam"]="190*1"; +w["tools."]="3*1,173*1"; +w["total"]="20*1,148*1,149*1"; +w["total_number_of_packet"]="23*1"; +w["tpi"]="1*1,38*2,161*52,162*42,163*42,164*42,165*41,166*42,167*42,168*46,169*6,171*1,180*56"; +w["tpi_cmd_enter_progmod"]="162*2,169*1"; +w["tpi_cmd_eras"]="165*2,169*1"; +w["tpi_cmd_erase_chip"]="165*1"; +w["tpi_cmd_leave_progmod"]="163*2,169*1"; +w["tpi_cmd_read_mem"]="167*2,169*1"; +w["tpi_cmd_set_param"]="164*2,169*1"; +w["tpi_cmd_write_mem"]="166*2,169*1"; +w["tpi_erase_app"]="165*2,169*1"; +w["tpi_erase_chip"]="165*2,169*1"; +w["tpi_erase_chip."]="165*1"; +w["tpi_erase_config"]="165*2,169*1"; +w["tpi_mem_type_appl"]="166*1,167*1,169*1"; +w["tpi_mem_type_fus"]="166*1,167*1,169*1"; +w["tpi_mem_type_lockbit"]="166*1,167*1,169*1"; +w["tpi_param_nvmcmd_addr"]="169*1"; +w["tpi_param_nvmcsr_addr"]="169*1"; +w["tpi_rsp_err_collis"]="162*1,165*1,166*1,167*1,168*1,169*1"; +w["tpi_rsp_err_fail"]="162*1,164*1,165*1,166*1,167*1,168*1,169*1"; +w["tpi_rsp_err_illegal_param"]="164*1,168*1,169*1"; +w["tpi_rsp_err_ok"]="162*1,163*1,164*1,165*1,166*1,167*1,168*1,169*1"; +w["tpi_rsp_err_timeout"]="165*1,166*1,168*1,169*1"; +w["tpiprotocol"]="169*1,180*2"; +w["tpiprotocol."]="169*1,180*1"; +w["trace"]="3*1,5*1,7*39,21*1,177*1,192*50"; +w["trademark"]="171*5"; +w["trail"]="34*1,56*2,85*1,126*1"; +w["transfer"]="13*1,148*1"; +w["transit"]="60*1,139*1"; +w["transitions."]="60*1"; +w["transmit"]="91*3,145*4,147*4,152*4,153*5"; +w["transport"]="13*54,37*1,91*3,130*1,192*1"; +w["transport-rel"]="91*3"; +w["transport_hid"]="186*1"; +w["transport_off"]="186*1"; +w["trial"]="62*1"; +w["trigger"]="185*1"; +w["tune"]="91*3"; +w["twi"]="186*3"; +w["two"]="23*1,85*1"; +w["tx"]="0*1,91*3"; +w["type"]="9*1,27*2,40*2,45*2,65*2,75*5,76*6,79*3,93*2,113*4,114*4,115*4,117*1,135*3,139*1,140*6,148*1,159*6,166*1,167*1,168*5,169*3,174*1,181*36,183*46,185*1,186*3"; +w["typic"]="135*2"; +w["u"]="148*1,171*2"; +w["u.s."]="171*2"; +w["uar"]="0*1"; +w["uart"]="14*2,186*3"; +w["uc3"]="38*1,90*1,173*2"; +w["uc3a"]="182*1"; +w["uc3c"]="182*2"; +w["ued."]="148*1"; +w["unaffected."]="110*1"; +w["uncondit"]="139*1"; +w["unconditionally."]="139*1"; +w["under"]="140*3"; +w["underrun"]="37*2"; +w["undesir"]="37*1"; +w["undo"]="37*1"; +w["unexpect"]="91*3"; +w["unknown"]="35*1,37*1,42*1,43*3,57*1,86*1,127*1,159*1,160*3,168*1"; +w["unless"]="171*1"; +w["unlimit"]="171*1"; +w["unlock"]="79*3"; +w["unspecifi"]="129*1,140*3"; +w["unsupport"]="43*3,140*3"; +w["until"]="139*1,148*1,185*1"; +w["unwrap"]="22*2,24*41,25*41"; +w["up"]="0*1,1*1,2*1,3*1,4*1,5*1,6*1,7*1,8*1,9*1,10*1,11*1,12*1,13*1,14*1,15*1,16*1,17*1,18*2,19*1,20*1,21*1,22*1,23*2,24*1,25*1,26*1,27*1,28*1,29*1,30*1,31*1,32*1,33*1,34*1,35*1,36*1,37*1,38*1,39*1,40*1,41*1,42*1,43*1,44*1,45*1,46*1,47*1,48*1,49*1,50*1,51*1,52*1,53*1,54*1,55*1,56*1,57*1,58*1,59*1,60*1,61*1,62*1,63*4,64*1,65*1,66*1,67*1,68*1,69*1,70*1,71*1,72*1,73*1,74*1,75*1,76*1,77*1,78*1,79*1,80*1,81*1,82*1,83*1,84*1,85*1,86*1,87*1,88*1,89*1,90*1,91*1,92*1,93*1,94*1,95*1,96*1,97*1,98*1,99*1,100*1,101*1,102*1,103*1,104*1,105*1,106*1,107*1,108*1,109*1,110*1,111*1,112*1,113*1,114*1,115*1,116*1,117*1,118*1,119*1,120*1,121*1,122*1,123*1,124*1,125*1,126*1,127*1,128*1,129*1,130*1,131*1,132*7,133*1,134*1,135*1,136*1,137*1,138*1,139*1,140*1,141*1,142*1,143*1,144*1,145*1,146*1,147*1,148*1,149*1,150*1,151*1,152*1,153*1,154*1,155*1,156*1,157*1,158*1,159*1,160*1,161*1,162*1,163*1,164*1,165*1,166*1,167*1,168*1,169*1,181*1,182*1,183*1,184*1,185*1,186*1,187*1,188*1,189*1,190*1,191*1,192*1,193*1"; +w["upd"]="171*1"; +w["updat"]="139*1"; +w["updated."]="139*1"; +w["upgrad"]="1*1,48*1,50*44,63*3"; +w["upon"]="1*1,36*1,73*1,131*1,132*1,135*1,175*1,180*1"; +w["usag"]="3*1,30*1,131*1,132*1,133*1"; +w["usart"]="186*3"; +w["usb"]="0*1,1*2,185*1"; +w["use"]="0*1,1*9,3*2,21*1,22*4,27*1,28*1,29*1,37*4,38*6,39*1,40*1,45*1,46*1,47*1,51*2,62*4,65*1,66*1,67*1,68*1,78*2,79*1,88*5,89*3,90*1,93*1,94*1,95*1,96*1,112*1,114*1,117*1,121*1,131*7,132*12,133*13,135*2,136*4,137*3,138*1,139*2,142*1,143*2,144*1,145*1,147*2,148*7,149*1,150*2,151*2,152*1,153*1,154*2,155*2,156*2,157*2,166*2,167*1,171*4,172*1,173*1,175*4,178*1,180*5,185*2,192*4"; +w["used."]="22*1,37*1,79*1,135*1,137*1,148*2"; +w["user"]="62*1,89*1,91*3,111*1,132*1,133*1,136*1,140*6,172*1,181*1,182*1,185*1"; +w["user_sign_base_addr"]="133*1,185*1"; +w["usual"]="75*1,76*1,136*1,182*1"; +w["usual."]="136*1"; +w["valid"]="27*1,28*1,29*1,34*1,40*1,45*1,46*1,47*1,56*1,65*1,66*1,67*1,85*1,89*2,91*9,93*1,94*1,95*1,126*1,136*2,140*3"; +w["valid."]="34*1,56*1,85*1,126*1"; +w["valu"]="3*1,4*1,9*1,10*1,37*4,60*1,63*6,70*1,78*1,84*2,89*1,91*12,96*1,98*1,107*1,110*1,117*1,125*2,129*1,132*1,135*1,136*2,139*1,140*12,148*15,153*1,159*1,160*3,164*2,168*1,175*1,180*1,182*1,185*6,193*1"; +w["values."]="139*1"; +w["values:"]="9*1,10*1,185*1"; +w["vari"]="1*1,111*1"; +w["variabl"]="185*1"; +w["variant"]="135*1,140*3"; +w["variant:"]="135*1"; +w["various"]="51*1"; +w["vector"]="101*1,109*1,139*1"; +w["ven"]="22*1"; +w["vendor"]="0*1,3*52,4*46,5*41,8*41,22*3,177*1,192*1"; +w["vendor-command"]="4*5"; +w["veri"]="1*1,90*1"; +w["version"]="1*3,27*2,28*2,29*2,32*2,33*2,34*7,35*2,37*4,40*2,41*2,42*2,45*2,46*2,47*2,49*3,50*2,51*2,52*2,54*2,55*2,56*8,57*2,59*2,60*2,61*2,62*1,65*2,66*2,67*2,68*2,69*2,70*2,71*2,72*2,73*2,74*2,75*2,76*2,77*2,78*2,79*2,81*2,82*2,83*2,84*2,85*15,86*2,91*6,93*2,94*2,95*2,96*2,97*2,98*2,99*2,100*2,101*2,102*2,103*2,104*2,105*2,106*2,107*2,108*2,109*2,110*2,111*2,112*2,113*2,114*2,115*2,116*2,117*2,118*2,119*2,120*2,121*2,123*2,124*2,125*2,126*7,127*2,129*2,130*2,140*3,188*2,193*3"; +w["via"]="140*3"; +w["violat"]="131*1,132*1"; +w["virtual"]="0*2,1*2"; +w["voltag"]="63*3,193*1"; +w["vtg"]="193*1"; +w["vtref"]="62*1"; +w["w"]="133*4,181*2,182*7,185*14"; +w["wait"]="91*3"; +w["want"]="140*6,172*1"; +w["warn"]="159*1,160*3"; +w["warrant"]="171*1"; +w["warranti"]="171*3"; +w["was"]="32*1,54*1,81*1,91*6,123*1"; +w["way"]="182*1"; +w["way."]="182*1"; +w["websit"]="171*1"; +w["well"]="0*1,1*1,135*1,180*1"; +w["went"]="63*6"; +w["what"]="135*1,148*1"; +w["whatsoev"]="171*1"; +w["when"]="6*1,24*1,28*1,29*1,46*1,47*1,66*1,67*1,78*2,88*3,89*1,94*1,95*1,101*1,102*1,104*1,109*1,113*1,114*1,115*1,119*1,120*1,135*1,136*2,138*1,139*1,140*12,148*2,185*3,192*1"; +w["where"]="37*1,121*1"; +w["wherea"]="135*1"; +w["whether"]="34*1,56*1,78*1,79*1,85*1,88*1,126*1,138*1"; +w["which"]="0*2,1*2,3*1,15*1,23*2,36*1,37*4,38*1,79*1,89*1,114*2,135*2,136*1,148*1,153*1,172*2,178*1"; +w["while"]="114*1,140*12"; +w["who"]="172*1"; +w["whole"]="165*1"; +w["will"]="1*1,10*1,23*1,24*1,37*4,49*1,51*3,52*1,60*1,79*3,89*1,101*1,102*1,109*4,110*2,115*1,131*2,135*1,136*2,137*2,138*1,139*1,148*1,172*1,175*2,180*2,185*2"; +w["window"]="171*1"; +w["within"]="79*1,131*1,132*1,140*3"; +w["without"]="52*1,171*2,172*1"; +w["woke"]="63*3"; +w["word"]="91*3,104*1,106*1,107*1,117*1,129*1,131*2,148*8,173*2,181*5,185*3"; +w["work"]="10*1,51*1,148*1"; +w["works."]="148*1"; +w["wr"]="137*1"; +w["wrap"]="22*1,23*43"; +w["wrapper"]="24*1"; +w["write"]="10*1,28*2,46*2,64*1,66*2,72*1,76*42,79*1,91*15,92*2,94*2,107*46,115*51,131*2,132*9,133*18,139*2,140*12,148*9,161*1,164*1,166*55,175*1,182*1,185*1"; +w["write."]="115*1"; +w["write:"]="139*2"; +w["writeabl"]="184*1,191*1"; +w["written"]="76*1,131*2,132*3,182*1,185*1"; +w["wrong"]="63*18"; +w["x"]="119*2,120*2,193*1"; +w["xmega"]="38*1,52*1,111*1,112*1,117*1,118*1,133*58,139*1,140*9,180*1,183*1,185*39"; +w["xmega_erase_app"]="140*1"; +w["xmega_erase_app_pag"]="140*1"; +w["xmega_erase_boot"]="140*1"; +w["xmega_erase_boot_pag"]="140*1"; +w["xmega_erase_chip"]="140*1"; +w["xmega_erase_eeprom"]="140*1"; +w["xmega_erase_eeprom_pag"]="140*1"; +w["xmega_erase_usersig"]="140*1"; +w["xml"]="135*1,145*7,146*2,147*2,148*3,153*1,175*1"; +w["xml:"]="145*7,146*2,147*2,148*2,153*1"; +w["xplain"]="1*2"; +w["xx"]="136*1"; +w["yet"]="109*1"; +w["yy"]="136*1"; +w["yyyymmddhhmmss"]="190*1"; +w[" "]="0*3,1*4,2*3,3*3,4*3,5*3,6*3,7*3,8*3,9*3,10*3,11*3,12*3,13*3,14*3,15*3,16*3,17*3,18*3,19*3,20*3,21*3,22*3,23*3,24*3,25*3,26*3,27*3,28*3,29*3,30*3,31*3,32*3,33*3,34*3,35*3,36*3,37*3,38*3,39*3,40*3,41*3,42*3,43*3,44*3,45*3,46*3,47*3,48*3,49*3,50*3,51*3,52*3,53*3,54*3,55*3,56*3,57*3,58*3,59*3,60*3,61*3,62*3,63*3,64*3,65*3,66*3,67*3,68*3,69*3,70*3,71*3,72*3,73*3,74*3,75*3,76*3,77*3,78*4,79*3,80*3,81*3,82*3,83*3,84*3,85*3,86*3,87*3,88*3,89*3,90*3,91*3,92*3,93*3,94*3,95*3,96*3,97*3,98*3,99*3,100*3,101*3,102*3,103*3,104*3,105*3,106*3,107*3,108*3,109*3,110*3,111*3,112*3,113*3,114*3,115*3,116*3,117*3,118*3,119*3,120*3,121*3,122*3,123*3,124*3,125*3,126*3,127*3,128*3,129*3,130*3,131*3,132*3,133*3,134*3,135*3,136*3,137*3,138*3,139*3,140*3,141*3,142*3,143*3,144*3,145*3,146*3,147*3,148*4,149*3,150*3,151*3,152*3,153*3,154*3,155*3,156*3,157*3,158*3,159*3,160*3,161*3,162*3,163*3,164*3,165*3,166*3,167*3,168*3,169*3,170*4,171*3,172*4,173*4,174*4,175*4,176*4,177*4,178*4,179*4,180*4,181*3,182*3,183*3,184*3,185*5,186*3,187*3,188*3,189*3,190*3,191*3,192*3,193*3"; +w[" 1"]="1*5"; +w[" 1."]="1*5"; +w[" 10"]="10*5"; +w[" 10."]="10*5"; +w[" 100"]="185*5"; +w[" 100."]="185*5"; +w[" 101"]="185*5"; +w[" 101."]="185*5"; +w[" 102"]="96*5"; +w[" 102."]="96*5"; +w[" 103"]="97*5"; +w[" 103."]="97*5"; +w[" 104"]="98*5"; +w[" 104."]="98*5"; +w[" 105"]="99*5"; +w[" 105."]="99*5"; +w[" 106"]="100*5"; +w[" 106."]="100*5"; +w[" 107"]="101*5"; +w[" 107."]="101*5"; +w[" 108"]="102*5"; +w[" 108."]="102*5"; +w[" 109"]="103*5"; +w[" 109."]="103*5"; +w[" 11"]="13*5"; +w[" 11."]="13*5"; +w[" 110"]="104*5"; +w[" 110."]="104*5"; +w[" 111"]="105*5"; +w[" 111."]="105*5"; +w[" 112"]="106*5"; +w[" 112."]="106*5"; +w[" 113"]="107*5"; +w[" 113."]="107*5"; +w[" 114"]="108*5"; +w[" 114."]="108*5"; +w[" 115"]="109*5"; +w[" 115."]="109*5"; +w[" 116"]="110*5"; +w[" 116."]="110*5"; +w[" 117"]="111*5"; +w[" 117."]="111*5"; +w[" 118"]="112*5"; +w[" 118."]="112*5"; +w[" 119"]="113*5"; +w[" 119."]="113*5"; +w[" 12"]="13*5"; +w[" 12."]="13*5"; +w[" 120"]="114*5"; +w[" 120."]="114*5"; +w[" 121"]="115*5"; +w[" 121."]="115*5"; +w[" 122"]="116*5"; +w[" 122."]="116*5"; +w[" 123"]="117*5"; +w[" 123."]="117*5"; +w[" 124"]="118*5"; +w[" 124."]="118*5"; +w[" 125"]="119*5"; +w[" 125."]="119*5"; +w[" 126"]="120*5"; +w[" 126."]="120*5"; +w[" 127"]="121*5"; +w[" 127."]="121*5"; +w[" 128"]="123*5"; +w[" 128."]="123*5"; +w[" 129"]="124*5"; +w[" 129."]="124*5"; +w[" 13"]="14*5"; +w[" 13."]="14*5"; +w[" 130"]="125*5"; +w[" 130."]="125*5"; +w[" 131"]="126*5"; +w[" 131."]="126*5"; +w[" 132"]="127*5"; +w[" 132."]="127*5"; +w[" 133"]="129*5"; +w[" 133."]="129*5"; +w[" 134"]="130*5"; +w[" 134."]="130*5"; +w[" 135"]="131*5"; +w[" 135."]="131*5"; +w[" 136"]="132*5"; +w[" 136."]="132*5"; +w[" 137"]="133*5"; +w[" 137."]="133*5"; +w[" 138"]="136*5"; +w[" 138."]="136*5"; +w[" 139"]="142*5"; +w[" 139."]="142*5"; +w[" 14"]="14*5"; +w[" 14."]="14*5"; +w[" 140"]="142*5"; +w[" 140."]="142*5"; +w[" 141"]="143*5"; +w[" 141."]="143*5"; +w[" 142"]="143*5"; +w[" 142."]="143*5"; +w[" 143"]="144*5"; +w[" 143."]="144*5"; +w[" 144"]="144*5"; +w[" 144."]="144*5"; +w[" 145"]="145*5"; +w[" 145."]="145*5"; +w[" 146"]="145*5"; +w[" 146."]="145*5"; +w[" 147"]="146*5"; +w[" 147."]="146*5"; +w[" 148"]="146*5"; +w[" 148."]="146*5"; +w[" 149"]="147*5"; +w[" 149."]="147*5"; +w[" 15"]="15*5"; +w[" 15."]="15*5"; +w[" 150"]="147*5"; +w[" 150."]="147*5"; +w[" 151"]="148*5"; +w[" 151."]="148*5"; +w[" 152"]="148*5"; +w[" 152."]="148*5"; +w[" 153"]="148*5"; +w[" 153."]="148*5"; +w[" 154"]="149*5"; +w[" 154."]="149*5"; +w[" 155"]="149*5"; +w[" 155."]="149*5"; +w[" 156"]="152*5"; +w[" 156."]="152*5"; +w[" 157"]="152*5"; +w[" 157."]="152*5"; +w[" 158"]="153*5"; +w[" 158."]="153*5"; +w[" 159"]="153*5"; +w[" 159."]="153*5"; +w[" 16"]="15*5"; +w[" 16."]="15*5"; +w[" 160"]="159*5"; +w[" 160."]="159*5"; +w[" 161"]="162*5"; +w[" 161."]="162*5"; +w[" 162"]="162*5"; +w[" 162."]="162*5"; +w[" 163"]="163*5"; +w[" 163."]="163*5"; +w[" 164"]="163*5"; +w[" 164."]="163*5"; +w[" 165"]="164*5"; +w[" 165."]="164*5"; +w[" 166"]="164*5"; +w[" 166."]="164*5"; +w[" 167"]="165*5"; +w[" 167."]="165*5"; +w[" 168"]="165*5"; +w[" 168."]="165*5"; +w[" 169"]="165*5"; +w[" 169."]="165*5"; +w[" 17"]="16*5"; +w[" 17."]="16*5"; +w[" 170"]="166*5"; +w[" 170."]="166*5"; +w[" 171"]="166*5"; +w[" 171."]="166*5"; +w[" 172"]="167*5"; +w[" 172."]="167*5"; +w[" 173"]="167*5"; +w[" 173."]="167*5"; +w[" 174"]="168*5"; +w[" 174."]="168*5"; +w[" 18"]="16*5"; +w[" 18."]="16*5"; +w[" 19"]="17*5"; +w[" 19."]="17*5"; +w[" 2"]="3*5"; +w[" 2."]="3*5"; +w[" 20"]="17*5"; +w[" 20."]="17*5"; +w[" 21"]="18*5"; +w[" 21."]="18*5"; +w[" 22"]="18*5"; +w[" 22."]="18*5"; +w[" 23"]="19*5"; +w[" 23."]="19*5"; +w[" 24"]="19*5"; +w[" 24."]="19*5"; +w[" 25"]="20*5"; +w[" 25."]="20*5"; +w[" 26"]="20*5"; +w[" 26."]="20*5"; +w[" 27"]="21*5"; +w[" 27."]="21*5"; +w[" 28"]="21*5"; +w[" 28."]="21*5"; +w[" 29"]="23*5"; +w[" 29."]="23*5"; +w[" 3"]="4*5"; +w[" 3."]="4*5"; +w[" 30"]="23*5"; +w[" 30."]="23*5"; +w[" 31"]="24*5"; +w[" 31."]="24*5"; +w[" 32"]="24*5"; +w[" 32."]="24*5"; +w[" 33"]="25*5"; +w[" 33."]="25*5"; +w[" 34"]="25*5"; +w[" 34."]="25*5"; +w[" 35"]="27*5"; +w[" 35."]="27*5"; +w[" 36"]="187*5"; +w[" 36."]="187*5"; +w[" 37"]="28*5"; +w[" 37."]="28*5"; +w[" 38"]="29*5"; +w[" 38."]="29*5"; +w[" 39"]="30*5"; +w[" 39."]="30*5"; +w[" 4"]="6*5"; +w[" 4."]="6*5"; +w[" 40"]="32*5"; +w[" 40."]="32*5"; +w[" 41"]="33*5"; +w[" 41."]="33*5"; +w[" 42"]="34*5"; +w[" 42."]="34*5"; +w[" 43"]="35*5"; +w[" 43."]="35*5"; +w[" 44"]="37*5"; +w[" 44."]="37*5"; +w[" 45"]="37*5"; +w[" 45."]="37*5"; +w[" 46"]="37*5"; +w[" 46."]="37*5"; +w[" 47"]="38*5"; +w[" 47."]="38*5"; +w[" 48"]="40*5"; +w[" 48."]="40*5"; +w[" 49"]="190*5"; +w[" 49."]="190*5"; +w[" 5"]="6*5"; +w[" 5."]="6*5"; +w[" 50"]="41*5"; +w[" 50."]="41*5"; +w[" 51"]="42*5"; +w[" 51."]="42*5"; +w[" 52"]="45*5"; +w[" 52."]="45*5"; +w[" 53"]="189*5"; +w[" 53."]="189*5"; +w[" 54"]="46*5"; +w[" 54."]="46*5"; +w[" 55"]="47*5"; +w[" 55."]="47*5"; +w[" 56"]="193*5"; +w[" 56."]="193*5"; +w[" 57"]="188*5"; +w[" 57."]="188*5"; +w[" 58"]="49*5"; +w[" 58."]="49*5"; +w[" 59"]="50*5"; +w[" 59."]="50*5"; +w[" 6"]="9*5"; +w[" 6."]="9*5"; +w[" 60"]="51*5"; +w[" 60."]="51*5"; +w[" 61"]="52*5"; +w[" 61."]="52*5"; +w[" 62"]="54*5"; +w[" 62."]="54*5"; +w[" 63"]="55*5"; +w[" 63."]="55*5"; +w[" 64"]="56*5"; +w[" 64."]="56*5"; +w[" 65"]="57*5"; +w[" 65."]="57*5"; +w[" 66"]="59*5"; +w[" 66."]="59*5"; +w[" 67"]="60*5"; +w[" 67."]="60*5"; +w[" 68"]="61*5"; +w[" 68."]="61*5"; +w[" 69"]="65*5"; +w[" 69."]="65*5"; +w[" 7"]="9*5"; +w[" 7."]="9*5"; +w[" 70"]="191*5"; +w[" 70."]="191*5"; +w[" 71"]="66*5"; +w[" 71."]="66*5"; +w[" 72"]="67*5"; +w[" 72."]="67*5"; +w[" 73"]="182*5"; +w[" 73."]="182*5"; +w[" 74"]="68*5"; +w[" 74."]="68*5"; +w[" 75"]="69*5"; +w[" 75."]="69*5"; +w[" 76"]="70*5"; +w[" 76."]="70*5"; +w[" 77"]="71*5"; +w[" 77."]="71*5"; +w[" 78"]="72*5"; +w[" 78."]="72*5"; +w[" 79"]="73*5"; +w[" 79."]="73*5"; +w[" 8"]="9*5"; +w[" 8."]="9*5"; +w[" 80"]="74*5"; +w[" 80."]="74*5"; +w[" 81"]="75*5"; +w[" 81."]="75*5"; +w[" 82"]="76*5"; +w[" 82."]="76*5"; +w[" 83"]="181*5"; +w[" 83."]="181*5"; +w[" 84"]="77*5"; +w[" 84."]="77*5"; +w[" 85"]="78*5"; +w[" 85."]="78*5"; +w[" 86"]="79*5"; +w[" 86."]="79*5"; +w[" 87"]="81*5"; +w[" 87."]="81*5"; +w[" 88"]="82*5"; +w[" 88."]="82*5"; +w[" 89"]="83*5"; +w[" 89."]="83*5"; +w[" 9"]="10*5"; +w[" 9."]="10*5"; +w[" 90"]="84*5"; +w[" 90."]="84*5"; +w[" 91"]="85*5"; +w[" 91."]="85*5"; +w[" 92"]="85*5"; +w[" 92."]="85*5"; +w[" 93"]="86*5"; +w[" 93."]="86*5"; +w[" 94"]="93*5"; +w[" 94."]="93*5"; +w[" 95"]="184*5"; +w[" 95."]="184*5"; +w[" 96"]="94*5"; +w[" 96."]="94*5"; +w[" 97"]="95*5"; +w[" 97."]="95*5"; +w[" 98"]="185*5"; +w[" 98."]="185*5"; +w[" 99"]="185*5"; +w[" 99."]="185*5"; +w[" activ"]="68*5,96*5"; +w[" atmel"]="1*5"; +w[" attach"]="99*5"; +w[" avr"]="4*5,133*5"; +w[" avr32"]="181*5,182*5,191*5"; +w[" avr8"]="184*5,185*5"; +w[" calibr"]="52*5"; +w[" command"]="37*5"; +w[" configur"]="9*5"; +w[" crc"]="112*5"; +w[" custom"]="6*5"; +w[" data"]="34*5,56*5,85*10,126*5"; +w[" deactiv"]="69*5,97*5"; +w[" debugwir"]="131*5"; +w[" detach"]="100*5"; +w[" devic"]="185*15"; +w[" disabl"]="110*5"; +w[" discoveri"]="190*5"; +w[" edbg"]="30*5,187*5"; +w[" end"]="49*5"; +w[" eras"]="6*5,71*5,79*5,111*5"; +w[" event"]="37*5,129*5,130*5"; +w[" event:"]="129*5,130*5"; +w[" extern"]="61*5"; +w[" fail"]="35*5,42*5,57*5,86*5,127*5"; +w[" firmwar"]="50*5"; +w[" get"]="9*10,18*10,19*10,20*10,29*5,47*5,67*5,70*5,95*5,98*5"; +w[" halt"]="72*5"; +w[" hardwar"]="117*5,118*5"; +w[" houekeep"]="189*5,193*5"; +w[" id"]="83*5,136*5"; +w[" jtag"]="51*5"; +w[" list"]="33*5,41*5,55*5,82*5,124*5"; +w[" megaavr"]="132*5"; +w[" memori"]="113*5,114*5,115*5"; +w[" ok"]="32*5,54*5,81*5,123*5"; +w[" page"]="116*5"; +w[" pc"]="84*5,106*5,107*5,125*5"; +w[" power"]="59*5"; +w[" prog"]="108*5,109*5"; +w[" protocol"]="38*5"; +w[" queri"]="27*5,40*5,45*5,65*5,93*5"; +w[" read"]="75*5"; +w[" reset"]="101*5"; +w[" respons"]="37*5"; +w[" run"]="103*5,104*5"; +w[" set"]="10*10,13*10,14*10,15*10,28*5,46*5,66*5,94*5"; +w[" signon"]="21*10"; +w[" sleep"]="60*5"; +w[" softwar"]="119*5,120*5,121*5"; +w[" spi"]="142*10,143*10,144*10,145*10,146*10,147*10,148*15,149*10,152*10,153*10,159*5"; +w[" start"]="16*10,188*5"; +w[" step"]="74*5,105*5"; +w[" stop"]="17*10,102*5"; +w[" tap"]="77*5"; +w[" tpi"]="162*10,163*10,164*10,165*15,166*10,167*10,168*5"; +w[" unwrap"]="23*5,24*5,25*5"; +w[" vendor"]="3*5"; +w[" wrap"]="23*5,24*5,25*5"; +w[" write"]="73*5,76*5"; +w["©"]="171*1"; +w["®"]="0*1,171*5,172*1"; +w["®."]="0*1"; +w["–"]="24*1,62*1,148*1"; +w["‘debug"]="109*1"; +w["‘program"]="109*1"; +w["’"]="109*2"; +w["’s"]="23*1"; +w["“activ"]="89*1,136*1"; +w["“attach"]="138*1"; +w["“avr32"]="65*1"; +w["“avr8"]="93*1"; +w["“deactiv"]="138*1"; +w["“debug"]="137*1"; +w["“detach"]="138*1"; +w["“devic"]="133*12"; +w["“discov"]="37*2"; +w["“discoveri"]="40*1"; +w["“edbg"]="27*1"; +w["“edbgctrl"]="28*1,29*1"; +w["“enter"]="137*1,138*1"; +w["“function"]="137*2"; +w["“housekeep"]="45*1,46*1,47*1"; +w["“leav"]="138*1"; +w["“memori"]="75*1,76*1,79*1,113*1,114*1,115*1"; +w["“program"]="137*1"; +w["“queri"]="37*2"; +w["“serial"]="7*1"; +w["“set"]="66*1,67*1,94*1,95*1"; +w["“start"]="88*1,135*1"; +w["â€"]="7*1,27*1,37*4,75*1,76*1,79*1,89*1,93*1,94*1,133*12,136*1,137*5,138*5"; + diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/l10n.js b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/l10n.js new file mode 100644 index 000000000..3147f961f --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/l10n.js @@ -0,0 +1,3 @@ +//Resource strings for localization +var localeresource = new Object; +localeresource["search_no_results"]="Your search returned no results."; diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/nwSearchFnt.js b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/nwSearchFnt.js new file mode 100644 index 000000000..bf4aa3fd2 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/nwSearchFnt.js @@ -0,0 +1,886 @@ +/*---------------------------------------------------------------------------- + * JavaScript for webhelp search + *---------------------------------------------------------------------------- + This file is part of the webhelpsearch plugin for DocBook WebHelp + Copyright (c) 2007-2008 NexWave Solutions All Rights Reserved. + www.nexwave.biz Nadege Quaine + http://kasunbg.blogspot.com/ Kasun Gajasinghe + */ + +//string initialization +var htmlfileList = "htmlFileInfoList.js"; +var htmlfileinfoList = "htmlFileInfoList.js"; +var useCJKTokenizing = false; + +var w = new Object(); +var scoring = new Object(); + +var searchTextField = ''; +var no = 0; +var noWords = 0; +var partialSearch = "There is no page containing all the search terms.
        Partial results:
        "; +var warningMsg = '
        '; +warningMsg+='Please note that due to security settings, Google Chrome does not highlight'; +warningMsg+=' the search results in the right frame.
        '; +warningMsg+='This happens only when the WebHelp files are loaded from the local file system.
        '; +warningMsg+='Workarounds:'; +warningMsg+='
          '; +warningMsg+='
        • Try using another web browser.
        • '; +warningMsg+='
        • Deploy the WebHelp files on a web server.
        • '; +warningMsg+='
        '; +txt_filesfound = 'Results'; +txt_enter_at_least_1_char = "You must enter at least one character."; +txt_enter_more_than_10_words = "Only first 10 words will be processed."; +txt_browser_not_supported = "Your browser is not supported. Use of Mozilla Firefox is recommended."; +txt_please_wait = "Please wait. Search in progress..."; +txt_results_for = "Results for: "; + +/* This function verify the validity of search input by the user + Cette fonction verifie la validite de la recherche entrre par l utilisateur */ +function Verifie(searchForm) { + + // Check browser compatibility + if (navigator.userAgent.indexOf("Konquerer") > -1) { + + alert(txt_browser_not_supported); + return; + } + + searchTextField = trim(document.searchForm.textToSearch.value); + searchTextField = searchTextField.replace(/['"]/g,''); + var expressionInput = searchTextField; + $.cookie('textToSearch', expressionInput); + + if (expressionInput.length < 1) { + + // expression is invalid + alert(txt_enter_at_least_1_char); + // reactive la fenetre de search (utile car cadres) + + document.searchForm.textToSearch.focus(); + } + else { + var splitSpace = searchTextField.split(" "); + var splitWords = []; + for (var i = 0 ; i < splitSpace.length ; i++) { + var splitDot = splitSpace[i].split("."); + + if(!(splitDot.length == 1)){ + splitWords.push(splitSpace[i]); + } + + for (var i1 = 0; i1 < splitDot.length; i1++) { + var splitColon = splitDot[i1].split(":"); + for (var i2 = 0; i2 < splitColon.length; i2++) { + var splitDash = splitColon[i2].split("-"); + for (var i3 = 0; i3 < splitDash.length; i3++) { + if (splitDash[i3].split("").length > 0) { + splitWords.push(splitDash[i3]); + } + } + } + } + } + noWords = splitWords; + if (noWords.length > 9){ + // Allow to search maximum 10 words + alert(txt_enter_more_than_10_words); + expressionInput = ''; + for (var x = 0 ; x < 10 ; x++){ + expressionInput = expressionInput + " " + noWords[x]; + } + Effectuer_recherche(expressionInput); + document.searchForm.textToSearch.focus(); + } else { + // Effectuer la recherche + expressionInput = ''; + for (var x = 0 ; x < noWords.length ; x++) { + expressionInput = expressionInput + " " + noWords[x]; + } + Effectuer_recherche(expressionInput); + // reactive la fenetre de search (utile car cadres) + document.searchForm.textToSearch.focus(); + } + } +} + +var stemQueryMap = new Array(); // A hashtable which maps stems to query words + +/* This function parses the search expression, loads the indices and displays the results*/ +function Effectuer_recherche(expressionInput) { + + /* Display a waiting message */ + //DisplayWaitingMessage(); + + /*data initialisation*/ + var searchFor = ""; // expression en lowercase et sans les caracte res speciaux + //w = new Object(); // hashtable, key=word, value = list of the index of the html files + scriptLetterTab = new Scriptfirstchar(); // Array containing the first letter of each word to look for + var wordsList = new Array(); // Array with the words to look for + var finalWordsList = new Array(); // Array with the words to look for after removing spaces + var linkTab = new Array(); + var fileAndWordList = new Array(); + var txt_wordsnotfound = ""; + + + // -------------------------------------- + // Begin Thu's patch + /*nqu: expressionInput, la recherche est lower cased, plus remplacement des char speciaux*/ + //The original replacement expression is: + //searchFor = expressionInput.toLowerCase().replace(/<\//g, "_st_").replace(/\$_/g, "_di_").replace(/\.|%2C|%3B|%21|%3A|@|\/|\*/g, " ").replace(/(%20)+/g, " ").replace(/_st_/g, " 0){ + var searchedWords = noWords.length; + var foundedWords = fileAndWordList[0][0].motslisteDisplay.split(",").length; + //console.info("search : " + noWords.length + " found : " + fileAndWordList[0][0].motslisteDisplay.split(",").length); + if (searchedWords != foundedWords){ + linkTab.push(partialSearch); + } + } + + + for (var i = 0; i < cpt; i++) { + + var hundredProcent = fileAndWordList[i][0].scoring + 100 * fileAndWordList[i][0].motsnb; + var ttScore_first = fileAndWordList[i][0].scoring; + var numberOfWords = fileAndWordList[i][0].motsnb; + + if (fileAndWordList[i] != undefined) { + linkTab.push("

        " + txt_results_for + " " + "" + fileAndWordList[i][0].motslisteDisplay + "" + "

        "); + + linkTab.push("
          "); + for (t in fileAndWordList[i]) { + //linkTab.push("
        • "+fl[fileAndWordList[i][t].filenb]+"
        • "); + + var ttInfo = fileAndWordList[i][t].filenb; + // Get scoring + var ttScore = fileAndWordList[i][t].scoring; + var tempInfo = fil[ttInfo]; + + var pos1 = tempInfo.indexOf("@@@"); + var pos2 = tempInfo.lastIndexOf("@@@"); + var tempPath = tempInfo.substring(0, pos1); + var tempTitle = tempInfo.substring(pos1 + 3, pos2); + var tempShortdesc = tempInfo.substring(pos2 + 3, tempInfo.length); + + + // toc.html will not be displayed on search result + if (tempPath == 'toc.html'){ + continue; + } + /* + //file:///home/kasun/docbook/WEBHELP/webhelp-draft-output-format-idea/src/main/resources/web/webhelp/installation.html + var linkString = "
        • " + tempTitle + ""; + // var linkString = "
        • " + tempTitle + ""; + */ + var split = fileAndWordList[i][t].motsliste.split(","); + // var splitedValues = expressionInput.split(" "); + // var finalArray = split.concat(splitedValues); + + arrayString = 'Array('; + for(var x in finalArray){ + if (finalArray[x].length > 2 || useCJKTokenizing){ + arrayString+= "'" + finalArray[x] + "',"; + } + } + arrayString = arrayString.substring(0,arrayString.length - 1) + ")"; + var idLink = 'foundLink' + no; + var linkString = '
        • ' + tempTitle + ''; + var starWidth = (ttScore * 100/ hundredProcent)/(ttScore_first/hundredProcent) * (numberOfWords/maxNumberOfWords); + starWidth = starWidth < 10 ? (starWidth + 5) : starWidth; + // Keep the 5 stars format + if (starWidth > 85){ + starWidth = 85; + } + /* + var noFullStars = Math.ceil(starWidth/17); + var fullStar = "curr"; + var emptyStar = ""; + if (starWidth % 17 == 0){ + // am stea plina + + } else { + + } + console.info(noFullStars); + */ + // Also check if we have a valid description + if ((tempShortdesc != "null" && tempShortdesc != '...')) { + + linkString += "\n
          " + tempShortdesc + "
          "; + } + linkString += "
        • "; + + // Add rating values for scoring at the list of matches + linkString += "
          "; + linkString += "
          "; + //linkString += "
          " + // + ((ttScore * 100/ hundredProcent)/(ttScore_first/hundredProcent)) * 1 + "
          "; + linkString += "
            "; + linkString += "
          • "; + linkString += "
          "; + + linkString += "
          "; + linkString += "
          "; + linkString += "
          "; + //linkString += 'Rating: ' + ttScore + ''; + + linkTab.push(linkString); + no++; + } + linkTab.push("
        "); + } + } + } + + var results = ""; + if (linkTab.length > 0) { + /*writeln ("

        " + txt_results_for + " " + "" + cleanwordsList + "" + "
        "+"

        ");*/ + results = "

        "; + //write("

          "); + for (t in linkTab) { + results += linkTab[t].toString(); + } + results += "

          "; + } else { + results = "

          " + localeresource.search_no_results + " " + txt_wordsnotfound + "" + "

          "; + } + + + // Verify if the browser is Google Chrome and the WebHelp is used on a local machine + // If browser is Google Chrome and WebHelp is used on a local machine a warning message will appear + // Highlighting will not work in this conditions. There is 2 workarounds + if (verifyBrowser()){ + document.getElementById('searchResults').innerHTML = results; + } else { + document.getElementById('searchResults').innerHTML = warningMsg + results; + } + +} + + +// Verify if the stemmed word is aproximately the same as the searched word +function verifyWord(word, arr){ + for (var i = 0 ; i < arr.length ; i++){ + if (word[0] == arr[i][0] + && word[1] == arr[i][1] + //&& word[2] == arr[i][2] + ){ + return true; + } + } + return false; +} + +// Look for elements that start with searchedValue. +function wordsStartsWith(searchedValue){ + var toReturn = ''; + for (var sv in w){ + if (searchedValue.length < 3){ + continue; + } else { + if (sv.toLowerCase().indexOf(searchedValue.toLowerCase()) == 0){ + toReturn+=sv + ","; + } + } + } + return toReturn.length > 0 ? toReturn : undefined; +} + + +function tokenize(wordsList){ + var stemmedWordsList = new Array(); // Array with the words to look for after removing spaces + var cleanwordsList = new Array(); // Array with the words to look for + // ------------------------------------------------- + // Thu's patch + for(var j=0;j"; + return this.input.substring(this.offset,this.offset+2); + } + + function getAllTokens(){ + while(this.incrementToken()){ + var tmp = this.tokenize(); + this.tokens.push(tmp); + } + return this.unique(this.tokens); +// document.getElementById("content").innerHTML += tokens+" "; +// document.getElementById("content").innerHTML += "
          dada"+sortedTokens+" "; +// console.log(tokens.length+"dsdsds"); + /*for(i=0;i t2.length) { + return 1; + } else { + return -1; + } + //return t1.length - t2.length); +} + +// return false if browser is Google Chrome and WebHelp is used on a local machine, not a web server +function verifyBrowser(){ + var returnedValue = true; + var browser = BrowserDetect.browser; + var addressBar = window.location.href; + if (browser == 'Chrome' && addressBar.indexOf('file://') === 0){ + returnedValue = false; + } + + return returnedValue; +} + +// Remove duplicate values from an array +function removeDuplicate(arr) { + var r = new Array(); + o:for(var i = 0, n = arr.length; i < n; i++) { + for(var x = 0, y = r.length; x < y; x++) { + if(r[x]==arr[i]) continue o; + } + r[r.length] = arr[i]; + } + return r; +} + +// Create startsWith method +String.prototype.startsWith = function(str) { + return (this.match("^"+str)==str); +} + +function trim(str, chars) { + return ltrim(rtrim(str, chars), chars); +} + +function ltrim(str, chars) { + chars = chars || "\\s"; + return str.replace(new RegExp("^[" + chars + "]+", "g"), ""); +} + +function rtrim(str, chars) { + chars = chars || "\\s"; + return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); +} diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/stemmers/en_stemmer.js b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/stemmers/en_stemmer.js new file mode 100644 index 000000000..2117c1bfb --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/search/stemmers/en_stemmer.js @@ -0,0 +1,234 @@ +// Porter stemmer in Javascript. Few comments, but it's easy to follow against the rules in the original +// paper, in +// +// Porter, 1980, An algorithm for suffix stripping, Program, Vol. 14, +// no. 3, pp 130-137, +// +// see also http://www.tartarus.org/~martin/PorterStemmer + +// Release 1 +// Derived from (http://tartarus.org/~martin/PorterStemmer/js.txt) - cjm (iizuu) Aug 24, 2009 + +var stemmer = (function(){ + var step2list = { + "ational" : "ate", + "tional" : "tion", + "enci" : "ence", + "anci" : "ance", + "izer" : "ize", + "bli" : "ble", + "alli" : "al", + "entli" : "ent", + "eli" : "e", + "ousli" : "ous", + "ization" : "ize", + "ation" : "ate", + "ator" : "ate", + "alism" : "al", + "iveness" : "ive", + "fulness" : "ful", + "ousness" : "ous", + "aliti" : "al", + "iviti" : "ive", + "biliti" : "ble", + "logi" : "log" + }, + + step3list = { + "icate" : "ic", + "ative" : "", + "alize" : "al", + "iciti" : "ic", + "ical" : "ic", + "ful" : "", + "ness" : "" + }, + + c = "[^aeiou]", // consonant + v = "[aeiouy]", // vowel + C = c + "[^aeiouy]*", // consonant sequence + V = v + "[aeiou]*", // vowel sequence + + mgr0 = "^(" + C + ")?" + V + C, // [C]VC... is m>0 + meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$", // [C]VC[V] is m=1 + mgr1 = "^(" + C + ")?" + V + C + V + C, // [C]VCVC... is m>1 + s_v = "^(" + C + ")?" + v; // vowel in stem + + return function (w) { + var stem, + suffix, + firstch, + re, + re2, + re3, + re4, + origword = w; + + if (w.length < 3) { return w; } + + firstch = w.substr(0,1); + if (firstch == "y") { + w = firstch.toUpperCase() + w.substr(1); + } + + // Step 1a + re = /^(.+?)(ss|i)es$/; + re2 = /^(.+?)([^s])s$/; + + if (re.test(w)) { w = w.replace(re,"$1$2"); } + else if (re2.test(w)) { w = w.replace(re2,"$1$2"); } + + // Step 1b + re = /^(.+?)eed$/; + re2 = /^(.+?)(ed|ing)$/; + if (re.test(w)) { + var fp = re.exec(w); + re = new RegExp(mgr0); + if (re.test(fp[1])) { + re = /.$/; + w = w.replace(re,""); + } + } else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1]; + re2 = new RegExp(s_v); + if (re2.test(stem)) { + w = stem; + re2 = /(at|bl|iz)$/; + re3 = new RegExp("([^aeiouylsz])\\1$"); + re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re2.test(w)) { w = w + "e"; } + else if (re3.test(w)) { re = /.$/; w = w.replace(re,""); } + else if (re4.test(w)) { w = w + "e"; } + } + } + + // Step 1c + re = new RegExp("^(.+" + c + ")y$"); + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + w = stem + "i"; + } + + // Step 2 + re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) { + w = stem + step2list[suffix]; + } + } + + // Step 3 + re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = new RegExp(mgr0); + if (re.test(stem)) { + w = stem + step3list[suffix]; + } + } + + // Step 4 + re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; + re2 = /^(.+?)(s|t)(ion)$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + if (re.test(stem)) { + w = stem; + } + } else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1] + fp[2]; + re2 = new RegExp(mgr1); + if (re2.test(stem)) { + w = stem; + } + } + + // Step 5 + re = /^(.+?)e$/; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = new RegExp(mgr1); + re2 = new RegExp(meq1); + re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) { + w = stem; + } + } + + re = /ll$/; + re2 = new RegExp(mgr1); + if (re.test(w) && re2.test(w)) { + re = /.$/; + w = w.replace(re,""); + } + + // and turn initial Y back to y + + if (firstch == "y") { + w = firstch.toLowerCase() + w.substr(1); + } + + // See http://snowball.tartarus.org/algorithms/english/stemmer.html + // "Exceptional forms in general" + var specialWords = { + "skis" : "ski", + "skies" : "sky", + "dying" : "die", + "lying" : "lie", + "tying" : "tie", + "idly" : "idl", + "gently" : "gentl", + "ugly" : "ugli", + "early": "earli", + "only": "onli", + "singly": "singl" + }; + + if(specialWords[origword]){ + w = specialWords[origword]; + } + + if( "sky news howe atlas cosmos bias \ + andes inning outing canning herring \ + earring proceed exceed succeed".indexOf(origword) !== -1 ){ + w = origword; + } + + // Address words overstemmed as gener- + re = /.*generate?s?d?(ing)?$/; + if( re.test(origword) ){ + w = w + 'at'; + } + re = /.*general(ly)?$/; + if( re.test(origword) ){ + w = w + 'al'; + } + re = /.*generic(ally)?$/; + if( re.test(origword) ){ + w = w + 'ic'; + } + re = /.*generous(ly)?$/; + if( re.test(origword) ){ + w = w + 'ous'; + } + // Address words overstemmed as commun- + re = /.*communit(ies)?y?/; + if( re.test(origword) ){ + w = w + 'iti'; + } + + return w; + } +})(); diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr32_memtypes.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr32_memtypes.html new file mode 100644 index 000000000..2020681c5 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr32_memtypes.html @@ -0,0 +1,211 @@ + + + + +Memory Types - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr32_setget_params.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr32_setget_params.html new file mode 100644 index 000000000..ba0618af9 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr32_setget_params.html @@ -0,0 +1,217 @@ + + + + +SET/GET parameters - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr8_memtypes.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr8_memtypes.html new file mode 100644 index 000000000..e2c655212 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr8_memtypes.html @@ -0,0 +1,211 @@ + + + + +Memory Types - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr8_query_contexts.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr8_query_contexts.html new file mode 100644 index 000000000..cd053c49e --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr8_query_contexts.html @@ -0,0 +1,211 @@ + + + + +AVR8 QUERY contexts - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr8_setget_params.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr8_setget_params.html new file mode 100644 index 000000000..50639ee46 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_avr8_setget_params.html @@ -0,0 +1,231 @@ + + + + +SET/GET parameters - - Atmel EDBG-based Tools Protocols

          Table 98. AVR8 SET/GET parameters

          ContextIDDescription / valuesAccessSize
          AVR8_CTXT_CONFIG AVR8_CONFIG_VARIANT

          AVR8_VARIANT_LOOPBACK

          AVR8_VARIANT_TINYOCD

          AVR8_VARIANT_MEGAOCD

          AVR8_VARIANT_XMEGA

          AVR8_VARIANT_NONE

          W1 byte
          AVR8_CONFIG_FUNCTION

          AVR8_FUNC_NONE

          AVR8_FUNC_PROGRAMMING

          +

          AVR8_FUNC_DEBUGGING

          W1 byte
          AVR8_CTXT_PHYSICALAVR8_PHY_PHYSICAL

          AVR8_PHY_INTF_NONE

          AVR8_PHY_INTF_JTAG

          AVR8_PHY_INTF_DW

          AVR8_PHY_INTF_PDI

          W1 byte
          AVR8_PHY_JTAG_DAISY

          Devices before << 24

          +

          Devices after << 16

          +

          IR-bits before << 8

          +

          IR-bits after << 0

          +

          Note that daisy chain settings must be written before activating the JTAG physical.

          RW4 bytes
          AVR8_PHY_DW_CLK_DIVdebugWIRE clock division factorW1 byte
          AVR8_PHY_MEGA_PRG_CLK

          JTAG clock frequency (kHz) for programming megaAVR

          +

          Note: this frequency is limited by the target silicon itself

          W2 bytes
          AVR8_PHY_MEGA_DBG_CLK

          JTAG clock frequency (kHz) for debugging megaAVR

          +

          Note: this frequency must be less than a quarter of the active target clock

          W2 bytes
          AVR8_PHY_XM_JTAG_CLK

          JTAG clock frequency (kHz) for programming and debugging AVR XMEGA

          +

          Note: this frequency is limited by the target silicon itself

          W2 bytes
          AVR8_PHY_XM_PDI_CLK

          PDI clock frequency (kHz) for programming and debugging AVR XMEGA

          +

          Note: this frequency is limited by the target silicon itself

          W2 bytes
          AVR8_CTXT_DEVICE see tables below for family specific contextsW 
          AVR8_CTXT_OPTIONSAVR8_OPT_RUN_TIMERSRun timers in stopped mode. + This option allows timers to continue to run even when the device has entered stopped mode. + This is especially useful for maintaining PWM output values for example in motor control applications. + Note that timer interrupts will NOT be serviced until RUN mode is entered. (Not available in AVR XMEGA) + W1 byte
          AVR8_OPT_DISABLE_DBPDisables data breaks when resetting. + Used internally to prevent variable initialisation routines from triggerring data breakpoints.W1 byte
          AVR8_OPT_ENABLE_IDREnables messages from the target core. + IDR messages can be sent from some target types by writing to the OCD data register during RUN mode. + When this option is enabled, these data values will be routed to USB EVENT messages.W1byte
          AVR8_OPT_POLL_INTAdjusts how often the debugger polls the target's state. Value + given as polling interval in ms. Possible values: 1, 5, 10, 20, 50 + and 100.W1byte
          AVR8_CTXT_SESSIONAVR8_SESS_MAIN_PC (deprecated)Program counter value [word address] of main() functionW4 bytes
          AVR8_CTXT_TESTAVR8_TEST_TGT_RUNNING

          Actively polls the targets RUN/STOP state.

          0x00 = STOPPED

          0x01 = RUNNING

          R1 byte

          \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_edbg_ctrl_setget_params.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_edbg_ctrl_setget_params.html new file mode 100644 index 000000000..26e6e639e --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_edbg_ctrl_setget_params.html @@ -0,0 +1,368 @@ + + + + +EDBGCTRL ID definitions - - Atmel EDBG-based Tools Protocols

          + This sections includes the header file defining the different command and + response IDs for the EDBGCTRL protocol. It also defines the different possible failure codes. +

          enum EdbgCommands {
          +    //**********************************************************
          +    // Protocol commands
          +    //**********************************************************
          +
          +    // Basics
          +    CMD_EDBG_QUERY                                      = 0x00,
          +    CMD_EDBG_SET                                        = 0x01,
          +    CMD_EDBG_GET                                        = 0x02,
          +};
          +
          +enum EdbgResponses {
          +    //**********************************************************
          +    // Protocol responses
          +    //**********************************************************
          +
          +    RSP_EDBG_OK                                         = 0x80,
          +    RSP_EDBG_LIST                                       = 0x81,
          +    RSP_EDBG_DATA                                       = 0x84,
          +    RSP_EDBG_FAILED                                     = 0xA0
          +};
          +
          +
          +enum EdbgFailureCodes {
          +    //**********************************************************
          +    // Failure response codes (RSP_FAILED)
          +    //**********************************************************
          +
          +    EDBG_FAILED_OK                                      = 0x00,
          +    EDBG_FAILED_NOT_SUPPORTED                           = 0x01,
          +    EDBG_FAILED_ILLEGAL_GPIO_PIN                        = 0x10,
          +    EDBG_FAILED_ILLEGAL_GPIO_MODE                       = 0x11,
          +    EDBG_FAILED_ILLEGAL_VOLTAGE_RANGE                   = 0x12,
          +    EDBG_FAILED_ILLEGAL_INTERVAL                        = 0x13,
          +    EDBG_FAILED_ILLEGAL_MAX_THRESHOLD                   = 0x14,
          +    EDBG_FAILED_ILLEGAL_MIN_THRESHOLD                   = 0x15,
          +    EDBG_FAILED_ILLEGAL_ACTION                          = 0x16,
          +    EDBG_FAILED_ILLEGAL_FREQUENCY                       = 0x17,
          +    EDBG_FAILED_ILLEGAL_MODE                            = 0x18,
          +    EDBG_FAILED_ILLEGAL_FLAGS                           = 0x19,
          +    EDBG_FAILED_FLASH_WRITE                             = 0x20,
          +    EDBG_FAILED_OVERFLOW                                = 0x30,
          +    EDBG_FAILED_UNKNOWN                                 = 0xFF
          +};
          +
          +enum EdbgConfigTypes {
          +    EDBG_CONFIGTYPE_CHAR                                = 0x00,
          +    EDBG_CONFIGTYPE_SHORT                               = 0x01,
          +    EDBG_CONFIGTYPE_WORD                                = 0x02,
          +    EDBG_CONFIGTYPE_BIT                                 = 0x03,
          +    EDBG_CONFIGTYPE_STRING                              = 0x10,
          +    EDBG_CONFIGTYPE_ARRAY                               = 0x20,
          +};
          +
          +enum EdbgConfigTags {
          +    //**********************************************************
          +    // EDBG Configuration Tags
          +    //**********************************************************
          +
          +    EDBG_CONFIG_VERSION                                 = 0x00,
          +    EDBG_CONFIG_SERIAL_NUMBER                           = 0x01,
          +    EDBG_CONFIG_BOARD_NAME                              = 0x02,
          +    EDBG_CONFIG_MANUFACTURER_NAME                       = 0x03,
          +    EDBG_CONFIG_TARGET_NAME                             = 0x04,
          +    EDBG_CONFIG_TARGET_SIGNATURE                        = 0x05,
          +    EDBG_CONFIG_TARGET_JTAGID                           = 0x06,
          +    EDBG_CONFIG_TARGET_CHIPID                           = 0x07,
          +    EDBG_CONFIG_INTERFACES                              = 0x08,
          +    EDBG_CONFIG_DGI_GPIO_MAP                            = 0x09,
          +    EDBG_CONFIG_EXTENSION_MAP                           = 0x0A,
          +    EDBG_CONFIG_EXTENSION_STATUS                        = 0x0B,
          +    EDBG_CONFIG_EXTENSION_MANUFACTURER                  = 0x0C,
          +    EDBG_CONFIG_EXTENSION_PRODUCT                       = 0x0D,
          +    EDBG_CONFIG_EXTENSION_REVISION                      = 0x0E,
          +    EDBG_CONFIG_EXTENSION_SERIAL                        = 0x0F,
          +    EDBG_CONFIG_EXTENSION_MIN_VOLTAGE                   = 0x10,
          +    EDBG_CONFIG_EXTENSION_MAX_VOLTAGE                   = 0x11,
          +    EDBG_CONFIG_EXTENSION_CURRENT                       = 0x12,
          +    EDBG_CONFIG_BOARD_TYPE                              = 0x13,
          +    EDBG_CONFIG_FAMILY_NAME                             = 0x14,
          +    EDBG_CONFIG_TVS                                     = 0x15,
          +    EDBG_CONFIG_VERSION_MINOR                           = 0x16,
          +    EDBG_CONFIG_USB_ID                                  = 0x17,
          +    EDBG_CONFIG_KIT_DATA                                = 0x20,
          +};
          +
          +enum EdbgInterfaces {
          +    //**********************************************************
          +    // EDBG Configuration Tags
          +    //********************************************************** 
          +    // GPIO, USART, UART, TWI, SPI, CDC
          +    // SWD, ARMJTAG, AVRJTAG, aW, dW, PDI, ISP, DBG_EN
          +
          +    EDBG_IF_DBG_EN                                      = 15,
          +    EDBG_IF_DBG_ISP                                     = 14,
          +    EDBG_IF_DBG_PDI                                     = 13,
          +    EDBG_IF_DBG_DW                                      = 12,
          +    EDBG_IF_DBG_AW                                      = 11,
          +    EDBG_IF_DBG_AVRJTAG                                 = 10,
          +    EDBG_IF_DBG_ARMJTAG                                 = 9,
          +    EDBG_IF_DBG_SWD                                     = 8,
          +    
          +    EDBG_IF_DGI_SPI                                     = 0,
          +    EDBG_IF_DGI_TWI                                     = 1,
          +    EDBG_IF_DGI_UART                                    = 2,
          +    EDBG_IF_DGI_USART                                   = 3,
          +    EDBG_IF_DGI_GPIO                                    = 4,
          +    EDBG_IF_CDC                                         = 5,
          +    
          +    EDBG_IF_ERASE_PIN                                   = 7,
          +};
          +enum EDBGQueryContexts {
          +    // QUERY types on this protocol
          +    EDBG_QUERY_COMMANDS                                 = 0x00
          +};
          +    
          +enum EDBGSetGetContexts {
          +    EDBG_CONTEXT_CONTROL                                = 0x00,
          +    EDBG_CONTEXT_CONFIG0                                = 0x10,
          +    EDBG_CONTEXT_CONFIG1                                = 0x11,
          +}; 
          +
          +enum EDBGControlContextParameters {
          +    EDBG_CONTROL_LED_USAGE                              = 0x00,
          +    EDBG_CONTROL_EXT_PROG                               = 0x01,
          +    EDBG_CONTROL_TARGET_POWER                           = 0x10
          +};
          +
          +enum SerialTraceCommands {
          +    ST_SET_TRANSPORT_MODE                               = 0x00,
          +    ST_SET_CAPTURE_MODE                                 = 0x01,
          +    ST_SET_BAUD                                         = 0x02,
          +    ST_START                                            = 0x03,
          +    ST_STOP                                             = 0x04,
          +    ST_GET_DATA                                         = 0x08,
          +    ST_GET_STATUS                                       = 0x09,
          +    ST_GET_BUFFER_SIZE                                  = 0x0A,
          +    ST_SIGNON                                           = 0x0F
          +};
          +
          +enum SerialTraceTransportModes {
          +    TRANSPORT_OFF                                       = 0x00,
          +    TRANSPORT_HID                                       = 0x01
          +};
          +
          +enum SerialTraceTransportModes {
          +    CAPTURE_OFF                                         = 0x00,
          +    CAPTURE_UART                                        = 0x02
          +};
          +
          +enum SerialTraceErrorBits {
          +    ERROR_OVERFLOW                                      = 15,
          +    ERROR_RECEIVER                                      = 14,
          +    RECEIVER_DISABLED                                   = 9
          +};
          \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_edbg_query_contexts.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_edbg_query_contexts.html new file mode 100644 index 000000000..e533d16ad --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_edbg_query_contexts.html @@ -0,0 +1,211 @@ + + + + +EDBG QUERY contexts - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_housekeeping_start_session.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_housekeeping_start_session.html new file mode 100644 index 000000000..0bafe24d8 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_housekeeping_start_session.html @@ -0,0 +1,214 @@ + + + + +Start session - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_i5v_3yz_rl.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_i5v_3yz_rl.html new file mode 100644 index 000000000..370df774d --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_i5v_3yz_rl.html @@ -0,0 +1,211 @@ + + + + +Housekeeping QUERY contexts - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_jdx_m11_sl.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_jdx_m11_sl.html new file mode 100644 index 000000000..0f51f8c43 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_jdx_m11_sl.html @@ -0,0 +1,211 @@ + + + + +Discovery QUERY contexts - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_qhb_x1c_sl.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_qhb_x1c_sl.html new file mode 100644 index 000000000..02f90b827 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_qhb_x1c_sl.html @@ -0,0 +1,211 @@ + + + + +AVR32 QUERY contexts - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_serial_trace.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_serial_trace.html new file mode 100644 index 000000000..9067bd286 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_serial_trace.html @@ -0,0 +1,214 @@ + + + + +Serial trace commands - - Atmel EDBG-based Tools Protocols

          Some ARM-based devices implement a serial trace output using the SWO pin. This is available + only when using th SWD interface, and it uses the JTAG TDO pin on the tool to sample the signal. + This section describes how to configure the tool for capturing serial trace and how to read the + captured serial trace data out of the tool.

          Note that the hardware tool performs only raw data capture, storage and forwarding.

          All serial trace commands use vendor command 7 (0x87)

          \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_t1f_hb1_sl.html b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_t1f_hb1_sl.html new file mode 100644 index 000000000..a5a163146 --- /dev/null +++ b/xs/src/avrdude/atmel-docs/EDBG/protocoldocs/section_t1f_hb1_sl.html @@ -0,0 +1,211 @@ + + + + +Housekeeping SET/GET parameters - - Atmel EDBG-based Tools Protocols \ No newline at end of file diff --git a/xs/src/avrdude/atmel-docs/JTAGICE-AVR060.pdf b/xs/src/avrdude/atmel-docs/JTAGICE-AVR060.pdf new file mode 100644 index 000000000..1b4cac8a9 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/JTAGICE-AVR060.pdf differ diff --git a/xs/src/avrdude/atmel-docs/JTAGICEmkII-AVR067.pdf b/xs/src/avrdude/atmel-docs/JTAGICEmkII-AVR067.pdf new file mode 100644 index 000000000..c72ccde8a Binary files /dev/null and b/xs/src/avrdude/atmel-docs/JTAGICEmkII-AVR067.pdf differ diff --git a/xs/src/avrdude/atmel-docs/STK500-AVR061.pdf b/xs/src/avrdude/atmel-docs/STK500-AVR061.pdf new file mode 100644 index 000000000..03e0ddf6b Binary files /dev/null and b/xs/src/avrdude/atmel-docs/STK500-AVR061.pdf differ diff --git a/xs/src/avrdude/atmel-docs/STK500v2-AVR068.pdf b/xs/src/avrdude/atmel-docs/STK500v2-AVR068.pdf new file mode 100644 index 000000000..1a8485655 Binary files /dev/null and b/xs/src/avrdude/atmel-docs/STK500v2-AVR068.pdf differ diff --git a/xs/src/avrdude/avr.c b/xs/src/avrdude/avr.c new file mode 100644 index 000000000..73dcaf4ff --- /dev/null +++ b/xs/src/avrdude/avr.c @@ -0,0 +1,1254 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2000-2004 Brian S. Dean + * 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 + * 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 "ac_cfg.h" + +#include +#include +#include +#include +#include + +#if !defined(WIN32NATIVE) +# include +#endif + +#include "avrdude.h" +#include "libavrdude.h" + +#include "tpi.h" + +FP_UpdateProgress update_progress; + +#define DEBUG 0 + +/* TPI: returns 1 if NVM controller busy, 0 if free */ +int avr_tpi_poll_nvmbsy(PROGRAMMER *pgm) +{ + unsigned char cmd; + unsigned char res; + + cmd = TPI_CMD_SIN | TPI_SIO_ADDR(TPI_IOREG_NVMCSR); + (void)pgm->cmd_tpi(pgm, &cmd, 1, &res, 1); + return (res & TPI_IOREG_NVMCSR_NVMBSY); +} + +/* TPI chip erase sequence */ +int avr_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + int err; + AVRMEM *mem; + + if (p->flags & AVRPART_HAS_TPI) { + pgm->pgm_led(pgm, ON); + + /* Set Pointer Register */ + mem = avr_locate_mem(p, "flash"); + if (mem == NULL) { + avrdude_message(MSG_INFO, "No flash memory to erase for part %s\n", + p->desc); + return -1; + } + + unsigned char cmd[] = { + /* write pointer register high byte */ + (TPI_CMD_SSTPR | 0), + ((mem->offset & 0xFF) | 1), + /* and low byte */ + (TPI_CMD_SSTPR | 1), + ((mem->offset >> 8) & 0xFF), + /* write CHIP_ERASE command to NVMCMD register */ + (TPI_CMD_SOUT | TPI_SIO_ADDR(TPI_IOREG_NVMCMD)), + TPI_NVMCMD_CHIP_ERASE, + /* write dummy value to start erase */ + TPI_CMD_SST, + 0xFF + }; + + while (avr_tpi_poll_nvmbsy(pgm)); + + err = pgm->cmd_tpi(pgm, cmd, sizeof(cmd), NULL, 0); + if(err) + return err; + + while (avr_tpi_poll_nvmbsy(pgm)); + + pgm->pgm_led(pgm, OFF); + + return 0; + } else { + avrdude_message(MSG_INFO, "%s called for a part that has no TPI\n", __func__); + return -1; + } +} + +/* TPI program enable sequence */ +int avr_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p, unsigned char guard_time) +{ + int err, retry; + unsigned char cmd[2]; + unsigned char response; + + if(p->flags & AVRPART_HAS_TPI) { + /* set guard time */ + cmd[0] = (TPI_CMD_SSTCS | TPI_REG_TPIPCR); + cmd[1] = guard_time; + + err = pgm->cmd_tpi(pgm, cmd, sizeof(cmd), NULL, 0); + if(err) + return err; + + /* read TPI ident reg */ + cmd[0] = (TPI_CMD_SLDCS | TPI_REG_TPIIR); + err = pgm->cmd_tpi(pgm, cmd, 1, &response, sizeof(response)); + if (err || response != TPI_IDENT_CODE) { + avrdude_message(MSG_INFO, "TPIIR not correct\n"); + return -1; + } + + /* send SKEY command + SKEY */ + err = pgm->cmd_tpi(pgm, tpi_skey_cmd, sizeof(tpi_skey_cmd), NULL, 0); + if(err) + return err; + + /* check if device is ready */ + for(retry = 0; retry < 10; retry++) + { + cmd[0] = (TPI_CMD_SLDCS | TPI_REG_TPISR); + err = pgm->cmd_tpi(pgm, cmd, 1, &response, sizeof(response)); + if(err || !(response & TPI_REG_TPISR_NVMEN)) + continue; + + return 0; + } + + avrdude_message(MSG_INFO, "Error enabling TPI external programming mode:"); + avrdude_message(MSG_INFO, "Target does not reply\n"); + return -1; + + } else { + avrdude_message(MSG_INFO, "%s called for a part that has no TPI\n", __func__); + return -1; + } +} + +/* TPI: setup NVMCMD register and pointer register (PR) for read/write/erase */ +static int avr_tpi_setup_rw(PROGRAMMER * pgm, AVRMEM * mem, + unsigned long addr, unsigned char nvmcmd) +{ + unsigned char cmd[4]; + int rc; + + /* set NVMCMD register */ + cmd[0] = TPI_CMD_SOUT | TPI_SIO_ADDR(TPI_IOREG_NVMCMD); + cmd[1] = nvmcmd; + rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0); + if (rc == -1) + return -1; + + /* set Pointer Register (PR) */ + cmd[0] = TPI_CMD_SSTPR | 0; + cmd[1] = (mem->offset + addr) & 0xFF; + rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0); + if (rc == -1) + return -1; + + cmd[0] = TPI_CMD_SSTPR | 1; + cmd[1] = ((mem->offset + addr) >> 8) & 0xFF; + rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0); + if (rc == -1) + return -1; + + return 0; +} + +int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value) +{ + unsigned char cmd[4]; + unsigned char res[4]; + unsigned char data; + int r; + OPCODE * readop, * lext; + + if (pgm->cmd == NULL) { + avrdude_message(MSG_INFO, "%s: Error: %s programmer uses avr_read_byte_default() but does not\n" + "provide a cmd() method.\n", + progname, pgm->type); + return -1; + } + + pgm->pgm_led(pgm, ON); + pgm->err_led(pgm, OFF); + + if (p->flags & AVRPART_HAS_TPI) { + if (pgm->cmd_tpi == NULL) { + avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n", + progname, pgm->type); + return -1; + } + + while (avr_tpi_poll_nvmbsy(pgm)); + + /* setup for read */ + avr_tpi_setup_rw(pgm, mem, addr, TPI_NVMCMD_NO_OPERATION); + + /* load byte */ + cmd[0] = TPI_CMD_SLD; + r = pgm->cmd_tpi(pgm, cmd, 1, value, 1); + if (r == -1) + return -1; + + return 0; + } + + /* + * figure out what opcode to use + */ + if (mem->op[AVR_OP_READ_LO]) { + if (addr & 0x00000001) + readop = mem->op[AVR_OP_READ_HI]; + else + readop = mem->op[AVR_OP_READ_LO]; + addr = addr / 2; + } + else { + readop = mem->op[AVR_OP_READ]; + } + + if (readop == NULL) { +#if DEBUG + avrdude_message(MSG_INFO, "avr_read_byte(): operation not supported on memory type \"%s\"\n", + mem->desc); +#endif + return -1; + } + + /* + * If this device has a "load extended address" command, issue it. + */ + lext = mem->op[AVR_OP_LOAD_EXT_ADDR]; + if (lext != NULL) { + memset(cmd, 0, sizeof(cmd)); + + avr_set_bits(lext, cmd); + avr_set_addr(lext, cmd, addr); + r = pgm->cmd(pgm, cmd, res); + if (r < 0) + return r; + } + + memset(cmd, 0, sizeof(cmd)); + + avr_set_bits(readop, cmd); + avr_set_addr(readop, cmd, addr); + r = pgm->cmd(pgm, cmd, res); + if (r < 0) + return r; + data = 0; + avr_get_output(readop, res, &data); + + pgm->pgm_led(pgm, OFF); + + *value = data; + + return 0; +} + + +/* + * Return the number of "interesting" bytes in a memory buffer, + * "interesting" being defined as up to the last non-0xff data + * value. This is useful for determining where to stop when dealing + * with "flash" memory, since writing 0xff to flash is typically a + * no-op. Always return an even number since flash is word addressed. + */ +int avr_mem_hiaddr(AVRMEM * mem) +{ + int i, n; + + /* return the highest non-0xff address regardless of how much + memory was read */ + for (i=mem->size-1; i>0; i--) { + if (mem->buf[i] != 0xff) { + n = i+1; + if (n & 0x01) + return n+1; + else + return n; + } + } + + return 0; +} + + +/* + * Read the entirety of the specified memory type 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(PROGRAMMER * pgm, AVRPART * p, char * memtype, + AVRPART * v) +{ + unsigned long i, lastaddr; + unsigned char cmd[4]; + AVRMEM * mem, * vmem = NULL; + int rc; + + mem = avr_locate_mem(p, memtype); + if (v != NULL) + vmem = avr_locate_mem(v, memtype); + if (mem == NULL) { + avrdude_message(MSG_INFO, "No \"%s\" memory for part %s\n", + memtype, p->desc); + return -1; + } + + /* + * start with all 0xff + */ + memset(mem->buf, 0xff, mem->size); + + /* supports "paged load" thru post-increment */ + if ((p->flags & AVRPART_HAS_TPI) && mem->page_size != 0 && + pgm->cmd_tpi != NULL) { + + while (avr_tpi_poll_nvmbsy(pgm)); + + /* setup for read (NOOP) */ + avr_tpi_setup_rw(pgm, mem, 0, TPI_NVMCMD_NO_OPERATION); + + /* load bytes */ + for (lastaddr = i = 0; i < mem->size; i++) { + RETURN_IF_CANCEL(); + if (vmem == NULL || + (vmem->tags[i] & TAG_ALLOCATED) != 0) + { + if (lastaddr != i) { + /* need to setup new address */ + avr_tpi_setup_rw(pgm, mem, i, TPI_NVMCMD_NO_OPERATION); + lastaddr = i; + } + cmd[0] = TPI_CMD_SLD_PI; + rc = pgm->cmd_tpi(pgm, cmd, 1, mem->buf + i, 1); + lastaddr++; + if (rc == -1) { + avrdude_message(MSG_INFO, "avr_read(): error reading address 0x%04lx\n", i); + return -1; + } + } + report_progress(i, mem->size, NULL); + } + return avr_mem_hiaddr(mem); + } + + if (pgm->paged_load != NULL && mem->page_size != 0) { + /* + * the programmer supports a paged mode read + */ + int need_read, failure; + unsigned int pageaddr; + unsigned int npages, nread; + + /* quickly scan number of pages to be written to first */ + for (pageaddr = 0, npages = 0; + pageaddr < mem->size; + pageaddr += mem->page_size) { + /* check whether this page must be read */ + for (i = pageaddr; + i < pageaddr + mem->page_size; + i++) + if (vmem == NULL /* no verify, read everything */ || + (mem->tags[i] & TAG_ALLOCATED) != 0 /* verify, do only + read pages that + are needed in + input file */) { + npages++; + break; + } + } + + for (pageaddr = 0, failure = 0, nread = 0; + !failure && pageaddr < mem->size; + pageaddr += mem->page_size) { + RETURN_IF_CANCEL(); + /* check whether this page must be read */ + for (i = pageaddr, need_read = 0; + i < pageaddr + mem->page_size; + i++) + if (vmem == NULL /* no verify, read everything */ || + (vmem->tags[i] & TAG_ALLOCATED) != 0 /* verify, do only + read pages that + are needed in + input file */) { + need_read = 1; + break; + } + if (need_read) { + rc = pgm->paged_load(pgm, p, mem, mem->page_size, + pageaddr, mem->page_size); + if (rc < 0) + /* paged load failed, fall back to byte-at-a-time read below */ + failure = 1; + } else { + avrdude_message(MSG_DEBUG, "%s: avr_read(): skipping page %u: no interesting data\n", + progname, pageaddr / mem->page_size); + } + nread++; + report_progress(nread, npages, NULL); + } + if (!failure) { + if (strcasecmp(mem->desc, "flash") == 0 || + strcasecmp(mem->desc, "application") == 0 || + strcasecmp(mem->desc, "apptable") == 0 || + strcasecmp(mem->desc, "boot") == 0) + return avr_mem_hiaddr(mem); + else + return mem->size; + } + /* else: fall back to byte-at-a-time write, for historical reasons */ + } + + if (strcmp(mem->desc, "signature") == 0) { + if (pgm->read_sig_bytes) { + return pgm->read_sig_bytes(pgm, p, mem); + } + } + + for (i=0; i < mem->size; i++) { + RETURN_IF_CANCEL(); + if (vmem == NULL || + (vmem->tags[i] & TAG_ALLOCATED) != 0) + { + rc = pgm->read_byte(pgm, p, mem, i, mem->buf + i); + if (rc != 0) { + avrdude_message(MSG_INFO, "avr_read(): error reading address 0x%04lx\n", i); + if (rc == -1) + avrdude_message(MSG_INFO, " read operation not supported for memory \"%s\"\n", + memtype); + return -2; + } + } + report_progress(i, mem->size, NULL); + } + + if (strcasecmp(mem->desc, "flash") == 0 || + strcasecmp(mem->desc, "application") == 0 || + strcasecmp(mem->desc, "apptable") == 0 || + strcasecmp(mem->desc, "boot") == 0) + return avr_mem_hiaddr(mem); + else + return i; +} + + +/* + * write a page data at the specified address + */ +int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr) +{ + unsigned char cmd[4]; + unsigned char res[4]; + OPCODE * wp, * lext; + + if (pgm->cmd == NULL) { + avrdude_message(MSG_INFO, "%s: Error: %s programmer uses avr_write_page() but does not\n" + "provide a cmd() method.\n", + progname, pgm->type); + return -1; + } + + wp = mem->op[AVR_OP_WRITEPAGE]; + if (wp == NULL) { + avrdude_message(MSG_INFO, "avr_write_page(): memory \"%s\" not configured for page writes\n", + mem->desc); + return -1; + } + + /* + * if this memory is word-addressable, adjust the address + * accordingly + */ + if ((mem->op[AVR_OP_LOADPAGE_LO]) || (mem->op[AVR_OP_READ_LO])) + addr = addr / 2; + + pgm->pgm_led(pgm, ON); + pgm->err_led(pgm, OFF); + + /* + * If this device has a "load extended address" command, issue it. + */ + lext = mem->op[AVR_OP_LOAD_EXT_ADDR]; + if (lext != NULL) { + memset(cmd, 0, sizeof(cmd)); + + avr_set_bits(lext, cmd); + avr_set_addr(lext, cmd, addr); + pgm->cmd(pgm, cmd, res); + } + + memset(cmd, 0, sizeof(cmd)); + + avr_set_bits(wp, cmd); + avr_set_addr(wp, cmd, addr); + pgm->cmd(pgm, cmd, res); + + /* + * since we don't know what voltage the target AVR is powered by, be + * conservative and delay the max amount the spec says to wait + */ + usleep(mem->max_write_delay); + + pgm->pgm_led(pgm, OFF); + return 0; +} + + +int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + unsigned char cmd[4]; + unsigned char res[4]; + unsigned char r; + int ready; + int tries; + unsigned long start_time; + unsigned long prog_time; + unsigned char b; + unsigned short caddr; + OPCODE * writeop; + int rc; + int readok=0; + struct timeval tv; + + if (pgm->cmd == NULL) { + avrdude_message(MSG_INFO, "%s: Error: %s programmer uses avr_write_byte_default() but does not\n" + "provide a cmd() method.\n", + progname, pgm->type); + return -1; + } + + if (p->flags & AVRPART_HAS_TPI) { + if (pgm->cmd_tpi == NULL) { + avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n", + progname, pgm->type); + return -1; + } + + if (strcmp(mem->desc, "flash") == 0) { + avrdude_message(MSG_INFO, "Writing a byte to flash is not supported for %s\n", p->desc); + return -1; + } else if ((mem->offset + addr) & 1) { + avrdude_message(MSG_INFO, "Writing a byte to an odd location is not supported for %s\n", p->desc); + return -1; + } + + while (avr_tpi_poll_nvmbsy(pgm)); + + /* must erase fuse first */ + if (strcmp(mem->desc, "fuse") == 0) { + /* setup for SECTION_ERASE (high byte) */ + avr_tpi_setup_rw(pgm, mem, addr | 1, TPI_NVMCMD_SECTION_ERASE); + + /* write dummy byte */ + cmd[0] = TPI_CMD_SST; + cmd[1] = 0xFF; + rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0); + + while (avr_tpi_poll_nvmbsy(pgm)); + } + + /* setup for WORD_WRITE */ + avr_tpi_setup_rw(pgm, mem, addr, TPI_NVMCMD_WORD_WRITE); + + cmd[0] = TPI_CMD_SST_PI; + cmd[1] = data; + rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0); + /* dummy high byte to start WORD_WRITE */ + cmd[0] = TPI_CMD_SST_PI; + cmd[1] = data; + rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0); + + while (avr_tpi_poll_nvmbsy(pgm)); + + return 0; + } + + if (!mem->paged && + (p->flags & AVRPART_IS_AT90S1200) == 0) { + /* + * check to see if the write is necessary by reading the existing + * value and only write if we are changing the value; we can't + * use this optimization for paged addressing. + * + * For mysterious reasons, on the AT90S1200, this read operation + * sometimes causes the high byte of the same word to be + * programmed to the value of the low byte that has just been + * programmed before. Avoid that optimization on this device. + */ + rc = pgm->read_byte(pgm, p, mem, addr, &b); + if (rc != 0) { + if (rc != -1) { + return -2; + } + /* + * the read operation is not support on this memory type + */ + } + else { + readok = 1; + if (b == data) { + return 0; + } + } + } + + /* + * determine which memory opcode to use + */ + if (mem->op[AVR_OP_WRITE_LO]) { + if (addr & 0x01) + writeop = mem->op[AVR_OP_WRITE_HI]; + else + writeop = mem->op[AVR_OP_WRITE_LO]; + caddr = addr / 2; + } + else if (mem->paged && mem->op[AVR_OP_LOADPAGE_LO]) { + if (addr & 0x01) + writeop = mem->op[AVR_OP_LOADPAGE_HI]; + else + writeop = mem->op[AVR_OP_LOADPAGE_LO]; + caddr = addr / 2; + } + else { + writeop = mem->op[AVR_OP_WRITE]; + caddr = addr; + } + + if (writeop == NULL) { +#if DEBUG + avrdude_message(MSG_INFO, "avr_write_byte(): write not supported for memory type \"%s\"\n", + mem->desc); +#endif + return -1; + } + + + pgm->pgm_led(pgm, ON); + pgm->err_led(pgm, OFF); + + memset(cmd, 0, sizeof(cmd)); + + avr_set_bits(writeop, cmd); + avr_set_addr(writeop, cmd, caddr); + avr_set_input(writeop, cmd, data); + pgm->cmd(pgm, cmd, res); + + if (mem->paged) { + /* + * in paged addressing, single bytes to be written to the memory + * page complete immediately, we only need to delay when we commit + * the whole page via the avr_write_page() routine. + */ + pgm->pgm_led(pgm, OFF); + return 0; + } + + if (readok == 0) { + /* + * read operation not supported for this memory type, just wait + * the max programming time and then return + */ + usleep(mem->max_write_delay); /* maximum write delay */ + pgm->pgm_led(pgm, OFF); + return 0; + } + + tries = 0; + ready = 0; + while (!ready) { + + if ((data == mem->readback[0]) || + (data == mem->readback[1])) { + /* + * use an extra long delay when we happen to be writing values + * used for polled data read-back. In this case, polling + * doesn't work, and we need to delay the worst case write time + * specified for the chip. + */ + usleep(mem->max_write_delay); + rc = pgm->read_byte(pgm, p, mem, addr, &r); + if (rc != 0) { + pgm->pgm_led(pgm, OFF); + pgm->err_led(pgm, OFF); + return -5; + } + } + else { + gettimeofday (&tv, NULL); + start_time = (tv.tv_sec * 1000000) + tv.tv_usec; + do { + /* + * Do polling, but timeout after max_write_delay. + */ + rc = pgm->read_byte(pgm, p, mem, addr, &r); + if (rc != 0) { + pgm->pgm_led(pgm, OFF); + pgm->err_led(pgm, ON); + return -4; + } + gettimeofday (&tv, NULL); + prog_time = (tv.tv_sec * 1000000) + tv.tv_usec; + } while ((r != data) && + ((prog_time-start_time) < mem->max_write_delay)); + } + + /* + * At this point we either have a valid readback or the + * max_write_delay is expired. + */ + + if (r == data) { + ready = 1; + } + else if (mem->pwroff_after_write) { + /* + * The device has been flagged as power-off after write to this + * memory type. The reason we don't just blindly follow the + * flag is that the power-off advice may only apply to some + * memory bits but not all. We only actually power-off the + * device if the data read back does not match what we wrote. + */ + pgm->pgm_led(pgm, OFF); + avrdude_message(MSG_INFO, "%s: this device must be powered off and back on to continue\n", + progname); + if (pgm->pinno[PPI_AVR_VCC]) { + avrdude_message(MSG_INFO, "%s: attempting to do this now ...\n", progname); + pgm->powerdown(pgm); + usleep(250000); + rc = pgm->initialize(pgm, p); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: initialization failed, rc=%d\n", progname, rc); + avrdude_message(MSG_INFO, "%s: can't re-initialize device after programming the " + "%s bits\n", progname, mem->desc); + avrdude_message(MSG_INFO, "%s: you must manually power-down the device and restart\n" + "%s: %s to continue.\n", + progname, progname, progname); + return -3; + } + + avrdude_message(MSG_INFO, "%s: device was successfully re-initialized\n", + progname); + return 0; + } + } + + tries++; + if (!ready && tries > 5) { + /* + * we wrote the data, but after waiting for what should have + * been plenty of time, the memory cell still doesn't match what + * we wrote. Indicate a write error. + */ + pgm->pgm_led(pgm, OFF); + pgm->err_led(pgm, ON); + + return -6; + } + } + + pgm->pgm_led(pgm, OFF); + return 0; +} + + +/* + * write a byte of data at the specified address + */ +int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + + unsigned char safemode_lfuse; + unsigned char safemode_hfuse; + unsigned char safemode_efuse; + unsigned char safemode_fuse; + + /* If we write the fuses, then we need to tell safemode that they *should* change */ + safemode_memfuses(0, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse); + + if (strcmp(mem->desc, "fuse")==0) { + safemode_fuse = data; + } + if (strcmp(mem->desc, "lfuse")==0) { + safemode_lfuse = data; + } + if (strcmp(mem->desc, "hfuse")==0) { + safemode_hfuse = data; + } + if (strcmp(mem->desc, "efuse")==0) { + safemode_efuse = data; + } + + safemode_memfuses(1, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse); + + return pgm->write_byte(pgm, p, mem, addr, data); +} + + +/* + * Write the whole memory region of the specified memory from the + * corresponding buffer of the avrpart pointed to by 'p'. Write up to + * 'size' bytes from the buffer. Data is only written if the new data + * value is different from the existing data value. Data beyond + * 'size' bytes is not affected. + * + * Return the number of bytes written, or -1 if an error occurs. + */ +int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size, + int auto_erase) +{ + int rc; + int newpage, page_tainted, flush_page, do_write; + int wsize; + unsigned int i, lastaddr; + unsigned char data; + int werror; + unsigned char cmd[4]; + AVRMEM * m; + + m = avr_locate_mem(p, memtype); + if (m == NULL) { + avrdude_message(MSG_INFO, "No \"%s\" memory for part %s\n", + memtype, p->desc); + return -1; + } + + pgm->err_led(pgm, OFF); + + werror = 0; + + wsize = m->size; + if (size < wsize) { + wsize = size; + } + else if (size > wsize) { + avrdude_message(MSG_INFO, "%s: WARNING: %d bytes requested, but memory region is only %d" + "bytes\n" + "%sOnly %d bytes will actually be written\n", + progname, size, wsize, + progbuf, wsize); + } + + + if ((p->flags & AVRPART_HAS_TPI) && m->page_size != 0 && + pgm->cmd_tpi != NULL) { + + while (avr_tpi_poll_nvmbsy(pgm)); + + /* setup for WORD_WRITE */ + avr_tpi_setup_rw(pgm, m, 0, TPI_NVMCMD_WORD_WRITE); + + /* make sure it's aligned to a word boundary */ + if (wsize & 0x1) { + wsize++; + } + + /* write words, low byte first */ + for (lastaddr = i = 0; i < wsize; i += 2) { + RETURN_IF_CANCEL(); + if ((m->tags[i] & TAG_ALLOCATED) != 0 || + (m->tags[i + 1] & TAG_ALLOCATED) != 0) { + + if (lastaddr != i) { + /* need to setup new address */ + avr_tpi_setup_rw(pgm, m, i, TPI_NVMCMD_WORD_WRITE); + lastaddr = i; + } + + cmd[0] = TPI_CMD_SST_PI; + cmd[1] = m->buf[i]; + rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0); + + cmd[1] = m->buf[i + 1]; + rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0); + + lastaddr += 2; + + while (avr_tpi_poll_nvmbsy(pgm)); + } + report_progress(i, wsize, NULL); + } + return i; + } + + if (pgm->paged_write != NULL && m->page_size != 0) { + /* + * the programmer supports a paged mode write + */ + int need_write, failure; + unsigned int pageaddr; + unsigned int npages, nwritten; + + /* quickly scan number of pages to be written to first */ + for (pageaddr = 0, npages = 0; + pageaddr < wsize; + pageaddr += m->page_size) { + /* check whether this page must be written to */ + for (i = pageaddr; + i < pageaddr + m->page_size; + i++) + if ((m->tags[i] & TAG_ALLOCATED) != 0) { + npages++; + break; + } + } + + for (pageaddr = 0, failure = 0, nwritten = 0; + !failure && pageaddr < wsize; + pageaddr += m->page_size) { + RETURN_IF_CANCEL(); + /* check whether this page must be written to */ + for (i = pageaddr, need_write = 0; + i < pageaddr + m->page_size; + i++) + if ((m->tags[i] & TAG_ALLOCATED) != 0) { + need_write = 1; + break; + } + if (need_write) { + rc = 0; + if (auto_erase) + rc = pgm->page_erase(pgm, p, m, pageaddr); + if (rc >= 0) + rc = pgm->paged_write(pgm, p, m, m->page_size, pageaddr, m->page_size); + if (rc < 0) + /* paged write failed, fall back to byte-at-a-time write below */ + failure = 1; + } else { + avrdude_message(MSG_DEBUG, "%s: avr_write(): skipping page %u: no interesting data\n", + progname, pageaddr / m->page_size); + } + nwritten++; + report_progress(nwritten, npages, NULL); + } + if (!failure) + return wsize; + /* else: fall back to byte-at-a-time write, for historical reasons */ + } + + if (pgm->write_setup) { + pgm->write_setup(pgm, p, m); + } + + newpage = 1; + page_tainted = 0; + flush_page = 0; + + for (i=0; ibuf[i]; + report_progress(i, wsize, NULL); + + /* + * Find out whether the write action must be invoked for this + * byte. + * + * For non-paged memory, this only happens if TAG_ALLOCATED is + * set for the byte. + * + * For paged memory, TAG_ALLOCATED also invokes the write + * operation, which is actually a page buffer fill only. This + * "taints" the page, and upon encountering the last byte of each + * tainted page, the write operation must also be invoked in order + * to actually write the page buffer to memory. + */ + do_write = (m->tags[i] & TAG_ALLOCATED) != 0; + if (m->paged) { + if (newpage) { + page_tainted = do_write; + } else { + page_tainted |= do_write; + } + if (i % m->page_size == m->page_size - 1 || + i == wsize - 1) { + /* last byte this page */ + flush_page = page_tainted; + newpage = 1; + } else { + flush_page = newpage = 0; + } + } + + if (!do_write && !flush_page) { + continue; + } + + if (do_write) { + rc = avr_write_byte(pgm, p, m, i, data); + if (rc) { + avrdude_message(MSG_INFO, " ***failed; "); + avrdude_message(MSG_INFO, "\n"); + pgm->err_led(pgm, ON); + werror = 1; + } + } + + /* + * check to see if it is time to flush the page with a page + * write + */ + if (flush_page) { + rc = avr_write_page(pgm, p, m, i); + if (rc) { + avrdude_message(MSG_INFO, " *** page %d (addresses 0x%04x - 0x%04x) failed " + "to write\n", + i % m->page_size, + i - m->page_size + 1, i); + avrdude_message(MSG_INFO, "\n"); + pgm->err_led(pgm, ON); + werror = 1; + } + } + + if (werror) { + /* + * make sure the error led stay on if there was a previous write + * error, otherwise it gets cleared in avr_write_byte() + */ + pgm->err_led(pgm, ON); + return -1; + } + } + + return i; +} + + + +/* + * read the AVR device's signature bytes + */ +int avr_signature(PROGRAMMER * pgm, AVRPART * p) +{ + int rc; + + report_progress(0,1,"Reading"); + rc = avr_read(pgm, p, "signature", 0); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: error reading signature data for part \"%s\", rc=%d\n", + progname, p->desc, rc); + return -1; + } + report_progress(1,1,NULL); + + return 0; +} + + +/* + * 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(AVRPART * p, AVRPART * v, char * memtype, int size) +{ + int i; + unsigned char * buf1, * buf2; + int vsize; + AVRMEM * a, * b; + + a = avr_locate_mem(p, memtype); + if (a == NULL) { + avrdude_message(MSG_INFO, "avr_verify(): memory type \"%s\" not defined for part %s\n", + memtype, p->desc); + return -1; + } + + b = avr_locate_mem(v, memtype); + if (b == NULL) { + avrdude_message(MSG_INFO, "avr_verify(): memory type \"%s\" not defined for part %s\n", + memtype, v->desc); + return -1; + } + + buf1 = a->buf; + buf2 = b->buf; + vsize = a->size; + + if (vsize < size) { + avrdude_message(MSG_INFO, "%s: WARNING: requested verification for %d bytes\n" + "%s%s memory region only contains %d bytes\n" + "%sOnly %d bytes will be verified.\n", + progname, size, + progbuf, memtype, vsize, + progbuf, vsize); + size = vsize; + } + + for (i=0; itags[i] & TAG_ALLOCATED) != 0 && + buf1[i] != buf2[i]) { + avrdude_message(MSG_INFO, "%s: verification error, first mismatch at byte 0x%04x\n" + "%s0x%02x != 0x%02x\n", + progname, i, + progbuf, buf1[i], buf2[i]); + return -1; + } + } + + return size; +} + + +int avr_get_cycle_count(PROGRAMMER * pgm, AVRPART * p, int * cycles) +{ + AVRMEM * a; + unsigned int cycle_count = 0; + unsigned char v1; + int rc; + int i; + + a = avr_locate_mem(p, "eeprom"); + if (a == NULL) { + return -1; + } + + for (i=4; i>0; i--) { + rc = pgm->read_byte(pgm, p, a, a->size-i, &v1); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: WARNING: can't read memory for cycle count, rc=%d\n", + progname, rc); + return -1; + } + cycle_count = (cycle_count << 8) | v1; + } + + /* + * If the EEPROM is erased, the cycle count reads 0xffffffff. + * In this case we return a cycle_count of zero. + * So, the calling function don't have to care about whether or not + * the cycle count was initialized. + */ + if (cycle_count == 0xffffffff) { + cycle_count = 0; + } + + *cycles = (int) cycle_count; + + return 0; +} + + +int avr_put_cycle_count(PROGRAMMER * pgm, AVRPART * p, int cycles) +{ + AVRMEM * a; + unsigned char v1; + int rc; + int i; + + a = avr_locate_mem(p, "eeprom"); + if (a == NULL) { + return -1; + } + + for (i=1; i<=4; i++) { + v1 = cycles & 0xff; + cycles = cycles >> 8; + + rc = avr_write_byte(pgm, p, a, a->size-i, v1); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: WARNING: can't write memory for cycle count, rc=%d\n", + progname, rc); + return -1; + } + } + + return 0; + } + +int avr_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + int rc; + + rc = pgm->chip_erase(pgm, p); + + return rc; +} + +/* + * Report the progress of a read or write operation from/to the + * device. + * + * The first call of report_progress() should look like this (for a write op): + * + * report_progress (0, 1, "Writing"); + * + * Then hdr should be passed NULL on subsequent calls while the + * operation is progressing. Once the operation is complete, a final + * call should be made as such to ensure proper termination of the + * progress report: + * + * report_progress (1, 1, NULL); + * + * It would be nice if we could reduce the usage to one and only one + * call for each of start, during and end cases. As things stand now, + * that is not possible and makes maintenance a bit more work. + */ +void report_progress (int completed, int total, char *hdr) +{ + static int last = 0; + static double start_time; + int percent = (total > 0) ? ((completed * 100) / total) : 100; + struct timeval tv; + double t; + + if (update_progress == NULL) + return; + + gettimeofday(&tv, NULL); + t = tv.tv_sec + ((double)tv.tv_usec)/1000000; + + if (hdr) { + last = 0; + start_time = t; + update_progress (percent, t - start_time, hdr); + } + + if (percent > 100) + percent = 100; + + if (percent > last) { + last = percent; + update_progress (percent, t - start_time, hdr); + } + + if (percent == 100) + last = 0; /* Get ready for next time. */ +} diff --git a/xs/src/avrdude/avr910.c b/xs/src/avrdude/avr910.c new file mode 100644 index 000000000..aa5cc07a9 --- /dev/null +++ b/xs/src/avrdude/avr910.c @@ -0,0 +1,777 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2003-2004 Theodore A. Roth + * Copyright 2007 Joerg Wunsch + * Copyright 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 + * 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$ */ + +/* + * avrdude interface for Atmel Low Cost Serial programmers which adher to the + * protocol described in application note avr910. + */ + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include + +#if !defined(WIN32NATIVE) +# include +#endif + +#include "avrdude.h" +#include "libavrdude.h" + +#include "avr910.h" + +/* + * Private data for this programmer. + */ +struct pdata +{ + char has_auto_incr_addr; + unsigned char devcode; + unsigned int buffersize; + unsigned char test_blockmode; + unsigned char use_blockmode; +}; + +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) + +static void avr910_setup(PROGRAMMER * pgm) +{ + if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + avrdude_message(MSG_INFO, "%s: avr910_setup(): Out of memory allocating private data\n", + progname); + exit(1); + } + memset(pgm->cookie, 0, sizeof(struct pdata)); + PDATA(pgm)->test_blockmode = 1; +} + +static void avr910_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); +} + + +static int avr910_send(PROGRAMMER * pgm, char * buf, size_t len) +{ + return serial_send(&pgm->fd, (unsigned char *)buf, len); +} + + +static int avr910_recv(PROGRAMMER * pgm, char * buf, size_t len) +{ + int rv; + + rv = serial_recv(&pgm->fd, (unsigned char *)buf, len); + if (rv < 0) { + avrdude_message(MSG_INFO, "%s: avr910_recv(): programmer is not responding\n", + progname); + return 1; + } + return 0; +} + + +static int avr910_drain(PROGRAMMER * pgm, int display) +{ + return serial_drain(&pgm->fd, display); +} + + +static int avr910_vfy_cmd_sent(PROGRAMMER * pgm, char * errmsg) +{ + char c; + + avr910_recv(pgm, &c, 1); + if (c != '\r') { + avrdude_message(MSG_INFO, "%s: error: programmer did not respond to command: %s\n", + progname, errmsg); + return 1; + } + return 0; +} + + +/* + * issue the 'chip erase' command to the AVR device + */ +static int avr910_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + avr910_send(pgm, "e", 1); + if (avr910_vfy_cmd_sent(pgm, "chip erase") < 0) + return -1; + + /* + * avr910 firmware may not delay long enough + */ + usleep (p->chip_erase_delay); + + return 0; +} + + +static int avr910_enter_prog_mode(PROGRAMMER * pgm) +{ + avr910_send(pgm, "P", 1); + return avr910_vfy_cmd_sent(pgm, "enter prog mode"); +} + + +static int avr910_leave_prog_mode(PROGRAMMER * pgm) +{ + avr910_send(pgm, "L", 1); + return avr910_vfy_cmd_sent(pgm, "leave prog mode"); +} + + +/* + * issue the 'program enable' command to the AVR device + */ +static int avr910_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + return -1; +} + + +/* + * initialize the AVR device and prepare it to accept commands + */ +static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + char id[8]; + char sw[2]; + char hw[2]; + char buf[10]; + char type; + char c; + AVRPART * part; + + /* Get the programmer identifier. Programmer returns exactly 7 chars + _without_ the null.*/ + + avr910_send(pgm, "S", 1); + memset (id, 0, sizeof(id)); + avr910_recv(pgm, id, sizeof(id)-1); + + /* Get the HW and SW versions to see if the programmer is present. */ + + avr910_send(pgm, "V", 1); + avr910_recv(pgm, sw, sizeof(sw)); + + avr910_send(pgm, "v", 1); + avr910_recv(pgm, hw, sizeof(hw)); + + /* Get the programmer type (serial or parallel). Expect serial. */ + + avr910_send(pgm, "p", 1); + avr910_recv(pgm, &type, 1); + + avrdude_message(MSG_INFO, "Found programmer: Id = \"%s\"; type = %c\n", id, type); + avrdude_message(MSG_INFO, " Software Version = %c.%c; ", sw[0], sw[1]); + avrdude_message(MSG_INFO, "Hardware Version = %c.%c\n", hw[0], hw[1]); + + /* See if programmer supports autoincrement of address. */ + + avr910_send(pgm, "a", 1); + avr910_recv(pgm, &PDATA(pgm)->has_auto_incr_addr, 1); + if (PDATA(pgm)->has_auto_incr_addr == 'Y') + avrdude_message(MSG_INFO, "Programmer supports auto addr increment.\n"); + + /* Check support for buffered memory access, ignore if not available */ + + if (PDATA(pgm)->test_blockmode == 1) { + avr910_send(pgm, "b", 1); + avr910_recv(pgm, &c, 1); + if (c == 'Y') { + avr910_recv(pgm, &c, 1); + PDATA(pgm)->buffersize = (unsigned int)(unsigned char)c<<8; + avr910_recv(pgm, &c, 1); + PDATA(pgm)->buffersize += (unsigned int)(unsigned char)c; + avrdude_message(MSG_INFO, "Programmer supports buffered memory access with " + "buffersize = %u bytes.\n", + PDATA(pgm)->buffersize); + PDATA(pgm)->use_blockmode = 1; + } else { + PDATA(pgm)->use_blockmode = 0; + } + } else { + PDATA(pgm)->use_blockmode = 0; + } + + if (PDATA(pgm)->devcode == 0) { + char devtype_1st; + int dev_supported = 0; + + /* Get list of devices that the programmer supports. */ + + avr910_send(pgm, "t", 1); + avrdude_message(MSG_INFO, "\nProgrammer supports the following devices:\n"); + devtype_1st = 0; + while (1) { + avr910_recv(pgm, &c, 1); + if (devtype_1st == 0) + devtype_1st = c; + if (c == 0) + break; + part = locate_part_by_avr910_devcode(part_list, c); + + avrdude_message(MSG_INFO, " Device code: 0x%02x = %s\n", c, part ? part->desc : "(unknown)"); + + /* FIXME: Need to lookup devcode and report the device. */ + + if (p->avr910_devcode == c) + dev_supported = 1; + }; + avrdude_message(MSG_INFO, "\n"); + + if (!dev_supported) { + avrdude_message(MSG_INFO, "%s: %s: selected device is not supported by programmer: %s\n", + progname, ovsigck? "warning": "error", p->id); + if (!ovsigck) + return -1; + } + /* If the user forced the selection, use the first device + type that is supported by the programmer. */ + buf[1] = ovsigck? devtype_1st: p->avr910_devcode; + } else { + /* devcode overridden by -x devcode= option */ + buf[1] = (char)(PDATA(pgm)->devcode); + } + + /* Tell the programmer which part we selected. */ + buf[0] = 'T'; + /* buf[1] has been set up above */ + + avr910_send(pgm, buf, 2); + avr910_vfy_cmd_sent(pgm, "select device"); + + avrdude_message(MSG_NOTICE, "%s: avr910_devcode selected: 0x%02x\n", + progname, (unsigned)buf[1]); + + avr910_enter_prog_mode(pgm); + + return 0; +} + + +static void avr910_disable(PROGRAMMER * pgm) +{ + /* Do nothing. */ + + return; +} + + +static void avr910_enable(PROGRAMMER * pgm) +{ + /* Do nothing. */ + + return; +} + + +/* + * transmit an AVR device command and return the results; 'cmd' and + * 'res' must point to at least a 4 byte data buffer + */ +static int avr910_cmd(PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res) +{ + char buf[5]; + + /* FIXME: Insert version check here */ + + buf[0] = '.'; /* New Universal Command */ + buf[1] = cmd[0]; + buf[2] = cmd[1]; + buf[3] = cmd[2]; + buf[4] = cmd[3]; + + avr910_send (pgm, buf, 5); + avr910_recv (pgm, buf, 2); + + res[0] = 0x00; /* Dummy value */ + res[1] = cmd[0]; + res[2] = cmd[1]; + res[3] = buf[0]; + + return 0; +} + + +static int avr910_parseextparms(PROGRAMMER * pgm, LISTID extparms) +{ + LNODEID ln; + const char *extended_param; + int rv = 0; + + for (ln = lfirst(extparms); ln; ln = lnext(ln)) { + extended_param = ldata(ln); + + if (strncmp(extended_param, "devcode=", strlen("devcode=")) == 0) { + int devcode; + if (sscanf(extended_param, "devcode=%i", &devcode) != 1 || + devcode <= 0 || devcode > 255) { + avrdude_message(MSG_INFO, "%s: avr910_parseextparms(): invalid devcode '%s'\n", + progname, extended_param); + rv = -1; + continue; + } + avrdude_message(MSG_NOTICE2, "%s: avr910_parseextparms(): devcode overwritten as 0x%02x\n", + progname, devcode); + PDATA(pgm)->devcode = devcode; + + continue; + } + if (strncmp(extended_param, "no_blockmode", strlen("no_blockmode")) == 0) { + avrdude_message(MSG_NOTICE2, "%s: avr910_parseextparms(-x): no testing for Blockmode\n", + progname); + PDATA(pgm)->test_blockmode = 0; + + continue; + } + + avrdude_message(MSG_INFO, "%s: avr910_parseextparms(): invalid extended parameter '%s'\n", + progname, extended_param); + rv = -1; + } + + return rv; +} + + +static int avr910_open(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + /* + * If baudrate was not specified use 19.200 Baud + */ + if(pgm->baudrate == 0) { + pgm->baudrate = 19200; + } + + strcpy(pgm->port, port); + pinfo.baud = pgm->baudrate; + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + avr910_drain (pgm, 0); + + return 0; +} + +static void avr910_close(PROGRAMMER * pgm) +{ + avr910_leave_prog_mode(pgm); + + serial_close(&pgm->fd); + pgm->fd.ifd = -1; +} + + +static void avr910_display(PROGRAMMER * pgm, const char * p) +{ + return; +} + + +static void avr910_set_addr(PROGRAMMER * pgm, unsigned long addr) +{ + char cmd[3]; + + cmd[0] = 'A'; + cmd[1] = (addr >> 8) & 0xff; + cmd[2] = addr & 0xff; + + avr910_send(pgm, cmd, sizeof(cmd)); + avr910_vfy_cmd_sent(pgm, "set addr"); +} + + +static int avr910_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned long addr, unsigned char value) +{ + char cmd[2]; + + if (strcmp(m->desc, "flash") == 0) { + if (addr & 0x01) { + cmd[0] = 'C'; /* Write Program Mem high byte */ + } + else { + cmd[0] = 'c'; + } + + addr >>= 1; + } + else if (strcmp(m->desc, "eeprom") == 0) { + cmd[0] = 'D'; + } + else { + return avr_write_byte_default(pgm, p, m, addr, value); + } + + cmd[1] = value; + + avr910_set_addr(pgm, addr); + + avr910_send(pgm, cmd, sizeof(cmd)); + avr910_vfy_cmd_sent(pgm, "write byte"); + + return 0; +} + + +static int avr910_read_byte_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned long addr, unsigned char * value) +{ + char buf[2]; + + avr910_set_addr(pgm, addr >> 1); + + avr910_send(pgm, "R", 1); + + /* Read back the program mem word (MSB first) */ + avr910_recv(pgm, buf, sizeof(buf)); + + if ((addr & 0x01) == 0) { + *value = buf[1]; + } + else { + *value = buf[0]; + } + + return 0; +} + + +static int avr910_read_byte_eeprom(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned long addr, unsigned char * value) +{ + avr910_set_addr(pgm, addr); + avr910_send(pgm, "d", 1); + avr910_recv(pgm, (char *)value, 1); + + return 0; +} + + +static int avr910_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned long addr, unsigned char * value) +{ + if (strcmp(m->desc, "flash") == 0) { + return avr910_read_byte_flash(pgm, p, m, addr, value); + } + + if (strcmp(m->desc, "eeprom") == 0) { + return avr910_read_byte_eeprom(pgm, p, m, addr, value); + } + + return avr_read_byte_default(pgm, p, m, addr, value); +} + + +static int avr910_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned char cmd[] = {'c', 'C'}; + char buf[2]; + unsigned int max_addr = addr + n_bytes; + unsigned int page_addr; + int page_bytes = page_size; + int page_wr_cmd_pending = 0; + + page_addr = addr; + avr910_set_addr(pgm, addr>>1); + + while (addr < max_addr) { + page_wr_cmd_pending = 1; + buf[0] = cmd[addr & 0x01]; + buf[1] = m->buf[addr]; + avr910_send(pgm, buf, sizeof(buf)); + avr910_vfy_cmd_sent(pgm, "write byte"); + + addr++; + page_bytes--; + + if (m->paged && (page_bytes == 0)) { + /* Send the "Issue Page Write" if we have sent a whole page. */ + + avr910_set_addr(pgm, page_addr>>1); + avr910_send(pgm, "m", 1); + avr910_vfy_cmd_sent(pgm, "flush page"); + + page_wr_cmd_pending = 0; + usleep(m->max_write_delay); + avr910_set_addr(pgm, addr>>1); + + /* Set page address for next page. */ + + page_addr = addr; + page_bytes = page_size; + } + else if ((PDATA(pgm)->has_auto_incr_addr != 'Y') && ((addr & 0x01) == 0)) { + avr910_set_addr(pgm, addr>>1); + } + } + + /* If we didn't send the page wr cmd after the last byte written in the + loop, send it now. */ + + if (page_wr_cmd_pending) { + avr910_set_addr(pgm, page_addr>>1); + avr910_send(pgm, "m", 1); + avr910_vfy_cmd_sent(pgm, "flush final page"); + usleep(m->max_write_delay); + } + + return addr; +} + + +static int avr910_paged_write_eeprom(PROGRAMMER * pgm, AVRPART * p, + AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + char cmd[2]; + unsigned int max_addr = addr + n_bytes; + + avr910_set_addr(pgm, addr); + + cmd[0] = 'D'; + + while (addr < max_addr) { + cmd[1] = m->buf[addr]; + avr910_send(pgm, cmd, sizeof(cmd)); + avr910_vfy_cmd_sent(pgm, "write byte"); + usleep(m->max_write_delay); + + addr++; + + if (PDATA(pgm)->has_auto_incr_addr != 'Y') { + avr910_set_addr(pgm, addr); + } + } + + return addr; +} + + +static int avr910_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + int rval = 0; + if (PDATA(pgm)->use_blockmode == 0) { + if (strcmp(m->desc, "flash") == 0) { + rval = avr910_paged_write_flash(pgm, p, m, page_size, addr, n_bytes); + } else if (strcmp(m->desc, "eeprom") == 0) { + rval = avr910_paged_write_eeprom(pgm, p, m, page_size, addr, n_bytes); + } else { + rval = -2; + } + } + + if (PDATA(pgm)->use_blockmode == 1) { + unsigned int max_addr = addr + n_bytes; + char *cmd; + unsigned int blocksize = PDATA(pgm)->buffersize; + int wr_size; + + if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom")) + return -2; + + if (m->desc[0] == 'e') { + blocksize = 1; /* Write to eeprom single bytes only */ + wr_size = 1; + } else { + wr_size = 2; + } + + avr910_set_addr(pgm, addr / wr_size); + + cmd = malloc(4 + blocksize); + if (!cmd) return -1; + + cmd[0] = 'B'; + cmd[3] = toupper((int)(m->desc[0])); + + while (addr < max_addr) { + if ((max_addr - addr) < blocksize) { + blocksize = max_addr - addr; + }; + memcpy(&cmd[4], &m->buf[addr], blocksize); + cmd[1] = (blocksize >> 8) & 0xff; + cmd[2] = blocksize & 0xff; + + avr910_send(pgm, cmd, 4 + blocksize); + avr910_vfy_cmd_sent(pgm, "write block"); + + addr += blocksize; + } /* while */ + free(cmd); + + rval = addr; + } + return rval; +} + + +static int avr910_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + char cmd[4]; + int rd_size; + unsigned int max_addr; + char buf[2]; + int rval=0; + + max_addr = addr + n_bytes; + + if (strcmp(m->desc, "flash") == 0) { + cmd[0] = 'R'; + rd_size = 2; /* read two bytes per addr */ + } else if (strcmp(m->desc, "eeprom") == 0) { + cmd[0] = 'd'; + rd_size = 1; + } else { + return -2; + } + + if (PDATA(pgm)->use_blockmode) { + /* use buffered mode */ + int blocksize = PDATA(pgm)->buffersize; + + cmd[0] = 'g'; + cmd[3] = toupper((int)(m->desc[0])); + + avr910_set_addr(pgm, addr / rd_size); + + while (addr < max_addr) { + if ((max_addr - addr) < blocksize) { + blocksize = max_addr - addr; + } + cmd[1] = (blocksize >> 8) & 0xff; + cmd[2] = blocksize & 0xff; + + avr910_send(pgm, cmd, 4); + avr910_recv(pgm, (char *)&m->buf[addr], blocksize); + + addr += blocksize; + } + + rval = addr; + } else { + + avr910_set_addr(pgm, addr / rd_size); + + while (addr < max_addr) { + avr910_send(pgm, cmd, 1); + if (rd_size == 2) { + /* The 'R' command returns two bytes, MSB first, we need to put the data + into the memory buffer LSB first. */ + avr910_recv(pgm, buf, 2); + m->buf[addr] = buf[1]; /* LSB */ + m->buf[addr + 1] = buf[0]; /* MSB */ + } + else { + avr910_recv(pgm, (char *)&m->buf[addr], 1); + } + + addr += rd_size; + + if (PDATA(pgm)->has_auto_incr_addr != 'Y') { + avr910_set_addr(pgm, addr / rd_size); + } + } + + rval = addr; + } + + return rval; +} + +/* Signature byte reads are always 3 bytes. */ + +static int avr910_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m) +{ + unsigned char tmp; + + if (m->size < 3) { + avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read", progname); + return -1; + } + + avr910_send(pgm, "s", 1); + avr910_recv(pgm, (char *)m->buf, 3); + /* Returned signature has wrong order. */ + tmp = m->buf[2]; + m->buf[2] = m->buf[0]; + m->buf[0] = tmp; + + return 3; +} + +const char avr910_desc[] = "Serial programmers using protocol described in application note AVR910"; + +void avr910_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "avr910"); + + /* + * mandatory functions + */ + pgm->initialize = avr910_initialize; + pgm->display = avr910_display; + pgm->enable = avr910_enable; + pgm->disable = avr910_disable; + pgm->program_enable = avr910_program_enable; + pgm->chip_erase = avr910_chip_erase; + pgm->cmd = avr910_cmd; + pgm->open = avr910_open; + pgm->close = avr910_close; + + /* + * optional functions + */ + + pgm->write_byte = avr910_write_byte; + pgm->read_byte = avr910_read_byte; + + pgm->paged_write = avr910_paged_write; + pgm->paged_load = avr910_paged_load; + + pgm->read_sig_bytes = avr910_read_sig_bytes; + + pgm->parseextparams = avr910_parseextparms; + pgm->setup = avr910_setup; + pgm->teardown = avr910_teardown; +} diff --git a/xs/src/avrdude/avr910.h b/xs/src/avrdude/avr910.h new file mode 100644 index 000000000..808f7e68f --- /dev/null +++ b/xs/src/avrdude/avr910.h @@ -0,0 +1,35 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 avr910_h +#define avr910_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char avr910_desc[]; +void avr910_initpgm (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif /* avr910_h */ diff --git a/xs/src/avrdude/avrdude-slic3r.cpp b/xs/src/avrdude/avrdude-slic3r.cpp new file mode 100644 index 000000000..a859200fb --- /dev/null +++ b/xs/src/avrdude/avrdude-slic3r.cpp @@ -0,0 +1,150 @@ +#include "avrdude-slic3r.hpp" + +#include + +extern "C" { +#include "ac_cfg.h" +#include "avrdude.h" +} + + +namespace Slic3r { + + +// C callbacks + +// Used by our custom code in avrdude to receive messages that avrdude normally outputs on stdout (see avrdude_message()) +static void avrdude_message_handler_closure(const char *msg, unsigned size, void *user_p) +{ + auto *message_fn = reinterpret_cast(user_p); + (*message_fn)(msg, size); +} + +// Used by our custom code in avrdude to report progress in the GUI +static void avrdude_progress_handler_closure(const char *task, unsigned progress, void *user_p) +{ + auto *progress_fn = reinterpret_cast(user_p); + (*progress_fn)(task, progress); +} + + +// Private + +struct AvrDude::priv +{ + std::string sys_config; + std::vector args; + MessageFn message_fn; + ProgressFn progress_fn; + CompleteFn complete_fn; + + std::thread avrdude_thread; + + int run(); +}; + +int AvrDude::priv::run() { + std::vector c_args {{ const_cast(PACKAGE_NAME) }}; + for (const auto &arg : args) { + c_args.push_back(const_cast(arg.data())); + } + + if (message_fn) { + ::avrdude_message_handler_set(avrdude_message_handler_closure, reinterpret_cast(&message_fn)); + } else { + ::avrdude_message_handler_set(nullptr, nullptr); + } + + if (progress_fn) { + ::avrdude_progress_handler_set(avrdude_progress_handler_closure, reinterpret_cast(&progress_fn)); + } else { + ::avrdude_progress_handler_set(nullptr, nullptr); + } + + const auto res = ::avrdude_main(static_cast(c_args.size()), c_args.data(), sys_config.c_str()); + + ::avrdude_message_handler_set(nullptr, nullptr); + ::avrdude_progress_handler_set(nullptr, nullptr); + return res; +} + + +// Public + +AvrDude::AvrDude() : p(new priv()) {} + +AvrDude::AvrDude(AvrDude &&other) : p(std::move(other.p)) {} + +AvrDude::~AvrDude() +{ + if (p && p->avrdude_thread.joinable()) { + p->avrdude_thread.detach(); + } +} + +AvrDude& AvrDude::sys_config(std::string sys_config) +{ + if (p) { p->sys_config = std::move(sys_config); } + return *this; +} + +AvrDude& AvrDude::args(std::vector args) +{ + if (p) { p->args = std::move(args); } + return *this; +} + +AvrDude& AvrDude::on_message(MessageFn fn) +{ + if (p) { p->message_fn = std::move(fn); } + return *this; +} + +AvrDude& AvrDude::on_progress(ProgressFn fn) +{ + if (p) { p->progress_fn = std::move(fn); } + return *this; +} + +AvrDude& AvrDude::on_complete(CompleteFn fn) +{ + if (p) { p->complete_fn = std::move(fn); } + return *this; +} + +int AvrDude::run_sync() +{ + return p->run(); +} + +AvrDude::Ptr AvrDude::run() +{ + auto self = std::make_shared(std::move(*this)); + + if (self->p) { + auto avrdude_thread = std::thread([self]() { + auto res = self->p->run(); + if (self->p->complete_fn) { + self->p->complete_fn(res); + } + }); + self->p->avrdude_thread = std::move(avrdude_thread); + } + + return self; +} + +void AvrDude::cancel() +{ + ::avrdude_cancel(); +} + +void AvrDude::join() +{ + if (p && p->avrdude_thread.joinable()) { + p->avrdude_thread.join(); + } +} + + +} diff --git a/xs/src/avrdude/avrdude-slic3r.hpp b/xs/src/avrdude/avrdude-slic3r.hpp new file mode 100644 index 000000000..8d881b094 --- /dev/null +++ b/xs/src/avrdude/avrdude-slic3r.hpp @@ -0,0 +1,55 @@ +#ifndef slic3r_avrdude_slic3r_hpp_ +#define slic3r_avrdude_slic3r_hpp_ + +#include +#include +#include +#include + +namespace Slic3r { + +class AvrDude +{ +public: + typedef std::shared_ptr Ptr; + typedef std::function MessageFn; + typedef std::function ProgressFn; + typedef std::function CompleteFn; + + AvrDude(); + AvrDude(AvrDude &&); + AvrDude(const AvrDude &) = delete; + AvrDude &operator=(AvrDude &&) = delete; + AvrDude &operator=(const AvrDude &) = delete; + ~AvrDude(); + + // Set location of avrdude's main configuration file + AvrDude& sys_config(std::string sys_config); + + // Set avrdude cli arguments + AvrDude& args(std::vector args); + + // Set message output callback + AvrDude& on_message(MessageFn fn); + + // Set progress report callback + // Progress is reported per each task (reading / writing) in percents. + AvrDude& on_progress(ProgressFn fn); + + // Called when avrdude's main function finishes + AvrDude& on_complete(CompleteFn fn); + + int run_sync(); + Ptr run(); + + void cancel(); + void join(); +private: + struct priv; + std::unique_ptr p; +}; + + +} + +#endif diff --git a/xs/src/avrdude/avrdude.1 b/xs/src/avrdude/avrdude.1 new file mode 100644 index 000000000..65fc7b1d6 --- /dev/null +++ b/xs/src/avrdude/avrdude.1 @@ -0,0 +1,1133 @@ +.\" +.\" avrdude - A Downloader/Uploader for AVR device programmers +.\" Copyright (C) 2001, 2002, 2003, 2005 - 2016 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 +.\" 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$ +.\" +.Dd DATE February 15, 2016 +.Os +.Dt AVRDUDE 1 +.Sh NAME +.Nm avrdude +.Nd driver program for ``simple'' Atmel AVR MCU programmer +.Sh SYNOPSIS +.Nm +.Fl p Ar partno +.Op Fl b Ar baudrate +.Op Fl B Ar bitclock +.Op Fl c Ar programmer-id +.Op Fl C Ar config-file +.Op Fl D +.Op Fl e +.Oo Fl E Ar exitspec Ns +.Op \&, Ns Ar exitspec +.Oc +.Op Fl F +.Op Fl i Ar delay +.Op Fl n logfile +.Op Fl n +.Op Fl O +.Op Fl P Ar port +.Op Fl q +.Op Fl s +.Op Fl t +.Op Fl u +.Op Fl U Ar memtype:op:filename:filefmt +.Op Fl v +.Op Fl x Ar extended_param +.Op Fl V +.Sh DESCRIPTION +.Nm Avrdude +is a program for downloading code and data to Atmel AVR +microcontrollers. +.Nm Avrdude +supports Atmel's STK500 programmer, +Atmel's AVRISP and AVRISP mkII devices, +Atmel's STK600, +Atmel's JTAG ICE (mkI, mkII and 3, the latter two also in ISP mode), +programmers complying to AppNote AVR910 and AVR109 (including the Butterfly), +as well as a simple hard-wired +programmer connected directly to a +.Xr ppi 4 +or +.Xr parport 4 +parallel port, or to a standard serial port. +In the simplest case, the hardware consists just of a +cable connecting the respective AVR signal lines to the parallel port. +.Pp +The MCU is programmed in +.Em serial programming mode , +so, for the +.Xr ppi 4 +based programmer, the MCU signals +.Ql /RESET , +.Ql SCK , +.Ql MISO +and +.Ql MOSI +need to be connected to the parallel port. Optionally, some otherwise +unused output pins of the parallel port can be used to supply power +for the MCU part, so it is also possible to construct a passive +stand-alone programming device. Some status LEDs indicating the +current operating state of the programmer can be connected, and a +signal is available to control a buffer/driver IC 74LS367 (or +74HCT367). The latter can be useful to decouple the parallel port +from the MCU when in-system programming is used. +.Pp +A number of equally simple bit-bang programming adapters that connect +to a serial port are supported as well, among them the popular +Ponyprog serial adapter, and the DASA and DASA3 adapters that used to +be supported by uisp(1). +Note that these adapters are meant to be attached to a physical serial +port. +Connecting to a serial port emulated on top of USB is likely to not +work at all, or to work abysmally slow. +.Pp +If you happen to have a Linux system with at least 4 hardware GPIOs +available (like almost all embedded Linux boards) you can do without +any additional hardware - just connect them to the MOSI, MISO, RESET +and SCK pins on the AVR and use the linuxgpio programmer type. It bitbangs +the lines using the Linux sysfs GPIO interface. Of course, care should +be taken about voltage level compatibility. Also, although not strictrly +required, it is strongly advisable to protect the GPIO pins from +overcurrent situations in some way. The simplest would be to just put +some resistors in series or better yet use a 3-state buffer driver like +the 74HC244. Have a look at http://kolev.info/avrdude-linuxgpio for a more +detailed tutorial about using this programmer type. +.Pp +Atmel's STK500 programmer is also supported and connects to a serial +port. +Both, firmware versions 1.x and 2.x can be handled, but require a +different programmer type specification (by now). +Using firmware version 2, high-voltage programming is also supported, +both parallel and serial +(programmer types stk500pp and stk500hvsp). +.Pp +Wiring boards are supported, utilizing STK500 V2.x protocol, but +a simple DTR/RTS toggle is used to set the boards into programming mode. +The programmer type is ``wiring''. +.Pp +The Arduino (which is very similar to the STK500 1.x) is supported via +its own programmer type specification ``arduino''. +.Pp +The BusPirate is a versatile tool that can also be used as an AVR programmer. +A single BusPirate can be connected to up to 3 independent AVRs. See +the section on +.Em extended parameters +below for details. +.Pp +Atmel's STK600 programmer is supported in ISP and high-voltage +programming modes, and connects through the USB. +For ATxmega devices, the STK600 is supported in PDI mode. +For ATtiny4/5/9/10 devices, the STK600 and AVRISP mkII are supported in TPI mode. +.Pp +The simple serial programmer described in Atmel's application note +AVR910, and the bootloader described in Atmel's application note +AVR109 (which is also used by the AVR Butterfly evaluation board), are +supported on a serial port. +.Pp +Atmel's JTAG ICE (mkI, mkII, and 3) is supported as well to up- or download memory +areas from/to an AVR target (no support for on-chip debugging). +For the JTAG ICE mkII, JTAG, debugWire and ISP mode are supported, provided +it has a firmware revision of at least 4.14 (decimal). +JTAGICE3 also supports all of JTAG, debugWIRE, and ISP mode. +See below for the limitations of debugWire. +For ATxmega devices, the JTAG ICE mkII is supported in PDI mode, provided it +has a revision 1 hardware and firmware version of at least 5.37 (decimal). +For ATxmega devices, the JTAGICE3 is supported in PDI mode. +.Pp +Atmel-ICE (ARM/AVR) is supported in all modes (JTAG, PDI for Xmega, debugWIRE, +ISP). +.Pp +Atmel's XplainedPro boards, using the EDBG protocol (CMSIS-DAP compatible), +are supported using the "jtag3" programmer type. +.Pp +Atmel's XplainedMini boards, using the mEDBG protocol, +are also supported using the "jtag3" programmer type. +.Pp +The AVR Dragon is supported in all modes (ISP, JTAG, HVSP, PP, debugWire). +When used in JTAG and debugWire mode, the AVR Dragon behaves similar to a +JTAG ICE mkII, so all device-specific comments for that device +will apply as well. +When used in ISP mode, the AVR Dragon behaves similar to an +AVRISP mkII (or JTAG ICE mkII in ISP mode), so all device-specific +comments will apply there. +In particular, the Dragon starts out with a rather fast ISP clock +frequency, so the +.Fl B Ar bitclock +option might be required to achieve a stable ISP communication. +For ATxmega devices, the AVR Dragon is supported in PDI mode, provided it +has a firmware version of at least 6.11 (decimal). +.Pp +The avrftdi, USBasp ISP and USBtinyISP adapters are also supported, provided +.Nm avrdude +has been compiled with libusb support. +USBasp ISP and USBtinyISP both feature simple firmware-only USB implementations, +running on an ATmega8 (or ATmega88), or ATtiny2313, respectively. If libftdi has +has been compiled in +.Nm avrdude , +the avrftdi device adds support for many programmers using FTDI's 2232C/D/H +and 4232H parts running in MPSSE mode, which hard-codes (in the chip) +SCK to bit 1, MOSI to bit 2, and MISO to bit 3. Reset is usually bit 4. +.Pp +The Atmel DFU bootloader is supported in both, FLIP protocol version 1 +(AT90USB* and ATmega*U* devices), as well as version 2 (Xmega devices). +See below for some hints about FLIP version 1 protocol behaviour. +.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 +format. There are a number of tools available to produce those files, +like +.Xr asl 1 +as a standalone assembler, or +.Xr avr-objcopy 1 +for the final stage of the GNU toolchain for the AVR microcontroller. +.Pp +Provided +.Xr libelf 3 +was present when compiling +.Nm avrdude , +the input file can also be the final ELF file as produced by the linker. +The appropriate ELF section(s) will be examined, according to the memory +area to write to. +.Pp +.Nm Avrdude +can program the EEPROM and flash ROM memory cells of supported AVR +parts. Where supported by the serial instruction set, fuse bits and +lock bits can be programmed as well. These are implemented within +.Nm +as separate memory types and can be programmed using data from a file +(see the +.Fl m +option) or from terminal mode (see the +.Ar dump +and +.Ar write +commands). It is also possible to read the chip (provided it has not +been code-protected previously, of course) and store the data in a +file. Finally, a ``terminal'' mode is available that allows one to +interactively communicate with the MCU, and to display or program +individual memory cells. +On the STK500 and STK600 programmer, several operational parameters (target supply +voltage, target Aref voltage, master clock) can be examined and changed +from within terminal mode as well. +.Ss Options +In order to control all the different operation modi, a number of options +need to be specified to +.Nm avrdude . +.Bl -tag -offset indent -width indent +.It Fl p Ar partno +This is the only option that is mandatory for every invocation of +.Nm avrdude . +It specifies the type of the MCU connected to the programmer. These are read from the config file. +For currently supported MCU types use ? as partno, this will print a list of partno ids and official part names on the terminal. (Both can be used with the -p option.) +.Pp +Following parts need special attention: +.Bl -tag -width "ATmega1234" +.It "AT90S1200" +The ISP programming protocol of the AT90S1200 differs in subtle ways +from that of other AVRs. Thus, not all programmers support this +device. Known to work are all direct bitbang programmers, and all +programmers talking the STK500v2 protocol. +.It "AT90S2343" +The AT90S2323 and ATtiny22 use the same algorithm. +.It "ATmega2560, ATmega2561" +Flash addressing above 128 KB is not supported by all +programming hardware. Known to work are jtag2, stk500v2, +and bit-bang programmers. +.It "ATtiny11" +The ATtiny11 can only be +programmed in high-voltage serial mode. +.El +.It Fl b Ar baudrate +Override the RS-232 connection baud rate specified in the respective +programmer's entry of the configuration file. +.It Fl B Ar bitclock +Specify the bit clock period for the JTAG interface or the ISP clock (JTAG ICE only). +The value is a floating-point number in microseconds. +Alternatively, the value might be suffixed with "Hz", "kHz", or "MHz", +in order to specify the bit clock frequency, rather than a period. +The default value of the JTAG ICE results in about 1 microsecond bit +clock period, suitable for target MCUs running at 4 MHz clock and +above. +Unlike certain parameters in the STK500, the JTAG ICE resets all its +parameters to default values when the programming software signs +off from the ICE, so for MCUs running at lower clock speeds, this +parameter must be specified on the command-line. +You can use the 'default_bitclock' keyword in your +.Pa ${HOME}/.avrduderc +file to assign a default value to keep from having to specify this +option on every invocation. +.It Fl c Ar programmer-id +Use the programmer specified by the argument. Programmers and their pin +configurations are read from the config file (see the +.Fl C +option). New pin configurations can be easily added or modified +through the use of a config file to make +.Nm avrdude +work with different programmers as long as the programmer supports the +Atmel AVR serial program method. You can use the 'default_programmer' +keyword in your +.Pa ${HOME}/.avrduderc +file to assign a default programmer to keep from having to specify +this option on every invocation. +A full list of all supported programmers is output to the terminal +by using ? as programmer-id. +.It Fl C Ar config-file +Use the specified config file to load configuration data. This file +contains all programmer and part definitions that +.Nm avrdude +knows about. +See the config file, located at +.Pa ${PREFIX}/etc/avrdude.conf , +which contains a description of the format. +.Pp +If +.Ar config-file +is written as +.Pa +filename +then this file is read after the system wide and user configuration +files. This can be used to add entries to the configuration +without patching your system wide configuration file. It can be used +several times, the files are read in same order as given on the command +line. +.It Fl D +Disable auto erase for flash. When the +.Fl U +option with 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. +.It Fl e +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 +contents would exclusively cause bits to be programmed from the value +.Ql 1 +to +.Ql 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. +.It Xo Fl E Ar exitspec Ns +.Op \&, Ns Ar exitspec +.Xc +By default, +.Nm +leaves the parallel port in the same state at exit as it has been +found at startup. This option modifies the state of the +.Ql /RESET +and +.Ql Vcc +lines the parallel port is left at, according to the +.Ar exitspec +arguments provided, as follows: +.Bl -tag -width noreset +.It Ar reset +The +.Ql /RESET +signal will be left activated at program exit, that is it will be held +.Em low , +in order to keep the MCU in reset state afterwards. Note in particular +that the programming algorithm for the AT90S1200 device mandates that +the +.Ql /RESET +signal is active +.Em before +powering up the MCU, so in case an external power supply is used for this +MCU type, a previous invocation of +.Nm +with this option specified is one of the possible ways to guarantee this +condition. +.It Ar noreset +The +.Ql /RESET +line will be deactivated at program exit, thus allowing the MCU target +program to run while the programming hardware remains connected. +.It Ar vcc +This option will leave those parallel port pins active +.Pq \&i. \&e. Em high +that can be used to supply +.Ql Vcc +power to the MCU. +.It Ar novcc +This option will pull the +.Ql Vcc +pins of the parallel port down at program exit. +.It Ar d_high +This option will leave the 8 data pins on the parallel port active. +.Pq \&i. \&e. Em high +.It Ar d_low +This option will leave the 8 data pins on the parallel port inactive. +.Pq \&i. \&e. Em low +.El +.Pp +Multiple +.Ar exitspec +arguments can be separated with commas. +.It Fl F +Normally, +.Nm +tries to verify that the device signature read from the part is +reasonable before continuing. Since it can happen from time to time +that a device has a broken (erased or overwritten) device signature +but is otherwise operating normally, this options is provided to +override the check. +Also, for programmers like the Atmel STK500 and STK600 which can +adjust parameters local to the programming tool (independent of an +actual connection to a target controller), this option can be used +together with +.Fl t +to continue in terminal mode. +.It Fl i Ar delay +For bitbang-type programmers, delay for approximately +.Ar delay +microseconds between each bit state change. +If the host system is very fast, or the target runs off a slow clock +(like a 32 kHz crystal, or the 128 kHz internal RC oscillator), this +can become necessary to satisfy the requirement that the ISP clock +frequency must not be higher than 1/4 of the CPU clock frequency. +This is implemented as a spin-loop delay to allow even for very +short delays. +On Unix-style operating systems, the spin loop is initially calibrated +against a system timer, so the number of microseconds might be rather +realistic, assuming a constant system load while +.Nm +is running. +On Win32 operating systems, a preconfigured number of cycles per +microsecond is assumed that might be off a bit for very fast or very +slow machines. +.It Fl l Ar logfile +Use +.Ar logfile +rather than +.Va stderr +for diagnostics output. +Note that initial diagnostic messages (during option parsing) are still +written to +.Va stderr +anyway. +.It Fl n +No-write - disables actually writing data to the MCU (useful for debugging +.Nm avrdude +). +.It Fl O +Perform a RC oscillator run-time calibration according to Atmel +application note AVR053. +This is only supported on the STK500v2, AVRISP mkII, and JTAG ICE mkII +hardware. +Note that the result will be stored in the EEPROM cell at address 0. +.It Fl P Ar port +Use +.Ar port +to identify the device to which the programmer is attached. By +default the +.Pa /dev/ppi0 +port is used, but if the programmer type normally connects to the +serial port, the +.Pa /dev/cuaa0 +port is the default. If you need to use a different parallel or +serial port, use this option to specify the alternate port name. +.Pp +On Win32 operating systems, the parallel ports are referred to as lpt1 +through lpt3, referring to the addresses 0x378, 0x278, and 0x3BC, +respectively. If the parallel port can be accessed through a different +address, this address can be specified directly, using the common C +language notation (i. e., hexadecimal values are prefixed by +.Ql 0x +). +.Pp +For the JTAG ICE mkII and JTAGICE3, if +.Nm +has been configured with libusb support, +.Ar port +can alternatively be specified as +.Pa usb Ns Op \&: Ns Ar serialno . +This will cause +.Nm +to search the programmer on USB. +If +.Ar serialno +is also specified, it will be matched against the serial number read +from any JTAG ICE mkII found on USB. +The match is done after stripping any existing colons from the given +serial number, and right-to-left, so only the least significant bytes +from the serial number need to be given. +.Pp +As the AVRISP mkII device can only be talked to over USB, the very +same method of specifying the port is required there. +.Pp +For the USB programmer "AVR-Doper" running in HID mode, the port must +be specified as +.Ar avrdoper. +Libusb support is required on Unix but not on Windows. For more +information about AVR-Doper see http://www.obdev.at/avrusb/avrdoper.html. +.Pp +For the USBtinyISP, which is a simplicistic device not implementing +serial numbers, multiple devices can be distinguished by their +location in the USB hierarchy. See the the respective +.Em Troubleshooting +entry in the detailed documentation for examples. +.Pp +For programmers that attach to a serial port using some kind of +higher level protocol (as opposed to bit-bang style programmers), +.Ar port +can be specified as +.Pa net Ns \&: Ns Ar host Ns \&: Ns Ar port . +In this case, instead of trying to open a local device, a TCP +network connection to (TCP) +.Ar port +on +.Ar host +is established. +The remote endpoint is assumed to be a terminal or console server +that connects the network stream to a local serial port where the +actual programmer has been attached to. +The port is assumed to be properly configured, for example using a +transparent 8-bit data connection without parity at 115200 Baud +for a STK500. +.It Fl q +Disable (or quell) output of the progress bar while reading or writing +to the device. Specify it a second time for even quieter operation. +.It Fl s +Disable safemode prompting. When safemode discovers that one or more +fuse bits have unintentionally changed, it will prompt for +confirmation regarding whether or not it should attempt to recover the +fuse bit(s). Specifying this flag disables the prompt and assumes +that the fuse bit(s) should be recovered without asking for +confirmation first. +.It Fl t +Tells +.Nm +to enter the interactive ``terminal'' mode instead of up- or downloading +files. See below for a detailed description of the terminal mode. +.It Fl u +Disable the safemode fuse bit checks. Safemode is enabled by default +and is intended to prevent unintentional fuse bit changes. When +enabled, safemode will issue a warning if the any fuse bits are found +to be different at program exit than they were when +.Nm +was invoked. Safemode won't alter fuse bits itself, but rather will +prompt for instructions, unless the terminal is non-interactive, in +which case safemode is disabled. See the +.Fl s +option to disable safemode prompting. +.Pp +If one of the configuration files has a line +.Dl "default_safemode = no;" +safemode is disabled by default. +The +.Fl u +option's effect is negated in that case, i. e. it +.Em enables +safemode. +.Pp +Safemode is always disabled for AVR32, Xmega and TPI devices. +.It Xo Fl U Ar memtype Ns +.Ar \&: Ns Ar op Ns +.Ar \&: Ns Ar filename Ns +.Op \&: Ns Ar format +.Xc +Perform a memory operation as indicated. The +.Ar memtype +field specifies the memory type to operate on. +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 +the memory types +.Ar flash +and +.Ar eeprom . +All memory types currently known are: +.Bl -tag -width "calibration" -compact +.It calibration +One or more bytes of RC oscillator calibration data. +.It eeprom +The EEPROM of the device. +.It efuse +The extended fuse byte. +.It flash +The flash ROM of the device. +.It fuse +The fuse byte in devices that have only a single fuse byte. +.It hfuse +The high fuse byte. +.It lfuse +The low fuse byte. +.It lock +The lock byte. +.It signature +The three device signature bytes (device ID). +.It fuse Ns Em N +The fuse bytes of ATxmega devices, +.Em N +is an integer number +for each fuse supported by the device. +.It application +The application flash area of ATxmega devices. +.It apptable +The application table flash area of ATxmega devices. +.It boot +The boot flash area of ATxmega devices. +.It prodsig +The production signature (calibration) area of ATxmega devices. +.It usersig +The user signature area of ATxmega devices. +.El +.Pp +The +.Ar op +field specifies what operation to perform: +.Bl -tag -width noreset +.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 +.It Ar v +read data from both the device and the specified file and perform a verify +.El +.Pp +The +.Ar filename +field indicates the name of the file to read or write. +The +.Ar format +field is optional and contains the format of the file to read or +write. +.Ar Format +can be one of: +.Bl -tag -width sss +.It Ar i +Intel Hex +.It Ar s +Motorola S-record +.It Ar r +raw binary; little-endian byte order, in the case of the flash ROM data +.It Ar e +ELF (Executable and Linkable Format) +.It Ar m +immediate; actual byte values specified on the command line, separated +by commas or spaces. This is good for programming fuse bytes without +having to create a single-byte file or enter terminal mode. +.It Ar a +auto detect; valid for input only, and only if the input is not +provided at +.Em stdin . +.It Ar d +decimal; this and the following formats are only valid on output. +They generate one line of output for the respective memory section, +forming a comma-separated list of the values. +This can be particularly useful for subsequent processing, like for +fuse bit settings. +.It Ar h +hexadecimal; each value will get the string +.Em 0x +prepended. +.It Ar o +octal; each value will get a +.Em 0 +prepended unless it is less than 8 in which case it gets no prefix. +.It Ar b +binary; each value will get the string +.Em 0b +prepended. +.El +.Pp +The default is to use auto detection for input files, and raw binary +format for output files. +Note that if +.Ar filename +contains a colon, the +.Ar format +field is no longer optional since the filename part following the colon +would otherwise be misinterpreted as +.Ar format . +.Pp +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 +trailing 0xFF bytes which indicate unprogrammed (erased) memory. +Thus, if the entire memory is unprogrammed, this will result in an output +file that has no contents at all. +.Pp +As an abbreviation, the form +.Fl U Ar filename +is equivalent to specifying +.Fl U Em flash:w: Ns Ar filename Ns :a . +This will only work if +.Ar filename +does not have a colon in it. +.It Fl v +Enable verbose output. +More +.Fl v +options increase verbosity level. +.It Fl V +Disable automatic verify check when uploading data. +.It Fl x Ar extended_param +Pass +.Ar extended_param +to the chosen programmer implementation as an extended parameter. +The interpretation of the extended parameter depends on the +programmer itself. +See below for a list of programmers accepting extended parameters. +.El +.Ss Terminal mode +In this mode, +.Nm +only initializes communication with the MCU, and then awaits user +commands on standard input. Commands and parameters may be +abbreviated to the shortest unambiguous form. Terminal mode provides +a command history using +.Xr readline 3 , +so previously entered command lines can be recalled and edited. The +following commands are currently implemented: +.Bl -tag -offset indent -width indent +.It Ar dump memtype addr nbytes +Read +.Ar nbytes +bytes from the specified memory area, and display them in the usual +hexadecimal and ASCII form. +.It Ar dump +Continue dumping the memory contents for another +.Ar nbytes +where the previous +.Ar dump +command left off. +.It Ar write memtype addr byte1 ... byteN +Manually program the respective memory cells, starting at address +.Ar addr , +using the values +.Ar byte1 +through +.Ar byteN . +This feature is not implemented for bank-addressed memories such as +the flash memory of ATMega devices. +.It Ar erase +Perform a chip erase. +.It Ar send b1 b2 b3 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 +.Nm , +this command allows you to use it, even though +.Nm +does not implement the command. When using direct SPI mode, up to 3 bytes +can be omitted. +.It Ar sig +Display the device signature bytes. +.It Ar spi +Enter direct SPI mode. The +.Em pgmled +pin acts as slave select. +.Em Only supported on parallel bitbang programmers. +.It Ar part +Display the current part settings and parameters. Includes chip +specific information including all memory types supported by the +device, read/write timing, etc. +.It Ar pgm +Return to programming mode (from direct SPI mode). +.It Ar vtarg voltage +Set the target's supply voltage to +.Ar voltage +Volts. +.Em Only supported on the STK500 and STK600 programmer. +.It Ar varef Oo Ar channel Oc Ar voltage +Set the adjustable voltage source to +.Ar voltage +Volts. +This voltage is normally used to drive the target's +.Em Aref +input on the STK500. +On the Atmel STK600, two reference voltages are available, which +can be selected by the optional +.Ar channel +argument (either 0 or 1). +.Em Only supported on the STK500 and STK600 programmer. +.It Ar fosc freq Ns Op M Ns \&| Ns k +Set the master oscillator to +.Ar freq +Hz. +An optional trailing letter +.Ar \&M +multiplies by 1E6, a trailing letter +.Ar \&k +by 1E3. +.Em Only supported on the STK500 and STK600 programmer. +.It Ar fosc off +Turn the master oscillator off. +.Em Only supported on the STK500 and STK600 programmer. +.It Ar sck period +.Em STK500 and STK600 programmer only: +Set the SCK clock period to +.Ar period +microseconds. +.Pp +.Em JTAG ICE only: +Set the JTAG ICE bit clock period to +.Ar period +microseconds. +Note that unlike STK500 settings, this setting will be reverted to +its default value (approximately 1 microsecond) when the programming +software signs off from the JTAG ICE. +This parameter can also be used on the JTAG ICE mkII, JTAGICE3, and Atmel-ICE to specify the +ISP clock period when operating the ICE in ISP mode. +.It Ar parms +.Em STK500 and STK600 programmer only: +Display the current voltage and master oscillator parameters. +.Pp +.Em JTAG ICE only: +Display the current target supply voltage and JTAG bit clock rate/period. +.It Ar verbose Op Ar level +Change (when +.Ar level +is provided), or display the verbosity level. +The initial verbosity level is controlled by the number of +.Fl v +options given on the commandline. +.It Ar \&? +.It Ar help +Give a short on-line summary of the available commands. +.It Ar quit +Leave terminal mode and thus +.Nm avrdude . +.El +.Ss Default Parallel port pin connections +(these can be changed, see the +.Fl c +option) +.TS +ll. +\fBPin number\fP \fBFunction\fP +2-5 Vcc (optional power supply to MCU) +7 /RESET (to MCU) +8 SCK (to MCU) +9 MOSI (to MCU) +10 MISO (from MCU) +18-25 GND +.TE +.Ss debugWire limitations +The debugWire protocol is Atmel's proprietary one-wire (plus ground) +protocol to allow an in-circuit emulation of the smaller AVR devices, +using the +.Ql /RESET +line. +DebugWire mode is initiated by activating the +.Ql DWEN +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. +It is also possible to read out the signature. +All other memory areas cannot be accessed. +There is no +.Em chip erase +functionality in debugWire mode; instead, while reprogramming the +flash ROM, each flash ROM 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 +debugWire mode will be temporarily disabled, and the target can +be accessed using normal ISP programming. +This sequence is automatically initiated by using the JTAG ICE mkII +or AVR Dragon in ISP mode, when they detect that ISP mode cannot be +entered. +.Ss FLIP version 1 idiosyncrasies +Bootloaders using the FLIP protocol version 1 experience some very +specific behaviour. +.Pp +These bootloaders have no option to access memory areas other than +Flash and EEPROM. +.Pp +When the bootloader is started, it enters a +.Em security mode +where the only acceptable access is to query the device configuration +parameters (which are used for the signature on AVR devices). +The only way to leave this mode is a +.Em chip erase . +As a chip erase is normally implied by the +.Fl U +option when reprogramming the flash, this peculiarity might not be +very obvious immediately. +.Pp +Sometimes, a bootloader with security mode already disabled seems to +no longer respond with sensible configuration data, but only 0xFF for +all queries. +As these queries are used to obtain the equivalent of a signature, +.Nm +can only continue in that situation by forcing the signature check +to be overridden with the +.Fl F +option. +.Pp +A +.Em chip erase +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 JTAG ICE mkII +.It Ar JTAGICE3 +.It Ar Atmel-ICE +.It Ar AVR Dragon +When using the JTAG ICE mkII, JTAGICE3, Atmel-ICE or AVR Dragon in JTAG mode, the +following extended parameter is accepted: +.Bl -tag -offset indent -width indent +.It Ar jtagchain=UB,UA,BB,BA +Setup the JTAG scan chain for +.Ar UB +units before, +.Ar UA +units after, +.Ar BB +bits before, and +.Ar BA +bits after the target AVR, respectively. +Each AVR unit within the chain shifts by 4 bits. +Other JTAG units might require a different bit shift count. +.El +.It Ar AVR910 +.Bl -tag -offset indent -width indent +.It Ar devcode=VALUE +Override the device code selection by using +.Ar VALUE +as the device code. +The programmer is not queried for the list of supported +device codes, and the specified +.Ar VALUE +is not verified but used directly within the +.Ql T +command sent to the programmer. +.Ar VALUE +can be specified using the conventional number notation of the +C programming language. +.El +.Bl -tag -offset indent -width indent +.It Ar no_blockmode +Disables the default checking for block transfer capability. +Use +.Ar no_blockmode +only if your +.Ar AVR910 +programmer creates errors during initial sequence. +.El +.It Ar buspirate +.Bl -tag -offset indent -width indent +.It Ar reset={cs,aux,aux2} +The default setup assumes the BusPirate's CS output pin connected to +the RESET pin on AVR side. It is however possible to have multiple AVRs +connected to the same BP with MISO, MOSI and SCK lines common for all of them. +In such a case one AVR should have its RESET connected to BusPirate's +.Pa CS +pin, second AVR's RESET connected to BusPirate's +.Pa AUX +pin and if your BusPirate has an +.Pa AUX2 +pin (only available on BusPirate version v1a with firmware 3.0 or newer) +use that to activate RESET on the third AVR. +.Pp +It may be a good idea to decouple the BusPirate and the AVR's SPI buses from +each other using a 3-state bus buffer. For example 74HC125 or 74HC244 are some +good candidates with the latches driven by the appropriate reset pin (cs, +aux or aux2). Otherwise the SPI traffic in one active circuit may interfere +with programming the AVR in the other design. +.It Ar spifreq=<0..7> +The SPI speed for the Bus Pirate's binary SPI mode: +.Bd -literal +0 .. 30 kHz (default) +1 .. 125 kHz +2 .. 250 kHz +3 .. 1 MHz +4 .. 2 MHz +5 .. 2.6 MHz +6 .. 4 MHz +7 .. 8 MHz +.Ed +.It Ar rawfreq=<0..3> +Sets the SPI speed and uses the Bus Pirate's binary "raw-wire" mode: +.Bd -literal +0 .. 5 kHz +1 .. 50 kHz +2 .. 100 kHz (Firmware v4.2+ only) +3 .. 400 kHz (v4.2+) +.Ed +.Pp +The only advantage of the "raw-wire" mode is the different SPI frequencies +available. Paged writing is not implemented in this mode. +.It Ar ascii +Attempt to use ASCII mode even when the firmware supports BinMode (binary +mode). +BinMode is supported in firmware 2.7 and newer, older FW's either don't +have BinMode or their BinMode is buggy. ASCII mode is slower and makes +the above +.Ar reset= , spifreq= +and +.Ar rawfreq= +parameters unavailable. Be aware that ASCII mode is not guaranteed to work +with newer firmware versions, and is retained only to maintain compatibility +with older firmware versions. +.It Ar nopagedwrite +Firmware versions 5.10 and newer support a binary mode SPI command that enables +whole pages to be written to AVR flash memory at once, resulting in a +significant write speed increase. If use of this mode is not desirable for some +reason, this option disables it. +.It Ar nopagedread +Newer firmware versions support in binary mode SPI command some AVR Extended +Commands. Using the "Bulk Memory Read from Flash" results in a +significant read speed increase. If use of this mode is not desirable for some +reason, this option disables it. +.It Ar cpufreq=<125..4000> +This sets the AUX pin to output a frequency of +.Ar n +kHz. Connecting +the AUX pin to the XTAL1 pin of your MCU, you can provide it a clock, +for example when it needs an external clock because of wrong fuses settings. +Make sure the CPU frequency is at least four times the SPI frequency. +.It Ar serial_recv_timeout=<1...> +This sets the serial receive timeout to the given value. +The timeout happens every time avrdude waits for the BusPirate prompt. +Especially in ascii mode this happens very often, so setting a smaller value +can speed up programming a lot. +The default value is 100ms. Using 10ms might work in most cases. +.El +.It Ar Wiring +When using the Wiring programmer type, the +following optional extended parameter is accepted: +.Bl -tag -offset indent -width indent +.It Ar snooze=<0..32767> +After performing the port open phase, AVRDUDE will wait/snooze for +.Ar snooze +milliseconds before continuing to the protocol sync phase. +No toggling of DTR/RTS is performed if +.Ar snooze +is greater than 0. +.El +.It Ar PICkit2 +Connection to the PICkit2 programmer: +.Bd -literal +(AVR) (PICkit2) +RST - VPP/MCLR (1) +VDD - VDD Target (2) -- possibly optional if AVR self powered +GND - GND (3) +MISO - PGD (4) +SCLK - PDC (5) +MOSI - AUX (6) + +.Ed +Extended commandline parameters: +.Bl -tag -offset indent -width indent +.It Ar clockrate= +Sets the SPI clocking rate in Hz (default is 100kHz). Alternately the -B or -i options can be used to set the period. +.It Ar timeout= +Sets the timeout for USB reads and writes in milliseconds (default is 1500 ms). +.El +.El +.Sh FILES +.Bl -tag -offset indent -width /dev/ppi0XXX +.It Pa /dev/ppi0 +default device to be used for communication with the programming +hardware +.It Pa ${PREFIX}/etc/avrdude.conf +programmer and parts configuration file +.It Pa ${HOME}/.avrduderc +programmer and parts configuration file (per-user overrides) +.It Pa ~/.inputrc +Initialization file for the +.Xr readline 3 +library +.It Pa ${PREFIX}/share/doc/avrdude/avrdude.pdf +Schematic of programming hardware +.El +.\" .Sh EXAMPLES +.Sh DIAGNOSTICS +.Bd -literal +avrdude: jtagmkII_setparm(): bad response to set parameter command: RSP_FAILED +avrdude: jtagmkII_getsync(): ISP activation failed, trying debugWire +avrdude: Target prepared for ISP, signed off. +avrdude: Please restart avrdude without power-cycling the target. +.Ed +.Pp +If the target AVR has been set up for debugWire mode (i. e. the +.Em DWEN +fuse is programmed), normal ISP connection attempts will fail as +the +.Em /RESET +pin is not available. +When using the JTAG ICE mkII in ISP mode, the message shown indicates +that +.Nm +has guessed this condition, and tried to initiate a debugWire reset +to the target. +When successful, this will leave the target AVR in a state where it +can respond to normal ISP communication again (until the next power +cycle). +Typically, the same command is going to be retried again immediately +afterwards, and will then succeed connecting to the target using +normal ISP communication. +.Sh SEE ALSO +.Xr avr-objcopy 1 , +.Xr ppi 4 , +.Xr libelf 3, +.Xr readline 3 +.Pp +The AVR microcontroller product description can be found at +.Pp +.Dl "http://www.atmel.com/products/AVR/" +.\" .Sh HISTORY +.Sh AUTHORS +.Nm Avrdude +was written by Brian S. Dean . +.Pp +This man page by +.ie t J\(:org Wunsch. +.el Joerg Wunsch. +.Sh BUGS +Please report bugs via +.Dl "http://savannah.nongnu.org/bugs/?group=avrdude" . +.Pp +The JTAG ICE programmers currently cannot write to the flash ROM +one byte at a time. +For that reason, updating the flash ROM from terminal mode does not +work. +.Pp +Page-mode programming the EEPROM through JTAG (i.e. through an +.Fl U +option) requires a prior chip erase. +This is an inherent feature of the way JTAG EEPROM programming works. +This also applies to the STK500 and STK600 in parallel programming mode. +.Pp +The USBasp and USBtinyISP drivers do not offer any option to distinguish multiple +devices connected simultaneously, so effectively only a single device +is supported. +.Pp +The avrftdi driver allows one to select specific devices using any combination of vid,pid +serial number (usbsn) vendor description (usbvendoror part description (usbproduct) +as seen with lsusb or whatever tool used to view USB device information. Multiple +devices can be on the bus at the same time. For the H parts, which have multiple MPSSE +interfaces, the interface can also be selected. It defaults to interface 'A'. diff --git a/xs/src/avrdude/avrdude.conf b/xs/src/avrdude/avrdude.conf new file mode 100644 index 000000000..991a1dcee --- /dev/null +++ b/xs/src/avrdude/avrdude.conf @@ -0,0 +1,14982 @@ +# $Id$ -*- text -*- +# +# AVRDUDE Configuration File +# +# This file contains configuration data used by AVRDUDE which describes +# the programming hardware pinouts and also provides part definitions. +# AVRDUDE's "-C" command line option specifies the location of the +# configuration file. The "-c" option names the programmer configuration +# which must match one of the entry's "id" parameter. The "-p" option +# identifies which part AVRDUDE is going to be programming and must match +# one of the parts' "id" parameter. +# +# DO NOT MODIFY THIS FILE. Modifications will be overwritten the next +# time a "make install" is run. For user-specific additions, use the +# "-C +filename" commandline option. +# +# Possible entry formats are: +# +# programmer +# parent # optional parent +# id = [, [, ] ...] ; # are quoted strings +# desc = ; # quoted string +# type = ; # programmer type, quoted string +# # supported programmer types can be listed by "-c ?type" +# connection_type = parallel | serial | usb +# baudrate = ; # baudrate for avr910-programmer +# vcc = [, ... ] ; # pin number(s) +# buff = [, ... ] ; # pin number(s) +# reset = ; # pin number +# sck = ; # pin number +# mosi = ; # pin number +# miso = ; # pin number +# errled = ; # pin number +# rdyled = ; # pin number +# pgmled = ; # pin number +# vfyled = ; # pin number +# usbvid = ; # USB VID (Vendor ID) +# usbpid = [, ...] # USB PID (Product ID) (1) +# usbdev = ; # USB interface or other device info +# usbvendor = ; # USB Vendor Name +# usbproduct = ; # USB Product Name +# usbsn = ; # USB Serial Number +# +# To invert a bit, use = ~ , the spaces are important. +# For a pin list all pins must be inverted. +# A single pin can be specified as usual = ~ , for lists +# specify it as follows = ~ ( [, ... ] ) . +# +# (1) Not all programmer types can process a list of PIDs. +# ; +# +# part +# id = ; # quoted string +# desc = ; # quoted string +# has_jtag = ; # part has JTAG i/f +# has_debugwire = ; # part has debugWire i/f +# has_pdi = ; # part has PDI i/f +# has_tpi = ; # part has TPI i/f +# devicecode = ; # deprecated, use stk500_devcode +# stk500_devcode = ; # numeric +# avr910_devcode = ; # numeric +# signature = ; # signature bytes +# usbpid = ; # DFU USB PID +# chip_erase_delay = ; # micro-seconds +# reset = dedicated | io; +# retry_pulse = reset | sck; +# pgm_enable = ; +# chip_erase = ; +# chip_erase_delay = ; # chip erase delay (us) +# # STK500 parameters (parallel programming IO lines) +# pagel = ; # pin name in hex, i.e., 0xD7 +# bs2 = ; # pin name in hex, i.e., 0xA0 +# serial = ; # can use serial downloading +# parallel = ; # can use par. programming +# # STK500v2 parameters, to be taken from Atmel's XML files +# timeout = ; +# stabdelay = ; +# cmdexedelay = ; +# synchloops = ; +# bytedelay = ; +# pollvalue = ; +# pollindex = ; +# predelay = ; +# postdelay = ; +# pollmethod = ; +# mode = ; +# delay = ; +# blocksize = ; +# readsize = ; +# hvspcmdexedelay = ; +# # STK500v2 HV programming parameters, from XML +# pp_controlstack = , , ...; # PP only +# hvsp_controlstack = , , ...; # HVSP only +# hventerstabdelay = ; +# progmodedelay = ; # PP only +# latchcycles = ; +# togglevtg = ; +# poweroffdelay = ; +# resetdelayms = ; +# resetdelayus = ; +# hvleavestabdelay = ; +# resetdelay = ; +# synchcycles = ; # HVSP only +# chiperasepulsewidth = ; # PP only +# chiperasepolltimeout = ; +# chiperasetime = ; # HVSP only +# programfusepulsewidth = ; # PP only +# programfusepolltimeout = ; +# programlockpulsewidth = ; # PP only +# programlockpolltimeout = ; +# # JTAG ICE mkII parameters, also from XML files +# allowfullpagebitstream = ; +# enablepageprogramming = ; +# idr = ; # IO addr of IDR (OCD) reg. +# rampz = ; # IO addr of RAMPZ reg. +# spmcr = ; # mem addr of SPMC[S]R reg. +# eecr = ; # mem addr of EECR reg. +# # (only when != 0x3c) +# is_at90s1200 = ; # AT90S1200 part +# is_avr32 = ; # AVR32 part +# +# memory +# paged = ; # yes / no +# size = ; # bytes +# page_size = ; # bytes +# num_pages = ; # numeric +# min_write_delay = ; # micro-seconds +# max_write_delay = ; # micro-seconds +# readback_p1 = ; # byte value +# readback_p2 = ; # byte value +# pwroff_after_write = ; # yes / no +# read = ; +# write = ; +# read_lo = ; +# read_hi = ; +# write_lo = ; +# write_hi = ; +# loadpage_lo = ; +# loadpage_hi = ; +# writepage = ; +# ; +# ; +# +# If any of the above parameters are not specified, the default value +# of 0 is used for numerics or the empty string ("") for string +# values. If a required parameter is left empty, AVRDUDE will +# complain. +# +# Parts can also inherit parameters from previously defined parts +# using the following syntax. In this case specified integer and +# string values override parameter values from the parent part. New +# memory definitions are added to the definitions inherited from the +# parent. +# +# part parent # quoted string +# id = ; # quoted string +# +# ; +# +# NOTES: +# * 'devicecode' is the device code used by the STK500 (see codes +# listed below) +# * Not all memory types will implement all instructions. +# * AVR Fuse bits and Lock bits are implemented as a type of memory. +# * Example memory types are: +# "flash", "eeprom", "fuse", "lfuse" (low fuse), "hfuse" (high +# fuse), "signature", "calibration", "lock" +# * The memory type specified on the avrdude command line must match +# one of the memory types defined for the specified chip. +# * The pwroff_after_write flag causes avrdude to attempt to +# power the device off and back on after an unsuccessful write to +# the affected memory area if VCC programmer pins are defined. If +# VCC pins are not defined for the programmer, a message +# indicating that the device needs a power-cycle is printed out. +# This flag was added to work around a problem with the +# at90s4433/2333's; see the at90s4433 errata at: +# +# http://www.atmel.com/dyn/resources/prod_documents/doc1280.pdf +# +# INSTRUCTION FORMATS +# +# Instruction formats are specified as a comma seperated list of +# string values containing information (bit specifiers) about each +# of the 32 bits of the instruction. Bit specifiers may be one of +# the following formats: +# +# '1' = the bit is always set on input as well as output +# +# '0' = the bit is always clear on input as well as output +# +# 'x' = the bit is ignored on input and output +# +# 'a' = the bit is an address bit, the bit-number matches this bit +# specifier's position within the current instruction byte +# +# 'aN' = the bit is the Nth address bit, bit-number = N, i.e., a12 +# is address bit 12 on input, a0 is address bit 0. +# +# 'i' = the bit is an input data bit +# +# 'o' = the bit is an output data bit +# +# Each instruction must be composed of 32 bit specifiers. The +# instruction specification closely follows the instruction data +# provided in Atmel's data sheets for their parts. +# +# See below for some examples. +# +# +# The following are STK500 part device codes to use for the +# "devicecode" field of the part. These came from Atmel's software +# section avr061.zip which accompanies the application note +# AVR061 available from: +# +# http://www.atmel.com/dyn/resources/prod_documents/doc2525.pdf +# + +#define ATTINY10 0x10 /* the _old_ one that never existed! */ +#define ATTINY11 0x11 +#define ATTINY12 0x12 +#define ATTINY15 0x13 +#define ATTINY13 0x14 + +#define ATTINY22 0x20 +#define ATTINY26 0x21 +#define ATTINY28 0x22 +#define ATTINY2313 0x23 + +#define AT90S1200 0x33 + +#define AT90S2313 0x40 +#define AT90S2323 0x41 +#define AT90S2333 0x42 +#define AT90S2343 0x43 + +#define AT90S4414 0x50 +#define AT90S4433 0x51 +#define AT90S4434 0x52 +#define ATMEGA48 0x59 + +#define AT90S8515 0x60 +#define AT90S8535 0x61 +#define AT90C8534 0x62 +#define ATMEGA8515 0x63 +#define ATMEGA8535 0x64 + +#define ATMEGA8 0x70 +#define ATMEGA88 0x73 +#define ATMEGA168 0x86 + +#define ATMEGA161 0x80 +#define ATMEGA163 0x81 +#define ATMEGA16 0x82 +#define ATMEGA162 0x83 +#define ATMEGA169 0x84 + +#define ATMEGA323 0x90 +#define ATMEGA32 0x91 + +#define ATMEGA64 0xA0 + +#define ATMEGA103 0xB1 +#define ATMEGA128 0xB2 +#define AT90CAN128 0xB3 +#define AT90CAN64 0xB3 +#define AT90CAN32 0xB3 + +#define AT86RF401 0xD0 + +#define AT89START 0xE0 +#define AT89S51 0xE0 +#define AT89S52 0xE1 + +# The following table lists the devices in the original AVR910 +# appnote: +# |Device |Signature | Code | +# +-------+----------+------+ +# |tiny12 | 1E 90 05 | 0x55 | +# |tiny15 | 1E 90 06 | 0x56 | +# | | | | +# | S1200 | 1E 90 01 | 0x13 | +# | | | | +# | S2313 | 1E 91 01 | 0x20 | +# | S2323 | 1E 91 02 | 0x48 | +# | S2333 | 1E 91 05 | 0x34 | +# | S2343 | 1E 91 03 | 0x4C | +# | | | | +# | S4414 | 1E 92 01 | 0x28 | +# | S4433 | 1E 92 03 | 0x30 | +# | S4434 | 1E 92 02 | 0x6C | +# | | | | +# | S8515 | 1E 93 01 | 0x38 | +# | S8535 | 1E 93 03 | 0x68 | +# | | | | +# |mega32 | 1E 95 01 | 0x72 | +# |mega83 | 1E 93 05 | 0x65 | +# |mega103| 1E 97 01 | 0x41 | +# |mega161| 1E 94 01 | 0x60 | +# |mega163| 1E 94 02 | 0x64 | + +# Appnote AVR109 also has a table of AVR910 device codes, which +# lists: +# dev avr910 signature +# ATmega8 0x77 0x1E 0x93 0x07 +# ATmega8515 0x3B 0x1E 0x93 0x06 +# ATmega8535 0x6A 0x1E 0x93 0x08 +# ATmega16 0x75 0x1E 0x94 0x03 +# ATmega162 0x63 0x1E 0x94 0x04 +# ATmega163 0x66 0x1E 0x94 0x02 +# ATmega169 0x79 0x1E 0x94 0x05 +# ATmega32 0x7F 0x1E 0x95 0x02 +# ATmega323 0x73 0x1E 0x95 0x01 +# ATmega64 0x46 0x1E 0x96 0x02 +# ATmega128 0x44 0x1E 0x97 0x02 +# +# These codes refer to "BOOT" device codes which are apparently +# different than standard device codes, for whatever reasons +# (often one above the standard code). + +# There are several extended versions of AVR910 implementations around +# in the Internet. These add the following codes (only devices that +# actually exist are listed): + +# ATmega8515 0x3A +# ATmega128 0x43 +# ATmega64 0x45 +# ATtiny26 0x5E +# ATmega8535 0x69 +# ATmega32 0x72 +# ATmega16 0x74 +# ATmega8 0x76 +# ATmega169 0x78 + +# +# Overall avrdude defaults; suitable for ~/.avrduderc +# +default_parallel = "/dev/parport0"; +default_serial = "/dev/ttyS0"; +# default_bitclock = 2.5; + +# Turn off safemode by default +#default_safemode = no; + + +# +# PROGRAMMER DEFINITIONS +# + +# http://wiring.org.co/ +# Basically STK500v2 protocol, with some glue to trigger the +# bootloader. +programmer + id = "wiring"; + desc = "Wiring"; + type = "wiring"; + connection_type = serial; +; + +programmer + id = "arduino"; + desc = "Arduino"; + type = "arduino"; + connection_type = serial; +; +# this will interface with the chips on these programmers: +# +# http://real.kiev.ua/old/avreal/en/adapters +# http://www.amontec.com/jtagkey.shtml, jtagkey-tiny.shtml +# http://www.olimex.com/dev/arm-usb-ocd.html, arm-usb-tiny.html +# http://www.ethernut.de/en/hardware/turtelizer/index.html +# http://elk.informatik.fh-augsburg.de/hhweb/doc/openocd/usbjtag/usbjtag.html +# http://dangerousprototypes.com/docs/FT2232_breakout_board +# http://www.ftdichip.com/Products/Modules/DLPModules.htm,DLP-2232*,DLP-USB1232H +# http://flashrom.org/FT2232SPI_Programmer +# +# The drivers will look for a specific device and use the first one found. +# If you have mulitple devices, then look for unique information (like SN) +# And fill that in here. +# +# Note that the pin numbers for the main ISP signals (reset, sck, +# mosi, miso) are fixed and cannot be changed, since they must match +# the way the Multi-Protocol Synchronous Serial Engine (MPSSE) of +# these FTDI ICs has been designed. + +programmer + id = "avrftdi"; + desc = "FT2232D based generic programmer"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; + usbpid = 0x6010; + usbvendor = ""; + usbproduct = ""; + usbdev = "A"; + usbsn = ""; +#ISP-signals - lower ADBUS-Nibble (default) + reset = 3; + sck = 0; + mosi = 1; + miso = 2; +#LED SIGNALs - higher ADBUS-Nibble +# errled = 4; +# rdyled = 5; +# pgmled = 6; +# vfyled = 7; +#Buffer Signal - ACBUS - Nibble +# buff = 8; +; +# This is an implementation of the above with a buffer IC (74AC244) and +# 4 LEDs directly attached, all active low. +programmer + id = "2232HIO"; + desc = "FT2232H based generic programmer"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; +# Note: This PID is reserved for generic H devices and +# should be programmed into the EEPROM +# usbpid = 0x8A48; + usbpid = 0x6010; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals + reset = 3; + sck = 0; + mosi = 1; + miso = 2; + buff = ~4; +#LED SIGNALs + errled = ~ 11; + rdyled = ~ 14; + pgmled = ~ 13; + vfyled = ~ 12; +; + +#The FT4232H can be treated as FT2232H, but it has a different USB +#device ID of 0x6011. +programmer parent "avrftdi" + id = "4232h"; + desc = "FT4232H based generic programmer"; + usbpid = 0x6011; +; + +programmer + id = "jtagkey"; + desc = "Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; +# Note: This PID is used in all JTAGKey variants + usbpid = 0xCFF8; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals => 20 - Pin connector on JTAGKey + reset = 3; # TMS 7 violet + sck = 0; # TCK 9 white + mosi = 1; # TDI 5 green + miso = 2; # TDO 13 orange + buff = ~4; +# VTG VREF 1 brown with red tip +# GND GND 20 black +# The colors are on the 20 pin breakout cable +# from Amontec +; + +# UM232H module from FTDI and Glyn.com.au. +# See helix.air.net.au for detailed usage information. +# J1: Connect pin 2 and 3 for USB power. +# J2: Connect pin 2 and 3 for USB power. +# J2: Pin 7 is SCK +# : Pin 8 is MOSI +# : Pin 9 is MISO +# : Pin 11 is RST +# : Pin 6 is ground +# Use the -b flag to set the SPI clock rate eg -b 3750000 is the fastest I could get +# a 16MHz Atmega1280 to program reliably. The 232H is conveniently 5V tolerant. +programmer + id = "UM232H"; + desc = "FT232H based module from FTDI and Glyn.com.au"; + type = "avrftdi"; + usbvid = 0x0403; +# Note: This PID is reserved for generic 232H devices and +# should be programmed into the EEPROM + usbpid = 0x6014; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals + sck = 0; + mosi = 1; + miso = 2; + reset = 3; +; + +# C232HM module from FTDI and Glyn.com.au. +# : Orange is SCK +# : Yellow is MOSI +# : Green is MISO +# : Brown is RST +# : Black is ground +# Use the -b flag to set the SPI clock rate eg -b 3750000 is the fastest I could get +# a 16MHz Atmega1280 to program reliably. The 232H is conveniently 5V tolerant. +programmer + id = "C232HM"; + desc = "FT232H based module from FTDI and Glyn.com.au"; + type = "avrftdi"; + usbvid = 0x0403; +# Note: This PID is reserved for generic 232H devices and +# should be programmed into the EEPROM + usbpid = 0x6014; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals + sck = 0; + mosi = 1; + miso = 2; + reset = 3; +; + + +# On the adapter you can read "O-Link". On the PCB is printed "OpenJTAG v3.1" +# You can find it as "OpenJTAG ARM JTAG USB" in the internet. +# (But there are also several projects called Open JTAG, eg. +# http://www.openjtag.org, which are completely different.) +# http://www.100ask.net/shop/english.html (website seems to be outdated) +# http://item.taobao.com/item.htm?id=1559277013 +# http://www.micro4you.com/store/openjtag-arm-jtag-usb.html (schematics!) +# some other sources which call it O-Link +# http://www.andahammer.com/olink/ +# http://www.developmentboard.net/31-o-link-debugger.html +# http://armwerks.com/catalog/o-link-debugger-copy/ +# or just have a look at ebay ... +# It is basically the same entry as jtagkey with different usb ids. +programmer parent "jtagkey" + id = "o-link"; + desc = "O-Link, OpenJTAG from www.100ask.net"; + usbvid = 0x1457; + usbpid = 0x5118; + usbvendor = "www.100ask.net"; + usbproduct = "USB<=>JTAG&RS232"; +; + +# http://wiki.openmoko.org/wiki/Debug_Board_v3 +programmer + id = "openmoko"; + desc = "Openmoko debug board (v3)"; + type = "avrftdi"; + usbvid = 0x1457; + usbpid = 0x5118; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; + reset = 3; # TMS 7 + sck = 0; # TCK 9 + mosi = 1; # TDI 5 + miso = 2; # TDO 13 +; + +# Only Rev. A boards. +# Schematic and user manual: http://www.cs.put.poznan.pl/wswitala/download/pdf/811EVBK.pdf +programmer + id = "lm3s811"; + desc = "Luminary Micro LM3S811 Eval Board (Rev. A)"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; + usbpid = 0xbcd9; + usbvendor = "LMI"; + usbproduct = "LM3S811 Evaluation Board"; + usbdev = "A"; + usbsn = ""; +#ISP-signals - lower ACBUS-Nibble (default) + reset = 3; + sck = 0; + mosi = 1; + miso = 2; +# Enable correct buffers + buff = 7; +; + +# submitted as bug #46020 +programmer + id = "tumpa"; + desc = "TIAO USB Multi-Protocol Adapter"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; + usbpid = 0x8A98; + usbdev = "A"; + usbvendor = "TIAO"; + usbproduct = ""; + usbsn = ""; + sck = 0; # TCK 9 + mosi = 1; # TDI 5 + miso = 2; # TDO 13 + reset = 3; # TMS 7 +; + +programmer + id = "avrisp"; + desc = "Atmel AVR ISP"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "avrispv2"; + desc = "Atmel AVR ISP V2"; + type = "stk500v2"; + connection_type = serial; +; + +programmer + id = "avrispmkII"; + desc = "Atmel AVR ISP mkII"; + type = "stk500v2"; + connection_type = usb; +; + +programmer parent "avrispmkII" + id = "avrisp2"; +; + +programmer + id = "buspirate"; + desc = "The Bus Pirate"; + type = "buspirate"; + connection_type = serial; +; + +programmer + id = "buspirate_bb"; + desc = "The Bus Pirate (bitbang interface, supports TPI)"; + type = "buspirate_bb"; + connection_type = serial; + # pins are bits in bitbang byte (numbers are 87654321) + # 1|POWER|PULLUP|AUX|MOSI|CLK|MISO|CS + reset = 1; + sck = 3; + mosi = 4; + miso = 2; + #vcc = 7; This is internally set independent of this setting. +; + +# This is supposed to be the "default" STK500 entry. +# Attempts to select the correct firmware version +# by probing for it. Better use one of the entries +# below instead. +programmer + id = "stk500"; + desc = "Atmel STK500"; + type = "stk500generic"; + connection_type = serial; +; + +programmer + id = "stk500v1"; + desc = "Atmel STK500 Version 1.x firmware"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "mib510"; + desc = "Crossbow MIB510 programming board"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "stk500v2"; + desc = "Atmel STK500 Version 2.x firmware"; + type = "stk500v2"; + connection_type = serial; +; + +programmer + id = "stk500pp"; + desc = "Atmel STK500 V2 in parallel programming mode"; + type = "stk500pp"; + connection_type = serial; +; + +programmer + id = "stk500hvsp"; + desc = "Atmel STK500 V2 in high-voltage serial programming mode"; + type = "stk500hvsp"; + connection_type = serial; +; + +programmer + id = "stk600"; + desc = "Atmel STK600"; + type = "stk600"; + connection_type = usb; +; + +programmer + id = "stk600pp"; + desc = "Atmel STK600 in parallel programming mode"; + type = "stk600pp"; + connection_type = usb; +; + +programmer + id = "stk600hvsp"; + desc = "Atmel STK600 in high-voltage serial programming mode"; + type = "stk600hvsp"; + connection_type = usb; +; + +programmer + id = "avr910"; + desc = "Atmel Low Cost Serial Programmer"; + type = "avr910"; + connection_type = serial; +; + +programmer + id = "ft245r"; + desc = "FT245R Synchronous BitBang"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 1; # D1 + sck = 0; # D0 + mosi = 2; # D2 + reset = 4; # D4 +; + +programmer + id = "ft232r"; + desc = "FT232R Synchronous BitBang"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 1; # RxD + sck = 0; # TxD + mosi = 2; # RTS + reset = 4; # DTR +; + +# see http://www.bitwizard.nl/wiki/index.php/FTDI_ATmega +programmer + id = "bwmega"; + desc = "BitWizard ftdi_atmega builtin programmer"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 5; # DSR + sck = 6; # DCD + mosi = 3; # CTS + reset = 7; # RI +; + +# see http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html +# Note: pins are numbered from 1! +programmer + id = "arduino-ft232r"; + desc = "Arduino: FT232R connected to ISP"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 3; # CTS X3(1) + sck = 5; # DSR X3(2) + mosi = 6; # DCD X3(3) + reset = 7; # RI X3(4) +; + +# website mentioned above uses this id +programmer parent "arduino-ft232r" + id = "diecimila"; + desc = "alias for arduino-ft232r"; +; + +# There is a ATmega328P kit PCB called "uncompatino". +# This board allows ISP via its on-board FT232R. +# This is designed like Arduino Duemilanove but has no standard ICPS header. +# Its 4 pairs of pins are shorted to enable ftdi_syncbb. +# http://akizukidenshi.com/catalog/g/gP-07487/ +# http://akizukidenshi.com/download/ds/akizuki/k6096_manual_20130816.pdf +programmer + id = "uncompatino"; + desc = "uncompatino with all pairs of pins shorted"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 3; # cts + sck = 5; # dsr + mosi = 6; # dcd + reset = 7; # ri +; + +# FTDI USB to serial cable TTL-232R-5V with a custom adapter for ICSP +# http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm +# http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232R_CABLES.pdf +# For ICSP pinout see for example http://www.atmel.com/images/doc2562.pdf +# (Figure 1. ISP6PIN header pinout and Table 1. Connections required for ISP ...) +# TTL-232R GND 1 Black -> ICPS GND (pin 6) +# TTL-232R CTS 2 Brown -> ICPS MOSI (pin 4) +# TTL-232R VCC 3 Red -> ICPS VCC (pin 2) +# TTL-232R TXD 4 Orange -> ICPS RESET (pin 5) +# TTL-232R RXD 5 Yellow -> ICPS SCK (pin 3) +# TTL-232R RTS 6 Green -> ICPS MISO (pin 1) +# Except for VCC and GND, you can connect arbitual pairs as long as +# the following table is adjusted. +programmer + id = "ttl232r"; + desc = "FTDI TTL232R-5V with ICSP adapter"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 2; # rts + sck = 1; # rxd + mosi = 3; # cts + reset = 0; # txd +; + +programmer + id = "usbasp"; + desc = "USBasp, http://www.fischl.de/usbasp/"; + type = "usbasp"; + connection_type = usb; + usbvid = 0x16C0; # VOTI + usbpid = 0x05DC; # Obdev's free shared PID + usbvendor = "www.fischl.de"; + usbproduct = "USBasp"; + + # following variants are autodetected for id "usbasp" + + # original usbasp from fischl.de + # see above "usbasp" + + # old usbasp from fischl.de + #usbvid = 0x03EB; # ATMEL + #usbpid = 0xC7B4; # (unoffical) USBasp + #usbvendor = "www.fischl.de"; + #usbproduct = "USBasp"; + + # NIBObee (only if -P nibobee is given on command line) + # see below "nibobee" +; + +programmer + id = "nibobee"; + desc = "NIBObee"; + type = "usbasp"; + connection_type = usb; + usbvid = 0x16C0; # VOTI + usbpid = 0x092F; # NIBObee PID + usbvendor = "www.nicai-systems.com"; + usbproduct = "NIBObee"; +; + +programmer + id = "usbasp-clone"; + desc = "Any usbasp clone with correct VID/PID"; + type = "usbasp"; + connection_type = usb; + usbvid = 0x16C0; # VOTI + usbpid = 0x05DC; # Obdev's free shared PID + #usbvendor = ""; + #usbproduct = ""; +; + +programmer + id = "usbtiny"; + desc = "USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/"; + type = "usbtiny"; + connection_type = usb; + usbvid = 0x1781; + usbpid = 0x0c9f; +; + +# commercial version of USBtiny, using a separate VID/PID +programmer + id = "ehajo-isp"; + desc = "avr-isp-programmer from eHaJo, http://www.eHaJo.de"; + type = "usbtiny"; + connection_type = usb; + usbvid = 0x16D0; + usbpid = 0x0BA5; +; + +programmer + id = "butterfly"; + desc = "Atmel Butterfly Development Board"; + type = "butterfly"; + connection_type = serial; +; + +programmer + id = "avr109"; + desc = "Atmel AppNote AVR109 Boot Loader"; + type = "butterfly"; + connection_type = serial; +; + +programmer + id = "avr911"; + desc = "Atmel AppNote AVR911 AVROSP"; + type = "butterfly"; + connection_type = serial; +; + +# suggested in http://forum.mikrokopter.de/topic-post48317.html +programmer + id = "mkbutterfly"; + desc = "Mikrokopter.de Butterfly"; + type = "butterfly_mk"; + connection_type = serial; +; + +programmer parent "mkbutterfly" + id = "butterfly_mk"; +; + +programmer + id = "jtagmkI"; + desc = "Atmel JTAG ICE (mkI)"; + baudrate = 115200; # default is 115200 + type = "jtagmki"; + connection_type = serial; +; + +# easier to type +programmer parent "jtagmkI" + id = "jtag1"; +; + +# easier to type +programmer parent "jtag1" + id = "jtag1slow"; + baudrate = 19200; +; + +# The JTAG ICE mkII has both, serial and USB connectivity. As it is +# mostly used through USB these days (AVR Studio 5 only supporting it +# that way), we make connection_type = usb the default. Users are +# still free to use a serial port with the -P option. + +programmer + id = "jtagmkII"; + desc = "Atmel JTAG ICE mkII"; + baudrate = 19200; # default is 19200 + type = "jtagmkii"; + connection_type = usb; +; + +# easier to type +programmer parent "jtagmkII" + id = "jtag2slow"; +; + +# JTAG ICE mkII @ 115200 Bd +programmer parent "jtag2slow" + id = "jtag2fast"; + baudrate = 115200; +; + +# make the fast one the default, people will love that +programmer parent "jtag2fast" + id = "jtag2"; +; + +# JTAG ICE mkII in ISP mode +programmer + id = "jtag2isp"; + desc = "Atmel JTAG ICE mkII in ISP mode"; + baudrate = 115200; + type = "jtagmkii_isp"; + connection_type = usb; +; + +# JTAG ICE mkII in debugWire mode +programmer + id = "jtag2dw"; + desc = "Atmel JTAG ICE mkII in debugWire mode"; + baudrate = 115200; + type = "jtagmkii_dw"; + connection_type = usb; +; + +# JTAG ICE mkII in AVR32 mode +programmer + id = "jtagmkII_avr32"; + desc = "Atmel JTAG ICE mkII im AVR32 mode"; + baudrate = 115200; + type = "jtagmkii_avr32"; + connection_type = usb; +; + +# JTAG ICE mkII in AVR32 mode +programmer + id = "jtag2avr32"; + desc = "Atmel JTAG ICE mkII im AVR32 mode"; + baudrate = 115200; + type = "jtagmkii_avr32"; + connection_type = usb; +; + +# JTAG ICE mkII in PDI mode +programmer + id = "jtag2pdi"; + desc = "Atmel JTAG ICE mkII PDI mode"; + baudrate = 115200; + type = "jtagmkii_pdi"; + connection_type = usb; +; + +# AVR Dragon in JTAG mode +programmer + id = "dragon_jtag"; + desc = "Atmel AVR Dragon in JTAG mode"; + baudrate = 115200; + type = "dragon_jtag"; + connection_type = usb; +; + +# AVR Dragon in ISP mode +programmer + id = "dragon_isp"; + desc = "Atmel AVR Dragon in ISP mode"; + baudrate = 115200; + type = "dragon_isp"; + connection_type = usb; +; + +# AVR Dragon in PP mode +programmer + id = "dragon_pp"; + desc = "Atmel AVR Dragon in PP mode"; + baudrate = 115200; + type = "dragon_pp"; + connection_type = usb; +; + +# AVR Dragon in HVSP mode +programmer + id = "dragon_hvsp"; + desc = "Atmel AVR Dragon in HVSP mode"; + baudrate = 115200; + type = "dragon_hvsp"; + connection_type = usb; +; + +# AVR Dragon in debugWire mode +programmer + id = "dragon_dw"; + desc = "Atmel AVR Dragon in debugWire mode"; + baudrate = 115200; + type = "dragon_dw"; + connection_type = usb; +; + +# AVR Dragon in PDI mode +programmer + id = "dragon_pdi"; + desc = "Atmel AVR Dragon in PDI mode"; + baudrate = 115200; + type = "dragon_pdi"; + connection_type = usb; +; + +programmer + id = "jtag3"; + desc = "Atmel AVR JTAGICE3 in JTAG mode"; + type = "jtagice3"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "jtag3pdi"; + desc = "Atmel AVR JTAGICE3 in PDI mode"; + type = "jtagice3_pdi"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "jtag3dw"; + desc = "Atmel AVR JTAGICE3 in debugWIRE mode"; + type = "jtagice3_dw"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "jtag3isp"; + desc = "Atmel AVR JTAGICE3 in ISP mode"; + type = "jtagice3_isp"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "xplainedpro"; + desc = "Atmel AVR XplainedPro in JTAG mode"; + type = "jtagice3"; + connection_type = usb; + usbpid = 0x2111; +; + +programmer + id = "xplainedmini"; + desc = "Atmel AVR XplainedMini in ISP mode"; + type = "jtagice3_isp"; + connection_type = usb; + usbpid = 0x2145; +; + +programmer + id = "xplainedmini_dw"; + desc = "Atmel AVR XplainedMini in debugWIRE mode"; + type = "jtagice3_dw"; + connection_type = usb; + usbpid = 0x2145; +; + +programmer + id = "atmelice"; + desc = "Atmel-ICE (ARM/AVR) in JTAG mode"; + type = "jtagice3"; + connection_type = usb; + usbpid = 0x2141; +; + +programmer + id = "atmelice_pdi"; + desc = "Atmel-ICE (ARM/AVR) in PDI mode"; + type = "jtagice3_pdi"; + connection_type = usb; + usbpid = 0x2141; +; + +programmer + id = "atmelice_dw"; + desc = "Atmel-ICE (ARM/AVR) in debugWIRE mode"; + type = "jtagice3_dw"; + connection_type = usb; + usbpid = 0x2141; +; + +programmer + id = "atmelice_isp"; + desc = "Atmel-ICE (ARM/AVR) in ISP mode"; + type = "jtagice3_isp"; + connection_type = usb; + usbpid = 0x2141; +; + + +programmer + id = "pavr"; + desc = "Jason Kyle's pAVR Serial Programmer"; + type = "avr910"; + connection_type = serial; +; + +programmer + id = "pickit2"; + desc = "MicroChip's PICkit2 Programmer"; + type = "pickit2"; + connection_type = usb; +; + +programmer + id = "flip1"; + desc = "FLIP USB DFU protocol version 1 (doc7618)"; + type = "flip1"; + connection_type = usb; +; + +programmer + id = "flip2"; + desc = "FLIP USB DFU protocol version 2 (AVR4023)"; + type = "flip2"; + connection_type = usb; +; + +# Parallel port programmers. + +programmer + id = "bsd"; + desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/"; + type = "par"; + connection_type = parallel; + vcc = 2, 3, 4, 5; + reset = 7; + sck = 8; + mosi = 9; + miso = 10; +; + +programmer + id = "stk200"; + desc = "STK200"; + type = "par"; + connection_type = parallel; + buff = 4, 5; + sck = 6; + mosi = 7; + reset = 9; + miso = 10; +; + +# The programming dongle used by the popular Ponyprog +# utility. It is almost similar to the STK200 one, +# except that there is a LED indicating that the +# programming is currently in progress. + +programmer parent "stk200" + id = "pony-stk200"; + desc = "Pony Prog STK200"; + pgmled = 8; +; + +programmer + id = "dt006"; + desc = "Dontronics DT006"; + type = "par"; + connection_type = parallel; + reset = 4; + sck = 5; + mosi = 2; + miso = 11; +; + +programmer parent "dt006" + id = "bascom"; + desc = "Bascom SAMPLE programming cable"; +; + +programmer + id = "alf"; + desc = "Nightshade ALF-PgmAVR, http://nightshade.homeip.net/"; + type = "par"; + connection_type = parallel; + vcc = 2, 3, 4, 5; + buff = 6; + reset = 7; + sck = 8; + mosi = 9; + miso = 10; + errled = 1; + rdyled = 14; + pgmled = 16; + vfyled = 17; +; + +programmer + id = "sp12"; + desc = "Steve Bolt's Programmer"; + type = "par"; + connection_type = parallel; + vcc = 4,5,6,7,8; + reset = 3; + sck = 2; + mosi = 9; + miso = 11; +; + +programmer + id = "picoweb"; + desc = "Picoweb Programming Cable, http://www.picoweb.net/"; + type = "par"; + connection_type = parallel; + reset = 2; + sck = 3; + mosi = 4; + miso = 13; +; + +programmer + id = "abcmini"; + desc = "ABCmini Board, aka Dick Smith HOTCHIP"; + type = "par"; + connection_type = parallel; + reset = 4; + sck = 3; + mosi = 2; + miso = 10; +; + +programmer + id = "futurlec"; + desc = "Futurlec.com programming cable."; + type = "par"; + connection_type = parallel; + reset = 3; + sck = 2; + mosi = 1; + miso = 10; +; + + +# From the contributor of the "xil" jtag cable: +# The "vcc" definition isn't really vcc (the cable gets its power from +# the programming circuit) but is necessary to switch one of the +# buffer lines (trying to add it to the "buff" lines doesn't work in +# avrdude versions before 5.5j). +# With this, TMS connects to RESET, TDI to MOSI, TDO to MISO and TCK +# to SCK (plus vcc/gnd of course) +programmer + id = "xil"; + desc = "Xilinx JTAG cable"; + type = "par"; + connection_type = parallel; + mosi = 2; + sck = 3; + reset = 4; + buff = 5; + miso = 13; + vcc = 6; +; + + +programmer + id = "dapa"; + desc = "Direct AVR Parallel Access cable"; + type = "par"; + connection_type = parallel; + vcc = 3; + reset = 16; + sck = 1; + mosi = 2; + miso = 11; +; + +programmer + id = "atisp"; + desc = "AT-ISP V1.1 programming cable for AVR-SDK1 from micro-research.co.th"; + type = "par"; + connection_type = parallel; + reset = ~6; + sck = ~8; + mosi = ~7; + miso = ~10; +; + +programmer + id = "ere-isp-avr"; + desc = "ERE ISP-AVR "; + type = "par"; + connection_type = parallel; + reset = ~4; + sck = 3; + mosi = 2; + miso = 10; +; + +programmer + id = "blaster"; + desc = "Altera ByteBlaster"; + type = "par"; + connection_type = parallel; + sck = 2; + miso = 11; + reset = 3; + mosi = 8; + buff = 14; +; + +# It is almost same as pony-stk200, except vcc on pin 5 to auto +# disconnect port (download on http://electropol.free.fr/spip/spip.php?article27) +programmer parent "pony-stk200" + id = "frank-stk200"; + desc = "Frank STK200"; + buff = ; # delete buff pin assignment + vcc = 5; +; + +# The AT98ISP Cable is a simple parallel dongle for AT89 family. +# http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2877 +programmer + id = "89isp"; + desc = "Atmel at89isp cable"; + type = "par"; + connection_type = parallel; + reset = 17; + sck = 1; + mosi = 2; + miso = 10; +; + + +#This programmer bitbangs GPIO lines using the Linux sysfs GPIO interface +# +#To enable it set the configuration below to match the GPIO lines connected to the +#relevant ISP header pins and uncomment the entry definition. In case you don't +#have the required permissions to edit this system wide config file put the +#entry in a separate .conf file and use it with -C+.conf +#on the command line. +# +#To check if your avrdude build has support for the linuxgpio programmer compiled in, +#use -c?type on the command line and look for linuxgpio in the list. If it's not available +#you need pass the --enable-linuxgpio=yes option to configure and recompile avrdude. +# +#programmer +# id = "linuxgpio"; +# desc = "Use the Linux sysfs interface to bitbang GPIO lines"; +# type = "linuxgpio"; +# reset = ?; +# sck = ?; +# mosi = ?; +# miso = ?; +#; + +# some ultra cheap programmers use bitbanging on the +# serialport. +# +# PC - DB9 - Pins for RS232: +# +# GND 5 -- |O +# | O| <- 9 RI +# DTR 4 <- |O | +# | O| <- 8 CTS +# TXD 3 <- |O | +# | O| -> 7 RTS +# RXD 2 -> |O | +# | O| <- 6 DSR +# DCD 1 -> |O +# +# Using RXD is currently not supported. +# Using RI is not supported under Win32 but is supported under Posix. + +# serial ponyprog design (dasa2 in uisp) +# reset=!txd sck=rts mosi=dtr miso=cts + +programmer + id = "ponyser"; + desc = "design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts"; + type = "serbb"; + connection_type = serial; + reset = ~3; + sck = 7; + mosi = 4; + miso = 8; +; + +# Same as above, different name +# reset=!txd sck=rts mosi=dtr miso=cts + +programmer parent "ponyser" + id = "siprog"; + desc = "Lancos SI-Prog "; +; + +# unknown (dasa in uisp) +# reset=rts sck=dtr mosi=txd miso=cts + +programmer + id = "dasa"; + desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts"; + type = "serbb"; + connection_type = serial; + reset = 7; + sck = 4; + mosi = 3; + miso = 8; +; + +# unknown (dasa3 in uisp) +# reset=!dtr sck=rts mosi=txd miso=cts + +programmer + id = "dasa3"; + desc = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts"; + type = "serbb"; + connection_type = serial; + reset = ~4; + sck = 7; + mosi = 3; + miso = 8; +; + +# C2N232i (jumper configuration "auto") +# reset=dtr sck=!rts mosi=!txd miso=!cts + +programmer + id = "c2n232i"; + desc = "serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts"; + type = "serbb"; + connection_type = serial; + reset = 4; + sck = ~7; + mosi = ~3; + miso = ~8; +; + +# +# PART DEFINITIONS +# + +#------------------------------------------------------------ +# ATtiny11 +#------------------------------------------------------------ + +# This is an HVSP-only device. + +part + id = "t11"; + desc = "ATtiny11"; + stk500_devcode = 0x11; + signature = 0x1e 0x90 0x04; + chip_erase_delay = 20000; + + timeout = 200; + 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; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + blocksize = 64; + readsize = 256; + delay = 5; + ; + + memory "flash" + size = 1024; + blocksize = 128; + readsize = 256; + delay = 3; + ; + + memory "signature" + size = 3; + ; + + memory "lock" + size = 1; + ; + + memory "calibration" + size = 1; + ; + + memory "fuse" + size = 1; + ; +; + +#------------------------------------------------------------ +# ATtiny12 +#------------------------------------------------------------ + +part + id = "t12"; + desc = "ATtiny12"; + stk500_devcode = 0x12; + avr910_devcode = 0x55; + signature = 0x1e 0x90 0x05; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 8; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + size = 1024; + min_write_delay = 4500; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; +; + +#------------------------------------------------------------ +# ATtiny13 +#------------------------------------------------------------ + +part + id = "t13"; + desc = "ATtiny13"; + has_debugwire = yes; + flash_instr = 0xB4, 0x0E, 0x1E; + eeprom_instr = 0xBB, 0xFE, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, + 0xBC, 0x0E, 0xB4, 0x0E, 0xBA, 0x0D, 0xBB, 0xBC, + 0x99, 0xE1, 0xBB, 0xAC; + stk500_devcode = 0x14; + signature = 0x1e 0x90 0x07; + chip_erase_delay = 4000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 90; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 0; + + memory "eeprom" + size = 64; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 1024; + page_size = 32; + num_pages = 32; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny15 +#------------------------------------------------------------ + +part + id = "t15"; + desc = "ATtiny15"; + stk500_devcode = 0x13; + avr910_devcode = 0x56; + signature = 0x1e 0x90 0x06; + chip_erase_delay = 8200; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 5; + synchcycles = 6; + latchcycles = 16; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + min_write_delay = 8200; + max_write_delay = 8200; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + size = 1024; + min_write_delay = 4100; + max_write_delay = 4100; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x o o o o x x o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x i i i i 1 1 i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; +; + +#------------------------------------------------------------ +# AT90s1200 +#------------------------------------------------------------ + +part + id = "1200"; + desc = "AT90S1200"; + is_at90s1200 = yes; + stk500_devcode = 0x33; + avr910_devcode = 0x13; + signature = 0x1e 0x90 0x01; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 1; + bytedelay = 0; + pollindex = 0; + pollvalue = 0xFF; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 64; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 32; + readsize = 256; + ; + memory "flash" + size = 1024; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x02; + delay = 15; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s4414 +#------------------------------------------------------------ + +part + id = "4414"; + desc = "AT90S4414"; + stk500_devcode = 0x50; + avr910_devcode = 0x28; + signature = 0x1e 0x92 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s2313 +#------------------------------------------------------------ + +part + id = "2313"; + desc = "AT90S2313"; + stk500_devcode = 0x40; + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 128; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 2048; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x i i x", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s2333 +#------------------------------------------------------------ + +part + id = "2333"; +##### WARNING: No XML file for device 'AT90S2333'! ##### + desc = "AT90S2333"; + stk500_devcode = 0x42; + avr910_devcode = 0x34; + signature = 0x1e 0x91 0x05; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + pwroff_after_write = yes; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + + +#------------------------------------------------------------ +# AT90s2343 (also AT90s2323 and ATtiny22) +#------------------------------------------------------------ + +part + id = "2343"; + desc = "AT90S2343"; + stk500_devcode = 0x43; + avr910_devcode = 0x4c; + signature = 0x1e 0x91 0x03; + chip_erase_delay = 18000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 0; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 128; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + 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 o o o x x x x o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 o o o x x x x o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + + +#------------------------------------------------------------ +# AT90s4433 +#------------------------------------------------------------ + +part + id = "4433"; + desc = "AT90S4433"; + stk500_devcode = 0x51; + avr910_devcode = 0x30; + signature = 0x1e 0x92 0x03; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + pwroff_after_write = yes; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s4434 +#------------------------------------------------------------ + +part + id = "4434"; +##### WARNING: No XML file for device 'AT90S4434'! ##### + desc = "AT90S4434"; + stk500_devcode = 0x52; + avr910_devcode = 0x6c; + signature = 0x1e 0x92 0x02; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s8515 +#------------------------------------------------------------ + +part + id = "8515"; + desc = "AT90S8515"; + stk500_devcode = 0x60; + avr910_devcode = 0x38; + signature = 0x1e 0x93 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 512; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 8192; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s8535 +#------------------------------------------------------------ + +part + id = "8535"; + desc = "AT90S8535"; + stk500_devcode = 0x61; + avr910_devcode = 0x68; + signature = 0x1e 0x93 0x03; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 8192; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + 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 x x x x x x x o"; + write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + memory "lock" + size = 1; + 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 o o x x x x x x"; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# ATmega103 +#------------------------------------------------------------ + +part + id = "m103"; + desc = "ATmega103"; + stk500_devcode = 0xB1; + avr910_devcode = 0x41; + signature = 0x1e 0x97 0x01; + chip_erase_delay = 112000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + pp_controlstack = + 0x0E, 0x1E, 0x8E, 0x9E, 0x2E, 0x3E, 0xAE, 0xBE, + 0x4E, 0x5E, 0xCE, 0xDE, 0x6E, 0x7E, 0xEE, 0xDE, + 0x66, 0x76, 0xE6, 0xF6, 0x6A, 0x7A, 0xEA, 0x7A, + 0x7F, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 10; + + memory "eeprom" + size = 4096; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 22000; + max_write_delay = 56000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x11; + delay = 70; + blocksize = 256; + readsize = 256; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o x o 1 o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 1 i 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega64 +#------------------------------------------------------------ + +part + id = "m64"; + desc = "ATmega64"; + has_jtag = yes; + stk500_devcode = 0xA0; + avr910_devcode = 0x45; + signature = 0x1e 0x96 0x02; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x22; + spmcr = 0x68; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + + +#------------------------------------------------------------ +# ATmega128 +#------------------------------------------------------------ + +part + id = "m128"; + desc = "ATmega128"; + has_jtag = yes; + stk500_devcode = 0xB2; + avr910_devcode = 0x43; + signature = 0x1e 0x97 0x02; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x22; + spmcr = 0x68; + rampz = 0x3b; + allowfullpagebitstream = yes; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN128 +#------------------------------------------------------------ + +part + id = "c128"; + desc = "AT90CAN128"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x97 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN64 +#------------------------------------------------------------ + +part + id = "c64"; + desc = "AT90CAN64"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x96 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN32 +#------------------------------------------------------------ + +part + id = "c32"; + desc = "AT90CAN32"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x95 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 256; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega16 +#------------------------------------------------------------ + +part + id = "m16"; + desc = "ATmega16"; + has_jtag = yes; + stk500_devcode = 0x82; + avr910_devcode = 0x74; + signature = 0x1e 0x94 0x03; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 100; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x04; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "calibration" + size = 4; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega164P +#------------------------------------------------------------ + +# close to ATmega16 + +part parent "m16" + id = "m164p"; + desc = "ATmega164P"; + signature = 0x1e 0x94 0x0a; + + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + allowfullpagebitstream = no; + chip_erase_delay = 55000; + + ocdrev = 3; + ; + + +#------------------------------------------------------------ +# ATmega324P +#------------------------------------------------------------ + +# similar to ATmega164P + +part + id = "m324p"; + desc = "ATmega324P"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x95 0x08; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega324PA +#------------------------------------------------------------ + +# similar to ATmega324P + +part parent "m324p" + id = "m324pa"; + desc = "ATmega324PA"; + signature = 0x1e 0x95 0x11; + + ocdrev = 3; + ; + + +#------------------------------------------------------------ +# ATmega644 +#------------------------------------------------------------ + +# similar to ATmega164 + +part + id = "m644"; + desc = "ATmega644"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x96 0x09; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega644P +#------------------------------------------------------------ + +# similar to ATmega164p + +part parent "m644" + id = "m644p"; + desc = "ATmega644P"; + signature = 0x1e 0x96 0x0a; + + ocdrev = 3; + ; + + + +#------------------------------------------------------------ +# ATmega1284 +#------------------------------------------------------------ + +# similar to ATmega164 + +part + id = "m1284"; + desc = "ATmega1284"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x97 0x06; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega1284P +#------------------------------------------------------------ + +# similar to ATmega164p + +part + id = "m1284p"; + desc = "ATmega1284P"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x97 0x05; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega162 +#------------------------------------------------------------ + +part + id = "m162"; + desc = "ATmega162"; + has_jtag = yes; + stk500_devcode = 0x83; + avr910_devcode = 0x63; + signature = 0x1e 0x94 0x04; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + + idr = 0x04; + spmcr = 0x57; + allowfullpagebitstream = yes; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + ocdrev = 2; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + + ; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + + read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; +; + + + +#------------------------------------------------------------ +# ATmega163 +#------------------------------------------------------------ + +part + id = "m163"; + desc = "ATmega163"; + stk500_devcode = 0x81; + avr910_devcode = 0x64; + signature = 0x1e 0x94 0x02; + chip_erase_delay = 32000; + pagel = 0xd7; + bs2 = 0xa0; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 30; + programfusepulsewidth = 0; + programfusepolltimeout = 2; + programlockpulsewidth = 0; + programlockpolltimeout = 2; + + + memory "eeprom" + size = 512; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 16000; + max_write_delay = 16000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x11; + delay = 20; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o x x o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i 1 1 i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x x x x x 1 o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x 0 x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega169 +#------------------------------------------------------------ + +part + id = "m169"; + desc = "ATmega169"; + has_jtag = yes; + stk500_devcode = 0x85; + avr910_devcode = 0x78; + signature = 0x1e 0x94 0x05; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega329 +#------------------------------------------------------------ + +part + id = "m329"; + desc = "ATmega329"; + has_jtag = yes; +# stk500_devcode = 0x85; # no STK500 support, only STK500v2 +# avr910_devcode = 0x?; # try the ATmega169 one: + avr910_devcode = 0x75; + signature = 0x1e 0x95 0x03; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega329P +#------------------------------------------------------------ +# Identical to ATmega329 except of the signature + +part parent "m329" + id = "m329p"; + desc = "ATmega329P"; + signature = 0x1e 0x95 0x0b; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega3290 +#------------------------------------------------------------ + +# identical to ATmega329 + +part parent "m329" + id = "m3290"; + desc = "ATmega3290"; + signature = 0x1e 0x95 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega3290P +#------------------------------------------------------------ + +# identical to ATmega3290 except of the signature + +part parent "m3290" + id = "m3290p"; + desc = "ATmega3290P"; + signature = 0x1e 0x95 0x0c; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega649 +#------------------------------------------------------------ + +part + id = "m649"; + desc = "ATmega649"; + has_jtag = yes; +# stk500_devcode = 0x85; # no STK500 support, only STK500v2 +# avr910_devcode = 0x?; # try the ATmega169 one: + avr910_devcode = 0x75; + signature = 0x1e 0x96 0x03; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega6490 +#------------------------------------------------------------ + +# identical to ATmega649 + +part parent "m649" + id = "m6490"; + desc = "ATmega6490"; + signature = 0x1e 0x96 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega32 +#------------------------------------------------------------ + +part + id = "m32"; + desc = "ATmega32"; + has_jtag = yes; + stk500_devcode = 0x91; + avr910_devcode = 0x72; + signature = 0x1e 0x95 0x02; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega161 +#------------------------------------------------------------ + +part + id = "m161"; + desc = "ATmega161"; + stk500_devcode = 0x80; + avr910_devcode = 0x60; + signature = 0x1e 0x94 0x01; + chip_erase_delay = 28000; + pagel = 0xd7; + bs2 = 0xa0; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 30; + programfusepulsewidth = 0; + programfusepolltimeout = 2; + programlockpulsewidth = 0; + programlockpolltimeout = 2; + + memory "eeprom" + size = 512; + min_write_delay = 3400; + max_write_delay = 3400; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 14000; + max_write_delay = 14000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 16; + blocksize = 128; + readsize = 256; + ; + + memory "fuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x o x o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x 1 i 1 i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega8 +#------------------------------------------------------------ + +part + id = "m8"; + desc = "ATmega8"; + stk500_devcode = 0x70; + avr910_devcode = 0x76; + signature = 0x1e 0x93 0x07; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 10000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega8515 +#------------------------------------------------------------ + +part + id = "m8515"; + desc = "ATmega8515"; + stk500_devcode = 0x63; + avr910_devcode = 0x3A; + signature = 0x1e 0x93 0x06; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + + +#------------------------------------------------------------ +# ATmega8535 +#------------------------------------------------------------ + +part + id = "m8535"; + desc = "ATmega8535"; + stk500_devcode = 0x64; + avr910_devcode = 0x69; + signature = 0x1e 0x93 0x08; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATtiny26 +#------------------------------------------------------------ + +part + id = "t26"; + desc = "ATtiny26"; + stk500_devcode = 0x21; + avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x09; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 16; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x x x x i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny261 +#------------------------------------------------------------ +# Close to ATtiny26 + +part + id = "t261"; + desc = "ATtiny261"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x0c; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 128; + page_size = 4; + num_pages = 32; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny461 +#------------------------------------------------------------ +# Close to ATtiny261 + +part + id = "t461"; + desc = "ATtiny461"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x92 0x08; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 256; + page_size = 4; + num_pages = 64; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny861 +#------------------------------------------------------------ +# Close to ATtiny461 + +part + id = "t861"; + desc = "ATtiny861"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x93 0x0d; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 512; + num_pages = 128; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny28 +#------------------------------------------------------------ + +# This is an HVPP-only device. + +part + id = "t28"; + desc = "ATtiny28"; + stk500_devcode = 0x22; + avr910_devcode = 0x5c; + signature = 0x1e 0x91 0x07; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "flash" + size = 2048; + page_size = 2; + readsize = 256; + delay = 5; + ; + + memory "signature" + size = 3; + ; + + memory "lock" + size = 1; + ; + + memory "calibration" + size = 1; + ; + + memory "fuse" + size = 1; + ; +; + + + +#------------------------------------------------------------ +# ATmega48 +#------------------------------------------------------------ + +part + id = "m48"; + desc = "ATmega48"; + has_debugwire = yes; + 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; + stk500_devcode = 0x59; +# avr910_devcode = 0x; + signature = 0x1e 0x92 0x05; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 45000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 256; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x x", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega48P +#------------------------------------------------------------ + +part parent "m48" + id = "m48p"; + desc = "ATmega48P"; + signature = 0x1e 0x92 0x0a; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega48PB +#------------------------------------------------------------ + +part parent "m48" + id = "m48pb"; + desc = "ATmega48PB"; + signature = 0x1e 0x92 0x10; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega88 +#------------------------------------------------------------ + +part + id = "m88"; + desc = "ATmega88"; + has_debugwire = yes; + 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; + stk500_devcode = 0x73; +# avr910_devcode = 0x; + signature = 0x1e 0x93 0x0a; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 512; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega88P +#------------------------------------------------------------ + +part parent "m88" + id = "m88p"; + desc = "ATmega88P"; + signature = 0x1e 0x93 0x0f; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega88PB +#------------------------------------------------------------ + +part parent "m88" + id = "m88pb"; + desc = "ATmega88PB"; + signature = 0x1e 0x93 0x16; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega168 +#------------------------------------------------------------ + +part + id = "m168"; + desc = "ATmega168"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x94 0x06; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 512; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# ATmega168P +#------------------------------------------------------------ + +part parent "m168" + id = "m168p"; + desc = "ATmega168P"; + signature = 0x1e 0x94 0x0b; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATmega168PB +#------------------------------------------------------------ + +part parent "m168" + id = "m168pb"; + desc = "ATmega168PB"; + signature = 0x1e 0x94 0x15; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATtiny88 +#------------------------------------------------------------ + +part + id = "t88"; + desc = "ATtiny88"; + has_debugwire = yes; + 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; + stk500_devcode = 0x73; +# avr910_devcode = 0x; + signature = 0x1e 0x93 0x11; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 64; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 64; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega328 +#------------------------------------------------------------ + +part + id = "m328"; + desc = "ATmega328"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x95 0x14; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 1024; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +part parent "m328" + id = "m328p"; + desc = "ATmega328P"; + signature = 0x1e 0x95 0x0F; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATmega32m1 +#------------------------------------------------------------ + +part parent "m328" + id = "m32m1"; + desc = "ATmega32M1"; + # stk500_devcode = 0x; + # avr910_devcode = 0x; + signature = 0x1e 0x95 0x84; + bs2 = 0xe2; + + memory "efuse" + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x i i i i i i"; + ; +; + +#------------------------------------------------------------ +# ATtiny2313 +#------------------------------------------------------------ + +part + id = "t2313"; + desc = "ATtiny2313"; + has_debugwire = yes; + 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; + stk500_devcode = 0x23; +## Use the ATtiny26 devcode: + avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x0a; + pagel = 0xD4; + bs2 = 0xD6; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 0; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + +# The information in the data sheet of April/2004 is wrong, this works: + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + +# The information in the data sheet of April/2004 is wrong, this works: + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + +# The information in the data sheet of April/2004 is wrong, this works: + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny2313 has Signature Bytes: 0x1E 0x91 0x0A. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + 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 = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny4313 +#------------------------------------------------------------ + +part + id = "t4313"; + desc = "ATtiny4313"; + has_debugwire = yes; + 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; + stk500_devcode = 0x23; +## Use the ATtiny26 devcode: + avr910_devcode = 0x5e; + signature = 0x1e 0x92 0x0d; + pagel = 0xD4; + bs2 = 0xD6; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 0; + + memory "eeprom" + size = 256; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny4313 has Signature Bytes: 0x1E 0x92 0x0D. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90PWM2 +#------------------------------------------------------------ + +part + id = "pwm2"; + desc = "AT90PWM2"; + has_debugwire = yes; + 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; + stk500_devcode = 0x65; +## avr910_devcode = ?; + signature = 0x1e 0x93 0x81; + pagel = 0xD8; + bs2 = 0xE2; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; +# AT90PWM2 has Signature Bytes: 0x1E 0x93 0x81. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90PWM3 +#------------------------------------------------------------ + +# Completely identical to AT90PWM2 (including the signature!) + +part parent "pwm2" + id = "pwm3"; + desc = "AT90PWM3"; + ; + +#------------------------------------------------------------ +# AT90PWM2B +#------------------------------------------------------------ +# Same as AT90PWM2 but different signature. + +part parent "pwm2" + id = "pwm2b"; + desc = "AT90PWM2B"; + signature = 0x1e 0x93 0x83; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# AT90PWM3B +#------------------------------------------------------------ + +# Completely identical to AT90PWM2B (including the signature!) + +part parent "pwm2b" + id = "pwm3b"; + desc = "AT90PWM3B"; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# AT90PWM316 +#------------------------------------------------------------ + +# Similar to AT90PWM3B, but with 16 kiB flash, 512 B EEPROM, and 1024 B SRAM. + +part parent "pwm3b" + id = "pwm316"; + desc = "AT90PWM316"; + signature = 0x1e 0x94 0x83; + + ocdrev = 1; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + ; + +#------------------------------------------------------------ +# AT90PWM216 +#------------------------------------------------------------ +# Completely identical to AT90PWM316 (including the signature!) + +part parent "pwm316" + id = "pwm216"; + desc = "AT90PWM216"; + ; + +#------------------------------------------------------------ +# ATtiny25 +#------------------------------------------------------------ + +part + id = "t25"; + desc = "ATtiny25"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x08; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny25 has Signature Bytes: 0x1E 0x91 0x08. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny45 +#------------------------------------------------------------ + +part + id = "t45"; + desc = "ATtiny45"; + has_debugwire = yes; + 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; + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x06; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 256; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny45 has Signature Bytes: 0x1E 0x92 0x08. (Data sheet 2586C-AVR-06/05 (doc2586.pdf) indicates otherwise!) + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny85 +#------------------------------------------------------------ + +part + id = "t85"; + desc = "ATtiny85"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x93 0x0b; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny85 has Signature Bytes: 0x1E 0x93 0x08. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega640 +#------------------------------------------------------------ +# Almost same as ATmega1280, except for different memory sizes + +part + id = "m640"; + desc = "ATmega640"; + signature = 0x1e 0x96 0x08; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega1280 +#------------------------------------------------------------ + +part + id = "m1280"; + desc = "ATmega1280"; + signature = 0x1e 0x97 0x03; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega1281 +#------------------------------------------------------------ +# Identical to ATmega1280 + +part parent "m1280" + id = "m1281"; + desc = "ATmega1281"; + signature = 0x1e 0x97 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega2560 +#------------------------------------------------------------ + +part + id = "m2560"; + desc = "ATmega2560"; + signature = 0x1e 0x98 0x01; + has_jtag = yes; + stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 4; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 262144; + page_size = 256; + num_pages = 1024; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + load_ext_addr = " 0 1 0 0 1 1 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 a16", + " 0 0 0 0 0 0 0 0"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega2561 +#------------------------------------------------------------ + +part parent "m2560" + id = "m2561"; + desc = "ATmega2561"; + signature = 0x1e 0x98 0x02; + + ocdrev = 4; + ; + +#------------------------------------------------------------ +# ATmega128RFA1 +#------------------------------------------------------------ +# Identical to ATmega2561 but half the ROM + +part parent "m2561" + id = "m128rfa1"; + desc = "ATmega128RFA1"; + signature = 0x1e 0xa7 0x01; + chip_erase_delay = 55000; + bs2 = 0xE2; + + ocdrev = 3; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 50000; + max_write_delay = 50000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 256; + readsize = 256; + ; + ; + +#------------------------------------------------------------ +# ATmega256RFR2 +#------------------------------------------------------------ + +part parent "m2561" + id = "m256rfr2"; + desc = "ATmega256RFR2"; + signature = 0x1e 0xa8 0x02; + chip_erase_delay = 18500; + bs2 = 0xE2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 8192; + min_write_delay = 13000; + max_write_delay = 13000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + + ocdrev = 4; + ; + +#------------------------------------------------------------ +# ATmega128RFR2 +#------------------------------------------------------------ + +part parent "m128rfa1" + id = "m128rfr2"; + desc = "ATmega128RFR2"; + signature = 0x1e 0xa7 0x02; + + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega64RFR2 +#------------------------------------------------------------ + +part parent "m128rfa1" + id = "m64rfr2"; + desc = "ATmega64RFR2"; + signature = 0x1e 0xa6 0x02; + + + ocdrev = 3; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 50000; + max_write_delay = 50000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 256; + readsize = 256; + ; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 13000; + max_write_delay = 13000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + + ; + +#------------------------------------------------------------ +# ATmega2564RFR2 +#------------------------------------------------------------ + +part parent "m256rfr2" + id = "m2564rfr2"; + desc = "ATmega2564RFR2"; + signature = 0x1e 0xa8 0x03; + ; + +#------------------------------------------------------------ +# ATmega1284RFR2 +#------------------------------------------------------------ + +part parent "m128rfr2" + id = "m1284rfr2"; + desc = "ATmega1284RFR2"; + signature = 0x1e 0xa7 0x03; + ; + +#------------------------------------------------------------ +# ATmega644RFR2 +#------------------------------------------------------------ + +part parent "m64rfr2" + id = "m644rfr2"; + desc = "ATmega644RFR2"; + signature = 0x1e 0xa6 0x03; + ; + +#------------------------------------------------------------ +# ATtiny24 +#------------------------------------------------------------ + +part + id = "t24"; + desc = "ATtiny24"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x0b; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny24 has Signature Bytes: 0x1E 0x91 0x0B. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny44 +#------------------------------------------------------------ + +part + id = "t44"; + desc = "ATtiny44"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x07; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 256; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny44 has Signature Bytes: 0x1E 0x92 0x07. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny84 +#------------------------------------------------------------ + +part + id = "t84"; + desc = "ATtiny84"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x93 0x0c; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny84 has Signature Bytes: 0x1E 0x93 0x0C. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny43U +#------------------------------------------------------------ + +part + id = "t43u"; + desc = "ATtiny43u"; + has_debugwire = yes; + 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; + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x0C; + reset = io; + chip_erase_delay = 1000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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, 0x06, 0x16, 0x46, 0x56, + 0x0A, 0x1A, 0x4A, 0x5A, 0x1E, 0x7C, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 20; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + memory "eeprom" + size = 64; + paged = yes; + page_size = 4; + num_pages = 16; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "0 0 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "0 0 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " 0 0 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# ATmega32u4 +#------------------------------------------------------------ + +part + id = "m32u4"; + desc = "ATmega32U4"; + signature = 0x1e 0x95 0x87; + usbpid = 0x2ff4; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB646 +#------------------------------------------------------------ + +part + id = "usb646"; + desc = "AT90USB646"; + signature = 0x1e 0x96 0x82; + usbpid = 0x2ff9; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB647 +#------------------------------------------------------------ +# identical to AT90USB646 + +part parent "usb646" + id = "usb647"; + desc = "AT90USB647"; + signature = 0x1e 0x96 0x82; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AT90USB1286 +#------------------------------------------------------------ + +part + id = "usb1286"; + desc = "AT90USB1286"; + signature = 0x1e 0x97 0x82; + usbpid = 0x2ffb; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB1287 +#------------------------------------------------------------ +# identical to AT90USB1286 + +part parent "usb1286" + id = "usb1287"; + desc = "AT90USB1287"; + signature = 0x1e 0x97 0x82; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AT90USB162 +#------------------------------------------------------------ + +part + id = "usb162"; + desc = "AT90USB162"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x94 0x82; + usbpid = 0x2ffa; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB82 +#------------------------------------------------------------ +# Changes against AT90USB162 (beside IDs) +# memory "flash" +# size = 8192; +# num_pages = 64; + +part + id = "usb82"; + desc = "AT90USB82"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x93 0x82; + usbpid = 0x2ff7; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega32U2 +#------------------------------------------------------------ +# Changes against AT90USB162 (beside IDs) +# memory "flash" +# size = 32768; +# num_pages = 256; +# memory "eeprom" +# size = 1024; +# num_pages = 256; +part + id = "m32u2"; + desc = "ATmega32U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x95 0x8a; + usbpid = 0x2ff0; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + num_pages = 256; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; +#------------------------------------------------------------ +# ATmega16U2 +#------------------------------------------------------------ +# Changes against ATmega32U2 (beside IDs) +# memory "flash" +# size = 16384; +# num_pages = 128; +# memory "eeprom" +# size = 512; +# num_pages = 128; +part + id = "m16u2"; + desc = "ATmega16U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x94 0x89; + usbpid = 0x2fef; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega8U2 +#------------------------------------------------------------ +# Changes against ATmega16U2 (beside IDs) +# memory "flash" +# size = 8192; +# page_size = 64; +# blocksize = 64; + +part + id = "m8u2"; + desc = "ATmega8U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x93 0x89; + usbpid = 0x2fee; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; +#------------------------------------------------------------ +# ATmega325 +#------------------------------------------------------------ + +part + id = "m325"; + desc = "ATmega325"; + signature = 0x1e 0x95 0x05; + has_jtag = yes; +# stk500_devcode = 0x??; # No STK500v1 support? +# avr910_devcode = 0x??; # Try the ATmega16 one + avr910_devcode = 0x74; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega645 +#------------------------------------------------------------ + +part + id = "m645"; + desc = "ATmega645"; + signature = 0x1E 0x96 0x05; + has_jtag = yes; +# stk500_devcode = 0x??; # No STK500v1 support? +# avr910_devcode = 0x??; # Try the ATmega16 one + avr910_devcode = 0x74; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " 0 0 0 0 0 0 0 0"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega3250 +#------------------------------------------------------------ + +part parent "m325" + id = "m3250"; + desc = "ATmega3250"; + signature = 0x1E 0x95 0x06; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega6450 +#------------------------------------------------------------ + +part parent "m645" + id = "m6450"; + desc = "ATmega6450"; + signature = 0x1E 0x96 0x06; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AVR XMEGA family common values +#------------------------------------------------------------ + +part + id = ".xmega"; + desc = "AVR XMEGA family common values"; + has_pdi = yes; + nvm_base = 0x01c0; + mcu_base = 0x0090; + + memory "signature" + size = 3; + offset = 0x1000090; + ; + + memory "prodsig" + size = 0x32; + offset = 0x8e0200; + page_size = 0x32; + readsize = 0x32; + ; + + memory "fuse1" + size = 1; + offset = 0x8f0021; + ; + + memory "fuse2" + size = 1; + offset = 0x8f0022; + ; + + memory "fuse4" + size = 1; + offset = 0x8f0024; + ; + + memory "fuse5" + size = 1; + offset = 0x8f0025; + ; + + memory "lock" + size = 1; + offset = 0x8f0027; + ; + + memory "data" + # SRAM, only used to supply the offset + offset = 0x1000000; + ; +; + +#------------------------------------------------------------ +# ATxmega16A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x16a4u"; + desc = "ATxmega16A4U"; + signature = 0x1e 0x94 0x41; + usbpid = 0x2fe3; + + memory "eeprom" + size = 0x400; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x4000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x803000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x804000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x5000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega16C4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16c4"; + desc = "ATxmega16C4"; + signature = 0x1e 0x95 0x44; +; + +#------------------------------------------------------------ +# ATxmega16D4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16d4"; + desc = "ATxmega16D4"; + signature = 0x1e 0x94 0x42; +; + +#------------------------------------------------------------ +# ATxmega16A4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16a4"; + desc = "ATxmega16A4"; + signature = 0x1e 0x94 0x41; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega32A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x32a4u"; + desc = "ATxmega32A4U"; + signature = 0x1e 0x95 0x41; + usbpid = 0x2fe4; + + memory "eeprom" + size = 0x400; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x8000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x807000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x808000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x9000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega32C4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32c4"; + desc = "ATxmega32C4"; + signature = 0x1e 0x94 0x43; +; + +#------------------------------------------------------------ +# ATxmega32D4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32d4"; + desc = "ATxmega32D4"; + signature = 0x1e 0x95 0x42; +; + +#------------------------------------------------------------ +# ATxmega32A4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32a4"; + desc = "ATxmega32A4"; + signature = 0x1e 0x95 0x41; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega64A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x64a4u"; + desc = "ATxmega64A4U"; + signature = 0x1e 0x96 0x46; + usbpid = 0x2fe5; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x10000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x80f000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x810000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x11000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega64C3 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64c3"; + desc = "ATxmega64C3"; + signature = 0x1e 0x96 0x49; + usbpid = 0x2fd6; +; + +#------------------------------------------------------------ +# ATxmega64D3 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64d3"; + desc = "ATxmega64D3"; + signature = 0x1e 0x96 0x4a; +; + +#------------------------------------------------------------ +# ATxmega64D4 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64d4"; + desc = "ATxmega64D4"; + signature = 0x1e 0x96 0x47; +; + +#------------------------------------------------------------ +# ATxmega64A1 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64a1"; + desc = "ATxmega64A1"; + signature = 0x1e 0x96 0x4e; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega64A1U +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a1u"; + desc = "ATxmega64A1U"; + signature = 0x1e 0x96 0x4e; + usbpid = 0x2fe8; +; + +#------------------------------------------------------------ +# ATxmega64A3 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a3"; + desc = "ATxmega64A3"; + signature = 0x1e 0x96 0x42; +; + +#------------------------------------------------------------ +# ATxmega64A3U +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a3u"; + desc = "ATxmega64A3U"; + signature = 0x1e 0x96 0x42; + usbpid = 0x2fe5; +; + +#------------------------------------------------------------ +# ATxmega64A4 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a4"; + desc = "ATxmega64A4"; + signature = 0x1e 0x96 0x46; +; + +#------------------------------------------------------------ +# ATxmega64B1 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64b1"; + desc = "ATxmega64B1"; + signature = 0x1e 0x96 0x52; + usbpid = 0x2fe1; +; + +#------------------------------------------------------------ +# ATxmega64B3 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64b3"; + desc = "ATxmega64B3"; + signature = 0x1e 0x96 0x51; + usbpid = 0x2fdf; +; + +#------------------------------------------------------------ +# ATxmega128C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128c3"; + desc = "ATxmega128C3"; + signature = 0x1e 0x97 0x52; + usbpid = 0x2fd7; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x81e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega128D3 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128d3"; + desc = "ATxmega128D3"; + signature = 0x1e 0x97 0x48; +; + +#------------------------------------------------------------ +# ATxmega128D4 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128d4"; + desc = "ATxmega128D4"; + signature = 0x1e 0x97 0x47; +; + +#------------------------------------------------------------ +# ATxmega128A1 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128a1"; + desc = "ATxmega128A1"; + signature = 0x1e 0x97 0x4c; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128A1 revision D +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a1d"; + desc = "ATxmega128A1revD"; + signature = 0x1e 0x97 0x41; +; + +#------------------------------------------------------------ +# ATxmega128A1U +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a1u"; + desc = "ATxmega128A1U"; + signature = 0x1e 0x97 0x4c; + usbpid = 0x2fed; +; + +#------------------------------------------------------------ +# ATxmega128A3 +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a3"; + desc = "ATxmega128A3"; + signature = 0x1e 0x97 0x42; +; + +#------------------------------------------------------------ +# ATxmega128A3U +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a3u"; + desc = "ATxmega128A3U"; + signature = 0x1e 0x97 0x42; + usbpid = 0x2fe6; +; + +#------------------------------------------------------------ +# ATxmega128A4 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128a4"; + desc = "ATxmega128A4"; + signature = 0x1e 0x97 0x46; + has_jtag = yes; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x81f000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128a4u"; + desc = "ATxmega128A4U"; + signature = 0x1e 0x97 0x46; + usbpid = 0x2fde; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x81f000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega128B1 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128b1"; + desc = "ATxmega128B1"; + signature = 0x1e 0x97 0x4d; + usbpid = 0x2fea; + has_jtag = yes; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x81e000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128B3 +#------------------------------------------------------------ + +part parent "x128b1" + id = "x128b3"; + desc = "ATxmega128B3"; + signature = 0x1e 0x97 0x4b; + usbpid = 0x2fe0; +; + +#------------------------------------------------------------ +# ATxmega192C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x192c3"; + desc = "ATxmega192C3"; + signature = 0x1e 0x97 0x51; + # usbpid = 0x2f??; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x30000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x82e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x830000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x32000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega192D3 +#------------------------------------------------------------ + +part parent "x192c3" + id = "x192d3"; + desc = "ATxmega192D3"; + signature = 0x1e 0x97 0x49; +; + +#------------------------------------------------------------ +# ATxmega192A1 +#------------------------------------------------------------ + +part parent "x192c3" + id = "x192a1"; + desc = "ATxmega192A1"; + signature = 0x1e 0x97 0x4e; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega192A3 +#------------------------------------------------------------ + +part parent "x192a1" + id = "x192a3"; + desc = "ATxmega192A3"; + signature = 0x1e 0x97 0x44; +; + +#------------------------------------------------------------ +# ATxmega192A3U +#------------------------------------------------------------ + +part parent "x192a1" + id = "x192a3u"; + desc = "ATxmega192A3U"; + signature = 0x1e 0x97 0x44; + usbpid = 0x2fe7; +; + +#------------------------------------------------------------ +# ATxmega256C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x256c3"; + desc = "ATxmega256C3"; + signature = 0x1e 0x98 0x46; + usbpid = 0x2fda; + + memory "eeprom" + size = 0x1000; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x40000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x83e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x840000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x42000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega256D3 +#------------------------------------------------------------ + +part parent "x256c3" + id = "x256d3"; + desc = "ATxmega256D3"; + signature = 0x1e 0x98 0x44; +; + +#------------------------------------------------------------ +# ATxmega256A1 +#------------------------------------------------------------ + +part parent "x256c3" + id = "x256a1"; + desc = "ATxmega256A1"; + signature = 0x1e 0x98 0x46; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega256A3 +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3"; + desc = "ATxmega256A3"; + signature = 0x1e 0x98 0x42; +; + +#------------------------------------------------------------ +# ATxmega256A3U +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3u"; + desc = "ATxmega256A3U"; + signature = 0x1e 0x98 0x42; + usbpid = 0x2fec; +; + +#------------------------------------------------------------ +# ATxmega256A3B +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3b"; + desc = "ATxmega256A3B"; + signature = 0x1e 0x98 0x43; +; + +#------------------------------------------------------------ +# ATxmega256A3BU +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3bu"; + desc = "ATxmega256A3BU"; + signature = 0x1e 0x98 0x43; + usbpid = 0x2fe2; +; + +#------------------------------------------------------------ +# ATxmega384C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x384c3"; + desc = "ATxmega384C3"; + signature = 0x1e 0x98 0x45; + usbpid = 0x2fdb; + + memory "eeprom" + size = 0x1000; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x60000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x85e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x860000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x62000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega384D3 +#------------------------------------------------------------ + +part parent "x384c3" + id = "x384d3"; + desc = "ATxmega384D3"; + signature = 0x1e 0x98 0x47; +; + +#------------------------------------------------------------ +# ATxmega8E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x8e5"; + desc = "ATxmega8E5"; + signature = 0x1e 0x93 0x41; + + memory "eeprom" + size = 0x0200; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x2000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x800; + offset = 0x00801800; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x800; + offset = 0x00802000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x2800; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega16E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x16e5"; + desc = "ATxmega16E5"; + signature = 0x1e 0x94 0x45; + + memory "eeprom" + size = 0x0200; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x4000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x00803000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x00804000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x5000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega32E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x32e5"; + desc = "ATxmega32E5"; + signature = 0x1e 0x95 0x4c; + + memory "eeprom" + size = 0x0400; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x8000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x00807000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x00808000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x9000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# AVR32UC3A0512 +#------------------------------------------------------------ + +part + id = "uc3a0512"; + desc = "AT32UC3A0512"; + signature = 0xED 0xC0 0x3F; + has_jtag = yes; + is_avr32 = yes; + + memory "flash" + paged = yes; + page_size = 512; # bytes + readsize = 512; # bytes + num_pages = 1024; # could be set dynamicly + size = 0x00080000; # could be set dynamicly + offset = 0x80000000; + ; +; + +part parent "uc3a0512" + id = "ucr2"; + desc = "deprecated, use 'uc3a0512'"; +; + +#------------------------------------------------------------ +# ATtiny1634. +#------------------------------------------------------------ + +part + id = "t1634"; + desc = "ATtiny1634"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x94 0x12; + pagel = 0xB3; + bs2 = 0xB1; + reset = io; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + paged = no; + page_size = 4; + size = 256; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 32; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 1 1 1 1 i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# Common values for reduced core tinys (4/5/9/10/20/40) +#------------------------------------------------------------ + +part + id = ".reduced_core_tiny"; + desc = "Common values for reduced core tinys"; + has_tpi = yes; + + memory "signature" + size = 3; + offset = 0x3fc0; + page_size = 16; + ; + + memory "fuse" + size = 1; + offset = 0x3f40; + page_size = 16; + blocksize = 4; + ; + + memory "calibration" + size = 1; + offset = 0x3f80; + page_size = 16; + ; + + memory "lockbits" + size = 1; + offset = 0x3f00; + page_size = 16; + ; +; + +#------------------------------------------------------------ +# ATtiny4 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t4"; + desc = "ATtiny4"; + signature = 0x1e 0x8f 0x0a; + + memory "flash" + size = 512; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny5 +#------------------------------------------------------------ + +part parent "t4" + id = "t5"; + desc = "ATtiny5"; + signature = 0x1e 0x8f 0x09; +; + +#------------------------------------------------------------ +# ATtiny9 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t9"; + desc = "ATtiny9"; + signature = 0x1e 0x90 0x08; + + memory "flash" + size = 1024; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny10 +#------------------------------------------------------------ + +part parent "t9" + id = "t10"; + desc = "ATtiny10"; + signature = 0x1e 0x90 0x03; +; + +#------------------------------------------------------------ +# ATtiny20 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t20"; + desc = "ATtiny20"; + signature = 0x1e 0x91 0x0F; + + memory "flash" + size = 2048; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny40 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t40"; + desc = "ATtiny40"; + signature = 0x1e 0x92 0x0E; + + memory "flash" + size = 4096; + offset = 0x4000; + page_size = 64; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATmega406 +#------------------------------------------------------------ + +part + id = "m406"; + desc = "ATMEGA406"; + has_jtag = yes; + signature = 0x1e 0x95 0x07; + + # STK500 parameters (parallel programming IO lines) + pagel = 0xa7; + bs2 = 0xa0; + serial = no; + parallel = yes; + + # 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; + + # JTAG ICE mkII parameters, also from XML files + allowfullpagebitstream = no; + enablepageprogramming = yes; + idr = 0x51; + rampz = 0x00; + spmcr = 0x57; + eecr = 0x3f; + + memory "eeprom" + paged = no; + size = 512; + page_size = 4; + blocksize = 4; + readsize = 4; + num_pages = 128; + ; + + memory "flash" + paged = yes; + size = 40960; + page_size = 128; + blocksize = 128; + readsize = 128; + num_pages = 320; + ; + + memory "hfuse" + size = 1; + ; + + memory "lfuse" + size = 1; + ; + + memory "lockbits" + size = 1; + ; + + memory "signature" + size = 3; + ; +; + + diff --git a/xs/src/avrdude/avrdude.conf.in b/xs/src/avrdude/avrdude.conf.in new file mode 100644 index 000000000..b247e5225 --- /dev/null +++ b/xs/src/avrdude/avrdude.conf.in @@ -0,0 +1,14984 @@ +# $Id$ -*- text -*- +# +# AVRDUDE Configuration File +# +# This file contains configuration data used by AVRDUDE which describes +# the programming hardware pinouts and also provides part definitions. +# AVRDUDE's "-C" command line option specifies the location of the +# configuration file. The "-c" option names the programmer configuration +# which must match one of the entry's "id" parameter. The "-p" option +# identifies which part AVRDUDE is going to be programming and must match +# one of the parts' "id" parameter. +# +# DO NOT MODIFY THIS FILE. Modifications will be overwritten the next +# time a "make install" is run. For user-specific additions, use the +# "-C +filename" commandline option. +# +# Possible entry formats are: +# +# programmer +# parent # optional parent +# id = [, [, ] ...] ; # are quoted strings +# desc = ; # quoted string +# type = ; # programmer type, quoted string +# # supported programmer types can be listed by "-c ?type" +# connection_type = parallel | serial | usb +# baudrate = ; # baudrate for avr910-programmer +# vcc = [, ... ] ; # pin number(s) +# buff = [, ... ] ; # pin number(s) +# reset = ; # pin number +# sck = ; # pin number +# mosi = ; # pin number +# miso = ; # pin number +# errled = ; # pin number +# rdyled = ; # pin number +# pgmled = ; # pin number +# vfyled = ; # pin number +# usbvid = ; # USB VID (Vendor ID) +# usbpid = [, ...] # USB PID (Product ID) (1) +# usbdev = ; # USB interface or other device info +# usbvendor = ; # USB Vendor Name +# usbproduct = ; # USB Product Name +# usbsn = ; # USB Serial Number +# +# To invert a bit, use = ~ , the spaces are important. +# For a pin list all pins must be inverted. +# A single pin can be specified as usual = ~ , for lists +# specify it as follows = ~ ( [, ... ] ) . +# +# (1) Not all programmer types can process a list of PIDs. +# ; +# +# part +# id = ; # quoted string +# desc = ; # quoted string +# has_jtag = ; # part has JTAG i/f +# has_debugwire = ; # part has debugWire i/f +# has_pdi = ; # part has PDI i/f +# has_tpi = ; # part has TPI i/f +# devicecode = ; # deprecated, use stk500_devcode +# stk500_devcode = ; # numeric +# avr910_devcode = ; # numeric +# signature = ; # signature bytes +# usbpid = ; # DFU USB PID +# chip_erase_delay = ; # micro-seconds +# reset = dedicated | io; +# retry_pulse = reset | sck; +# pgm_enable = ; +# chip_erase = ; +# chip_erase_delay = ; # chip erase delay (us) +# # STK500 parameters (parallel programming IO lines) +# pagel = ; # pin name in hex, i.e., 0xD7 +# bs2 = ; # pin name in hex, i.e., 0xA0 +# serial = ; # can use serial downloading +# parallel = ; # can use par. programming +# # STK500v2 parameters, to be taken from Atmel's XML files +# timeout = ; +# stabdelay = ; +# cmdexedelay = ; +# synchloops = ; +# bytedelay = ; +# pollvalue = ; +# pollindex = ; +# predelay = ; +# postdelay = ; +# pollmethod = ; +# mode = ; +# delay = ; +# blocksize = ; +# readsize = ; +# hvspcmdexedelay = ; +# # STK500v2 HV programming parameters, from XML +# pp_controlstack = , , ...; # PP only +# hvsp_controlstack = , , ...; # HVSP only +# hventerstabdelay = ; +# progmodedelay = ; # PP only +# latchcycles = ; +# togglevtg = ; +# poweroffdelay = ; +# resetdelayms = ; +# resetdelayus = ; +# hvleavestabdelay = ; +# resetdelay = ; +# synchcycles = ; # HVSP only +# chiperasepulsewidth = ; # PP only +# chiperasepolltimeout = ; +# chiperasetime = ; # HVSP only +# programfusepulsewidth = ; # PP only +# programfusepolltimeout = ; +# programlockpulsewidth = ; # PP only +# programlockpolltimeout = ; +# # JTAG ICE mkII parameters, also from XML files +# allowfullpagebitstream = ; +# enablepageprogramming = ; +# idr = ; # IO addr of IDR (OCD) reg. +# rampz = ; # IO addr of RAMPZ reg. +# spmcr = ; # mem addr of SPMC[S]R reg. +# eecr = ; # mem addr of EECR reg. +# # (only when != 0x3c) +# is_at90s1200 = ; # AT90S1200 part +# is_avr32 = ; # AVR32 part +# +# memory +# paged = ; # yes / no +# size = ; # bytes +# page_size = ; # bytes +# num_pages = ; # numeric +# min_write_delay = ; # micro-seconds +# max_write_delay = ; # micro-seconds +# readback_p1 = ; # byte value +# readback_p2 = ; # byte value +# pwroff_after_write = ; # yes / no +# read = ; +# write = ; +# read_lo = ; +# read_hi = ; +# write_lo = ; +# write_hi = ; +# loadpage_lo = ; +# loadpage_hi = ; +# writepage = ; +# ; +# ; +# +# If any of the above parameters are not specified, the default value +# of 0 is used for numerics or the empty string ("") for string +# values. If a required parameter is left empty, AVRDUDE will +# complain. +# +# Parts can also inherit parameters from previously defined parts +# using the following syntax. In this case specified integer and +# string values override parameter values from the parent part. New +# memory definitions are added to the definitions inherited from the +# parent. +# +# part parent # quoted string +# id = ; # quoted string +# +# ; +# +# NOTES: +# * 'devicecode' is the device code used by the STK500 (see codes +# listed below) +# * Not all memory types will implement all instructions. +# * AVR Fuse bits and Lock bits are implemented as a type of memory. +# * Example memory types are: +# "flash", "eeprom", "fuse", "lfuse" (low fuse), "hfuse" (high +# fuse), "signature", "calibration", "lock" +# * The memory type specified on the avrdude command line must match +# one of the memory types defined for the specified chip. +# * The pwroff_after_write flag causes avrdude to attempt to +# power the device off and back on after an unsuccessful write to +# the affected memory area if VCC programmer pins are defined. If +# VCC pins are not defined for the programmer, a message +# indicating that the device needs a power-cycle is printed out. +# This flag was added to work around a problem with the +# at90s4433/2333's; see the at90s4433 errata at: +# +# http://www.atmel.com/dyn/resources/prod_documents/doc1280.pdf +# +# INSTRUCTION FORMATS +# +# Instruction formats are specified as a comma seperated list of +# string values containing information (bit specifiers) about each +# of the 32 bits of the instruction. Bit specifiers may be one of +# the following formats: +# +# '1' = the bit is always set on input as well as output +# +# '0' = the bit is always clear on input as well as output +# +# 'x' = the bit is ignored on input and output +# +# 'a' = the bit is an address bit, the bit-number matches this bit +# specifier's position within the current instruction byte +# +# 'aN' = the bit is the Nth address bit, bit-number = N, i.e., a12 +# is address bit 12 on input, a0 is address bit 0. +# +# 'i' = the bit is an input data bit +# +# 'o' = the bit is an output data bit +# +# Each instruction must be composed of 32 bit specifiers. The +# instruction specification closely follows the instruction data +# provided in Atmel's data sheets for their parts. +# +# See below for some examples. +# +# +# The following are STK500 part device codes to use for the +# "devicecode" field of the part. These came from Atmel's software +# section avr061.zip which accompanies the application note +# AVR061 available from: +# +# http://www.atmel.com/dyn/resources/prod_documents/doc2525.pdf +# + +#define ATTINY10 0x10 /* the _old_ one that never existed! */ +#define ATTINY11 0x11 +#define ATTINY12 0x12 +#define ATTINY15 0x13 +#define ATTINY13 0x14 + +#define ATTINY22 0x20 +#define ATTINY26 0x21 +#define ATTINY28 0x22 +#define ATTINY2313 0x23 + +#define AT90S1200 0x33 + +#define AT90S2313 0x40 +#define AT90S2323 0x41 +#define AT90S2333 0x42 +#define AT90S2343 0x43 + +#define AT90S4414 0x50 +#define AT90S4433 0x51 +#define AT90S4434 0x52 +#define ATMEGA48 0x59 + +#define AT90S8515 0x60 +#define AT90S8535 0x61 +#define AT90C8534 0x62 +#define ATMEGA8515 0x63 +#define ATMEGA8535 0x64 + +#define ATMEGA8 0x70 +#define ATMEGA88 0x73 +#define ATMEGA168 0x86 + +#define ATMEGA161 0x80 +#define ATMEGA163 0x81 +#define ATMEGA16 0x82 +#define ATMEGA162 0x83 +#define ATMEGA169 0x84 + +#define ATMEGA323 0x90 +#define ATMEGA32 0x91 + +#define ATMEGA64 0xA0 + +#define ATMEGA103 0xB1 +#define ATMEGA128 0xB2 +#define AT90CAN128 0xB3 +#define AT90CAN64 0xB3 +#define AT90CAN32 0xB3 + +#define AT86RF401 0xD0 + +#define AT89START 0xE0 +#define AT89S51 0xE0 +#define AT89S52 0xE1 + +# The following table lists the devices in the original AVR910 +# appnote: +# |Device |Signature | Code | +# +-------+----------+------+ +# |tiny12 | 1E 90 05 | 0x55 | +# |tiny15 | 1E 90 06 | 0x56 | +# | | | | +# | S1200 | 1E 90 01 | 0x13 | +# | | | | +# | S2313 | 1E 91 01 | 0x20 | +# | S2323 | 1E 91 02 | 0x48 | +# | S2333 | 1E 91 05 | 0x34 | +# | S2343 | 1E 91 03 | 0x4C | +# | | | | +# | S4414 | 1E 92 01 | 0x28 | +# | S4433 | 1E 92 03 | 0x30 | +# | S4434 | 1E 92 02 | 0x6C | +# | | | | +# | S8515 | 1E 93 01 | 0x38 | +# | S8535 | 1E 93 03 | 0x68 | +# | | | | +# |mega32 | 1E 95 01 | 0x72 | +# |mega83 | 1E 93 05 | 0x65 | +# |mega103| 1E 97 01 | 0x41 | +# |mega161| 1E 94 01 | 0x60 | +# |mega163| 1E 94 02 | 0x64 | + +# Appnote AVR109 also has a table of AVR910 device codes, which +# lists: +# dev avr910 signature +# ATmega8 0x77 0x1E 0x93 0x07 +# ATmega8515 0x3B 0x1E 0x93 0x06 +# ATmega8535 0x6A 0x1E 0x93 0x08 +# ATmega16 0x75 0x1E 0x94 0x03 +# ATmega162 0x63 0x1E 0x94 0x04 +# ATmega163 0x66 0x1E 0x94 0x02 +# ATmega169 0x79 0x1E 0x94 0x05 +# ATmega32 0x7F 0x1E 0x95 0x02 +# ATmega323 0x73 0x1E 0x95 0x01 +# ATmega64 0x46 0x1E 0x96 0x02 +# ATmega128 0x44 0x1E 0x97 0x02 +# +# These codes refer to "BOOT" device codes which are apparently +# different than standard device codes, for whatever reasons +# (often one above the standard code). + +# There are several extended versions of AVR910 implementations around +# in the Internet. These add the following codes (only devices that +# actually exist are listed): + +# ATmega8515 0x3A +# ATmega128 0x43 +# ATmega64 0x45 +# ATtiny26 0x5E +# ATmega8535 0x69 +# ATmega32 0x72 +# ATmega16 0x74 +# ATmega8 0x76 +# ATmega169 0x78 + +# +# Overall avrdude defaults; suitable for ~/.avrduderc +# +default_parallel = "@DEFAULT_PAR_PORT@"; +default_serial = "@DEFAULT_SER_PORT@"; +# default_bitclock = 2.5; + +# Turn off safemode by default +#default_safemode = no; + + +# +# PROGRAMMER DEFINITIONS +# + +# http://wiring.org.co/ +# Basically STK500v2 protocol, with some glue to trigger the +# bootloader. +programmer + id = "wiring"; + desc = "Wiring"; + type = "wiring"; + connection_type = serial; +; + +programmer + id = "arduino"; + desc = "Arduino"; + type = "arduino"; + connection_type = serial; +; +# this will interface with the chips on these programmers: +# +# http://real.kiev.ua/old/avreal/en/adapters +# http://www.amontec.com/jtagkey.shtml, jtagkey-tiny.shtml +# http://www.olimex.com/dev/arm-usb-ocd.html, arm-usb-tiny.html +# http://www.ethernut.de/en/hardware/turtelizer/index.html +# http://elk.informatik.fh-augsburg.de/hhweb/doc/openocd/usbjtag/usbjtag.html +# http://dangerousprototypes.com/docs/FT2232_breakout_board +# http://www.ftdichip.com/Products/Modules/DLPModules.htm,DLP-2232*,DLP-USB1232H +# http://flashrom.org/FT2232SPI_Programmer +# +# The drivers will look for a specific device and use the first one found. +# If you have mulitple devices, then look for unique information (like SN) +# And fill that in here. +# +# Note that the pin numbers for the main ISP signals (reset, sck, +# mosi, miso) are fixed and cannot be changed, since they must match +# the way the Multi-Protocol Synchronous Serial Engine (MPSSE) of +# these FTDI ICs has been designed. + +programmer + id = "avrftdi"; + desc = "FT2232D based generic programmer"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; + usbpid = 0x6010; + usbvendor = ""; + usbproduct = ""; + usbdev = "A"; + usbsn = ""; +#ISP-signals - lower ADBUS-Nibble (default) + reset = 3; + sck = 0; + mosi = 1; + miso = 2; +#LED SIGNALs - higher ADBUS-Nibble +# errled = 4; +# rdyled = 5; +# pgmled = 6; +# vfyled = 7; +#Buffer Signal - ACBUS - Nibble +# buff = 8; +; +# This is an implementation of the above with a buffer IC (74AC244) and +# 4 LEDs directly attached, all active low. +programmer + id = "2232HIO"; + desc = "FT2232H based generic programmer"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; +# Note: This PID is reserved for generic H devices and +# should be programmed into the EEPROM +# usbpid = 0x8A48; + usbpid = 0x6010; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals + reset = 3; + sck = 0; + mosi = 1; + miso = 2; + buff = ~4; +#LED SIGNALs + errled = ~ 11; + rdyled = ~ 14; + pgmled = ~ 13; + vfyled = ~ 12; +; + +#The FT4232H can be treated as FT2232H, but it has a different USB +#device ID of 0x6011. +programmer parent "avrftdi" + id = "4232h"; + desc = "FT4232H based generic programmer"; + usbpid = 0x6011; +; + +programmer + id = "jtagkey"; + desc = "Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; +# Note: This PID is used in all JTAGKey variants + usbpid = 0xCFF8; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals => 20 - Pin connector on JTAGKey + reset = 3; # TMS 7 violet + sck = 0; # TCK 9 white + mosi = 1; # TDI 5 green + miso = 2; # TDO 13 orange + buff = ~4; +# VTG VREF 1 brown with red tip +# GND GND 20 black +# The colors are on the 20 pin breakout cable +# from Amontec +; + +# UM232H module from FTDI and Glyn.com.au. +# See helix.air.net.au for detailed usage information. +# J1: Connect pin 2 and 3 for USB power. +# J2: Connect pin 2 and 3 for USB power. +# J2: Pin 7 is SCK +# : Pin 8 is MOSI +# : Pin 9 is MISO +# : Pin 11 is RST +# : Pin 6 is ground +# Use the -b flag to set the SPI clock rate eg -b 3750000 is the fastest I could get +# a 16MHz Atmega1280 to program reliably. The 232H is conveniently 5V tolerant. +programmer + id = "UM232H"; + desc = "FT232H based module from FTDI and Glyn.com.au"; + type = "avrftdi"; + usbvid = 0x0403; +# Note: This PID is reserved for generic 232H devices and +# should be programmed into the EEPROM + usbpid = 0x6014; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals + sck = 0; + mosi = 1; + miso = 2; + reset = 3; +; + +# C232HM module from FTDI and Glyn.com.au. +# : Orange is SCK +# : Yellow is MOSI +# : Green is MISO +# : Brown is RST +# : Black is ground +# Use the -b flag to set the SPI clock rate eg -b 3750000 is the fastest I could get +# a 16MHz Atmega1280 to program reliably. The 232H is conveniently 5V tolerant. +programmer + id = "C232HM"; + desc = "FT232H based module from FTDI and Glyn.com.au"; + type = "avrftdi"; + usbvid = 0x0403; +# Note: This PID is reserved for generic 232H devices and +# should be programmed into the EEPROM + usbpid = 0x6014; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals + sck = 0; + mosi = 1; + miso = 2; + reset = 3; +; + + +# On the adapter you can read "O-Link". On the PCB is printed "OpenJTAG v3.1" +# You can find it as "OpenJTAG ARM JTAG USB" in the internet. +# (But there are also several projects called Open JTAG, eg. +# http://www.openjtag.org, which are completely different.) +# http://www.100ask.net/shop/english.html (website seems to be outdated) +# http://item.taobao.com/item.htm?id=1559277013 +# http://www.micro4you.com/store/openjtag-arm-jtag-usb.html (schematics!) +# some other sources which call it O-Link +# http://www.andahammer.com/olink/ +# http://www.developmentboard.net/31-o-link-debugger.html +# http://armwerks.com/catalog/o-link-debugger-copy/ +# or just have a look at ebay ... +# It is basically the same entry as jtagkey with different usb ids. +programmer parent "jtagkey" + id = "o-link"; + desc = "O-Link, OpenJTAG from www.100ask.net"; + usbvid = 0x1457; + usbpid = 0x5118; + usbvendor = "www.100ask.net"; + usbproduct = "USB<=>JTAG&RS232"; +; + +# http://wiki.openmoko.org/wiki/Debug_Board_v3 +programmer + id = "openmoko"; + desc = "Openmoko debug board (v3)"; + type = "avrftdi"; + usbvid = 0x1457; + usbpid = 0x5118; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; + reset = 3; # TMS 7 + sck = 0; # TCK 9 + mosi = 1; # TDI 5 + miso = 2; # TDO 13 +; + +# Only Rev. A boards. +# Schematic and user manual: http://www.cs.put.poznan.pl/wswitala/download/pdf/811EVBK.pdf +programmer + id = "lm3s811"; + desc = "Luminary Micro LM3S811 Eval Board (Rev. A)"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; + usbpid = 0xbcd9; + usbvendor = "LMI"; + usbproduct = "LM3S811 Evaluation Board"; + usbdev = "A"; + usbsn = ""; +#ISP-signals - lower ACBUS-Nibble (default) + reset = 3; + sck = 0; + mosi = 1; + miso = 2; +# Enable correct buffers + buff = 7; +; + +# submitted as bug #46020 +programmer + id = "tumpa"; + desc = "TIAO USB Multi-Protocol Adapter"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; + usbpid = 0x8A98; + usbdev = "A"; + usbvendor = "TIAO"; + usbproduct = ""; + usbsn = ""; + sck = 0; # TCK 9 + mosi = 1; # TDI 5 + miso = 2; # TDO 13 + reset = 3; # TMS 7 +; + +programmer + id = "avrisp"; + desc = "Atmel AVR ISP"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "avrispv2"; + desc = "Atmel AVR ISP V2"; + type = "stk500v2"; + connection_type = serial; +; + +programmer + id = "avrispmkII"; + desc = "Atmel AVR ISP mkII"; + type = "stk500v2"; + connection_type = usb; +; + +programmer parent "avrispmkII" + id = "avrisp2"; +; + +programmer + id = "buspirate"; + desc = "The Bus Pirate"; + type = "buspirate"; + connection_type = serial; +; + +programmer + id = "buspirate_bb"; + desc = "The Bus Pirate (bitbang interface, supports TPI)"; + type = "buspirate_bb"; + connection_type = serial; + # pins are bits in bitbang byte (numbers are 87654321) + # 1|POWER|PULLUP|AUX|MOSI|CLK|MISO|CS + reset = 1; + sck = 3; + mosi = 4; + miso = 2; + #vcc = 7; This is internally set independent of this setting. +; + +# This is supposed to be the "default" STK500 entry. +# Attempts to select the correct firmware version +# by probing for it. Better use one of the entries +# below instead. +programmer + id = "stk500"; + desc = "Atmel STK500"; + type = "stk500generic"; + connection_type = serial; +; + +programmer + id = "stk500v1"; + desc = "Atmel STK500 Version 1.x firmware"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "mib510"; + desc = "Crossbow MIB510 programming board"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "stk500v2"; + desc = "Atmel STK500 Version 2.x firmware"; + type = "stk500v2"; + connection_type = serial; +; + +programmer + id = "stk500pp"; + desc = "Atmel STK500 V2 in parallel programming mode"; + type = "stk500pp"; + connection_type = serial; +; + +programmer + id = "stk500hvsp"; + desc = "Atmel STK500 V2 in high-voltage serial programming mode"; + type = "stk500hvsp"; + connection_type = serial; +; + +programmer + id = "stk600"; + desc = "Atmel STK600"; + type = "stk600"; + connection_type = usb; +; + +programmer + id = "stk600pp"; + desc = "Atmel STK600 in parallel programming mode"; + type = "stk600pp"; + connection_type = usb; +; + +programmer + id = "stk600hvsp"; + desc = "Atmel STK600 in high-voltage serial programming mode"; + type = "stk600hvsp"; + connection_type = usb; +; + +programmer + id = "avr910"; + desc = "Atmel Low Cost Serial Programmer"; + type = "avr910"; + connection_type = serial; +; + +programmer + id = "ft245r"; + desc = "FT245R Synchronous BitBang"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 1; # D1 + sck = 0; # D0 + mosi = 2; # D2 + reset = 4; # D4 +; + +programmer + id = "ft232r"; + desc = "FT232R Synchronous BitBang"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 1; # RxD + sck = 0; # TxD + mosi = 2; # RTS + reset = 4; # DTR +; + +# see http://www.bitwizard.nl/wiki/index.php/FTDI_ATmega +programmer + id = "bwmega"; + desc = "BitWizard ftdi_atmega builtin programmer"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 5; # DSR + sck = 6; # DCD + mosi = 3; # CTS + reset = 7; # RI +; + +# see http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html +# Note: pins are numbered from 1! +programmer + id = "arduino-ft232r"; + desc = "Arduino: FT232R connected to ISP"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 3; # CTS X3(1) + sck = 5; # DSR X3(2) + mosi = 6; # DCD X3(3) + reset = 7; # RI X3(4) +; + +# website mentioned above uses this id +programmer parent "arduino-ft232r" + id = "diecimila"; + desc = "alias for arduino-ft232r"; +; + +# There is a ATmega328P kit PCB called "uncompatino". +# This board allows ISP via its on-board FT232R. +# This is designed like Arduino Duemilanove but has no standard ICPS header. +# Its 4 pairs of pins are shorted to enable ftdi_syncbb. +# http://akizukidenshi.com/catalog/g/gP-07487/ +# http://akizukidenshi.com/download/ds/akizuki/k6096_manual_20130816.pdf +programmer + id = "uncompatino"; + desc = "uncompatino with all pairs of pins shorted"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 3; # cts + sck = 5; # dsr + mosi = 6; # dcd + reset = 7; # ri +; + +# FTDI USB to serial cable TTL-232R-5V with a custom adapter for ICSP +# http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm +# http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232R_CABLES.pdf +# For ICSP pinout see for example http://www.atmel.com/images/doc2562.pdf +# (Figure 1. ISP6PIN header pinout and Table 1. Connections required for ISP ...) +# TTL-232R GND 1 Black -> ICPS GND (pin 6) +# TTL-232R CTS 2 Brown -> ICPS MOSI (pin 4) +# TTL-232R VCC 3 Red -> ICPS VCC (pin 2) +# TTL-232R TXD 4 Orange -> ICPS RESET (pin 5) +# TTL-232R RXD 5 Yellow -> ICPS SCK (pin 3) +# TTL-232R RTS 6 Green -> ICPS MISO (pin 1) +# Except for VCC and GND, you can connect arbitual pairs as long as +# the following table is adjusted. +programmer + id = "ttl232r"; + desc = "FTDI TTL232R-5V with ICSP adapter"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 2; # rts + sck = 1; # rxd + mosi = 3; # cts + reset = 0; # txd +; + +programmer + id = "usbasp"; + desc = "USBasp, http://www.fischl.de/usbasp/"; + type = "usbasp"; + connection_type = usb; + usbvid = 0x16C0; # VOTI + usbpid = 0x05DC; # Obdev's free shared PID + usbvendor = "www.fischl.de"; + usbproduct = "USBasp"; + + # following variants are autodetected for id "usbasp" + + # original usbasp from fischl.de + # see above "usbasp" + + # old usbasp from fischl.de + #usbvid = 0x03EB; # ATMEL + #usbpid = 0xC7B4; # (unoffical) USBasp + #usbvendor = "www.fischl.de"; + #usbproduct = "USBasp"; + + # NIBObee (only if -P nibobee is given on command line) + # see below "nibobee" +; + +programmer + id = "nibobee"; + desc = "NIBObee"; + type = "usbasp"; + connection_type = usb; + usbvid = 0x16C0; # VOTI + usbpid = 0x092F; # NIBObee PID + usbvendor = "www.nicai-systems.com"; + usbproduct = "NIBObee"; +; + +programmer + id = "usbasp-clone"; + desc = "Any usbasp clone with correct VID/PID"; + type = "usbasp"; + connection_type = usb; + usbvid = 0x16C0; # VOTI + usbpid = 0x05DC; # Obdev's free shared PID + #usbvendor = ""; + #usbproduct = ""; +; + +programmer + id = "usbtiny"; + desc = "USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/"; + type = "usbtiny"; + connection_type = usb; + usbvid = 0x1781; + usbpid = 0x0c9f; +; + +# commercial version of USBtiny, using a separate VID/PID +programmer + id = "ehajo-isp"; + desc = "avr-isp-programmer from eHaJo, http://www.eHaJo.de"; + type = "usbtiny"; + connection_type = usb; + usbvid = 0x16D0; + usbpid = 0x0BA5; +; + +programmer + id = "butterfly"; + desc = "Atmel Butterfly Development Board"; + type = "butterfly"; + connection_type = serial; +; + +programmer + id = "avr109"; + desc = "Atmel AppNote AVR109 Boot Loader"; + type = "butterfly"; + connection_type = serial; +; + +programmer + id = "avr911"; + desc = "Atmel AppNote AVR911 AVROSP"; + type = "butterfly"; + connection_type = serial; +; + +# suggested in http://forum.mikrokopter.de/topic-post48317.html +programmer + id = "mkbutterfly"; + desc = "Mikrokopter.de Butterfly"; + type = "butterfly_mk"; + connection_type = serial; +; + +programmer parent "mkbutterfly" + id = "butterfly_mk"; +; + +programmer + id = "jtagmkI"; + desc = "Atmel JTAG ICE (mkI)"; + baudrate = 115200; # default is 115200 + type = "jtagmki"; + connection_type = serial; +; + +# easier to type +programmer parent "jtagmkI" + id = "jtag1"; +; + +# easier to type +programmer parent "jtag1" + id = "jtag1slow"; + baudrate = 19200; +; + +# The JTAG ICE mkII has both, serial and USB connectivity. As it is +# mostly used through USB these days (AVR Studio 5 only supporting it +# that way), we make connection_type = usb the default. Users are +# still free to use a serial port with the -P option. + +programmer + id = "jtagmkII"; + desc = "Atmel JTAG ICE mkII"; + baudrate = 19200; # default is 19200 + type = "jtagmkii"; + connection_type = usb; +; + +# easier to type +programmer parent "jtagmkII" + id = "jtag2slow"; +; + +# JTAG ICE mkII @ 115200 Bd +programmer parent "jtag2slow" + id = "jtag2fast"; + baudrate = 115200; +; + +# make the fast one the default, people will love that +programmer parent "jtag2fast" + id = "jtag2"; +; + +# JTAG ICE mkII in ISP mode +programmer + id = "jtag2isp"; + desc = "Atmel JTAG ICE mkII in ISP mode"; + baudrate = 115200; + type = "jtagmkii_isp"; + connection_type = usb; +; + +# JTAG ICE mkII in debugWire mode +programmer + id = "jtag2dw"; + desc = "Atmel JTAG ICE mkII in debugWire mode"; + baudrate = 115200; + type = "jtagmkii_dw"; + connection_type = usb; +; + +# JTAG ICE mkII in AVR32 mode +programmer + id = "jtagmkII_avr32"; + desc = "Atmel JTAG ICE mkII im AVR32 mode"; + baudrate = 115200; + type = "jtagmkii_avr32"; + connection_type = usb; +; + +# JTAG ICE mkII in AVR32 mode +programmer + id = "jtag2avr32"; + desc = "Atmel JTAG ICE mkII im AVR32 mode"; + baudrate = 115200; + type = "jtagmkii_avr32"; + connection_type = usb; +; + +# JTAG ICE mkII in PDI mode +programmer + id = "jtag2pdi"; + desc = "Atmel JTAG ICE mkII PDI mode"; + baudrate = 115200; + type = "jtagmkii_pdi"; + connection_type = usb; +; + +# AVR Dragon in JTAG mode +programmer + id = "dragon_jtag"; + desc = "Atmel AVR Dragon in JTAG mode"; + baudrate = 115200; + type = "dragon_jtag"; + connection_type = usb; +; + +# AVR Dragon in ISP mode +programmer + id = "dragon_isp"; + desc = "Atmel AVR Dragon in ISP mode"; + baudrate = 115200; + type = "dragon_isp"; + connection_type = usb; +; + +# AVR Dragon in PP mode +programmer + id = "dragon_pp"; + desc = "Atmel AVR Dragon in PP mode"; + baudrate = 115200; + type = "dragon_pp"; + connection_type = usb; +; + +# AVR Dragon in HVSP mode +programmer + id = "dragon_hvsp"; + desc = "Atmel AVR Dragon in HVSP mode"; + baudrate = 115200; + type = "dragon_hvsp"; + connection_type = usb; +; + +# AVR Dragon in debugWire mode +programmer + id = "dragon_dw"; + desc = "Atmel AVR Dragon in debugWire mode"; + baudrate = 115200; + type = "dragon_dw"; + connection_type = usb; +; + +# AVR Dragon in PDI mode +programmer + id = "dragon_pdi"; + desc = "Atmel AVR Dragon in PDI mode"; + baudrate = 115200; + type = "dragon_pdi"; + connection_type = usb; +; + +programmer + id = "jtag3"; + desc = "Atmel AVR JTAGICE3 in JTAG mode"; + type = "jtagice3"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "jtag3pdi"; + desc = "Atmel AVR JTAGICE3 in PDI mode"; + type = "jtagice3_pdi"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "jtag3dw"; + desc = "Atmel AVR JTAGICE3 in debugWIRE mode"; + type = "jtagice3_dw"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "jtag3isp"; + desc = "Atmel AVR JTAGICE3 in ISP mode"; + type = "jtagice3_isp"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "xplainedpro"; + desc = "Atmel AVR XplainedPro in JTAG mode"; + type = "jtagice3"; + connection_type = usb; + usbpid = 0x2111; +; + +programmer + id = "xplainedmini"; + desc = "Atmel AVR XplainedMini in ISP mode"; + type = "jtagice3_isp"; + connection_type = usb; + usbpid = 0x2145; +; + +programmer + id = "xplainedmini_dw"; + desc = "Atmel AVR XplainedMini in debugWIRE mode"; + type = "jtagice3_dw"; + connection_type = usb; + usbpid = 0x2145; +; + +programmer + id = "atmelice"; + desc = "Atmel-ICE (ARM/AVR) in JTAG mode"; + type = "jtagice3"; + connection_type = usb; + usbpid = 0x2141; +; + +programmer + id = "atmelice_pdi"; + desc = "Atmel-ICE (ARM/AVR) in PDI mode"; + type = "jtagice3_pdi"; + connection_type = usb; + usbpid = 0x2141; +; + +programmer + id = "atmelice_dw"; + desc = "Atmel-ICE (ARM/AVR) in debugWIRE mode"; + type = "jtagice3_dw"; + connection_type = usb; + usbpid = 0x2141; +; + +programmer + id = "atmelice_isp"; + desc = "Atmel-ICE (ARM/AVR) in ISP mode"; + type = "jtagice3_isp"; + connection_type = usb; + usbpid = 0x2141; +; + + +programmer + id = "pavr"; + desc = "Jason Kyle's pAVR Serial Programmer"; + type = "avr910"; + connection_type = serial; +; + +programmer + id = "pickit2"; + desc = "MicroChip's PICkit2 Programmer"; + type = "pickit2"; + connection_type = usb; +; + +programmer + id = "flip1"; + desc = "FLIP USB DFU protocol version 1 (doc7618)"; + type = "flip1"; + connection_type = usb; +; + +programmer + id = "flip2"; + desc = "FLIP USB DFU protocol version 2 (AVR4023)"; + type = "flip2"; + connection_type = usb; +; + +@HAVE_PARPORT_BEGIN@ Inclusion of the following depends on --enable-parport +# Parallel port programmers. + +programmer + id = "bsd"; + desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/"; + type = "par"; + connection_type = parallel; + vcc = 2, 3, 4, 5; + reset = 7; + sck = 8; + mosi = 9; + miso = 10; +; + +programmer + id = "stk200"; + desc = "STK200"; + type = "par"; + connection_type = parallel; + buff = 4, 5; + sck = 6; + mosi = 7; + reset = 9; + miso = 10; +; + +# The programming dongle used by the popular Ponyprog +# utility. It is almost similar to the STK200 one, +# except that there is a LED indicating that the +# programming is currently in progress. + +programmer parent "stk200" + id = "pony-stk200"; + desc = "Pony Prog STK200"; + pgmled = 8; +; + +programmer + id = "dt006"; + desc = "Dontronics DT006"; + type = "par"; + connection_type = parallel; + reset = 4; + sck = 5; + mosi = 2; + miso = 11; +; + +programmer parent "dt006" + id = "bascom"; + desc = "Bascom SAMPLE programming cable"; +; + +programmer + id = "alf"; + desc = "Nightshade ALF-PgmAVR, http://nightshade.homeip.net/"; + type = "par"; + connection_type = parallel; + vcc = 2, 3, 4, 5; + buff = 6; + reset = 7; + sck = 8; + mosi = 9; + miso = 10; + errled = 1; + rdyled = 14; + pgmled = 16; + vfyled = 17; +; + +programmer + id = "sp12"; + desc = "Steve Bolt's Programmer"; + type = "par"; + connection_type = parallel; + vcc = 4,5,6,7,8; + reset = 3; + sck = 2; + mosi = 9; + miso = 11; +; + +programmer + id = "picoweb"; + desc = "Picoweb Programming Cable, http://www.picoweb.net/"; + type = "par"; + connection_type = parallel; + reset = 2; + sck = 3; + mosi = 4; + miso = 13; +; + +programmer + id = "abcmini"; + desc = "ABCmini Board, aka Dick Smith HOTCHIP"; + type = "par"; + connection_type = parallel; + reset = 4; + sck = 3; + mosi = 2; + miso = 10; +; + +programmer + id = "futurlec"; + desc = "Futurlec.com programming cable."; + type = "par"; + connection_type = parallel; + reset = 3; + sck = 2; + mosi = 1; + miso = 10; +; + + +# From the contributor of the "xil" jtag cable: +# The "vcc" definition isn't really vcc (the cable gets its power from +# the programming circuit) but is necessary to switch one of the +# buffer lines (trying to add it to the "buff" lines doesn't work in +# avrdude versions before 5.5j). +# With this, TMS connects to RESET, TDI to MOSI, TDO to MISO and TCK +# to SCK (plus vcc/gnd of course) +programmer + id = "xil"; + desc = "Xilinx JTAG cable"; + type = "par"; + connection_type = parallel; + mosi = 2; + sck = 3; + reset = 4; + buff = 5; + miso = 13; + vcc = 6; +; + + +programmer + id = "dapa"; + desc = "Direct AVR Parallel Access cable"; + type = "par"; + connection_type = parallel; + vcc = 3; + reset = 16; + sck = 1; + mosi = 2; + miso = 11; +; + +programmer + id = "atisp"; + desc = "AT-ISP V1.1 programming cable for AVR-SDK1 from micro-research.co.th"; + type = "par"; + connection_type = parallel; + reset = ~6; + sck = ~8; + mosi = ~7; + miso = ~10; +; + +programmer + id = "ere-isp-avr"; + desc = "ERE ISP-AVR "; + type = "par"; + connection_type = parallel; + reset = ~4; + sck = 3; + mosi = 2; + miso = 10; +; + +programmer + id = "blaster"; + desc = "Altera ByteBlaster"; + type = "par"; + connection_type = parallel; + sck = 2; + miso = 11; + reset = 3; + mosi = 8; + buff = 14; +; + +# It is almost same as pony-stk200, except vcc on pin 5 to auto +# disconnect port (download on http://electropol.free.fr/spip/spip.php?article27) +programmer parent "pony-stk200" + id = "frank-stk200"; + desc = "Frank STK200"; + buff = ; # delete buff pin assignment + vcc = 5; +; + +# The AT98ISP Cable is a simple parallel dongle for AT89 family. +# http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2877 +programmer + id = "89isp"; + desc = "Atmel at89isp cable"; + type = "par"; + connection_type = parallel; + reset = 17; + sck = 1; + mosi = 2; + miso = 10; +; + +@HAVE_PARPORT_END@ + +#This programmer bitbangs GPIO lines using the Linux sysfs GPIO interface +# +#To enable it set the configuration below to match the GPIO lines connected to the +#relevant ISP header pins and uncomment the entry definition. In case you don't +#have the required permissions to edit this system wide config file put the +#entry in a separate .conf file and use it with -C+.conf +#on the command line. +# +#To check if your avrdude build has support for the linuxgpio programmer compiled in, +#use -c?type on the command line and look for linuxgpio in the list. If it's not available +#you need pass the --enable-linuxgpio=yes option to configure and recompile avrdude. +# +#programmer +# id = "linuxgpio"; +# desc = "Use the Linux sysfs interface to bitbang GPIO lines"; +# type = "linuxgpio"; +# reset = ?; +# sck = ?; +# mosi = ?; +# miso = ?; +#; + +# some ultra cheap programmers use bitbanging on the +# serialport. +# +# PC - DB9 - Pins for RS232: +# +# GND 5 -- |O +# | O| <- 9 RI +# DTR 4 <- |O | +# | O| <- 8 CTS +# TXD 3 <- |O | +# | O| -> 7 RTS +# RXD 2 -> |O | +# | O| <- 6 DSR +# DCD 1 -> |O +# +# Using RXD is currently not supported. +# Using RI is not supported under Win32 but is supported under Posix. + +# serial ponyprog design (dasa2 in uisp) +# reset=!txd sck=rts mosi=dtr miso=cts + +programmer + id = "ponyser"; + desc = "design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts"; + type = "serbb"; + connection_type = serial; + reset = ~3; + sck = 7; + mosi = 4; + miso = 8; +; + +# Same as above, different name +# reset=!txd sck=rts mosi=dtr miso=cts + +programmer parent "ponyser" + id = "siprog"; + desc = "Lancos SI-Prog "; +; + +# unknown (dasa in uisp) +# reset=rts sck=dtr mosi=txd miso=cts + +programmer + id = "dasa"; + desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts"; + type = "serbb"; + connection_type = serial; + reset = 7; + sck = 4; + mosi = 3; + miso = 8; +; + +# unknown (dasa3 in uisp) +# reset=!dtr sck=rts mosi=txd miso=cts + +programmer + id = "dasa3"; + desc = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts"; + type = "serbb"; + connection_type = serial; + reset = ~4; + sck = 7; + mosi = 3; + miso = 8; +; + +# C2N232i (jumper configuration "auto") +# reset=dtr sck=!rts mosi=!txd miso=!cts + +programmer + id = "c2n232i"; + desc = "serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts"; + type = "serbb"; + connection_type = serial; + reset = 4; + sck = ~7; + mosi = ~3; + miso = ~8; +; + +# +# PART DEFINITIONS +# + +#------------------------------------------------------------ +# ATtiny11 +#------------------------------------------------------------ + +# This is an HVSP-only device. + +part + id = "t11"; + desc = "ATtiny11"; + stk500_devcode = 0x11; + signature = 0x1e 0x90 0x04; + chip_erase_delay = 20000; + + timeout = 200; + 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; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + blocksize = 64; + readsize = 256; + delay = 5; + ; + + memory "flash" + size = 1024; + blocksize = 128; + readsize = 256; + delay = 3; + ; + + memory "signature" + size = 3; + ; + + memory "lock" + size = 1; + ; + + memory "calibration" + size = 1; + ; + + memory "fuse" + size = 1; + ; +; + +#------------------------------------------------------------ +# ATtiny12 +#------------------------------------------------------------ + +part + id = "t12"; + desc = "ATtiny12"; + stk500_devcode = 0x12; + avr910_devcode = 0x55; + signature = 0x1e 0x90 0x05; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 8; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + size = 1024; + min_write_delay = 4500; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; +; + +#------------------------------------------------------------ +# ATtiny13 +#------------------------------------------------------------ + +part + id = "t13"; + desc = "ATtiny13"; + has_debugwire = yes; + flash_instr = 0xB4, 0x0E, 0x1E; + eeprom_instr = 0xBB, 0xFE, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, + 0xBC, 0x0E, 0xB4, 0x0E, 0xBA, 0x0D, 0xBB, 0xBC, + 0x99, 0xE1, 0xBB, 0xAC; + stk500_devcode = 0x14; + signature = 0x1e 0x90 0x07; + chip_erase_delay = 4000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 90; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 0; + + memory "eeprom" + size = 64; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 1024; + page_size = 32; + num_pages = 32; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny15 +#------------------------------------------------------------ + +part + id = "t15"; + desc = "ATtiny15"; + stk500_devcode = 0x13; + avr910_devcode = 0x56; + signature = 0x1e 0x90 0x06; + chip_erase_delay = 8200; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 5; + synchcycles = 6; + latchcycles = 16; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + min_write_delay = 8200; + max_write_delay = 8200; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + size = 1024; + min_write_delay = 4100; + max_write_delay = 4100; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x o o o o x x o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x i i i i 1 1 i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; +; + +#------------------------------------------------------------ +# AT90s1200 +#------------------------------------------------------------ + +part + id = "1200"; + desc = "AT90S1200"; + is_at90s1200 = yes; + stk500_devcode = 0x33; + avr910_devcode = 0x13; + signature = 0x1e 0x90 0x01; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 1; + bytedelay = 0; + pollindex = 0; + pollvalue = 0xFF; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 64; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 32; + readsize = 256; + ; + memory "flash" + size = 1024; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x02; + delay = 15; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s4414 +#------------------------------------------------------------ + +part + id = "4414"; + desc = "AT90S4414"; + stk500_devcode = 0x50; + avr910_devcode = 0x28; + signature = 0x1e 0x92 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s2313 +#------------------------------------------------------------ + +part + id = "2313"; + desc = "AT90S2313"; + stk500_devcode = 0x40; + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 128; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 2048; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x i i x", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s2333 +#------------------------------------------------------------ + +part + id = "2333"; +##### WARNING: No XML file for device 'AT90S2333'! ##### + desc = "AT90S2333"; + stk500_devcode = 0x42; + avr910_devcode = 0x34; + signature = 0x1e 0x91 0x05; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + pwroff_after_write = yes; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + + +#------------------------------------------------------------ +# AT90s2343 (also AT90s2323 and ATtiny22) +#------------------------------------------------------------ + +part + id = "2343"; + desc = "AT90S2343"; + stk500_devcode = 0x43; + avr910_devcode = 0x4c; + signature = 0x1e 0x91 0x03; + chip_erase_delay = 18000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 0; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 128; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + 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 o o o x x x x o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 o o o x x x x o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + + +#------------------------------------------------------------ +# AT90s4433 +#------------------------------------------------------------ + +part + id = "4433"; + desc = "AT90S4433"; + stk500_devcode = 0x51; + avr910_devcode = 0x30; + signature = 0x1e 0x92 0x03; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + pwroff_after_write = yes; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s4434 +#------------------------------------------------------------ + +part + id = "4434"; +##### WARNING: No XML file for device 'AT90S4434'! ##### + desc = "AT90S4434"; + stk500_devcode = 0x52; + avr910_devcode = 0x6c; + signature = 0x1e 0x92 0x02; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s8515 +#------------------------------------------------------------ + +part + id = "8515"; + desc = "AT90S8515"; + stk500_devcode = 0x60; + avr910_devcode = 0x38; + signature = 0x1e 0x93 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 512; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 8192; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s8535 +#------------------------------------------------------------ + +part + id = "8535"; + desc = "AT90S8535"; + stk500_devcode = 0x61; + avr910_devcode = 0x68; + signature = 0x1e 0x93 0x03; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 8192; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + 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 x x x x x x x o"; + write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + memory "lock" + size = 1; + 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 o o x x x x x x"; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# ATmega103 +#------------------------------------------------------------ + +part + id = "m103"; + desc = "ATmega103"; + stk500_devcode = 0xB1; + avr910_devcode = 0x41; + signature = 0x1e 0x97 0x01; + chip_erase_delay = 112000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + pp_controlstack = + 0x0E, 0x1E, 0x8E, 0x9E, 0x2E, 0x3E, 0xAE, 0xBE, + 0x4E, 0x5E, 0xCE, 0xDE, 0x6E, 0x7E, 0xEE, 0xDE, + 0x66, 0x76, 0xE6, 0xF6, 0x6A, 0x7A, 0xEA, 0x7A, + 0x7F, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 10; + + memory "eeprom" + size = 4096; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 22000; + max_write_delay = 56000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x11; + delay = 70; + blocksize = 256; + readsize = 256; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o x o 1 o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 1 i 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega64 +#------------------------------------------------------------ + +part + id = "m64"; + desc = "ATmega64"; + has_jtag = yes; + stk500_devcode = 0xA0; + avr910_devcode = 0x45; + signature = 0x1e 0x96 0x02; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x22; + spmcr = 0x68; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + + +#------------------------------------------------------------ +# ATmega128 +#------------------------------------------------------------ + +part + id = "m128"; + desc = "ATmega128"; + has_jtag = yes; + stk500_devcode = 0xB2; + avr910_devcode = 0x43; + signature = 0x1e 0x97 0x02; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x22; + spmcr = 0x68; + rampz = 0x3b; + allowfullpagebitstream = yes; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN128 +#------------------------------------------------------------ + +part + id = "c128"; + desc = "AT90CAN128"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x97 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN64 +#------------------------------------------------------------ + +part + id = "c64"; + desc = "AT90CAN64"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x96 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN32 +#------------------------------------------------------------ + +part + id = "c32"; + desc = "AT90CAN32"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x95 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 256; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega16 +#------------------------------------------------------------ + +part + id = "m16"; + desc = "ATmega16"; + has_jtag = yes; + stk500_devcode = 0x82; + avr910_devcode = 0x74; + signature = 0x1e 0x94 0x03; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 100; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x04; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "calibration" + size = 4; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega164P +#------------------------------------------------------------ + +# close to ATmega16 + +part parent "m16" + id = "m164p"; + desc = "ATmega164P"; + signature = 0x1e 0x94 0x0a; + + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + allowfullpagebitstream = no; + chip_erase_delay = 55000; + + ocdrev = 3; + ; + + +#------------------------------------------------------------ +# ATmega324P +#------------------------------------------------------------ + +# similar to ATmega164P + +part + id = "m324p"; + desc = "ATmega324P"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x95 0x08; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega324PA +#------------------------------------------------------------ + +# similar to ATmega324P + +part parent "m324p" + id = "m324pa"; + desc = "ATmega324PA"; + signature = 0x1e 0x95 0x11; + + ocdrev = 3; + ; + + +#------------------------------------------------------------ +# ATmega644 +#------------------------------------------------------------ + +# similar to ATmega164 + +part + id = "m644"; + desc = "ATmega644"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x96 0x09; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega644P +#------------------------------------------------------------ + +# similar to ATmega164p + +part parent "m644" + id = "m644p"; + desc = "ATmega644P"; + signature = 0x1e 0x96 0x0a; + + ocdrev = 3; + ; + + + +#------------------------------------------------------------ +# ATmega1284 +#------------------------------------------------------------ + +# similar to ATmega164 + +part + id = "m1284"; + desc = "ATmega1284"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x97 0x06; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega1284P +#------------------------------------------------------------ + +# similar to ATmega164p + +part + id = "m1284p"; + desc = "ATmega1284P"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x97 0x05; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega162 +#------------------------------------------------------------ + +part + id = "m162"; + desc = "ATmega162"; + has_jtag = yes; + stk500_devcode = 0x83; + avr910_devcode = 0x63; + signature = 0x1e 0x94 0x04; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + + idr = 0x04; + spmcr = 0x57; + allowfullpagebitstream = yes; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + ocdrev = 2; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + + ; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + + read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; +; + + + +#------------------------------------------------------------ +# ATmega163 +#------------------------------------------------------------ + +part + id = "m163"; + desc = "ATmega163"; + stk500_devcode = 0x81; + avr910_devcode = 0x64; + signature = 0x1e 0x94 0x02; + chip_erase_delay = 32000; + pagel = 0xd7; + bs2 = 0xa0; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 30; + programfusepulsewidth = 0; + programfusepolltimeout = 2; + programlockpulsewidth = 0; + programlockpolltimeout = 2; + + + memory "eeprom" + size = 512; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 16000; + max_write_delay = 16000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x11; + delay = 20; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o x x o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i 1 1 i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x x x x x 1 o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x 0 x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega169 +#------------------------------------------------------------ + +part + id = "m169"; + desc = "ATmega169"; + has_jtag = yes; + stk500_devcode = 0x85; + avr910_devcode = 0x78; + signature = 0x1e 0x94 0x05; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega329 +#------------------------------------------------------------ + +part + id = "m329"; + desc = "ATmega329"; + has_jtag = yes; +# stk500_devcode = 0x85; # no STK500 support, only STK500v2 +# avr910_devcode = 0x?; # try the ATmega169 one: + avr910_devcode = 0x75; + signature = 0x1e 0x95 0x03; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega329P +#------------------------------------------------------------ +# Identical to ATmega329 except of the signature + +part parent "m329" + id = "m329p"; + desc = "ATmega329P"; + signature = 0x1e 0x95 0x0b; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega3290 +#------------------------------------------------------------ + +# identical to ATmega329 + +part parent "m329" + id = "m3290"; + desc = "ATmega3290"; + signature = 0x1e 0x95 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega3290P +#------------------------------------------------------------ + +# identical to ATmega3290 except of the signature + +part parent "m3290" + id = "m3290p"; + desc = "ATmega3290P"; + signature = 0x1e 0x95 0x0c; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega649 +#------------------------------------------------------------ + +part + id = "m649"; + desc = "ATmega649"; + has_jtag = yes; +# stk500_devcode = 0x85; # no STK500 support, only STK500v2 +# avr910_devcode = 0x?; # try the ATmega169 one: + avr910_devcode = 0x75; + signature = 0x1e 0x96 0x03; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega6490 +#------------------------------------------------------------ + +# identical to ATmega649 + +part parent "m649" + id = "m6490"; + desc = "ATmega6490"; + signature = 0x1e 0x96 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega32 +#------------------------------------------------------------ + +part + id = "m32"; + desc = "ATmega32"; + has_jtag = yes; + stk500_devcode = 0x91; + avr910_devcode = 0x72; + signature = 0x1e 0x95 0x02; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega161 +#------------------------------------------------------------ + +part + id = "m161"; + desc = "ATmega161"; + stk500_devcode = 0x80; + avr910_devcode = 0x60; + signature = 0x1e 0x94 0x01; + chip_erase_delay = 28000; + pagel = 0xd7; + bs2 = 0xa0; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 30; + programfusepulsewidth = 0; + programfusepolltimeout = 2; + programlockpulsewidth = 0; + programlockpolltimeout = 2; + + memory "eeprom" + size = 512; + min_write_delay = 3400; + max_write_delay = 3400; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 14000; + max_write_delay = 14000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 16; + blocksize = 128; + readsize = 256; + ; + + memory "fuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x o x o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x 1 i 1 i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega8 +#------------------------------------------------------------ + +part + id = "m8"; + desc = "ATmega8"; + stk500_devcode = 0x70; + avr910_devcode = 0x76; + signature = 0x1e 0x93 0x07; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 10000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega8515 +#------------------------------------------------------------ + +part + id = "m8515"; + desc = "ATmega8515"; + stk500_devcode = 0x63; + avr910_devcode = 0x3A; + signature = 0x1e 0x93 0x06; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + + +#------------------------------------------------------------ +# ATmega8535 +#------------------------------------------------------------ + +part + id = "m8535"; + desc = "ATmega8535"; + stk500_devcode = 0x64; + avr910_devcode = 0x69; + signature = 0x1e 0x93 0x08; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATtiny26 +#------------------------------------------------------------ + +part + id = "t26"; + desc = "ATtiny26"; + stk500_devcode = 0x21; + avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x09; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 16; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x x x x i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny261 +#------------------------------------------------------------ +# Close to ATtiny26 + +part + id = "t261"; + desc = "ATtiny261"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x0c; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 128; + page_size = 4; + num_pages = 32; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny461 +#------------------------------------------------------------ +# Close to ATtiny261 + +part + id = "t461"; + desc = "ATtiny461"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x92 0x08; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 256; + page_size = 4; + num_pages = 64; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny861 +#------------------------------------------------------------ +# Close to ATtiny461 + +part + id = "t861"; + desc = "ATtiny861"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x93 0x0d; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 512; + num_pages = 128; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny28 +#------------------------------------------------------------ + +# This is an HVPP-only device. + +part + id = "t28"; + desc = "ATtiny28"; + stk500_devcode = 0x22; + avr910_devcode = 0x5c; + signature = 0x1e 0x91 0x07; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "flash" + size = 2048; + page_size = 2; + readsize = 256; + delay = 5; + ; + + memory "signature" + size = 3; + ; + + memory "lock" + size = 1; + ; + + memory "calibration" + size = 1; + ; + + memory "fuse" + size = 1; + ; +; + + + +#------------------------------------------------------------ +# ATmega48 +#------------------------------------------------------------ + +part + id = "m48"; + desc = "ATmega48"; + has_debugwire = yes; + 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; + stk500_devcode = 0x59; +# avr910_devcode = 0x; + signature = 0x1e 0x92 0x05; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 45000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 256; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x x", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega48P +#------------------------------------------------------------ + +part parent "m48" + id = "m48p"; + desc = "ATmega48P"; + signature = 0x1e 0x92 0x0a; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega48PB +#------------------------------------------------------------ + +part parent "m48" + id = "m48pb"; + desc = "ATmega48PB"; + signature = 0x1e 0x92 0x10; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega88 +#------------------------------------------------------------ + +part + id = "m88"; + desc = "ATmega88"; + has_debugwire = yes; + 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; + stk500_devcode = 0x73; +# avr910_devcode = 0x; + signature = 0x1e 0x93 0x0a; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 512; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega88P +#------------------------------------------------------------ + +part parent "m88" + id = "m88p"; + desc = "ATmega88P"; + signature = 0x1e 0x93 0x0f; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega88PB +#------------------------------------------------------------ + +part parent "m88" + id = "m88pb"; + desc = "ATmega88PB"; + signature = 0x1e 0x93 0x16; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega168 +#------------------------------------------------------------ + +part + id = "m168"; + desc = "ATmega168"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x94 0x06; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 512; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# ATmega168P +#------------------------------------------------------------ + +part parent "m168" + id = "m168p"; + desc = "ATmega168P"; + signature = 0x1e 0x94 0x0b; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATmega168PB +#------------------------------------------------------------ + +part parent "m168" + id = "m168pb"; + desc = "ATmega168PB"; + signature = 0x1e 0x94 0x15; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATtiny88 +#------------------------------------------------------------ + +part + id = "t88"; + desc = "ATtiny88"; + has_debugwire = yes; + 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; + stk500_devcode = 0x73; +# avr910_devcode = 0x; + signature = 0x1e 0x93 0x11; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 64; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 64; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega328 +#------------------------------------------------------------ + +part + id = "m328"; + desc = "ATmega328"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x95 0x14; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 1024; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +part parent "m328" + id = "m328p"; + desc = "ATmega328P"; + signature = 0x1e 0x95 0x0F; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATmega32m1 +#------------------------------------------------------------ + +part parent "m328" + id = "m32m1"; + desc = "ATmega32M1"; + # stk500_devcode = 0x; + # avr910_devcode = 0x; + signature = 0x1e 0x95 0x84; + bs2 = 0xe2; + + memory "efuse" + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x i i i i i i"; + ; +; + +#------------------------------------------------------------ +# ATtiny2313 +#------------------------------------------------------------ + +part + id = "t2313"; + desc = "ATtiny2313"; + has_debugwire = yes; + 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; + stk500_devcode = 0x23; +## Use the ATtiny26 devcode: + avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x0a; + pagel = 0xD4; + bs2 = 0xD6; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 0; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + +# The information in the data sheet of April/2004 is wrong, this works: + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + +# The information in the data sheet of April/2004 is wrong, this works: + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + +# The information in the data sheet of April/2004 is wrong, this works: + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny2313 has Signature Bytes: 0x1E 0x91 0x0A. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + 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 = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny4313 +#------------------------------------------------------------ + +part + id = "t4313"; + desc = "ATtiny4313"; + has_debugwire = yes; + 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; + stk500_devcode = 0x23; +## Use the ATtiny26 devcode: + avr910_devcode = 0x5e; + signature = 0x1e 0x92 0x0d; + pagel = 0xD4; + bs2 = 0xD6; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 0; + + memory "eeprom" + size = 256; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny4313 has Signature Bytes: 0x1E 0x92 0x0D. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90PWM2 +#------------------------------------------------------------ + +part + id = "pwm2"; + desc = "AT90PWM2"; + has_debugwire = yes; + 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; + stk500_devcode = 0x65; +## avr910_devcode = ?; + signature = 0x1e 0x93 0x81; + pagel = 0xD8; + bs2 = 0xE2; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; +# AT90PWM2 has Signature Bytes: 0x1E 0x93 0x81. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90PWM3 +#------------------------------------------------------------ + +# Completely identical to AT90PWM2 (including the signature!) + +part parent "pwm2" + id = "pwm3"; + desc = "AT90PWM3"; + ; + +#------------------------------------------------------------ +# AT90PWM2B +#------------------------------------------------------------ +# Same as AT90PWM2 but different signature. + +part parent "pwm2" + id = "pwm2b"; + desc = "AT90PWM2B"; + signature = 0x1e 0x93 0x83; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# AT90PWM3B +#------------------------------------------------------------ + +# Completely identical to AT90PWM2B (including the signature!) + +part parent "pwm2b" + id = "pwm3b"; + desc = "AT90PWM3B"; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# AT90PWM316 +#------------------------------------------------------------ + +# Similar to AT90PWM3B, but with 16 kiB flash, 512 B EEPROM, and 1024 B SRAM. + +part parent "pwm3b" + id = "pwm316"; + desc = "AT90PWM316"; + signature = 0x1e 0x94 0x83; + + ocdrev = 1; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + ; + +#------------------------------------------------------------ +# AT90PWM216 +#------------------------------------------------------------ +# Completely identical to AT90PWM316 (including the signature!) + +part parent "pwm316" + id = "pwm216"; + desc = "AT90PWM216"; + ; + +#------------------------------------------------------------ +# ATtiny25 +#------------------------------------------------------------ + +part + id = "t25"; + desc = "ATtiny25"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x08; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny25 has Signature Bytes: 0x1E 0x91 0x08. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny45 +#------------------------------------------------------------ + +part + id = "t45"; + desc = "ATtiny45"; + has_debugwire = yes; + 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; + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x06; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 256; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny45 has Signature Bytes: 0x1E 0x92 0x08. (Data sheet 2586C-AVR-06/05 (doc2586.pdf) indicates otherwise!) + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny85 +#------------------------------------------------------------ + +part + id = "t85"; + desc = "ATtiny85"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x93 0x0b; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny85 has Signature Bytes: 0x1E 0x93 0x08. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega640 +#------------------------------------------------------------ +# Almost same as ATmega1280, except for different memory sizes + +part + id = "m640"; + desc = "ATmega640"; + signature = 0x1e 0x96 0x08; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega1280 +#------------------------------------------------------------ + +part + id = "m1280"; + desc = "ATmega1280"; + signature = 0x1e 0x97 0x03; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega1281 +#------------------------------------------------------------ +# Identical to ATmega1280 + +part parent "m1280" + id = "m1281"; + desc = "ATmega1281"; + signature = 0x1e 0x97 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega2560 +#------------------------------------------------------------ + +part + id = "m2560"; + desc = "ATmega2560"; + signature = 0x1e 0x98 0x01; + has_jtag = yes; + stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 4; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 262144; + page_size = 256; + num_pages = 1024; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + load_ext_addr = " 0 1 0 0 1 1 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 a16", + " 0 0 0 0 0 0 0 0"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega2561 +#------------------------------------------------------------ + +part parent "m2560" + id = "m2561"; + desc = "ATmega2561"; + signature = 0x1e 0x98 0x02; + + ocdrev = 4; + ; + +#------------------------------------------------------------ +# ATmega128RFA1 +#------------------------------------------------------------ +# Identical to ATmega2561 but half the ROM + +part parent "m2561" + id = "m128rfa1"; + desc = "ATmega128RFA1"; + signature = 0x1e 0xa7 0x01; + chip_erase_delay = 55000; + bs2 = 0xE2; + + ocdrev = 3; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 50000; + max_write_delay = 50000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 256; + readsize = 256; + ; + ; + +#------------------------------------------------------------ +# ATmega256RFR2 +#------------------------------------------------------------ + +part parent "m2561" + id = "m256rfr2"; + desc = "ATmega256RFR2"; + signature = 0x1e 0xa8 0x02; + chip_erase_delay = 18500; + bs2 = 0xE2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 8192; + min_write_delay = 13000; + max_write_delay = 13000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + + ocdrev = 4; + ; + +#------------------------------------------------------------ +# ATmega128RFR2 +#------------------------------------------------------------ + +part parent "m128rfa1" + id = "m128rfr2"; + desc = "ATmega128RFR2"; + signature = 0x1e 0xa7 0x02; + + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega64RFR2 +#------------------------------------------------------------ + +part parent "m128rfa1" + id = "m64rfr2"; + desc = "ATmega64RFR2"; + signature = 0x1e 0xa6 0x02; + + + ocdrev = 3; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 50000; + max_write_delay = 50000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 256; + readsize = 256; + ; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 13000; + max_write_delay = 13000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + + ; + +#------------------------------------------------------------ +# ATmega2564RFR2 +#------------------------------------------------------------ + +part parent "m256rfr2" + id = "m2564rfr2"; + desc = "ATmega2564RFR2"; + signature = 0x1e 0xa8 0x03; + ; + +#------------------------------------------------------------ +# ATmega1284RFR2 +#------------------------------------------------------------ + +part parent "m128rfr2" + id = "m1284rfr2"; + desc = "ATmega1284RFR2"; + signature = 0x1e 0xa7 0x03; + ; + +#------------------------------------------------------------ +# ATmega644RFR2 +#------------------------------------------------------------ + +part parent "m64rfr2" + id = "m644rfr2"; + desc = "ATmega644RFR2"; + signature = 0x1e 0xa6 0x03; + ; + +#------------------------------------------------------------ +# ATtiny24 +#------------------------------------------------------------ + +part + id = "t24"; + desc = "ATtiny24"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x0b; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny24 has Signature Bytes: 0x1E 0x91 0x0B. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny44 +#------------------------------------------------------------ + +part + id = "t44"; + desc = "ATtiny44"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x07; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 256; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny44 has Signature Bytes: 0x1E 0x92 0x07. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny84 +#------------------------------------------------------------ + +part + id = "t84"; + desc = "ATtiny84"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x93 0x0c; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny84 has Signature Bytes: 0x1E 0x93 0x0C. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny43U +#------------------------------------------------------------ + +part + id = "t43u"; + desc = "ATtiny43u"; + has_debugwire = yes; + 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; + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x0C; + reset = io; + chip_erase_delay = 1000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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, 0x06, 0x16, 0x46, 0x56, + 0x0A, 0x1A, 0x4A, 0x5A, 0x1E, 0x7C, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 20; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + memory "eeprom" + size = 64; + paged = yes; + page_size = 4; + num_pages = 16; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "0 0 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "0 0 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " 0 0 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# ATmega32u4 +#------------------------------------------------------------ + +part + id = "m32u4"; + desc = "ATmega32U4"; + signature = 0x1e 0x95 0x87; + usbpid = 0x2ff4; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB646 +#------------------------------------------------------------ + +part + id = "usb646"; + desc = "AT90USB646"; + signature = 0x1e 0x96 0x82; + usbpid = 0x2ff9; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB647 +#------------------------------------------------------------ +# identical to AT90USB646 + +part parent "usb646" + id = "usb647"; + desc = "AT90USB647"; + signature = 0x1e 0x96 0x82; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AT90USB1286 +#------------------------------------------------------------ + +part + id = "usb1286"; + desc = "AT90USB1286"; + signature = 0x1e 0x97 0x82; + usbpid = 0x2ffb; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB1287 +#------------------------------------------------------------ +# identical to AT90USB1286 + +part parent "usb1286" + id = "usb1287"; + desc = "AT90USB1287"; + signature = 0x1e 0x97 0x82; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AT90USB162 +#------------------------------------------------------------ + +part + id = "usb162"; + desc = "AT90USB162"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x94 0x82; + usbpid = 0x2ffa; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB82 +#------------------------------------------------------------ +# Changes against AT90USB162 (beside IDs) +# memory "flash" +# size = 8192; +# num_pages = 64; + +part + id = "usb82"; + desc = "AT90USB82"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x93 0x82; + usbpid = 0x2ff7; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega32U2 +#------------------------------------------------------------ +# Changes against AT90USB162 (beside IDs) +# memory "flash" +# size = 32768; +# num_pages = 256; +# memory "eeprom" +# size = 1024; +# num_pages = 256; +part + id = "m32u2"; + desc = "ATmega32U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x95 0x8a; + usbpid = 0x2ff0; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + num_pages = 256; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; +#------------------------------------------------------------ +# ATmega16U2 +#------------------------------------------------------------ +# Changes against ATmega32U2 (beside IDs) +# memory "flash" +# size = 16384; +# num_pages = 128; +# memory "eeprom" +# size = 512; +# num_pages = 128; +part + id = "m16u2"; + desc = "ATmega16U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x94 0x89; + usbpid = 0x2fef; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega8U2 +#------------------------------------------------------------ +# Changes against ATmega16U2 (beside IDs) +# memory "flash" +# size = 8192; +# page_size = 64; +# blocksize = 64; + +part + id = "m8u2"; + desc = "ATmega8U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x93 0x89; + usbpid = 0x2fee; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; +#------------------------------------------------------------ +# ATmega325 +#------------------------------------------------------------ + +part + id = "m325"; + desc = "ATmega325"; + signature = 0x1e 0x95 0x05; + has_jtag = yes; +# stk500_devcode = 0x??; # No STK500v1 support? +# avr910_devcode = 0x??; # Try the ATmega16 one + avr910_devcode = 0x74; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega645 +#------------------------------------------------------------ + +part + id = "m645"; + desc = "ATmega645"; + signature = 0x1E 0x96 0x05; + has_jtag = yes; +# stk500_devcode = 0x??; # No STK500v1 support? +# avr910_devcode = 0x??; # Try the ATmega16 one + avr910_devcode = 0x74; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " 0 0 0 0 0 0 0 0"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega3250 +#------------------------------------------------------------ + +part parent "m325" + id = "m3250"; + desc = "ATmega3250"; + signature = 0x1E 0x95 0x06; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega6450 +#------------------------------------------------------------ + +part parent "m645" + id = "m6450"; + desc = "ATmega6450"; + signature = 0x1E 0x96 0x06; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AVR XMEGA family common values +#------------------------------------------------------------ + +part + id = ".xmega"; + desc = "AVR XMEGA family common values"; + has_pdi = yes; + nvm_base = 0x01c0; + mcu_base = 0x0090; + + memory "signature" + size = 3; + offset = 0x1000090; + ; + + memory "prodsig" + size = 0x32; + offset = 0x8e0200; + page_size = 0x32; + readsize = 0x32; + ; + + memory "fuse1" + size = 1; + offset = 0x8f0021; + ; + + memory "fuse2" + size = 1; + offset = 0x8f0022; + ; + + memory "fuse4" + size = 1; + offset = 0x8f0024; + ; + + memory "fuse5" + size = 1; + offset = 0x8f0025; + ; + + memory "lock" + size = 1; + offset = 0x8f0027; + ; + + memory "data" + # SRAM, only used to supply the offset + offset = 0x1000000; + ; +; + +#------------------------------------------------------------ +# ATxmega16A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x16a4u"; + desc = "ATxmega16A4U"; + signature = 0x1e 0x94 0x41; + usbpid = 0x2fe3; + + memory "eeprom" + size = 0x400; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x4000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x803000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x804000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x5000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega16C4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16c4"; + desc = "ATxmega16C4"; + signature = 0x1e 0x95 0x44; +; + +#------------------------------------------------------------ +# ATxmega16D4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16d4"; + desc = "ATxmega16D4"; + signature = 0x1e 0x94 0x42; +; + +#------------------------------------------------------------ +# ATxmega16A4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16a4"; + desc = "ATxmega16A4"; + signature = 0x1e 0x94 0x41; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega32A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x32a4u"; + desc = "ATxmega32A4U"; + signature = 0x1e 0x95 0x41; + usbpid = 0x2fe4; + + memory "eeprom" + size = 0x400; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x8000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x807000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x808000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x9000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega32C4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32c4"; + desc = "ATxmega32C4"; + signature = 0x1e 0x94 0x43; +; + +#------------------------------------------------------------ +# ATxmega32D4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32d4"; + desc = "ATxmega32D4"; + signature = 0x1e 0x95 0x42; +; + +#------------------------------------------------------------ +# ATxmega32A4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32a4"; + desc = "ATxmega32A4"; + signature = 0x1e 0x95 0x41; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega64A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x64a4u"; + desc = "ATxmega64A4U"; + signature = 0x1e 0x96 0x46; + usbpid = 0x2fe5; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x10000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x80f000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x810000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x11000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega64C3 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64c3"; + desc = "ATxmega64C3"; + signature = 0x1e 0x96 0x49; + usbpid = 0x2fd6; +; + +#------------------------------------------------------------ +# ATxmega64D3 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64d3"; + desc = "ATxmega64D3"; + signature = 0x1e 0x96 0x4a; +; + +#------------------------------------------------------------ +# ATxmega64D4 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64d4"; + desc = "ATxmega64D4"; + signature = 0x1e 0x96 0x47; +; + +#------------------------------------------------------------ +# ATxmega64A1 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64a1"; + desc = "ATxmega64A1"; + signature = 0x1e 0x96 0x4e; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega64A1U +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a1u"; + desc = "ATxmega64A1U"; + signature = 0x1e 0x96 0x4e; + usbpid = 0x2fe8; +; + +#------------------------------------------------------------ +# ATxmega64A3 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a3"; + desc = "ATxmega64A3"; + signature = 0x1e 0x96 0x42; +; + +#------------------------------------------------------------ +# ATxmega64A3U +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a3u"; + desc = "ATxmega64A3U"; + signature = 0x1e 0x96 0x42; + usbpid = 0x2fe5; +; + +#------------------------------------------------------------ +# ATxmega64A4 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a4"; + desc = "ATxmega64A4"; + signature = 0x1e 0x96 0x46; +; + +#------------------------------------------------------------ +# ATxmega64B1 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64b1"; + desc = "ATxmega64B1"; + signature = 0x1e 0x96 0x52; + usbpid = 0x2fe1; +; + +#------------------------------------------------------------ +# ATxmega64B3 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64b3"; + desc = "ATxmega64B3"; + signature = 0x1e 0x96 0x51; + usbpid = 0x2fdf; +; + +#------------------------------------------------------------ +# ATxmega128C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128c3"; + desc = "ATxmega128C3"; + signature = 0x1e 0x97 0x52; + usbpid = 0x2fd7; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x81e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega128D3 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128d3"; + desc = "ATxmega128D3"; + signature = 0x1e 0x97 0x48; +; + +#------------------------------------------------------------ +# ATxmega128D4 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128d4"; + desc = "ATxmega128D4"; + signature = 0x1e 0x97 0x47; +; + +#------------------------------------------------------------ +# ATxmega128A1 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128a1"; + desc = "ATxmega128A1"; + signature = 0x1e 0x97 0x4c; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128A1 revision D +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a1d"; + desc = "ATxmega128A1revD"; + signature = 0x1e 0x97 0x41; +; + +#------------------------------------------------------------ +# ATxmega128A1U +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a1u"; + desc = "ATxmega128A1U"; + signature = 0x1e 0x97 0x4c; + usbpid = 0x2fed; +; + +#------------------------------------------------------------ +# ATxmega128A3 +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a3"; + desc = "ATxmega128A3"; + signature = 0x1e 0x97 0x42; +; + +#------------------------------------------------------------ +# ATxmega128A3U +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a3u"; + desc = "ATxmega128A3U"; + signature = 0x1e 0x97 0x42; + usbpid = 0x2fe6; +; + +#------------------------------------------------------------ +# ATxmega128A4 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128a4"; + desc = "ATxmega128A4"; + signature = 0x1e 0x97 0x46; + has_jtag = yes; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x81f000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128a4u"; + desc = "ATxmega128A4U"; + signature = 0x1e 0x97 0x46; + usbpid = 0x2fde; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x81f000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega128B1 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128b1"; + desc = "ATxmega128B1"; + signature = 0x1e 0x97 0x4d; + usbpid = 0x2fea; + has_jtag = yes; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x81e000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128B3 +#------------------------------------------------------------ + +part parent "x128b1" + id = "x128b3"; + desc = "ATxmega128B3"; + signature = 0x1e 0x97 0x4b; + usbpid = 0x2fe0; +; + +#------------------------------------------------------------ +# ATxmega192C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x192c3"; + desc = "ATxmega192C3"; + signature = 0x1e 0x97 0x51; + # usbpid = 0x2f??; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x30000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x82e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x830000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x32000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega192D3 +#------------------------------------------------------------ + +part parent "x192c3" + id = "x192d3"; + desc = "ATxmega192D3"; + signature = 0x1e 0x97 0x49; +; + +#------------------------------------------------------------ +# ATxmega192A1 +#------------------------------------------------------------ + +part parent "x192c3" + id = "x192a1"; + desc = "ATxmega192A1"; + signature = 0x1e 0x97 0x4e; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega192A3 +#------------------------------------------------------------ + +part parent "x192a1" + id = "x192a3"; + desc = "ATxmega192A3"; + signature = 0x1e 0x97 0x44; +; + +#------------------------------------------------------------ +# ATxmega192A3U +#------------------------------------------------------------ + +part parent "x192a1" + id = "x192a3u"; + desc = "ATxmega192A3U"; + signature = 0x1e 0x97 0x44; + usbpid = 0x2fe7; +; + +#------------------------------------------------------------ +# ATxmega256C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x256c3"; + desc = "ATxmega256C3"; + signature = 0x1e 0x98 0x46; + usbpid = 0x2fda; + + memory "eeprom" + size = 0x1000; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x40000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x83e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x840000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x42000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega256D3 +#------------------------------------------------------------ + +part parent "x256c3" + id = "x256d3"; + desc = "ATxmega256D3"; + signature = 0x1e 0x98 0x44; +; + +#------------------------------------------------------------ +# ATxmega256A1 +#------------------------------------------------------------ + +part parent "x256c3" + id = "x256a1"; + desc = "ATxmega256A1"; + signature = 0x1e 0x98 0x46; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega256A3 +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3"; + desc = "ATxmega256A3"; + signature = 0x1e 0x98 0x42; +; + +#------------------------------------------------------------ +# ATxmega256A3U +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3u"; + desc = "ATxmega256A3U"; + signature = 0x1e 0x98 0x42; + usbpid = 0x2fec; +; + +#------------------------------------------------------------ +# ATxmega256A3B +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3b"; + desc = "ATxmega256A3B"; + signature = 0x1e 0x98 0x43; +; + +#------------------------------------------------------------ +# ATxmega256A3BU +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3bu"; + desc = "ATxmega256A3BU"; + signature = 0x1e 0x98 0x43; + usbpid = 0x2fe2; +; + +#------------------------------------------------------------ +# ATxmega384C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x384c3"; + desc = "ATxmega384C3"; + signature = 0x1e 0x98 0x45; + usbpid = 0x2fdb; + + memory "eeprom" + size = 0x1000; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x60000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x85e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x860000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x62000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega384D3 +#------------------------------------------------------------ + +part parent "x384c3" + id = "x384d3"; + desc = "ATxmega384D3"; + signature = 0x1e 0x98 0x47; +; + +#------------------------------------------------------------ +# ATxmega8E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x8e5"; + desc = "ATxmega8E5"; + signature = 0x1e 0x93 0x41; + + memory "eeprom" + size = 0x0200; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x2000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x800; + offset = 0x00801800; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x800; + offset = 0x00802000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x2800; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega16E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x16e5"; + desc = "ATxmega16E5"; + signature = 0x1e 0x94 0x45; + + memory "eeprom" + size = 0x0200; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x4000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x00803000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x00804000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x5000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega32E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x32e5"; + desc = "ATxmega32E5"; + signature = 0x1e 0x95 0x4c; + + memory "eeprom" + size = 0x0400; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x8000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x00807000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x00808000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x9000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# AVR32UC3A0512 +#------------------------------------------------------------ + +part + id = "uc3a0512"; + desc = "AT32UC3A0512"; + signature = 0xED 0xC0 0x3F; + has_jtag = yes; + is_avr32 = yes; + + memory "flash" + paged = yes; + page_size = 512; # bytes + readsize = 512; # bytes + num_pages = 1024; # could be set dynamicly + size = 0x00080000; # could be set dynamicly + offset = 0x80000000; + ; +; + +part parent "uc3a0512" + id = "ucr2"; + desc = "deprecated, use 'uc3a0512'"; +; + +#------------------------------------------------------------ +# ATtiny1634. +#------------------------------------------------------------ + +part + id = "t1634"; + desc = "ATtiny1634"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x94 0x12; + pagel = 0xB3; + bs2 = 0xB1; + reset = io; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + paged = no; + page_size = 4; + size = 256; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 32; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 1 1 1 1 i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# Common values for reduced core tinys (4/5/9/10/20/40) +#------------------------------------------------------------ + +part + id = ".reduced_core_tiny"; + desc = "Common values for reduced core tinys"; + has_tpi = yes; + + memory "signature" + size = 3; + offset = 0x3fc0; + page_size = 16; + ; + + memory "fuse" + size = 1; + offset = 0x3f40; + page_size = 16; + blocksize = 4; + ; + + memory "calibration" + size = 1; + offset = 0x3f80; + page_size = 16; + ; + + memory "lockbits" + size = 1; + offset = 0x3f00; + page_size = 16; + ; +; + +#------------------------------------------------------------ +# ATtiny4 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t4"; + desc = "ATtiny4"; + signature = 0x1e 0x8f 0x0a; + + memory "flash" + size = 512; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny5 +#------------------------------------------------------------ + +part parent "t4" + id = "t5"; + desc = "ATtiny5"; + signature = 0x1e 0x8f 0x09; +; + +#------------------------------------------------------------ +# ATtiny9 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t9"; + desc = "ATtiny9"; + signature = 0x1e 0x90 0x08; + + memory "flash" + size = 1024; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny10 +#------------------------------------------------------------ + +part parent "t9" + id = "t10"; + desc = "ATtiny10"; + signature = 0x1e 0x90 0x03; +; + +#------------------------------------------------------------ +# ATtiny20 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t20"; + desc = "ATtiny20"; + signature = 0x1e 0x91 0x0F; + + memory "flash" + size = 2048; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny40 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t40"; + desc = "ATtiny40"; + signature = 0x1e 0x92 0x0E; + + memory "flash" + size = 4096; + offset = 0x4000; + page_size = 64; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATmega406 +#------------------------------------------------------------ + +part + id = "m406"; + desc = "ATMEGA406"; + has_jtag = yes; + signature = 0x1e 0x95 0x07; + + # STK500 parameters (parallel programming IO lines) + pagel = 0xa7; + bs2 = 0xa0; + serial = no; + parallel = yes; + + # 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; + + # JTAG ICE mkII parameters, also from XML files + allowfullpagebitstream = no; + enablepageprogramming = yes; + idr = 0x51; + rampz = 0x00; + spmcr = 0x57; + eecr = 0x3f; + + memory "eeprom" + paged = no; + size = 512; + page_size = 4; + blocksize = 4; + readsize = 4; + num_pages = 128; + ; + + memory "flash" + paged = yes; + size = 40960; + page_size = 128; + blocksize = 128; + readsize = 128; + num_pages = 320; + ; + + memory "hfuse" + size = 1; + ; + + memory "lfuse" + size = 1; + ; + + memory "lockbits" + size = 1; + ; + + memory "signature" + size = 3; + ; +; + + diff --git a/xs/src/avrdude/avrdude.conf.tmp b/xs/src/avrdude/avrdude.conf.tmp new file mode 100644 index 000000000..82c73afa2 --- /dev/null +++ b/xs/src/avrdude/avrdude.conf.tmp @@ -0,0 +1,14984 @@ +# $Id$ -*- text -*- +# +# AVRDUDE Configuration File +# +# This file contains configuration data used by AVRDUDE which describes +# the programming hardware pinouts and also provides part definitions. +# AVRDUDE's "-C" command line option specifies the location of the +# configuration file. The "-c" option names the programmer configuration +# which must match one of the entry's "id" parameter. The "-p" option +# identifies which part AVRDUDE is going to be programming and must match +# one of the parts' "id" parameter. +# +# DO NOT MODIFY THIS FILE. Modifications will be overwritten the next +# time a "make install" is run. For user-specific additions, use the +# "-C +filename" commandline option. +# +# Possible entry formats are: +# +# programmer +# parent # optional parent +# id = [, [, ] ...] ; # are quoted strings +# desc = ; # quoted string +# type = ; # programmer type, quoted string +# # supported programmer types can be listed by "-c ?type" +# connection_type = parallel | serial | usb +# baudrate = ; # baudrate for avr910-programmer +# vcc = [, ... ] ; # pin number(s) +# buff = [, ... ] ; # pin number(s) +# reset = ; # pin number +# sck = ; # pin number +# mosi = ; # pin number +# miso = ; # pin number +# errled = ; # pin number +# rdyled = ; # pin number +# pgmled = ; # pin number +# vfyled = ; # pin number +# usbvid = ; # USB VID (Vendor ID) +# usbpid = [, ...] # USB PID (Product ID) (1) +# usbdev = ; # USB interface or other device info +# usbvendor = ; # USB Vendor Name +# usbproduct = ; # USB Product Name +# usbsn = ; # USB Serial Number +# +# To invert a bit, use = ~ , the spaces are important. +# For a pin list all pins must be inverted. +# A single pin can be specified as usual = ~ , for lists +# specify it as follows = ~ ( [, ... ] ) . +# +# (1) Not all programmer types can process a list of PIDs. +# ; +# +# part +# id = ; # quoted string +# desc = ; # quoted string +# has_jtag = ; # part has JTAG i/f +# has_debugwire = ; # part has debugWire i/f +# has_pdi = ; # part has PDI i/f +# has_tpi = ; # part has TPI i/f +# devicecode = ; # deprecated, use stk500_devcode +# stk500_devcode = ; # numeric +# avr910_devcode = ; # numeric +# signature = ; # signature bytes +# usbpid = ; # DFU USB PID +# chip_erase_delay = ; # micro-seconds +# reset = dedicated | io; +# retry_pulse = reset | sck; +# pgm_enable = ; +# chip_erase = ; +# chip_erase_delay = ; # chip erase delay (us) +# # STK500 parameters (parallel programming IO lines) +# pagel = ; # pin name in hex, i.e., 0xD7 +# bs2 = ; # pin name in hex, i.e., 0xA0 +# serial = ; # can use serial downloading +# parallel = ; # can use par. programming +# # STK500v2 parameters, to be taken from Atmel's XML files +# timeout = ; +# stabdelay = ; +# cmdexedelay = ; +# synchloops = ; +# bytedelay = ; +# pollvalue = ; +# pollindex = ; +# predelay = ; +# postdelay = ; +# pollmethod = ; +# mode = ; +# delay = ; +# blocksize = ; +# readsize = ; +# hvspcmdexedelay = ; +# # STK500v2 HV programming parameters, from XML +# pp_controlstack = , , ...; # PP only +# hvsp_controlstack = , , ...; # HVSP only +# hventerstabdelay = ; +# progmodedelay = ; # PP only +# latchcycles = ; +# togglevtg = ; +# poweroffdelay = ; +# resetdelayms = ; +# resetdelayus = ; +# hvleavestabdelay = ; +# resetdelay = ; +# synchcycles = ; # HVSP only +# chiperasepulsewidth = ; # PP only +# chiperasepolltimeout = ; +# chiperasetime = ; # HVSP only +# programfusepulsewidth = ; # PP only +# programfusepolltimeout = ; +# programlockpulsewidth = ; # PP only +# programlockpolltimeout = ; +# # JTAG ICE mkII parameters, also from XML files +# allowfullpagebitstream = ; +# enablepageprogramming = ; +# idr = ; # IO addr of IDR (OCD) reg. +# rampz = ; # IO addr of RAMPZ reg. +# spmcr = ; # mem addr of SPMC[S]R reg. +# eecr = ; # mem addr of EECR reg. +# # (only when != 0x3c) +# is_at90s1200 = ; # AT90S1200 part +# is_avr32 = ; # AVR32 part +# +# memory +# paged = ; # yes / no +# size = ; # bytes +# page_size = ; # bytes +# num_pages = ; # numeric +# min_write_delay = ; # micro-seconds +# max_write_delay = ; # micro-seconds +# readback_p1 = ; # byte value +# readback_p2 = ; # byte value +# pwroff_after_write = ; # yes / no +# read = ; +# write = ; +# read_lo = ; +# read_hi = ; +# write_lo = ; +# write_hi = ; +# loadpage_lo = ; +# loadpage_hi = ; +# writepage = ; +# ; +# ; +# +# If any of the above parameters are not specified, the default value +# of 0 is used for numerics or the empty string ("") for string +# values. If a required parameter is left empty, AVRDUDE will +# complain. +# +# Parts can also inherit parameters from previously defined parts +# using the following syntax. In this case specified integer and +# string values override parameter values from the parent part. New +# memory definitions are added to the definitions inherited from the +# parent. +# +# part parent # quoted string +# id = ; # quoted string +# +# ; +# +# NOTES: +# * 'devicecode' is the device code used by the STK500 (see codes +# listed below) +# * Not all memory types will implement all instructions. +# * AVR Fuse bits and Lock bits are implemented as a type of memory. +# * Example memory types are: +# "flash", "eeprom", "fuse", "lfuse" (low fuse), "hfuse" (high +# fuse), "signature", "calibration", "lock" +# * The memory type specified on the avrdude command line must match +# one of the memory types defined for the specified chip. +# * The pwroff_after_write flag causes avrdude to attempt to +# power the device off and back on after an unsuccessful write to +# the affected memory area if VCC programmer pins are defined. If +# VCC pins are not defined for the programmer, a message +# indicating that the device needs a power-cycle is printed out. +# This flag was added to work around a problem with the +# at90s4433/2333's; see the at90s4433 errata at: +# +# http://www.atmel.com/dyn/resources/prod_documents/doc1280.pdf +# +# INSTRUCTION FORMATS +# +# Instruction formats are specified as a comma seperated list of +# string values containing information (bit specifiers) about each +# of the 32 bits of the instruction. Bit specifiers may be one of +# the following formats: +# +# '1' = the bit is always set on input as well as output +# +# '0' = the bit is always clear on input as well as output +# +# 'x' = the bit is ignored on input and output +# +# 'a' = the bit is an address bit, the bit-number matches this bit +# specifier's position within the current instruction byte +# +# 'aN' = the bit is the Nth address bit, bit-number = N, i.e., a12 +# is address bit 12 on input, a0 is address bit 0. +# +# 'i' = the bit is an input data bit +# +# 'o' = the bit is an output data bit +# +# Each instruction must be composed of 32 bit specifiers. The +# instruction specification closely follows the instruction data +# provided in Atmel's data sheets for their parts. +# +# See below for some examples. +# +# +# The following are STK500 part device codes to use for the +# "devicecode" field of the part. These came from Atmel's software +# section avr061.zip which accompanies the application note +# AVR061 available from: +# +# http://www.atmel.com/dyn/resources/prod_documents/doc2525.pdf +# + +#define ATTINY10 0x10 /* the _old_ one that never existed! */ +#define ATTINY11 0x11 +#define ATTINY12 0x12 +#define ATTINY15 0x13 +#define ATTINY13 0x14 + +#define ATTINY22 0x20 +#define ATTINY26 0x21 +#define ATTINY28 0x22 +#define ATTINY2313 0x23 + +#define AT90S1200 0x33 + +#define AT90S2313 0x40 +#define AT90S2323 0x41 +#define AT90S2333 0x42 +#define AT90S2343 0x43 + +#define AT90S4414 0x50 +#define AT90S4433 0x51 +#define AT90S4434 0x52 +#define ATMEGA48 0x59 + +#define AT90S8515 0x60 +#define AT90S8535 0x61 +#define AT90C8534 0x62 +#define ATMEGA8515 0x63 +#define ATMEGA8535 0x64 + +#define ATMEGA8 0x70 +#define ATMEGA88 0x73 +#define ATMEGA168 0x86 + +#define ATMEGA161 0x80 +#define ATMEGA163 0x81 +#define ATMEGA16 0x82 +#define ATMEGA162 0x83 +#define ATMEGA169 0x84 + +#define ATMEGA323 0x90 +#define ATMEGA32 0x91 + +#define ATMEGA64 0xA0 + +#define ATMEGA103 0xB1 +#define ATMEGA128 0xB2 +#define AT90CAN128 0xB3 +#define AT90CAN64 0xB3 +#define AT90CAN32 0xB3 + +#define AT86RF401 0xD0 + +#define AT89START 0xE0 +#define AT89S51 0xE0 +#define AT89S52 0xE1 + +# The following table lists the devices in the original AVR910 +# appnote: +# |Device |Signature | Code | +# +-------+----------+------+ +# |tiny12 | 1E 90 05 | 0x55 | +# |tiny15 | 1E 90 06 | 0x56 | +# | | | | +# | S1200 | 1E 90 01 | 0x13 | +# | | | | +# | S2313 | 1E 91 01 | 0x20 | +# | S2323 | 1E 91 02 | 0x48 | +# | S2333 | 1E 91 05 | 0x34 | +# | S2343 | 1E 91 03 | 0x4C | +# | | | | +# | S4414 | 1E 92 01 | 0x28 | +# | S4433 | 1E 92 03 | 0x30 | +# | S4434 | 1E 92 02 | 0x6C | +# | | | | +# | S8515 | 1E 93 01 | 0x38 | +# | S8535 | 1E 93 03 | 0x68 | +# | | | | +# |mega32 | 1E 95 01 | 0x72 | +# |mega83 | 1E 93 05 | 0x65 | +# |mega103| 1E 97 01 | 0x41 | +# |mega161| 1E 94 01 | 0x60 | +# |mega163| 1E 94 02 | 0x64 | + +# Appnote AVR109 also has a table of AVR910 device codes, which +# lists: +# dev avr910 signature +# ATmega8 0x77 0x1E 0x93 0x07 +# ATmega8515 0x3B 0x1E 0x93 0x06 +# ATmega8535 0x6A 0x1E 0x93 0x08 +# ATmega16 0x75 0x1E 0x94 0x03 +# ATmega162 0x63 0x1E 0x94 0x04 +# ATmega163 0x66 0x1E 0x94 0x02 +# ATmega169 0x79 0x1E 0x94 0x05 +# ATmega32 0x7F 0x1E 0x95 0x02 +# ATmega323 0x73 0x1E 0x95 0x01 +# ATmega64 0x46 0x1E 0x96 0x02 +# ATmega128 0x44 0x1E 0x97 0x02 +# +# These codes refer to "BOOT" device codes which are apparently +# different than standard device codes, for whatever reasons +# (often one above the standard code). + +# There are several extended versions of AVR910 implementations around +# in the Internet. These add the following codes (only devices that +# actually exist are listed): + +# ATmega8515 0x3A +# ATmega128 0x43 +# ATmega64 0x45 +# ATtiny26 0x5E +# ATmega8535 0x69 +# ATmega32 0x72 +# ATmega16 0x74 +# ATmega8 0x76 +# ATmega169 0x78 + +# +# Overall avrdude defaults; suitable for ~/.avrduderc +# +default_parallel = "/dev/parport0"; +default_serial = "/dev/ttyS0"; +# default_bitclock = 2.5; + +# Turn off safemode by default +#default_safemode = no; + + +# +# PROGRAMMER DEFINITIONS +# + +# http://wiring.org.co/ +# Basically STK500v2 protocol, with some glue to trigger the +# bootloader. +programmer + id = "wiring"; + desc = "Wiring"; + type = "wiring"; + connection_type = serial; +; + +programmer + id = "arduino"; + desc = "Arduino"; + type = "arduino"; + connection_type = serial; +; +# this will interface with the chips on these programmers: +# +# http://real.kiev.ua/old/avreal/en/adapters +# http://www.amontec.com/jtagkey.shtml, jtagkey-tiny.shtml +# http://www.olimex.com/dev/arm-usb-ocd.html, arm-usb-tiny.html +# http://www.ethernut.de/en/hardware/turtelizer/index.html +# http://elk.informatik.fh-augsburg.de/hhweb/doc/openocd/usbjtag/usbjtag.html +# http://dangerousprototypes.com/docs/FT2232_breakout_board +# http://www.ftdichip.com/Products/Modules/DLPModules.htm,DLP-2232*,DLP-USB1232H +# http://flashrom.org/FT2232SPI_Programmer +# +# The drivers will look for a specific device and use the first one found. +# If you have mulitple devices, then look for unique information (like SN) +# And fill that in here. +# +# Note that the pin numbers for the main ISP signals (reset, sck, +# mosi, miso) are fixed and cannot be changed, since they must match +# the way the Multi-Protocol Synchronous Serial Engine (MPSSE) of +# these FTDI ICs has been designed. + +programmer + id = "avrftdi"; + desc = "FT2232D based generic programmer"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; + usbpid = 0x6010; + usbvendor = ""; + usbproduct = ""; + usbdev = "A"; + usbsn = ""; +#ISP-signals - lower ADBUS-Nibble (default) + reset = 3; + sck = 0; + mosi = 1; + miso = 2; +#LED SIGNALs - higher ADBUS-Nibble +# errled = 4; +# rdyled = 5; +# pgmled = 6; +# vfyled = 7; +#Buffer Signal - ACBUS - Nibble +# buff = 8; +; +# This is an implementation of the above with a buffer IC (74AC244) and +# 4 LEDs directly attached, all active low. +programmer + id = "2232HIO"; + desc = "FT2232H based generic programmer"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; +# Note: This PID is reserved for generic H devices and +# should be programmed into the EEPROM +# usbpid = 0x8A48; + usbpid = 0x6010; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals + reset = 3; + sck = 0; + mosi = 1; + miso = 2; + buff = ~4; +#LED SIGNALs + errled = ~ 11; + rdyled = ~ 14; + pgmled = ~ 13; + vfyled = ~ 12; +; + +#The FT4232H can be treated as FT2232H, but it has a different USB +#device ID of 0x6011. +programmer parent "avrftdi" + id = "4232h"; + desc = "FT4232H based generic programmer"; + usbpid = 0x6011; +; + +programmer + id = "jtagkey"; + desc = "Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; +# Note: This PID is used in all JTAGKey variants + usbpid = 0xCFF8; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals => 20 - Pin connector on JTAGKey + reset = 3; # TMS 7 violet + sck = 0; # TCK 9 white + mosi = 1; # TDI 5 green + miso = 2; # TDO 13 orange + buff = ~4; +# VTG VREF 1 brown with red tip +# GND GND 20 black +# The colors are on the 20 pin breakout cable +# from Amontec +; + +# UM232H module from FTDI and Glyn.com.au. +# See helix.air.net.au for detailed usage information. +# J1: Connect pin 2 and 3 for USB power. +# J2: Connect pin 2 and 3 for USB power. +# J2: Pin 7 is SCK +# : Pin 8 is MOSI +# : Pin 9 is MISO +# : Pin 11 is RST +# : Pin 6 is ground +# Use the -b flag to set the SPI clock rate eg -b 3750000 is the fastest I could get +# a 16MHz Atmega1280 to program reliably. The 232H is conveniently 5V tolerant. +programmer + id = "UM232H"; + desc = "FT232H based module from FTDI and Glyn.com.au"; + type = "avrftdi"; + usbvid = 0x0403; +# Note: This PID is reserved for generic 232H devices and +# should be programmed into the EEPROM + usbpid = 0x6014; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals + sck = 0; + mosi = 1; + miso = 2; + reset = 3; +; + +# C232HM module from FTDI and Glyn.com.au. +# : Orange is SCK +# : Yellow is MOSI +# : Green is MISO +# : Brown is RST +# : Black is ground +# Use the -b flag to set the SPI clock rate eg -b 3750000 is the fastest I could get +# a 16MHz Atmega1280 to program reliably. The 232H is conveniently 5V tolerant. +programmer + id = "C232HM"; + desc = "FT232H based module from FTDI and Glyn.com.au"; + type = "avrftdi"; + usbvid = 0x0403; +# Note: This PID is reserved for generic 232H devices and +# should be programmed into the EEPROM + usbpid = 0x6014; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; +#ISP-signals + sck = 0; + mosi = 1; + miso = 2; + reset = 3; +; + + +# On the adapter you can read "O-Link". On the PCB is printed "OpenJTAG v3.1" +# You can find it as "OpenJTAG ARM JTAG USB" in the internet. +# (But there are also several projects called Open JTAG, eg. +# http://www.openjtag.org, which are completely different.) +# http://www.100ask.net/shop/english.html (website seems to be outdated) +# http://item.taobao.com/item.htm?id=1559277013 +# http://www.micro4you.com/store/openjtag-arm-jtag-usb.html (schematics!) +# some other sources which call it O-Link +# http://www.andahammer.com/olink/ +# http://www.developmentboard.net/31-o-link-debugger.html +# http://armwerks.com/catalog/o-link-debugger-copy/ +# or just have a look at ebay ... +# It is basically the same entry as jtagkey with different usb ids. +programmer parent "jtagkey" + id = "o-link"; + desc = "O-Link, OpenJTAG from www.100ask.net"; + usbvid = 0x1457; + usbpid = 0x5118; + usbvendor = "www.100ask.net"; + usbproduct = "USB<=>JTAG&RS232"; +; + +# http://wiki.openmoko.org/wiki/Debug_Board_v3 +programmer + id = "openmoko"; + desc = "Openmoko debug board (v3)"; + type = "avrftdi"; + usbvid = 0x1457; + usbpid = 0x5118; + usbdev = "A"; + usbvendor = ""; + usbproduct = ""; + usbsn = ""; + reset = 3; # TMS 7 + sck = 0; # TCK 9 + mosi = 1; # TDI 5 + miso = 2; # TDO 13 +; + +# Only Rev. A boards. +# Schematic and user manual: http://www.cs.put.poznan.pl/wswitala/download/pdf/811EVBK.pdf +programmer + id = "lm3s811"; + desc = "Luminary Micro LM3S811 Eval Board (Rev. A)"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; + usbpid = 0xbcd9; + usbvendor = "LMI"; + usbproduct = "LM3S811 Evaluation Board"; + usbdev = "A"; + usbsn = ""; +#ISP-signals - lower ACBUS-Nibble (default) + reset = 3; + sck = 0; + mosi = 1; + miso = 2; +# Enable correct buffers + buff = 7; +; + +# submitted as bug #46020 +programmer + id = "tumpa"; + desc = "TIAO USB Multi-Protocol Adapter"; + type = "avrftdi"; + connection_type = usb; + usbvid = 0x0403; + usbpid = 0x8A98; + usbdev = "A"; + usbvendor = "TIAO"; + usbproduct = ""; + usbsn = ""; + sck = 0; # TCK 9 + mosi = 1; # TDI 5 + miso = 2; # TDO 13 + reset = 3; # TMS 7 +; + +programmer + id = "avrisp"; + desc = "Atmel AVR ISP"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "avrispv2"; + desc = "Atmel AVR ISP V2"; + type = "stk500v2"; + connection_type = serial; +; + +programmer + id = "avrispmkII"; + desc = "Atmel AVR ISP mkII"; + type = "stk500v2"; + connection_type = usb; +; + +programmer parent "avrispmkII" + id = "avrisp2"; +; + +programmer + id = "buspirate"; + desc = "The Bus Pirate"; + type = "buspirate"; + connection_type = serial; +; + +programmer + id = "buspirate_bb"; + desc = "The Bus Pirate (bitbang interface, supports TPI)"; + type = "buspirate_bb"; + connection_type = serial; + # pins are bits in bitbang byte (numbers are 87654321) + # 1|POWER|PULLUP|AUX|MOSI|CLK|MISO|CS + reset = 1; + sck = 3; + mosi = 4; + miso = 2; + #vcc = 7; This is internally set independent of this setting. +; + +# This is supposed to be the "default" STK500 entry. +# Attempts to select the correct firmware version +# by probing for it. Better use one of the entries +# below instead. +programmer + id = "stk500"; + desc = "Atmel STK500"; + type = "stk500generic"; + connection_type = serial; +; + +programmer + id = "stk500v1"; + desc = "Atmel STK500 Version 1.x firmware"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "mib510"; + desc = "Crossbow MIB510 programming board"; + type = "stk500"; + connection_type = serial; +; + +programmer + id = "stk500v2"; + desc = "Atmel STK500 Version 2.x firmware"; + type = "stk500v2"; + connection_type = serial; +; + +programmer + id = "stk500pp"; + desc = "Atmel STK500 V2 in parallel programming mode"; + type = "stk500pp"; + connection_type = serial; +; + +programmer + id = "stk500hvsp"; + desc = "Atmel STK500 V2 in high-voltage serial programming mode"; + type = "stk500hvsp"; + connection_type = serial; +; + +programmer + id = "stk600"; + desc = "Atmel STK600"; + type = "stk600"; + connection_type = usb; +; + +programmer + id = "stk600pp"; + desc = "Atmel STK600 in parallel programming mode"; + type = "stk600pp"; + connection_type = usb; +; + +programmer + id = "stk600hvsp"; + desc = "Atmel STK600 in high-voltage serial programming mode"; + type = "stk600hvsp"; + connection_type = usb; +; + +programmer + id = "avr910"; + desc = "Atmel Low Cost Serial Programmer"; + type = "avr910"; + connection_type = serial; +; + +programmer + id = "ft245r"; + desc = "FT245R Synchronous BitBang"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 1; # D1 + sck = 0; # D0 + mosi = 2; # D2 + reset = 4; # D4 +; + +programmer + id = "ft232r"; + desc = "FT232R Synchronous BitBang"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 1; # RxD + sck = 0; # TxD + mosi = 2; # RTS + reset = 4; # DTR +; + +# see http://www.bitwizard.nl/wiki/index.php/FTDI_ATmega +programmer + id = "bwmega"; + desc = "BitWizard ftdi_atmega builtin programmer"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 5; # DSR + sck = 6; # DCD + mosi = 3; # CTS + reset = 7; # RI +; + +# see http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html +# Note: pins are numbered from 1! +programmer + id = "arduino-ft232r"; + desc = "Arduino: FT232R connected to ISP"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 3; # CTS X3(1) + sck = 5; # DSR X3(2) + mosi = 6; # DCD X3(3) + reset = 7; # RI X3(4) +; + +# website mentioned above uses this id +programmer parent "arduino-ft232r" + id = "diecimila"; + desc = "alias for arduino-ft232r"; +; + +# There is a ATmega328P kit PCB called "uncompatino". +# This board allows ISP via its on-board FT232R. +# This is designed like Arduino Duemilanove but has no standard ICPS header. +# Its 4 pairs of pins are shorted to enable ftdi_syncbb. +# http://akizukidenshi.com/catalog/g/gP-07487/ +# http://akizukidenshi.com/download/ds/akizuki/k6096_manual_20130816.pdf +programmer + id = "uncompatino"; + desc = "uncompatino with all pairs of pins shorted"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 3; # cts + sck = 5; # dsr + mosi = 6; # dcd + reset = 7; # ri +; + +# FTDI USB to serial cable TTL-232R-5V with a custom adapter for ICSP +# http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm +# http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232R_CABLES.pdf +# For ICSP pinout see for example http://www.atmel.com/images/doc2562.pdf +# (Figure 1. ISP6PIN header pinout and Table 1. Connections required for ISP ...) +# TTL-232R GND 1 Black -> ICPS GND (pin 6) +# TTL-232R CTS 2 Brown -> ICPS MOSI (pin 4) +# TTL-232R VCC 3 Red -> ICPS VCC (pin 2) +# TTL-232R TXD 4 Orange -> ICPS RESET (pin 5) +# TTL-232R RXD 5 Yellow -> ICPS SCK (pin 3) +# TTL-232R RTS 6 Green -> ICPS MISO (pin 1) +# Except for VCC and GND, you can connect arbitual pairs as long as +# the following table is adjusted. +programmer + id = "ttl232r"; + desc = "FTDI TTL232R-5V with ICSP adapter"; + type = "ftdi_syncbb"; + connection_type = usb; + miso = 2; # rts + sck = 1; # rxd + mosi = 3; # cts + reset = 0; # txd +; + +programmer + id = "usbasp"; + desc = "USBasp, http://www.fischl.de/usbasp/"; + type = "usbasp"; + connection_type = usb; + usbvid = 0x16C0; # VOTI + usbpid = 0x05DC; # Obdev's free shared PID + usbvendor = "www.fischl.de"; + usbproduct = "USBasp"; + + # following variants are autodetected for id "usbasp" + + # original usbasp from fischl.de + # see above "usbasp" + + # old usbasp from fischl.de + #usbvid = 0x03EB; # ATMEL + #usbpid = 0xC7B4; # (unoffical) USBasp + #usbvendor = "www.fischl.de"; + #usbproduct = "USBasp"; + + # NIBObee (only if -P nibobee is given on command line) + # see below "nibobee" +; + +programmer + id = "nibobee"; + desc = "NIBObee"; + type = "usbasp"; + connection_type = usb; + usbvid = 0x16C0; # VOTI + usbpid = 0x092F; # NIBObee PID + usbvendor = "www.nicai-systems.com"; + usbproduct = "NIBObee"; +; + +programmer + id = "usbasp-clone"; + desc = "Any usbasp clone with correct VID/PID"; + type = "usbasp"; + connection_type = usb; + usbvid = 0x16C0; # VOTI + usbpid = 0x05DC; # Obdev's free shared PID + #usbvendor = ""; + #usbproduct = ""; +; + +programmer + id = "usbtiny"; + desc = "USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/"; + type = "usbtiny"; + connection_type = usb; + usbvid = 0x1781; + usbpid = 0x0c9f; +; + +# commercial version of USBtiny, using a separate VID/PID +programmer + id = "ehajo-isp"; + desc = "avr-isp-programmer from eHaJo, http://www.eHaJo.de"; + type = "usbtiny"; + connection_type = usb; + usbvid = 0x16D0; + usbpid = 0x0BA5; +; + +programmer + id = "butterfly"; + desc = "Atmel Butterfly Development Board"; + type = "butterfly"; + connection_type = serial; +; + +programmer + id = "avr109"; + desc = "Atmel AppNote AVR109 Boot Loader"; + type = "butterfly"; + connection_type = serial; +; + +programmer + id = "avr911"; + desc = "Atmel AppNote AVR911 AVROSP"; + type = "butterfly"; + connection_type = serial; +; + +# suggested in http://forum.mikrokopter.de/topic-post48317.html +programmer + id = "mkbutterfly"; + desc = "Mikrokopter.de Butterfly"; + type = "butterfly_mk"; + connection_type = serial; +; + +programmer parent "mkbutterfly" + id = "butterfly_mk"; +; + +programmer + id = "jtagmkI"; + desc = "Atmel JTAG ICE (mkI)"; + baudrate = 115200; # default is 115200 + type = "jtagmki"; + connection_type = serial; +; + +# easier to type +programmer parent "jtagmkI" + id = "jtag1"; +; + +# easier to type +programmer parent "jtag1" + id = "jtag1slow"; + baudrate = 19200; +; + +# The JTAG ICE mkII has both, serial and USB connectivity. As it is +# mostly used through USB these days (AVR Studio 5 only supporting it +# that way), we make connection_type = usb the default. Users are +# still free to use a serial port with the -P option. + +programmer + id = "jtagmkII"; + desc = "Atmel JTAG ICE mkII"; + baudrate = 19200; # default is 19200 + type = "jtagmkii"; + connection_type = usb; +; + +# easier to type +programmer parent "jtagmkII" + id = "jtag2slow"; +; + +# JTAG ICE mkII @ 115200 Bd +programmer parent "jtag2slow" + id = "jtag2fast"; + baudrate = 115200; +; + +# make the fast one the default, people will love that +programmer parent "jtag2fast" + id = "jtag2"; +; + +# JTAG ICE mkII in ISP mode +programmer + id = "jtag2isp"; + desc = "Atmel JTAG ICE mkII in ISP mode"; + baudrate = 115200; + type = "jtagmkii_isp"; + connection_type = usb; +; + +# JTAG ICE mkII in debugWire mode +programmer + id = "jtag2dw"; + desc = "Atmel JTAG ICE mkII in debugWire mode"; + baudrate = 115200; + type = "jtagmkii_dw"; + connection_type = usb; +; + +# JTAG ICE mkII in AVR32 mode +programmer + id = "jtagmkII_avr32"; + desc = "Atmel JTAG ICE mkII im AVR32 mode"; + baudrate = 115200; + type = "jtagmkii_avr32"; + connection_type = usb; +; + +# JTAG ICE mkII in AVR32 mode +programmer + id = "jtag2avr32"; + desc = "Atmel JTAG ICE mkII im AVR32 mode"; + baudrate = 115200; + type = "jtagmkii_avr32"; + connection_type = usb; +; + +# JTAG ICE mkII in PDI mode +programmer + id = "jtag2pdi"; + desc = "Atmel JTAG ICE mkII PDI mode"; + baudrate = 115200; + type = "jtagmkii_pdi"; + connection_type = usb; +; + +# AVR Dragon in JTAG mode +programmer + id = "dragon_jtag"; + desc = "Atmel AVR Dragon in JTAG mode"; + baudrate = 115200; + type = "dragon_jtag"; + connection_type = usb; +; + +# AVR Dragon in ISP mode +programmer + id = "dragon_isp"; + desc = "Atmel AVR Dragon in ISP mode"; + baudrate = 115200; + type = "dragon_isp"; + connection_type = usb; +; + +# AVR Dragon in PP mode +programmer + id = "dragon_pp"; + desc = "Atmel AVR Dragon in PP mode"; + baudrate = 115200; + type = "dragon_pp"; + connection_type = usb; +; + +# AVR Dragon in HVSP mode +programmer + id = "dragon_hvsp"; + desc = "Atmel AVR Dragon in HVSP mode"; + baudrate = 115200; + type = "dragon_hvsp"; + connection_type = usb; +; + +# AVR Dragon in debugWire mode +programmer + id = "dragon_dw"; + desc = "Atmel AVR Dragon in debugWire mode"; + baudrate = 115200; + type = "dragon_dw"; + connection_type = usb; +; + +# AVR Dragon in PDI mode +programmer + id = "dragon_pdi"; + desc = "Atmel AVR Dragon in PDI mode"; + baudrate = 115200; + type = "dragon_pdi"; + connection_type = usb; +; + +programmer + id = "jtag3"; + desc = "Atmel AVR JTAGICE3 in JTAG mode"; + type = "jtagice3"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "jtag3pdi"; + desc = "Atmel AVR JTAGICE3 in PDI mode"; + type = "jtagice3_pdi"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "jtag3dw"; + desc = "Atmel AVR JTAGICE3 in debugWIRE mode"; + type = "jtagice3_dw"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "jtag3isp"; + desc = "Atmel AVR JTAGICE3 in ISP mode"; + type = "jtagice3_isp"; + connection_type = usb; + usbpid = 0x2110, 0x2140; +; + +programmer + id = "xplainedpro"; + desc = "Atmel AVR XplainedPro in JTAG mode"; + type = "jtagice3"; + connection_type = usb; + usbpid = 0x2111; +; + +programmer + id = "xplainedmini"; + desc = "Atmel AVR XplainedMini in ISP mode"; + type = "jtagice3_isp"; + connection_type = usb; + usbpid = 0x2145; +; + +programmer + id = "xplainedmini_dw"; + desc = "Atmel AVR XplainedMini in debugWIRE mode"; + type = "jtagice3_dw"; + connection_type = usb; + usbpid = 0x2145; +; + +programmer + id = "atmelice"; + desc = "Atmel-ICE (ARM/AVR) in JTAG mode"; + type = "jtagice3"; + connection_type = usb; + usbpid = 0x2141; +; + +programmer + id = "atmelice_pdi"; + desc = "Atmel-ICE (ARM/AVR) in PDI mode"; + type = "jtagice3_pdi"; + connection_type = usb; + usbpid = 0x2141; +; + +programmer + id = "atmelice_dw"; + desc = "Atmel-ICE (ARM/AVR) in debugWIRE mode"; + type = "jtagice3_dw"; + connection_type = usb; + usbpid = 0x2141; +; + +programmer + id = "atmelice_isp"; + desc = "Atmel-ICE (ARM/AVR) in ISP mode"; + type = "jtagice3_isp"; + connection_type = usb; + usbpid = 0x2141; +; + + +programmer + id = "pavr"; + desc = "Jason Kyle's pAVR Serial Programmer"; + type = "avr910"; + connection_type = serial; +; + +programmer + id = "pickit2"; + desc = "MicroChip's PICkit2 Programmer"; + type = "pickit2"; + connection_type = usb; +; + +programmer + id = "flip1"; + desc = "FLIP USB DFU protocol version 1 (doc7618)"; + type = "flip1"; + connection_type = usb; +; + +programmer + id = "flip2"; + desc = "FLIP USB DFU protocol version 2 (AVR4023)"; + type = "flip2"; + connection_type = usb; +; + +@HAVE_PARPORT_BEGIN@ Inclusion of the following depends on --enable-parport +# Parallel port programmers. + +programmer + id = "bsd"; + desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/"; + type = "par"; + connection_type = parallel; + vcc = 2, 3, 4, 5; + reset = 7; + sck = 8; + mosi = 9; + miso = 10; +; + +programmer + id = "stk200"; + desc = "STK200"; + type = "par"; + connection_type = parallel; + buff = 4, 5; + sck = 6; + mosi = 7; + reset = 9; + miso = 10; +; + +# The programming dongle used by the popular Ponyprog +# utility. It is almost similar to the STK200 one, +# except that there is a LED indicating that the +# programming is currently in progress. + +programmer parent "stk200" + id = "pony-stk200"; + desc = "Pony Prog STK200"; + pgmled = 8; +; + +programmer + id = "dt006"; + desc = "Dontronics DT006"; + type = "par"; + connection_type = parallel; + reset = 4; + sck = 5; + mosi = 2; + miso = 11; +; + +programmer parent "dt006" + id = "bascom"; + desc = "Bascom SAMPLE programming cable"; +; + +programmer + id = "alf"; + desc = "Nightshade ALF-PgmAVR, http://nightshade.homeip.net/"; + type = "par"; + connection_type = parallel; + vcc = 2, 3, 4, 5; + buff = 6; + reset = 7; + sck = 8; + mosi = 9; + miso = 10; + errled = 1; + rdyled = 14; + pgmled = 16; + vfyled = 17; +; + +programmer + id = "sp12"; + desc = "Steve Bolt's Programmer"; + type = "par"; + connection_type = parallel; + vcc = 4,5,6,7,8; + reset = 3; + sck = 2; + mosi = 9; + miso = 11; +; + +programmer + id = "picoweb"; + desc = "Picoweb Programming Cable, http://www.picoweb.net/"; + type = "par"; + connection_type = parallel; + reset = 2; + sck = 3; + mosi = 4; + miso = 13; +; + +programmer + id = "abcmini"; + desc = "ABCmini Board, aka Dick Smith HOTCHIP"; + type = "par"; + connection_type = parallel; + reset = 4; + sck = 3; + mosi = 2; + miso = 10; +; + +programmer + id = "futurlec"; + desc = "Futurlec.com programming cable."; + type = "par"; + connection_type = parallel; + reset = 3; + sck = 2; + mosi = 1; + miso = 10; +; + + +# From the contributor of the "xil" jtag cable: +# The "vcc" definition isn't really vcc (the cable gets its power from +# the programming circuit) but is necessary to switch one of the +# buffer lines (trying to add it to the "buff" lines doesn't work in +# avrdude versions before 5.5j). +# With this, TMS connects to RESET, TDI to MOSI, TDO to MISO and TCK +# to SCK (plus vcc/gnd of course) +programmer + id = "xil"; + desc = "Xilinx JTAG cable"; + type = "par"; + connection_type = parallel; + mosi = 2; + sck = 3; + reset = 4; + buff = 5; + miso = 13; + vcc = 6; +; + + +programmer + id = "dapa"; + desc = "Direct AVR Parallel Access cable"; + type = "par"; + connection_type = parallel; + vcc = 3; + reset = 16; + sck = 1; + mosi = 2; + miso = 11; +; + +programmer + id = "atisp"; + desc = "AT-ISP V1.1 programming cable for AVR-SDK1 from micro-research.co.th"; + type = "par"; + connection_type = parallel; + reset = ~6; + sck = ~8; + mosi = ~7; + miso = ~10; +; + +programmer + id = "ere-isp-avr"; + desc = "ERE ISP-AVR "; + type = "par"; + connection_type = parallel; + reset = ~4; + sck = 3; + mosi = 2; + miso = 10; +; + +programmer + id = "blaster"; + desc = "Altera ByteBlaster"; + type = "par"; + connection_type = parallel; + sck = 2; + miso = 11; + reset = 3; + mosi = 8; + buff = 14; +; + +# It is almost same as pony-stk200, except vcc on pin 5 to auto +# disconnect port (download on http://electropol.free.fr/spip/spip.php?article27) +programmer parent "pony-stk200" + id = "frank-stk200"; + desc = "Frank STK200"; + buff = ; # delete buff pin assignment + vcc = 5; +; + +# The AT98ISP Cable is a simple parallel dongle for AT89 family. +# http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2877 +programmer + id = "89isp"; + desc = "Atmel at89isp cable"; + type = "par"; + connection_type = parallel; + reset = 17; + sck = 1; + mosi = 2; + miso = 10; +; + +@HAVE_PARPORT_END@ + +#This programmer bitbangs GPIO lines using the Linux sysfs GPIO interface +# +#To enable it set the configuration below to match the GPIO lines connected to the +#relevant ISP header pins and uncomment the entry definition. In case you don't +#have the required permissions to edit this system wide config file put the +#entry in a separate .conf file and use it with -C+.conf +#on the command line. +# +#To check if your avrdude build has support for the linuxgpio programmer compiled in, +#use -c?type on the command line and look for linuxgpio in the list. If it's not available +#you need pass the --enable-linuxgpio=yes option to configure and recompile avrdude. +# +#programmer +# id = "linuxgpio"; +# desc = "Use the Linux sysfs interface to bitbang GPIO lines"; +# type = "linuxgpio"; +# reset = ?; +# sck = ?; +# mosi = ?; +# miso = ?; +#; + +# some ultra cheap programmers use bitbanging on the +# serialport. +# +# PC - DB9 - Pins for RS232: +# +# GND 5 -- |O +# | O| <- 9 RI +# DTR 4 <- |O | +# | O| <- 8 CTS +# TXD 3 <- |O | +# | O| -> 7 RTS +# RXD 2 -> |O | +# | O| <- 6 DSR +# DCD 1 -> |O +# +# Using RXD is currently not supported. +# Using RI is not supported under Win32 but is supported under Posix. + +# serial ponyprog design (dasa2 in uisp) +# reset=!txd sck=rts mosi=dtr miso=cts + +programmer + id = "ponyser"; + desc = "design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts"; + type = "serbb"; + connection_type = serial; + reset = ~3; + sck = 7; + mosi = 4; + miso = 8; +; + +# Same as above, different name +# reset=!txd sck=rts mosi=dtr miso=cts + +programmer parent "ponyser" + id = "siprog"; + desc = "Lancos SI-Prog "; +; + +# unknown (dasa in uisp) +# reset=rts sck=dtr mosi=txd miso=cts + +programmer + id = "dasa"; + desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts"; + type = "serbb"; + connection_type = serial; + reset = 7; + sck = 4; + mosi = 3; + miso = 8; +; + +# unknown (dasa3 in uisp) +# reset=!dtr sck=rts mosi=txd miso=cts + +programmer + id = "dasa3"; + desc = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts"; + type = "serbb"; + connection_type = serial; + reset = ~4; + sck = 7; + mosi = 3; + miso = 8; +; + +# C2N232i (jumper configuration "auto") +# reset=dtr sck=!rts mosi=!txd miso=!cts + +programmer + id = "c2n232i"; + desc = "serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts"; + type = "serbb"; + connection_type = serial; + reset = 4; + sck = ~7; + mosi = ~3; + miso = ~8; +; + +# +# PART DEFINITIONS +# + +#------------------------------------------------------------ +# ATtiny11 +#------------------------------------------------------------ + +# This is an HVSP-only device. + +part + id = "t11"; + desc = "ATtiny11"; + stk500_devcode = 0x11; + signature = 0x1e 0x90 0x04; + chip_erase_delay = 20000; + + timeout = 200; + 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; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + blocksize = 64; + readsize = 256; + delay = 5; + ; + + memory "flash" + size = 1024; + blocksize = 128; + readsize = 256; + delay = 3; + ; + + memory "signature" + size = 3; + ; + + memory "lock" + size = 1; + ; + + memory "calibration" + size = 1; + ; + + memory "fuse" + size = 1; + ; +; + +#------------------------------------------------------------ +# ATtiny12 +#------------------------------------------------------------ + +part + id = "t12"; + desc = "ATtiny12"; + stk500_devcode = 0x12; + avr910_devcode = 0x55; + signature = 0x1e 0x90 0x05; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 8; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + size = 1024; + min_write_delay = 4500; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; +; + +#------------------------------------------------------------ +# ATtiny13 +#------------------------------------------------------------ + +part + id = "t13"; + desc = "ATtiny13"; + has_debugwire = yes; + flash_instr = 0xB4, 0x0E, 0x1E; + eeprom_instr = 0xBB, 0xFE, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, + 0xBC, 0x0E, 0xB4, 0x0E, 0xBA, 0x0D, 0xBB, 0xBC, + 0x99, 0xE1, 0xBB, 0xAC; + stk500_devcode = 0x14; + signature = 0x1e 0x90 0x07; + chip_erase_delay = 4000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 90; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 0; + + memory "eeprom" + size = 64; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 1024; + page_size = 32; + num_pages = 32; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 0 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny15 +#------------------------------------------------------------ + +part + id = "t15"; + desc = "ATtiny15"; + stk500_devcode = 0x13; + avr910_devcode = 0x56; + signature = 0x1e 0x90 0x06; + chip_erase_delay = 8200; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 5; + synchcycles = 6; + latchcycles = 16; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 64; + min_write_delay = 8200; + max_write_delay = 8200; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + size = 1024; + min_write_delay = 4100; + max_write_delay = 4100; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x o o o o x x o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x i i i i 1 1 i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; +; + +#------------------------------------------------------------ +# AT90s1200 +#------------------------------------------------------------ + +part + id = "1200"; + desc = "AT90S1200"; + is_at90s1200 = yes; + stk500_devcode = 0x33; + avr910_devcode = 0x13; + signature = 0x1e 0x90 0x01; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 1; + bytedelay = 0; + pollindex = 0; + pollvalue = 0xFF; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 64; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 32; + readsize = 256; + ; + memory "flash" + size = 1024; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x02; + delay = 15; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s4414 +#------------------------------------------------------------ + +part + id = "4414"; + desc = "AT90S4414"; + stk500_devcode = 0x50; + avr910_devcode = 0x28; + signature = 0x1e 0x92 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s2313 +#------------------------------------------------------------ + +part + id = "2313"; + desc = "AT90S2313"; + stk500_devcode = 0x40; + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 128; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 2048; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x i i x", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s2333 +#------------------------------------------------------------ + +part + id = "2333"; +##### WARNING: No XML file for device 'AT90S2333'! ##### + desc = "AT90S2333"; + stk500_devcode = 0x42; + avr910_devcode = 0x34; + signature = 0x1e 0x91 0x05; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + pwroff_after_write = yes; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + + +#------------------------------------------------------------ +# AT90s2343 (also AT90s2323 and ATtiny22) +#------------------------------------------------------------ + +part + id = "2343"; + desc = "AT90S2343"; + stk500_devcode = 0x43; + avr910_devcode = 0x4c; + signature = 0x1e 0x91 0x03; + chip_erase_delay = 18000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 0; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 50; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + memory "flash" + size = 2048; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 128; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + 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 o o o x x x x o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 o o o x x x x o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + + +#------------------------------------------------------------ +# AT90s4433 +#------------------------------------------------------------ + +part + id = "4433"; + desc = "AT90S4433"; + stk500_devcode = 0x51; + avr910_devcode = 0x30; + signature = 0x1e 0x92 0x03; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + pwroff_after_write = yes; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s4434 +#------------------------------------------------------------ + +part + id = "4434"; +##### WARNING: No XML file for device 'AT90S4434'! ##### + desc = "AT90S4434"; + stk500_devcode = 0x52; + avr910_devcode = 0x6c; + signature = 0x1e 0x92 0x02; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + memory "eeprom" + size = 256; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + ; + memory "flash" + size = 4096; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + min_write_delay = 9000; + max_write_delay = 20000; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", + "x x x x x x x x x x x x x x x x"; + ; + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + ; + ; + +#------------------------------------------------------------ +# AT90s8515 +#------------------------------------------------------------ + +part + id = "8515"; + desc = "AT90S8515"; + stk500_devcode = 0x60; + avr910_devcode = 0x38; + signature = 0x1e 0x93 0x01; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 512; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 8192; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x7f; + readback_p2 = 0x7f; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# AT90s8535 +#------------------------------------------------------------ + +part + id = "8535"; + desc = "AT90S8535"; + stk500_devcode = 0x61; + avr910_devcode = 0x68; + signature = 0x1e 0x93 0x03; + chip_erase_delay = 20000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 1; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0x00; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "flash" + size = 8192; + min_write_delay = 9000; + max_write_delay = 20000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write_lo = " 0 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + write_hi = " 0 1 0 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 128; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "fuse" + size = 1; + 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 x x x x x x x o"; + write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + memory "lock" + size = 1; + 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 o o x x x x x x"; + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + ; + +#------------------------------------------------------------ +# ATmega103 +#------------------------------------------------------------ + +part + id = "m103"; + desc = "ATmega103"; + stk500_devcode = 0xB1; + avr910_devcode = 0x41; + signature = 0x1e 0x97 0x01; + chip_erase_delay = 112000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + pp_controlstack = + 0x0E, 0x1E, 0x8E, 0x9E, 0x2E, 0x3E, 0xAE, 0xBE, + 0x4E, 0x5E, 0xCE, 0xDE, 0x6E, 0x7E, 0xEE, 0xDE, + 0x66, 0x76, 0xE6, 0xF6, 0x6A, 0x7A, 0xEA, 0x7A, + 0x7F, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 15; + chiperasepolltimeout = 0; + programfusepulsewidth = 2; + programfusepolltimeout = 0; + programlockpulsewidth = 0; + programlockpolltimeout = 10; + + memory "eeprom" + size = 4096; + min_write_delay = 4000; + max_write_delay = 9000; + readback_p1 = 0x80; + readback_p2 = 0x7f; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 22000; + max_write_delay = 56000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x11; + delay = 70; + blocksize = 256; + readsize = 256; + ; + + memory "fuse" + size = 1; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x x o x o 1 o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 1 i 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + 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 x x x x x o o x"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega64 +#------------------------------------------------------------ + +part + id = "m64"; + desc = "ATmega64"; + has_jtag = yes; + stk500_devcode = 0xA0; + avr910_devcode = 0x45; + signature = 0x1e 0x96 0x02; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x22; + spmcr = 0x68; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + + +#------------------------------------------------------------ +# ATmega128 +#------------------------------------------------------------ + +part + id = "m128"; + desc = "ATmega128"; + has_jtag = yes; + stk500_devcode = 0xB2; + avr910_devcode = 0x43; + signature = 0x1e 0x97 0x02; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x22; + spmcr = 0x68; + rampz = 0x3b; + allowfullpagebitstream = yes; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 12; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN128 +#------------------------------------------------------------ + +part + id = "c128"; + desc = "AT90CAN128"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x97 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN64 +#------------------------------------------------------------ + +part + id = "c64"; + desc = "AT90CAN64"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x96 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90CAN32 +#------------------------------------------------------------ + +part + id = "c32"; + desc = "AT90CAN32"; + has_jtag = yes; + stk500_devcode = 0xB3; +# avr910_devcode = 0x43; + signature = 0x1e 0x95 0x81; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + eecr = 0x3f; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 256; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega16 +#------------------------------------------------------------ + +part + id = "m16"; + desc = "ATmega16"; + has_jtag = yes; + stk500_devcode = 0x82; + avr910_devcode = 0x74; + signature = 0x1e 0x94 0x03; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 100; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x04; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "calibration" + size = 4; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega164P +#------------------------------------------------------------ + +# close to ATmega16 + +part parent "m16" + id = "m164p"; + desc = "ATmega164P"; + signature = 0x1e 0x94 0x0a; + + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + allowfullpagebitstream = no; + chip_erase_delay = 55000; + + ocdrev = 3; + ; + + +#------------------------------------------------------------ +# ATmega324P +#------------------------------------------------------------ + +# similar to ATmega164P + +part + id = "m324p"; + desc = "ATmega324P"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x95 0x08; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega324PA +#------------------------------------------------------------ + +# similar to ATmega324P + +part parent "m324p" + id = "m324pa"; + desc = "ATmega324PA"; + signature = 0x1e 0x95 0x11; + + ocdrev = 3; + ; + + +#------------------------------------------------------------ +# ATmega644 +#------------------------------------------------------------ + +# similar to ATmega164 + +part + id = "m644"; + desc = "ATmega644"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x96 0x09; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega644P +#------------------------------------------------------------ + +# similar to ATmega164p + +part parent "m644" + id = "m644p"; + desc = "ATmega644P"; + signature = 0x1e 0x96 0x0a; + + ocdrev = 3; + ; + + + +#------------------------------------------------------------ +# ATmega1284 +#------------------------------------------------------------ + +# similar to ATmega164 + +part + id = "m1284"; + desc = "ATmega1284"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x97 0x06; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega1284P +#------------------------------------------------------------ + +# similar to ATmega164p + +part + id = "m1284p"; + desc = "ATmega1284P"; + has_jtag = yes; + stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one + avr910_devcode = 0x74; + signature = 0x1e 0x97 0x05; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 55000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega162 +#------------------------------------------------------------ + +part + id = "m162"; + desc = "ATmega162"; + has_jtag = yes; + stk500_devcode = 0x83; + avr910_devcode = 0x63; + signature = 0x1e 0x94 0x04; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + + idr = 0x04; + spmcr = 0x57; + allowfullpagebitstream = yes; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + ocdrev = 2; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + + ; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 16000; + max_write_delay = 16000; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + + read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; +; + + + +#------------------------------------------------------------ +# ATmega163 +#------------------------------------------------------------ + +part + id = "m163"; + desc = "ATmega163"; + stk500_devcode = 0x81; + avr910_devcode = 0x64; + signature = 0x1e 0x94 0x02; + chip_erase_delay = 32000; + pagel = 0xd7; + bs2 = 0xa0; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 30; + programfusepulsewidth = 0; + programfusepolltimeout = 2; + programlockpulsewidth = 0; + programlockpolltimeout = 2; + + + memory "eeprom" + size = 512; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 16000; + max_write_delay = 16000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x11; + delay = 20; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o x x o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i 1 1 i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x x x x x 1 o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x 1 1 1 1 1 i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x 0 x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega169 +#------------------------------------------------------------ + +part + id = "m169"; + desc = "ATmega169"; + has_jtag = yes; + stk500_devcode = 0x85; + avr910_devcode = 0x78; + signature = 0x1e 0x94 0x05; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega329 +#------------------------------------------------------------ + +part + id = "m329"; + desc = "ATmega329"; + has_jtag = yes; +# stk500_devcode = 0x85; # no STK500 support, only STK500v2 +# avr910_devcode = 0x?; # try the ATmega169 one: + avr910_devcode = 0x75; + signature = 0x1e 0x95 0x03; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega329P +#------------------------------------------------------------ +# Identical to ATmega329 except of the signature + +part parent "m329" + id = "m329p"; + desc = "ATmega329P"; + signature = 0x1e 0x95 0x0b; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega3290 +#------------------------------------------------------------ + +# identical to ATmega329 + +part parent "m329" + id = "m3290"; + desc = "ATmega3290"; + signature = 0x1e 0x95 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega3290P +#------------------------------------------------------------ + +# identical to ATmega3290 except of the signature + +part parent "m3290" + id = "m3290p"; + desc = "ATmega3290P"; + signature = 0x1e 0x95 0x0c; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega649 +#------------------------------------------------------------ + +part + id = "m649"; + desc = "ATmega649"; + has_jtag = yes; +# stk500_devcode = 0x85; # no STK500 support, only STK500v2 +# avr910_devcode = 0x?; # try the ATmega169 one: + avr910_devcode = 0x75; + signature = 0x1e 0x96 0x03; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega6490 +#------------------------------------------------------------ + +# identical to ATmega649 + +part parent "m649" + id = "m6490"; + desc = "ATmega6490"; + signature = 0x1e 0x96 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega32 +#------------------------------------------------------------ + +part + id = "m32"; + desc = "ATmega32"; + has_jtag = yes; + stk500_devcode = 0x91; + avr910_devcode = 0x72; + signature = 0x1e 0x95 0x02; + chip_erase_delay = 9000; + pagel = 0xd7; + bs2 = 0xa0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = yes; + + ocdrev = 2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega161 +#------------------------------------------------------------ + +part + id = "m161"; + desc = "ATmega161"; + stk500_devcode = 0x80; + avr910_devcode = 0x60; + signature = 0x1e 0x94 0x01; + chip_erase_delay = 28000; + pagel = 0xd7; + bs2 = 0xa0; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 30; + programfusepulsewidth = 0; + programfusepolltimeout = 2; + programlockpulsewidth = 0; + programlockpolltimeout = 2; + + memory "eeprom" + size = 512; + min_write_delay = 3400; + max_write_delay = 3400; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 5; + blocksize = 128; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 14000; + max_write_delay = 14000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 16; + blocksize = 128; + readsize = 256; + ; + + memory "fuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 x x x x x x x x", + "x x x x x x x x x o x o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", + "x x x x x x x x 1 i 1 i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATmega8 +#------------------------------------------------------------ + +part + id = "m8"; + desc = "ATmega8"; + stk500_devcode = 0x70; + avr910_devcode = 0x76; + signature = 0x1e 0x93 0x07; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 10000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + page_size = 4; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + +#------------------------------------------------------------ +# ATmega8515 +#------------------------------------------------------------ + +part + id = "m8515"; + desc = "ATmega8515"; + stk500_devcode = 0x63; + avr910_devcode = 0x3A; + signature = 0x1e 0x93 0x06; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + + + +#------------------------------------------------------------ +# ATmega8535 +#------------------------------------------------------------ + +part + id = "m8535"; + desc = "ATmega8535"; + stk500_devcode = 0x64; + avr910_devcode = 0x69; + signature = 0x1e 0x93 0x08; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 6; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x04; + delay = 20; + blocksize = 128; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 2000; + max_write_delay = 2000; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + + +#------------------------------------------------------------ +# ATtiny26 +#------------------------------------------------------------ + +part + id = "t26"; + desc = "ATtiny26"; + stk500_devcode = 0x21; + avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x09; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + mode = 0x04; + delay = 10; + blocksize = 64; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 16; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x x x x i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 4; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny261 +#------------------------------------------------------------ +# Close to ATtiny26 + +part + id = "t261"; + desc = "ATtiny261"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x0c; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 128; + page_size = 4; + num_pages = 32; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x x a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny461 +#------------------------------------------------------------ +# Close to ATtiny261 + +part + id = "t461"; + desc = "ATtiny461"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x92 0x08; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 256; + page_size = 4; + num_pages = 64; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny861 +#------------------------------------------------------------ +# Close to ATtiny461 + +part + id = "t861"; + desc = "ATtiny861"; + has_debugwire = yes; + 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; +# stk500_devcode = 0x21; +# avr910_devcode = 0x5e; + signature = 0x1e 0x93 0x0d; + pagel = 0xb3; + bs2 = 0xb2; + chip_erase_delay = 4000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 0; + + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 2; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + size = 512; + num_pages = 128; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4000; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + 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 x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", + "x x x x x x x x x x x x x x x x"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + +; + + +#------------------------------------------------------------ +# ATtiny28 +#------------------------------------------------------------ + +# This is an HVPP-only device. + +part + id = "t28"; + desc = "ATtiny28"; + stk500_devcode = 0x22; + avr910_devcode = 0x5c; + signature = 0x1e 0x91 0x07; + + 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; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 0; + poweroffdelay = 0; + resetdelayms = 0; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "flash" + size = 2048; + page_size = 2; + readsize = 256; + delay = 5; + ; + + memory "signature" + size = 3; + ; + + memory "lock" + size = 1; + ; + + memory "calibration" + size = 1; + ; + + memory "fuse" + size = 1; + ; +; + + + +#------------------------------------------------------------ +# ATmega48 +#------------------------------------------------------------ + +part + id = "m48"; + desc = "ATmega48"; + has_debugwire = yes; + 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; + stk500_devcode = 0x59; +# avr910_devcode = 0x; + signature = 0x1e 0x92 0x05; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 45000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 256; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x x", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega48P +#------------------------------------------------------------ + +part parent "m48" + id = "m48p"; + desc = "ATmega48P"; + signature = 0x1e 0x92 0x0a; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega48PB +#------------------------------------------------------------ + +part parent "m48" + id = "m48pb"; + desc = "ATmega48PB"; + signature = 0x1e 0x92 0x10; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega88 +#------------------------------------------------------------ + +part + id = "m88"; + desc = "ATmega88"; + has_debugwire = yes; + 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; + stk500_devcode = 0x73; +# avr910_devcode = 0x; + signature = 0x1e 0x93 0x0a; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 512; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega88P +#------------------------------------------------------------ + +part parent "m88" + id = "m88p"; + desc = "ATmega88P"; + signature = 0x1e 0x93 0x0f; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega88PB +#------------------------------------------------------------ + +part parent "m88" + id = "m88pb"; + desc = "ATmega88PB"; + signature = 0x1e 0x93 0x16; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# ATmega168 +#------------------------------------------------------------ + +part + id = "m168"; + desc = "ATmega168"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x94 0x06; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 512; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# ATmega168P +#------------------------------------------------------------ + +part parent "m168" + id = "m168p"; + desc = "ATmega168P"; + signature = 0x1e 0x94 0x0b; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATmega168PB +#------------------------------------------------------------ + +part parent "m168" + id = "m168pb"; + desc = "ATmega168PB"; + signature = 0x1e 0x94 0x15; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATtiny88 +#------------------------------------------------------------ + +part + id = "t88"; + desc = "ATtiny88"; + has_debugwire = yes; + 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; + stk500_devcode = 0x73; +# avr910_devcode = 0x; + signature = 0x1e 0x93 0x11; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 64; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 64; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega328 +#------------------------------------------------------------ + +part + id = "m328"; + desc = "ATmega328"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x95 0x14; + pagel = 0xd7; + bs2 = 0xc2; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; + page_size = 4; + size = 1024; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +part parent "m328" + id = "m328p"; + desc = "ATmega328P"; + signature = 0x1e 0x95 0x0F; + + ocdrev = 1; +; + +#------------------------------------------------------------ +# ATmega32m1 +#------------------------------------------------------------ + +part parent "m328" + id = "m32m1"; + desc = "ATmega32M1"; + # stk500_devcode = 0x; + # avr910_devcode = 0x; + signature = 0x1e 0x95 0x84; + bs2 = 0xe2; + + memory "efuse" + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x i i i i i i"; + ; +; + +#------------------------------------------------------------ +# ATtiny2313 +#------------------------------------------------------------ + +part + id = "t2313"; + desc = "ATtiny2313"; + has_debugwire = yes; + 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; + stk500_devcode = 0x23; +## Use the ATtiny26 devcode: + avr910_devcode = 0x5e; + signature = 0x1e 0x91 0x0a; + pagel = 0xD4; + bs2 = 0xD6; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 0; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + +# The information in the data sheet of April/2004 is wrong, this works: + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + +# The information in the data sheet of April/2004 is wrong, this works: + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + +# The information in the data sheet of April/2004 is wrong, this works: + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny2313 has Signature Bytes: 0x1E 0x91 0x0A. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + 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 = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny4313 +#------------------------------------------------------------ + +part + id = "t4313"; + desc = "ATtiny4313"; + has_debugwire = yes; + 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; + stk500_devcode = 0x23; +## Use the ATtiny26 devcode: + avr910_devcode = 0x5e; + signature = 0x1e 0x92 0x0d; + pagel = 0xD4; + bs2 = 0xD6; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 0; + + memory "eeprom" + size = 256; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny4313 has Signature Bytes: 0x1E 0x92 0x0D. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90PWM2 +#------------------------------------------------------------ + +part + id = "pwm2"; + desc = "AT90PWM2"; + has_debugwire = yes; + 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; + stk500_devcode = 0x65; +## avr910_devcode = ?; + signature = 0x1e 0x93 0x81; + pagel = 0xD8; + bs2 = 0xE2; + reset = io; + chip_erase_delay = 9000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 64; + readsize = 256; + ; +# AT90PWM2 has Signature Bytes: 0x1E 0x93 0x81. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90PWM3 +#------------------------------------------------------------ + +# Completely identical to AT90PWM2 (including the signature!) + +part parent "pwm2" + id = "pwm3"; + desc = "AT90PWM3"; + ; + +#------------------------------------------------------------ +# AT90PWM2B +#------------------------------------------------------------ +# Same as AT90PWM2 but different signature. + +part parent "pwm2" + id = "pwm2b"; + desc = "AT90PWM2B"; + signature = 0x1e 0x93 0x83; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# AT90PWM3B +#------------------------------------------------------------ + +# Completely identical to AT90PWM2B (including the signature!) + +part parent "pwm2b" + id = "pwm3b"; + desc = "AT90PWM3B"; + + ocdrev = 1; + ; + +#------------------------------------------------------------ +# AT90PWM316 +#------------------------------------------------------------ + +# Similar to AT90PWM3B, but with 16 kiB flash, 512 B EEPROM, and 1024 B SRAM. + +part parent "pwm3b" + id = "pwm316"; + desc = "AT90PWM316"; + signature = 0x1e 0x94 0x83; + + ocdrev = 1; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x21; + delay = 6; + blocksize = 128; + readsize = 256; + ; + ; + +#------------------------------------------------------------ +# AT90PWM216 +#------------------------------------------------------------ +# Completely identical to AT90PWM316 (including the signature!) + +part parent "pwm316" + id = "pwm216"; + desc = "AT90PWM216"; + ; + +#------------------------------------------------------------ +# ATtiny25 +#------------------------------------------------------------ + +part + id = "t25"; + desc = "ATtiny25"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x08; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny25 has Signature Bytes: 0x1E 0x91 0x08. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny45 +#------------------------------------------------------------ + +part + id = "t45"; + desc = "ATtiny45"; + has_debugwire = yes; + 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; + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x06; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 256; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny45 has Signature Bytes: 0x1E 0x92 0x08. (Data sheet 2586C-AVR-06/05 (doc2586.pdf) indicates otherwise!) + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny85 +#------------------------------------------------------------ + +part + id = "t85"; + desc = "ATtiny85"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x93 0x0b; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny85 has Signature Bytes: 0x1E 0x93 0x08. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega640 +#------------------------------------------------------------ +# Almost same as ATmega1280, except for different memory sizes + +part + id = "m640"; + desc = "ATmega640"; + signature = 0x1e 0x96 0x08; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega1280 +#------------------------------------------------------------ + +part + id = "m1280"; + desc = "ATmega1280"; + signature = 0x1e 0x97 0x03; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega1281 +#------------------------------------------------------------ +# Identical to ATmega1280 + +part parent "m1280" + id = "m1281"; + desc = "ATmega1281"; + signature = 0x1e 0x97 0x04; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega2560 +#------------------------------------------------------------ + +part + id = "m2560"; + desc = "ATmega2560"; + signature = 0x1e 0x98 0x01; + has_jtag = yes; + stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 4; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 262144; + page_size = 256; + num_pages = 1024; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + load_ext_addr = " 0 1 0 0 1 1 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 a16", + " 0 0 0 0 0 0 0 0"; + + mode = 0x41; + delay = 10; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega2561 +#------------------------------------------------------------ + +part parent "m2560" + id = "m2561"; + desc = "ATmega2561"; + signature = 0x1e 0x98 0x02; + + ocdrev = 4; + ; + +#------------------------------------------------------------ +# ATmega128RFA1 +#------------------------------------------------------------ +# Identical to ATmega2561 but half the ROM + +part parent "m2561" + id = "m128rfa1"; + desc = "ATmega128RFA1"; + signature = 0x1e 0xa7 0x01; + chip_erase_delay = 55000; + bs2 = 0xE2; + + ocdrev = 3; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 50000; + max_write_delay = 50000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 256; + readsize = 256; + ; + ; + +#------------------------------------------------------------ +# ATmega256RFR2 +#------------------------------------------------------------ + +part parent "m2561" + id = "m256rfr2"; + desc = "ATmega256RFR2"; + signature = 0x1e 0xa8 0x02; + chip_erase_delay = 18500; + bs2 = 0xE2; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 8192; + min_write_delay = 13000; + max_write_delay = 13000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + + ocdrev = 4; + ; + +#------------------------------------------------------------ +# ATmega128RFR2 +#------------------------------------------------------------ + +part parent "m128rfa1" + id = "m128rfr2"; + desc = "ATmega128RFR2"; + signature = 0x1e 0xa7 0x02; + + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega64RFR2 +#------------------------------------------------------------ + +part parent "m128rfa1" + id = "m64rfr2"; + desc = "ATmega64RFR2"; + signature = 0x1e 0xa6 0x02; + + + ocdrev = 3; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 50000; + max_write_delay = 50000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 256; + readsize = 256; + ; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 13000; + max_write_delay = 13000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + + ; + +#------------------------------------------------------------ +# ATmega2564RFR2 +#------------------------------------------------------------ + +part parent "m256rfr2" + id = "m2564rfr2"; + desc = "ATmega2564RFR2"; + signature = 0x1e 0xa8 0x03; + ; + +#------------------------------------------------------------ +# ATmega1284RFR2 +#------------------------------------------------------------ + +part parent "m128rfr2" + id = "m1284rfr2"; + desc = "ATmega1284RFR2"; + signature = 0x1e 0xa7 0x03; + ; + +#------------------------------------------------------------ +# ATmega644RFR2 +#------------------------------------------------------------ + +part parent "m64rfr2" + id = "m644rfr2"; + desc = "ATmega644RFR2"; + signature = 0x1e 0xa6 0x03; + ; + +#------------------------------------------------------------ +# ATtiny24 +#------------------------------------------------------------ + +part + id = "t24"; + desc = "ATtiny24"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x91 0x0b; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 128; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 2048; + page_size = 32; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x x a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny24 has Signature Bytes: 0x1E 0x91 0x0B. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny44 +#------------------------------------------------------------ + +part + id = "t44"; + desc = "ATtiny44"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x07; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 256; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny44 has Signature Bytes: 0x1E 0x92 0x07. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny84 +#------------------------------------------------------------ + +part + id = "t84"; + desc = "ATtiny84"; + has_debugwire = yes; + 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; +## no STK500 devcode in XML file, use the ATtiny45 one + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x93 0x0c; + reset = io; + chip_erase_delay = 4500; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + hvspcmdexedelay = 0; + synchcycles = 6; + latchcycles = 1; + togglevtg = 1; + poweroffdelay = 25; + resetdelayms = 0; + resetdelayus = 70; + hvleavestabdelay = 100; + resetdelay = 25; + chiperasepolltimeout = 40; + chiperasetime = 0; + programfusepolltimeout = 25; + programlockpolltimeout = 25; + + ocdrev = 1; + + memory "eeprom" + size = 512; + paged = no; + page_size = 4; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " x a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 8192; + page_size = 64; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 32; + readsize = 256; + ; +# ATtiny84 has Signature Bytes: 0x1E 0x93 0x0C. + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x x x x x x x i i"; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATtiny43U +#------------------------------------------------------------ + +part + id = "t43u"; + desc = "ATtiny43u"; + has_debugwire = yes; + 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; + stk500_devcode = 0x14; +## avr910_devcode = ?; +## Try the AT90S2313 devcode: + avr910_devcode = 0x20; + signature = 0x1e 0x92 0x0C; + reset = io; + chip_erase_delay = 1000; + + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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, 0x06, 0x16, 0x46, 0x56, + 0x0A, 0x1A, 0x4A, 0x5A, 0x1E, 0x7C, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00; + hventerstabdelay = 100; + progmodedelay = 0; + hvspcmdexedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 20; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + memory "eeprom" + size = 64; + paged = yes; + page_size = 4; + num_pages = 16; + min_write_delay = 4000; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", + "0 0 a4 a3 a2 a1 a0 o o o o o o o o"; + + write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", + "0 0 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x x", + " 0 0 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + memory "flash" + paged = yes; + size = 4096; + page_size = 64; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x x a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 64; + readsize = 256; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + memory "lock" + size = 1; + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x x i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 4500; + max_write_delay = 4500; + ; + + memory "calibration" + size = 2; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# ATmega32u4 +#------------------------------------------------------------ + +part + id = "m32u4"; + desc = "ATmega32U4"; + signature = 0x1e 0x95 0x87; + usbpid = 0x2ff4; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB646 +#------------------------------------------------------------ + +part + id = "usb646"; + desc = "AT90USB646"; + signature = 0x1e 0x96 0x82; + usbpid = 0x2ff9; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x x a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB647 +#------------------------------------------------------------ +# identical to AT90USB646 + +part parent "usb646" + id = "usb647"; + desc = "AT90USB647"; + signature = 0x1e 0x96 0x82; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AT90USB1286 +#------------------------------------------------------------ + +part + id = "usb1286"; + desc = "AT90USB1286"; + signature = 0x1e 0x97 0x82; + usbpid = 0x2ffb; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 131072; + page_size = 256; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB1287 +#------------------------------------------------------------ +# identical to AT90USB1286 + +part parent "usb1286" + id = "usb1287"; + desc = "AT90USB1287"; + signature = 0x1e 0x97 0x82; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AT90USB162 +#------------------------------------------------------------ + +part + id = "usb162"; + desc = "AT90USB162"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x94 0x82; + usbpid = 0x2ffa; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# AT90USB82 +#------------------------------------------------------------ +# Changes against AT90USB162 (beside IDs) +# memory "flash" +# size = 8192; +# num_pages = 64; + +part + id = "usb82"; + desc = "AT90USB82"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x93 0x82; + usbpid = 0x2ff7; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega32U2 +#------------------------------------------------------------ +# Changes against AT90USB162 (beside IDs) +# memory "flash" +# size = 32768; +# num_pages = 256; +# memory "eeprom" +# size = 1024; +# num_pages = 256; +part + id = "m32u2"; + desc = "ATmega32U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x95 0x8a; + usbpid = 0x2ff0; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + num_pages = 256; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; +#------------------------------------------------------------ +# ATmega16U2 +#------------------------------------------------------------ +# Changes against ATmega32U2 (beside IDs) +# memory "flash" +# size = 16384; +# num_pages = 128; +# memory "eeprom" +# size = 512; +# num_pages = 128; +part + id = "m16u2"; + desc = "ATmega16U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x94 0x89; + usbpid = 0x2fef; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 128; + num_pages = 128; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega8U2 +#------------------------------------------------------------ +# Changes against ATmega16U2 (beside IDs) +# memory "flash" +# size = 8192; +# page_size = 64; +# blocksize = 64; + +part + id = "m8u2"; + desc = "ATmega8U2"; + has_jtag = no; + has_debugwire = yes; + signature = 0x1e 0x93 0x89; + usbpid = 0x2fee; + chip_erase_delay = 9000; + reset = io; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + pagel = 0xD7; + bs2 = 0xC6; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + ocdrev = 1; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 512; + num_pages = 128; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 20; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 8192; + page_size = 128; + num_pages = 64; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; +#------------------------------------------------------------ +# ATmega325 +#------------------------------------------------------------ + +part + id = "m325"; + desc = "ATmega325"; + signature = 0x1e 0x95 0x05; + has_jtag = yes; +# stk500_devcode = 0x??; # No STK500v1 support? +# avr910_devcode = 0x??; # Try the ATmega16 one + avr910_devcode = 0x74; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 4; /* for parallel programming */ + size = 1024; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 0 0 a9 a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 32768; + page_size = 128; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega645 +#------------------------------------------------------------ + +part + id = "m645"; + desc = "ATmega645"; + signature = 0x1E 0x96 0x05; + has_jtag = yes; +# stk500_devcode = 0x??; # No STK500v1 support? +# avr910_devcode = 0x??; # Try the ATmega16 one + avr910_devcode = 0x74; + pagel = 0xd7; + bs2 = 0xa0; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + progmodedelay = 0; + latchcycles = 5; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + idr = 0x31; + spmcr = 0x57; + allowfullpagebitstream = no; + + ocdrev = 3; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 2048; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 0 0 0 a10 a9 a8", + " a7 a6 a5 a4 a3 0 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 65536; + page_size = 256; + num_pages = 256; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 0 0 0 0 0", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " 0 0 0 0 0 0 0 0"; + + mode = 0x41; + delay = 10; + blocksize = 128; + readsize = 256; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 1 1 i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "lfuse" + size = 1; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "hfuse" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "0 0 0 0 0 0 0 0 i i i i i i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "efuse" + size = 1; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; + min_write_delay = 9000; + max_write_delay = 9000; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 a1 a0 o o o o o o o o"; + ; + + memory "calibration" + size = 1; + + read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega3250 +#------------------------------------------------------------ + +part parent "m325" + id = "m3250"; + desc = "ATmega3250"; + signature = 0x1E 0x95 0x06; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# ATmega6450 +#------------------------------------------------------------ + +part parent "m645" + id = "m6450"; + desc = "ATmega6450"; + signature = 0x1E 0x96 0x06; + + ocdrev = 3; + ; + +#------------------------------------------------------------ +# AVR XMEGA family common values +#------------------------------------------------------------ + +part + id = ".xmega"; + desc = "AVR XMEGA family common values"; + has_pdi = yes; + nvm_base = 0x01c0; + mcu_base = 0x0090; + + memory "signature" + size = 3; + offset = 0x1000090; + ; + + memory "prodsig" + size = 0x32; + offset = 0x8e0200; + page_size = 0x32; + readsize = 0x32; + ; + + memory "fuse1" + size = 1; + offset = 0x8f0021; + ; + + memory "fuse2" + size = 1; + offset = 0x8f0022; + ; + + memory "fuse4" + size = 1; + offset = 0x8f0024; + ; + + memory "fuse5" + size = 1; + offset = 0x8f0025; + ; + + memory "lock" + size = 1; + offset = 0x8f0027; + ; + + memory "data" + # SRAM, only used to supply the offset + offset = 0x1000000; + ; +; + +#------------------------------------------------------------ +# ATxmega16A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x16a4u"; + desc = "ATxmega16A4U"; + signature = 0x1e 0x94 0x41; + usbpid = 0x2fe3; + + memory "eeprom" + size = 0x400; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x4000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x803000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x804000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x5000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega16C4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16c4"; + desc = "ATxmega16C4"; + signature = 0x1e 0x95 0x44; +; + +#------------------------------------------------------------ +# ATxmega16D4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16d4"; + desc = "ATxmega16D4"; + signature = 0x1e 0x94 0x42; +; + +#------------------------------------------------------------ +# ATxmega16A4 +#------------------------------------------------------------ + +part parent "x16a4u" + id = "x16a4"; + desc = "ATxmega16A4"; + signature = 0x1e 0x94 0x41; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega32A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x32a4u"; + desc = "ATxmega32A4U"; + signature = 0x1e 0x95 0x41; + usbpid = 0x2fe4; + + memory "eeprom" + size = 0x400; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x8000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x807000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x808000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x9000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega32C4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32c4"; + desc = "ATxmega32C4"; + signature = 0x1e 0x94 0x43; +; + +#------------------------------------------------------------ +# ATxmega32D4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32d4"; + desc = "ATxmega32D4"; + signature = 0x1e 0x95 0x42; +; + +#------------------------------------------------------------ +# ATxmega32A4 +#------------------------------------------------------------ + +part parent "x32a4u" + id = "x32a4"; + desc = "ATxmega32A4"; + signature = 0x1e 0x95 0x41; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega64A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x64a4u"; + desc = "ATxmega64A4U"; + signature = 0x1e 0x96 0x46; + usbpid = 0x2fe5; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x10000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x80f000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x810000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x11000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega64C3 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64c3"; + desc = "ATxmega64C3"; + signature = 0x1e 0x96 0x49; + usbpid = 0x2fd6; +; + +#------------------------------------------------------------ +# ATxmega64D3 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64d3"; + desc = "ATxmega64D3"; + signature = 0x1e 0x96 0x4a; +; + +#------------------------------------------------------------ +# ATxmega64D4 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64d4"; + desc = "ATxmega64D4"; + signature = 0x1e 0x96 0x47; +; + +#------------------------------------------------------------ +# ATxmega64A1 +#------------------------------------------------------------ + +part parent "x64a4u" + id = "x64a1"; + desc = "ATxmega64A1"; + signature = 0x1e 0x96 0x4e; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega64A1U +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a1u"; + desc = "ATxmega64A1U"; + signature = 0x1e 0x96 0x4e; + usbpid = 0x2fe8; +; + +#------------------------------------------------------------ +# ATxmega64A3 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a3"; + desc = "ATxmega64A3"; + signature = 0x1e 0x96 0x42; +; + +#------------------------------------------------------------ +# ATxmega64A3U +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a3u"; + desc = "ATxmega64A3U"; + signature = 0x1e 0x96 0x42; + usbpid = 0x2fe5; +; + +#------------------------------------------------------------ +# ATxmega64A4 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64a4"; + desc = "ATxmega64A4"; + signature = 0x1e 0x96 0x46; +; + +#------------------------------------------------------------ +# ATxmega64B1 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64b1"; + desc = "ATxmega64B1"; + signature = 0x1e 0x96 0x52; + usbpid = 0x2fe1; +; + +#------------------------------------------------------------ +# ATxmega64B3 +#------------------------------------------------------------ + +part parent "x64a1" + id = "x64b3"; + desc = "ATxmega64B3"; + signature = 0x1e 0x96 0x51; + usbpid = 0x2fdf; +; + +#------------------------------------------------------------ +# ATxmega128C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128c3"; + desc = "ATxmega128C3"; + signature = 0x1e 0x97 0x52; + usbpid = 0x2fd7; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x81e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega128D3 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128d3"; + desc = "ATxmega128D3"; + signature = 0x1e 0x97 0x48; +; + +#------------------------------------------------------------ +# ATxmega128D4 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128d4"; + desc = "ATxmega128D4"; + signature = 0x1e 0x97 0x47; +; + +#------------------------------------------------------------ +# ATxmega128A1 +#------------------------------------------------------------ + +part parent "x128c3" + id = "x128a1"; + desc = "ATxmega128A1"; + signature = 0x1e 0x97 0x4c; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128A1 revision D +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a1d"; + desc = "ATxmega128A1revD"; + signature = 0x1e 0x97 0x41; +; + +#------------------------------------------------------------ +# ATxmega128A1U +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a1u"; + desc = "ATxmega128A1U"; + signature = 0x1e 0x97 0x4c; + usbpid = 0x2fed; +; + +#------------------------------------------------------------ +# ATxmega128A3 +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a3"; + desc = "ATxmega128A3"; + signature = 0x1e 0x97 0x42; +; + +#------------------------------------------------------------ +# ATxmega128A3U +#------------------------------------------------------------ + +part parent "x128a1" + id = "x128a3u"; + desc = "ATxmega128A3U"; + signature = 0x1e 0x97 0x42; + usbpid = 0x2fe6; +; + +#------------------------------------------------------------ +# ATxmega128A4 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128a4"; + desc = "ATxmega128A4"; + signature = 0x1e 0x97 0x46; + has_jtag = yes; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x81f000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128A4U +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128a4u"; + desc = "ATxmega128A4U"; + signature = 0x1e 0x97 0x46; + usbpid = 0x2fde; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x81f000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega128B1 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x128b1"; + desc = "ATxmega128B1"; + signature = 0x1e 0x97 0x4d; + usbpid = 0x2fea; + has_jtag = yes; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x20000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x81e000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x820000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "flash" + size = 0x22000; + offset = 0x800000; + page_size = 0x100; + readsize = 0x100; + ; + + memory "usersig" + size = 0x100; + offset = 0x8e0400; + page_size = 0x100; + readsize = 0x100; + ; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega128B3 +#------------------------------------------------------------ + +part parent "x128b1" + id = "x128b3"; + desc = "ATxmega128B3"; + signature = 0x1e 0x97 0x4b; + usbpid = 0x2fe0; +; + +#------------------------------------------------------------ +# ATxmega192C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x192c3"; + desc = "ATxmega192C3"; + signature = 0x1e 0x97 0x51; + # usbpid = 0x2f??; + + memory "eeprom" + size = 0x800; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x30000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x82e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x830000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x32000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega192D3 +#------------------------------------------------------------ + +part parent "x192c3" + id = "x192d3"; + desc = "ATxmega192D3"; + signature = 0x1e 0x97 0x49; +; + +#------------------------------------------------------------ +# ATxmega192A1 +#------------------------------------------------------------ + +part parent "x192c3" + id = "x192a1"; + desc = "ATxmega192A1"; + signature = 0x1e 0x97 0x4e; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega192A3 +#------------------------------------------------------------ + +part parent "x192a1" + id = "x192a3"; + desc = "ATxmega192A3"; + signature = 0x1e 0x97 0x44; +; + +#------------------------------------------------------------ +# ATxmega192A3U +#------------------------------------------------------------ + +part parent "x192a1" + id = "x192a3u"; + desc = "ATxmega192A3U"; + signature = 0x1e 0x97 0x44; + usbpid = 0x2fe7; +; + +#------------------------------------------------------------ +# ATxmega256C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x256c3"; + desc = "ATxmega256C3"; + signature = 0x1e 0x98 0x46; + usbpid = 0x2fda; + + memory "eeprom" + size = 0x1000; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x40000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x83e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x840000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x42000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega256D3 +#------------------------------------------------------------ + +part parent "x256c3" + id = "x256d3"; + desc = "ATxmega256D3"; + signature = 0x1e 0x98 0x44; +; + +#------------------------------------------------------------ +# ATxmega256A1 +#------------------------------------------------------------ + +part parent "x256c3" + id = "x256a1"; + desc = "ATxmega256A1"; + signature = 0x1e 0x98 0x46; + has_jtag = yes; + + memory "fuse0" + size = 1; + offset = 0x8f0020; + ; +; + +#------------------------------------------------------------ +# ATxmega256A3 +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3"; + desc = "ATxmega256A3"; + signature = 0x1e 0x98 0x42; +; + +#------------------------------------------------------------ +# ATxmega256A3U +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3u"; + desc = "ATxmega256A3U"; + signature = 0x1e 0x98 0x42; + usbpid = 0x2fec; +; + +#------------------------------------------------------------ +# ATxmega256A3B +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3b"; + desc = "ATxmega256A3B"; + signature = 0x1e 0x98 0x43; +; + +#------------------------------------------------------------ +# ATxmega256A3BU +#------------------------------------------------------------ + +part parent "x256a1" + id = "x256a3bu"; + desc = "ATxmega256A3BU"; + signature = 0x1e 0x98 0x43; + usbpid = 0x2fe2; +; + +#------------------------------------------------------------ +# ATxmega384C3 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x384c3"; + desc = "ATxmega384C3"; + signature = 0x1e 0x98 0x45; + usbpid = 0x2fdb; + + memory "eeprom" + size = 0x1000; + offset = 0x8c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x60000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "apptable" + size = 0x2000; + offset = 0x85e000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "boot" + size = 0x2000; + offset = 0x860000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "flash" + size = 0x62000; + offset = 0x800000; + page_size = 0x200; + readsize = 0x100; + ; + + memory "usersig" + size = 0x200; + offset = 0x8e0400; + page_size = 0x200; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega384D3 +#------------------------------------------------------------ + +part parent "x384c3" + id = "x384d3"; + desc = "ATxmega384D3"; + signature = 0x1e 0x98 0x47; +; + +#------------------------------------------------------------ +# ATxmega8E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x8e5"; + desc = "ATxmega8E5"; + signature = 0x1e 0x93 0x41; + + memory "eeprom" + size = 0x0200; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x2000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x800; + offset = 0x00801800; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x800; + offset = 0x00802000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x2800; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega16E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x16e5"; + desc = "ATxmega16E5"; + signature = 0x1e 0x94 0x45; + + memory "eeprom" + size = 0x0200; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x4000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x00803000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x00804000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x5000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# ATxmega32E5 +#------------------------------------------------------------ + +part parent ".xmega" + id = "x32e5"; + desc = "ATxmega32E5"; + signature = 0x1e 0x95 0x4c; + + memory "eeprom" + size = 0x0400; + offset = 0x08c0000; + page_size = 0x20; + readsize = 0x100; + ; + + memory "application" + size = 0x8000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "apptable" + size = 0x1000; + offset = 0x00807000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "boot" + size = 0x1000; + offset = 0x00808000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "flash" + size = 0x9000; + offset = 0x0800000; + page_size = 0x80; + readsize = 0x100; + ; + + memory "usersig" + size = 0x80; + offset = 0x8e0400; + page_size = 0x80; + readsize = 0x100; + ; +; + +#------------------------------------------------------------ +# AVR32UC3A0512 +#------------------------------------------------------------ + +part + id = "uc3a0512"; + desc = "AT32UC3A0512"; + signature = 0xED 0xC0 0x3F; + has_jtag = yes; + is_avr32 = yes; + + memory "flash" + paged = yes; + page_size = 512; # bytes + readsize = 512; # bytes + num_pages = 1024; # could be set dynamicly + size = 0x00080000; # could be set dynamicly + offset = 0x80000000; + ; +; + +part parent "uc3a0512" + id = "ucr2"; + desc = "deprecated, use 'uc3a0512'"; +; + +#------------------------------------------------------------ +# ATtiny1634. +#------------------------------------------------------------ + +part + id = "t1634"; + desc = "ATtiny1634"; + has_debugwire = yes; + 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; + stk500_devcode = 0x86; + # avr910_devcode = 0x; + signature = 0x1e 0x94 0x12; + pagel = 0xB3; + bs2 = 0xB1; + reset = io; + chip_erase_delay = 9000; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + 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; + hventerstabdelay = 100; + progmodedelay = 0; + latchcycles = 0; + togglevtg = 1; + poweroffdelay = 15; + resetdelayms = 1; + resetdelayus = 0; + hvleavestabdelay = 15; + resetdelay = 15; + chiperasepulsewidth = 0; + chiperasepolltimeout = 10; + programfusepulsewidth = 0; + programfusepolltimeout = 5; + programlockpulsewidth = 0; + programlockpolltimeout = 5; + + memory "eeprom" + paged = no; + page_size = 4; + size = 256; + min_write_delay = 3600; + max_write_delay = 3600; + readback_p1 = 0xff; + readback_p2 = 0xff; + read = " 1 0 1 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " 0 0 0 x x x x a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_lo = " 1 1 0 0 0 0 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 a1 a0", + " i i i i i i i i"; + + writepage = " 1 1 0 0 0 0 1 0", + " 0 0 x x x x x a8", + " a7 a6 a5 a4 a3 a2 0 0", + " x x x x x x x x"; + + mode = 0x41; + delay = 5; + blocksize = 4; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 16384; + page_size = 32; + num_pages = 512; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0xff; + readback_p2 = 0xff; + read_lo = " 0 0 1 0 0 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " 0 0 0 x x x x x", + " x x a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + " 0 0 0 a12 a11 a10 a9 a8", + " a7 a6 x x x x x x", + " x x x x x x x x"; + + mode = 0x41; + delay = 6; + blocksize = 128; + readsize = 256; + + ; + + memory "lfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "hfuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + ; + + memory "efuse" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x i i i i i"; + ; + + memory "lock" + size = 1; + min_write_delay = 4500; + max_write_delay = 4500; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 1 1 1 1 i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; +; + +#------------------------------------------------------------ +# Common values for reduced core tinys (4/5/9/10/20/40) +#------------------------------------------------------------ + +part + id = ".reduced_core_tiny"; + desc = "Common values for reduced core tinys"; + has_tpi = yes; + + memory "signature" + size = 3; + offset = 0x3fc0; + page_size = 16; + ; + + memory "fuse" + size = 1; + offset = 0x3f40; + page_size = 16; + blocksize = 4; + ; + + memory "calibration" + size = 1; + offset = 0x3f80; + page_size = 16; + ; + + memory "lockbits" + size = 1; + offset = 0x3f00; + page_size = 16; + ; +; + +#------------------------------------------------------------ +# ATtiny4 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t4"; + desc = "ATtiny4"; + signature = 0x1e 0x8f 0x0a; + + memory "flash" + size = 512; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny5 +#------------------------------------------------------------ + +part parent "t4" + id = "t5"; + desc = "ATtiny5"; + signature = 0x1e 0x8f 0x09; +; + +#------------------------------------------------------------ +# ATtiny9 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t9"; + desc = "ATtiny9"; + signature = 0x1e 0x90 0x08; + + memory "flash" + size = 1024; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny10 +#------------------------------------------------------------ + +part parent "t9" + id = "t10"; + desc = "ATtiny10"; + signature = 0x1e 0x90 0x03; +; + +#------------------------------------------------------------ +# ATtiny20 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t20"; + desc = "ATtiny20"; + signature = 0x1e 0x91 0x0F; + + memory "flash" + size = 2048; + offset = 0x4000; + page_size = 16; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATtiny40 +#------------------------------------------------------------ + +part parent ".reduced_core_tiny" + id = "t40"; + desc = "ATtiny40"; + signature = 0x1e 0x92 0x0E; + + memory "flash" + size = 4096; + offset = 0x4000; + page_size = 64; + blocksize = 128; + ; +; + +#------------------------------------------------------------ +# ATmega406 +#------------------------------------------------------------ + +part + id = "m406"; + desc = "ATMEGA406"; + has_jtag = yes; + signature = 0x1e 0x95 0x07; + + # STK500 parameters (parallel programming IO lines) + pagel = 0xa7; + bs2 = 0xa0; + serial = no; + parallel = yes; + + # 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; + + # JTAG ICE mkII parameters, also from XML files + allowfullpagebitstream = no; + enablepageprogramming = yes; + idr = 0x51; + rampz = 0x00; + spmcr = 0x57; + eecr = 0x3f; + + memory "eeprom" + paged = no; + size = 512; + page_size = 4; + blocksize = 4; + readsize = 4; + num_pages = 128; + ; + + memory "flash" + paged = yes; + size = 40960; + page_size = 128; + blocksize = 128; + readsize = 128; + num_pages = 320; + ; + + memory "hfuse" + size = 1; + ; + + memory "lfuse" + size = 1; + ; + + memory "lockbits" + size = 1; + ; + + memory "signature" + size = 3; + ; +; + + diff --git a/xs/src/avrdude/avrdude.h b/xs/src/avrdude/avrdude.h new file mode 100644 index 000000000..9f724433f --- /dev/null +++ b/xs/src/avrdude/avrdude.h @@ -0,0 +1,83 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 avrdude_h +#define avrdude_h + + +extern char * progname; /* name of program, for messages */ +extern char progbuf[]; /* spaces same length as progname */ + +extern int ovsigck; /* override signature check (-F) */ +extern int verbose; /* verbosity level (-v, -vv, ...) */ +extern int quell_progress; /* quiteness level (-q, -qq) */ + +typedef void (*avrdude_message_handler_t)(const char *msg, unsigned size, void *user_p); +void avrdude_message_handler_set(avrdude_message_handler_t newhandler, void *user_p); +int avrdude_message(const int msglvl, const char *format, ...); + +// Progress reporting callback +// `progress` is in range 0 ~ 100 percent +typedef void (*avrdude_progress_handler_t)(const char *task, unsigned progress, void *user_p); +void avrdude_progress_handler_set(avrdude_progress_handler_t newhandler, void *user_p); +void avrdude_progress_external(const char *task, unsigned progress); + +// Cancellation +void avrdude_cancel(); + +#define MSG_INFO (0) /* no -v option, can be supressed with -qq */ +#define MSG_NOTICE (1) /* displayed with -v */ +#define MSG_NOTICE2 (2) /* displayed with -vv, used rarely */ +#define MSG_DEBUG (3) /* displayed with -vvv */ +#define MSG_TRACE (4) /* displayed with -vvvv, show trace commuication */ +#define MSG_TRACE2 (5) /* displayed with -vvvvv */ + +int avrdude_main(int argc, char * argv [], const char *sys_config); + +#if defined(WIN32NATIVE) + +// #include "ac_cfg.h" + +#include +#include + +#ifdef UNICODE +#error "UNICODE should not be defined for avrdude bits on Windows" +#endif + +// #ifdef __cplusplus +// extern "C" { +// #endif + +// #if !defined(HAVE_USLEEP) +// int usleep(unsigned int us); +// #endif + +// #if !defined(HAVE_GETTIMEOFDAY) +// struct timezone; +// int gettimeofday(struct timeval *tv, struct timezone *tz); +// #endif /* HAVE_GETTIMEOFDAY */ + +// #ifdef __cplusplus +// } +// #endif +#endif /* defined(WIN32NATIVE) */ + +#endif diff --git a/xs/src/avrdude/avrdude.spec.in b/xs/src/avrdude/avrdude.spec.in new file mode 100644 index 000000000..ff9879f6f --- /dev/null +++ b/xs/src/avrdude/avrdude.spec.in @@ -0,0 +1,113 @@ +## -*- mode: rpm-spec; -*- +## +## $Id$ +## +## @configure_input@ +## + +%define debug_package %{nil} + +%define _with_docs 1 +%{?_without_docs: %define _with_docs 0} + +Summary: AVRDUDE is software for programming Atmel AVR Microcontrollers. +Name: avrdude +Version: @VERSION@ +Release: 1 +URL: http://savannah.nongnu.org/projects/avrdude +Source0: %{name}-%{version}.tar.gz +License: GPL +Group: Development/Tools +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +AVRDUDE is software for programming Atmel AVR Microcontrollers. + +%if %{_with_docs} +## The avrdude-docs subpackage +%package docs +Summary: Documentation for AVRDUDE. +Group: Documentation +%description docs +Documentation for avrdude in info, html, postscript and pdf formats. +%endif + +%prep +%setup -q + +%build + +./configure --prefix=%{_prefix} --sysconfdir=/etc --mandir=%{_mandir} \ + --infodir=%{_infodir} \ +%if %{_with_docs} + --enable-doc=yes +%else + --enable-doc=no +%endif + +make + +%install +rm -rf $RPM_BUILD_ROOT +make prefix=$RPM_BUILD_ROOT%{_prefix} \ + sysconfdir=$RPM_BUILD_ROOT/etc \ + mandir=$RPM_BUILD_ROOT%{_mandir} \ + infodir=$RPM_BUILD_ROOT%{_infodir} \ + install + +rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/%{name}-%{version} +rm -f $RPM_BUILD_ROOT%{_infodir}/dir + +%clean +rm -rf $RPM_BUILD_ROOT + +%if %{_with_docs} +%post docs +[ -f %{_infodir}/avrdude.info ] && \ + /sbin/install-info %{_infodir}/avrdude.info %{_infodir}/dir || : +[ -f %{_infodir}/avrdude.info.gz ] && \ + /sbin/install-info %{_infodir}/avrdude.info.gz %{_infodir}/dir || : + +%preun docs +if [ $1 = 0 ]; then + [ -f %{_infodir}/avrdude.info ] && \ + /sbin/install-info --delete %{_infodir}/avrdude.info %{_infodir}/dir || : + [ -f %{_infodir}/avrdude.info.gz ] && \ + /sbin/install-info --delete %{_infodir}/avrdude.info.gz %{_infodir}/dir || : +fi +%endif + +%files +%defattr(-,root,root) +%{_prefix}/bin/avrdude +%{_mandir}/man1/avrdude.1.gz +%attr(0644,root,root) %config /etc/avrdude.conf + +%if %{_with_docs} +%files docs +%doc %{_infodir}/*info* +%doc doc/avrdude-html/*.html +%doc doc/TODO +%doc doc/avrdude.ps +%doc doc/avrdude.pdf +%endif + +%changelog +* Fri Sep 23 2005 Galen Seitz +- Default to enable-doc=yes during configure. +- Move info file to docs package. +- Make building of docs package conditional. Basic idea copied from avr-gcc. + +* Wed Aug 27 2003 Theodore A. Roth + [Thanks to Artur Lipowski ] +- Do not build debug package. +- Remove files not packaged to quell RH9 rpmbuild complaints. + +* Wed Mar 05 2003 Theodore A. Roth +- Add docs sub-package. +- Add %post and %preun scriptlets for handling info files. + +* Wed Feb 26 2003 Theodore A. Roth +- Initial build. + + diff --git a/xs/src/avrdude/avrftdi.c b/xs/src/avrdude/avrftdi.c new file mode 100644 index 000000000..29d10332a --- /dev/null +++ b/xs/src/avrdude/avrftdi.c @@ -0,0 +1,1275 @@ +/* + * avrftdi - extension for avrdude, Wolfgang Moser, Ville Voipio + * Copyright (C) 2011 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 + * 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$ */ +/* + * Interface to the MPSSE Engine of FTDI Chips using libftdi. + */ +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "avrftdi.h" +#include "avrftdi_tpi.h" +#include "avrftdi_private.h" +#include "usbdevs.h" + +#ifndef MAX +#define MAX(a,b) ((a)>(b)?(a):(b)) +#endif +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +#ifdef DO_NOT_BUILD_AVRFTDI + +static int avrftdi_noftdi_open (struct programmer_t *pgm, char * name) +{ + avrdude_message(MSG_INFO, "%s: Error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n", + progname); + + return -1; +} + +void avrftdi_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "avrftdi"); + pgm->open = avrftdi_noftdi_open; +} + +#else + +enum { FTDI_SCK = 0, FTDI_MOSI, FTDI_MISO, FTDI_RESET }; + +static int write_flush(avrftdi_t *); + +/* + * 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 str[128]; + + char interface = '@'; + + /* INTERFACE_ANY is zero, so @ is used + * INTERFACE_A is one, so '@' + 1 = 'A' + * and so forth ... + * be aware, there is an 'interface' member in ftdi_context, + * however, we really want the 'index' member here. + */ + interface += pdata->ftdic->index; + + int pinno; + int n = 0; + int mask = pin.mask[0]; + + const char * fmt; + + str[0] = 0; + + for(pinno = 0; mask; mask >>= 1, pinno++) { + if(!(mask & 1)) + continue; + + int chars = 0; + + char port; + /* This is FTDI's naming scheme. + * probably 'D' is for data and 'C' for control + */ + if(pinno < 8) + port = 'D'; + else + port = 'C'; + + if(str[0] == 0) + fmt = "%c%cBUS%d%n"; + else + fmt = ", %c%cBUS%d%n"; + + snprintf(&str[n], sizeof(str) - n, fmt, interface, port, pinno, &chars); + n += chars; + } + + return str; +} + +/* + * output function, to save if(vebose>level)-constructs. also prefixes output + * with "avrftdi function-name(line-number):" to identify were messages came + * from. + * This function is the backend of the log_*-macros, but it can be used + * directly. + */ +void avrftdi_log(int level, const char * func, int line, + const char * fmt, ...) { + static int skip_prefix = 0; + const char *p = fmt; + va_list ap; + + if(verbose >= level) + { + if(!skip_prefix) + { + switch(level) { + case ERR: avrdude_message(MSG_INFO, "E "); break; + case WARN: avrdude_message(MSG_INFO, "W "); break; + case INFO: avrdude_message(MSG_INFO, "I "); break; + case DEBUG: avrdude_message(MSG_INFO, "D "); break; + case TRACE: avrdude_message(MSG_INFO, "T "); break; + default: avrdude_message(MSG_INFO, " "); break; + } + avrdude_message(MSG_INFO, "%s(%d): ", func, line); + } + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + } + + skip_prefix = 1; + while(*p++) + if(*p == '\n' && !(*(p+1))) + skip_prefix = 0; +} + +/* + * helper function to print a binary buffer *buf of size len. begin and end of + * the dump are enclosed in the string contained in *desc. offset denotes the + * number of bytes which are printed on the first line (may be 0). after that + * width bytes are printed on each line + */ +static void buf_dump(const unsigned char *buf, int len, char *desc, + int offset, int width) +{ + int i; + avrdude_message(MSG_INFO, "%s begin:\n", desc); + for (i = 0; i < offset; i++) + avrdude_message(MSG_INFO, "%02x ", buf[i]); + avrdude_message(MSG_INFO, "\n"); + for (i++; i <= len; i++) { + avrdude_message(MSG_INFO, "%02x ", buf[i-1]); + if((i-offset) != 0 && (i-offset)%width == 0) + avrdude_message(MSG_INFO, "\n"); + } + avrdude_message(MSG_INFO, "%s end\n", 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) +{ + int32_t divisor; + uint8_t buf[3]; + + /* divisor on 6000000 / freq - 1 */ + divisor = (6000000 / freq) - 1; + if (divisor < 0) { + log_warn("Frequency too high (%u > 6 MHz)\n", freq); + log_warn("Resetting Frequency to 6MHz\n"); + divisor = 0; + } + + if (divisor > 65535) { + log_warn("Frequency too low (%u < 91.553 Hz)\n", freq); + log_warn("Resetting Frequency to 91.553Hz\n"); + divisor = 65535; + } + + log_info("Using frequency: %d\n", 6000000/(divisor+1)); + log_info("Clock divisor: 0x%04x\n", divisor); + + buf[0] = TCK_DIVISOR; + buf[1] = (uint8_t)(divisor & 0xff); + buf[2] = (uint8_t)((divisor >> 8) & 0xff); + + E(ftdi_write_data(ftdi->ftdic, buf, 3) < 0, ftdi->ftdic); + + return 0; +} + +/* + * This function sets or clears any pin, except SCK, MISO and MOSI. Depending + * on the pin configuration, a non-zero value sets the pin in the 'active' + * state (high active, low active) and a zero value sets the pin in the + * inactive state. + * Because we configured the pin direction mask earlier, nothing bad can happen + * here. + */ +static int set_pin(PROGRAMMER * pgm, int pinfunc, int value) +{ + avrftdi_t* pdata = to_pdata(pgm); + struct pindef_t pin = pgm->pin[pinfunc]; + + if (pin.mask[0] == 0) { + // ignore not defined pins (might be the led or vcc or buff if not needed) + return 0; + } + + log_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"); + + pdata->pin_value = SET_BITS_0(pdata->pin_value, pgm, pinfunc, value); + + return write_flush(pdata); +} + +/* + * Mandatory callbacks which boil down to GPIO. + */ +static int set_led_pgm(struct programmer_t * pgm, int value) +{ + return set_pin(pgm, PIN_LED_PGM, value); +} + +static int set_led_rdy(struct programmer_t * pgm, int value) +{ + return set_pin(pgm, PIN_LED_RDY, value); +} + +static int set_led_err(struct programmer_t * pgm, int value) +{ + return set_pin(pgm, PIN_LED_ERR, value); +} + +static int set_led_vfy(struct programmer_t * pgm, int value) +{ + return set_pin(pgm, PIN_LED_VFY, value); +} + +static void avrftdi_enable(PROGRAMMER * pgm) +{ + set_pin(pgm, PPI_AVR_BUFF, ON); +} + +static void avrftdi_disable(PROGRAMMER * pgm) +{ + set_pin(pgm, PPI_AVR_BUFF, OFF); +} + +static void avrftdi_powerup(PROGRAMMER * pgm) +{ + set_pin(pgm, PPI_AVR_VCC, ON); +} + +static void avrftdi_powerdown(PROGRAMMER * pgm) +{ + set_pin(pgm, PPI_AVR_VCC, OFF); +} + +static inline int set_data(PROGRAMMER * pgm, unsigned char *buf, unsigned char data, bool read_data) { + int j; + int buf_pos = 0; + unsigned char bit = 0x80; + avrftdi_t* pdata = to_pdata(pgm); + + for (j=0; j<8; j++) { + pdata->pin_value = SET_BITS_0(pdata->pin_value,pgm,PIN_AVR_MOSI,data & bit); + pdata->pin_value = SET_BITS_0(pdata->pin_value,pgm,PIN_AVR_SCK,0); + buf[buf_pos++] = SET_BITS_LOW; + buf[buf_pos++] = (pdata->pin_value) & 0xff; + buf[buf_pos++] = (pdata->pin_direction) & 0xff; + buf[buf_pos++] = SET_BITS_HIGH; + buf[buf_pos++] = ((pdata->pin_value) >> 8) & 0xff; + buf[buf_pos++] = ((pdata->pin_direction) >> 8) & 0xff; + + pdata->pin_value = SET_BITS_0(pdata->pin_value,pgm,PIN_AVR_SCK,1); + buf[buf_pos++] = SET_BITS_LOW; + buf[buf_pos++] = (pdata->pin_value) & 0xff; + buf[buf_pos++] = (pdata->pin_direction) & 0xff; + buf[buf_pos++] = SET_BITS_HIGH; + buf[buf_pos++] = ((pdata->pin_value) >> 8) & 0xff; + buf[buf_pos++] = ((pdata->pin_direction) >> 8) & 0xff; + + if (read_data) { + buf[buf_pos++] = GET_BITS_LOW; + buf[buf_pos++] = GET_BITS_HIGH; + } + + bit >>= 1; + } + return buf_pos; +} + +static inline unsigned char extract_data(PROGRAMMER * pgm, unsigned char *buf, int offset) { + int j; + unsigned char bit = 0x80; + unsigned char r = 0; + + buf += offset * 16; // 2 bytes per bit, 8 bits + for (j=0; j<8; j++) { + uint16_t in = buf[0] | (buf[1] << 8); + if (GET_BITS_0(in,pgm,PIN_AVR_MISO)) { + r |= bit; + } + buf += 2; // 2 bytes per input + bit >>= 1; + } + return r; +} + + +static int avrftdi_transmit_bb(PROGRAMMER * pgm, unsigned char mode, const unsigned char *buf, + unsigned char *data, int buf_size) +{ + size_t remaining = buf_size; + size_t written = 0; + avrftdi_t* 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 + size_t max_size = MIN(pdata->ftdic->max_packet_size,pdata->tx_buffer_size); + // select block size so that resulting commands does not exceed max_size if possible + blocksize = MAX(1,(max_size-7)/((8*2*6)+(8*1*2))); + //avrdude_message(MSG_INFO, "blocksize %d \n",blocksize); + + while(remaining) + { + + size_t transfer_size = (remaining > blocksize) ? blocksize : remaining; + + // (8*2) outputs per data byte, 6 transmit bytes per output (SET_BITS_LOW/HIGH), + // (8*1) inputs per data byte, 2 transmit bytes per input (GET_BITS_LOW/HIGH), + // 1x SEND_IMMEDIATE + unsigned char send_buffer[(8*2*6)*transfer_size+(8*1*2)*transfer_size+7]; + int len = 0; + int i; + + for(i = 0 ; i< transfer_size; i++) { + len += set_data(pgm, send_buffer + len, buf[written+i], (mode & MPSSE_DO_READ) != 0); + } + + pdata->pin_value = SET_BITS_0(pdata->pin_value,pgm,PIN_AVR_SCK,0); + send_buffer[len++] = SET_BITS_LOW; + send_buffer[len++] = (pdata->pin_value) & 0xff; + send_buffer[len++] = (pdata->pin_direction) & 0xff; + send_buffer[len++] = SET_BITS_HIGH; + send_buffer[len++] = ((pdata->pin_value) >> 8) & 0xff; + send_buffer[len++] = ((pdata->pin_direction) >> 8) & 0xff; + + send_buffer[len++] = SEND_IMMEDIATE; + + E(ftdi_write_data(pdata->ftdic, send_buffer, len) != len, pdata->ftdic); + if (mode & MPSSE_DO_READ) { + unsigned char recv_buffer[2*16*transfer_size]; + int n; + int k = 0; + do { + n = ftdi_read_data(pdata->ftdic, &recv_buffer[k], 2*16*transfer_size - k); + E(n < 0, pdata->ftdic); + k += n; + } while (k < transfer_size); + + for(i = 0 ; i< transfer_size; i++) { + data[written + i] = extract_data(pgm, recv_buffer, i); + } + } + + written += transfer_size; + remaining -= transfer_size; + } + + return written; +} + +/* Send 'buf_size' bytes from 'cmd' to device and return data from device in + * buffer 'data'. + * 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, + unsigned char *data, int buf_size) +{ + size_t blocksize; + size_t remaining = buf_size; + size_t written = 0; + + unsigned char cmd[3]; +// unsigned char si = SEND_IMMEDIATE; + + cmd[0] = mode | MPSSE_WRITE_NEG; + cmd[1] = ((buf_size - 1) & 0xff); + cmd[2] = (((buf_size - 1) >> 8) & 0xff); + + //if we are not reading back, we can just write the data out + if(!(mode & MPSSE_DO_READ)) + blocksize = buf_size; + else + blocksize = pdata->rx_buffer_size; + + E(ftdi_write_data(pdata->ftdic, cmd, sizeof(cmd)) != sizeof(cmd), pdata->ftdic); + + while(remaining) + { + size_t transfer_size = (remaining > blocksize) ? blocksize : remaining; + + E(ftdi_write_data(pdata->ftdic, (unsigned char*)&buf[written], transfer_size) != transfer_size, pdata->ftdic); +#if 0 + if(remaining < blocksize) + E(ftdi_write_data(pdata->ftdic, &si, sizeof(si)) != sizeof(si), pdata->ftdic); +#endif + + if (mode & MPSSE_DO_READ) { + int n; + int k = 0; + do { + n = ftdi_read_data(pdata->ftdic, &data[written + k], transfer_size - k); + E(n < 0, pdata->ftdic); + k += n; + } while (k < transfer_size); + + } + + written += transfer_size; + remaining -= transfer_size; + } + + return written; +} + +static inline int avrftdi_transmit(PROGRAMMER * pgm, unsigned char mode, const unsigned char *buf, + unsigned char *data, int buf_size) +{ + avrftdi_t* 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) +{ + unsigned char buf[6]; + + log_debug("Setting pin direction (0x%04x) and value (0x%04x)\n", + pdata->pin_direction, pdata->pin_value); + + buf[0] = SET_BITS_LOW; + buf[1] = (pdata->pin_value) & 0xff; + buf[2] = (pdata->pin_direction) & 0xff; + buf[3] = SET_BITS_HIGH; + buf[4] = ((pdata->pin_value) >> 8) & 0xff; + buf[5] = ((pdata->pin_direction) >> 8) & 0xff; + + E(ftdi_write_data(pdata->ftdic, buf, 6) != 6, pdata->ftdic); + + log_trace("Set pins command: %02x %02x %02x %02x %02x %02x\n", + buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); + + /* we need to flush here, because set_pin is used as reset. + * if we want to sleep reset periods, we must be certain the + * avr has got the reset signal when we start sleeping. + * (it may be stuck in the USB stack or some USB hub) + * + * Add.: purge does NOT flush. It clears. Also, it is unknown, when the purge + * command actually arrives at the chip. + * Use read pin status command as sync. + */ + //E(ftdi_usb_purge_buffers(pdata->ftdic), pdata->ftdic); + + unsigned char cmd[] = { GET_BITS_LOW, SEND_IMMEDIATE }; + E(ftdi_write_data(pdata->ftdic, cmd, sizeof(cmd)) != sizeof(cmd), pdata->ftdic); + + int num = 0; + do + { + int n = ftdi_read_data(pdata->ftdic, buf, sizeof(buf)); + if(n > 0) + num += n; + E(n < 0, pdata->ftdic); + } while(num < 1); + + if(num > 1) + log_warn("Read %d extra bytes\n", num-1); + + return 0; + +} + +static int avrftdi_check_pins_bb(PROGRAMMER * pgm, bool output) +{ + int pin; + + /* pin checklist. */ + struct pin_checklist_t pin_checklist[N_PINS]; + + avrftdi_t* pdata = to_pdata(pgm); + + /* value for 8/12/16 bit wide interface */ + int valid_mask = ((1 << pdata->pin_limit) - 1); + + log_debug("Using valid mask bibanging: 0x%08x\n", valid_mask); + static struct pindef_t valid_pins; + valid_pins.mask[0] = valid_mask; + valid_pins.inverse[0] = valid_mask ; + + /* build pin checklist */ + for(pin = 0; pin < N_PINS; ++pin) { + pin_checklist[pin].pinname = pin; + pin_checklist[pin].mandatory = 0; + pin_checklist[pin].valid_pins = &valid_pins; + } + + /* assumes all checklists above have same number of entries */ + return pins_check(pgm, pin_checklist, N_PINS, output); +} + +static int avrftdi_check_pins_mpsse(PROGRAMMER * pgm, bool output) +{ + int pin; + + /* pin checklist. */ + struct pin_checklist_t pin_checklist[N_PINS]; + + avrftdi_t* pdata = to_pdata(pgm); + + /* SCK/MOSI/MISO are fixed and not invertable?*/ + /* TODO: inverted SCK/MISO/MOSI */ + static const struct pindef_t valid_pins_SCK = {{0x01},{0x00}} ; + static const struct pindef_t valid_pins_MOSI = {{0x02},{0x00}} ; + static const struct pindef_t valid_pins_MISO = {{0x04},{0x00}} ; + + /* value for 8/12/16 bit wide interface for other pins */ + int valid_mask = ((1 << pdata->pin_limit) - 1); + /* mask out SCK/MISO/MOSI */ + valid_mask &= ~((1 << FTDI_SCK) | (1 << FTDI_MOSI) | (1 << FTDI_MISO)); + + log_debug("Using valid mask mpsse: 0x%08x\n", valid_mask); + static struct pindef_t valid_pins_others; + valid_pins_others.mask[0] = valid_mask; + valid_pins_others.inverse[0] = valid_mask ; + + /* build pin checklist */ + for(pin = 0; pin < N_PINS; ++pin) { + pin_checklist[pin].pinname = pin; + pin_checklist[pin].mandatory = 0; + pin_checklist[pin].valid_pins = &valid_pins_others; + } + + /* now set mpsse specific pins */ + pin_checklist[PIN_AVR_SCK].mandatory = 1; + pin_checklist[PIN_AVR_SCK].valid_pins = &valid_pins_SCK; + pin_checklist[PIN_AVR_MOSI].mandatory = 1; + pin_checklist[PIN_AVR_MOSI].valid_pins = &valid_pins_MOSI; + pin_checklist[PIN_AVR_MISO].mandatory = 1; + pin_checklist[PIN_AVR_MISO].valid_pins = &valid_pins_MISO; + pin_checklist[PIN_AVR_RESET].mandatory = 1; + + /* assumes all checklists above have same number of entries */ + return pins_check(pgm, pin_checklist, N_PINS, output); +} + +static int avrftdi_pin_setup(PROGRAMMER * pgm) +{ + int pin; + + /************* + * pin setup * + *************/ + + avrftdi_t* pdata = to_pdata(pgm); + + bool pin_check_mpsse = (0 == avrftdi_check_pins_mpsse(pgm, verbose>3)); + + bool pin_check_bitbanging = (0 == avrftdi_check_pins_bb(pgm, verbose>3)); + + if (!pin_check_mpsse && !pin_check_bitbanging) { + log_err("No valid pin configuration found.\n"); + avrftdi_check_pins_bb(pgm, true); + log_err("Pin configuration for FTDI MPSSE must be:\n"); + log_err("%s: 0, %s: 1, %s: 2 (is: %s, %s, %s)\n", avr_pin_name(PIN_AVR_SCK), + avr_pin_name(PIN_AVR_MOSI), avr_pin_name(PIN_AVR_MISO), + pins_to_str(&pgm->pin[PIN_AVR_SCK]), + pins_to_str(&pgm->pin[PIN_AVR_MOSI]), + pins_to_str(&pgm->pin[PIN_AVR_MISO])); + log_err("If other pin configuration is used, fallback to slower bitbanging mode is used.\n"); + + return -1; + } + + pdata->use_bitbanging = !pin_check_mpsse; + if (pdata->use_bitbanging) log_info("Because of pin configuration fallback to bitbanging mode.\n"); + + /* + * TODO: No need to fail for a wrongly configured led or something. + * Maybe we should only fail for SCK; MISO, MOSI, RST (and probably + * VCC and BUFF). + */ + + /* everything is an output, except MISO */ + for(pin = 0; pin < N_PINS; ++pin) { + pdata->pin_direction |= pgm->pin[pin].mask[0]; + pdata->pin_value = SET_BITS_0(pdata->pin_value, pgm, pin, OFF); + } + pdata->pin_direction &= ~pgm->pin[PIN_AVR_MISO].mask[0]; + + for(pin = PIN_LED_ERR; pin < N_PINS; ++pin) { + pdata->led_mask |= pgm->pin[pin].mask[0]; + } + + + log_info("Pin direction mask: %04x\n", pdata->pin_direction); + log_info("Pin value mask: %04x\n", pdata->pin_value); + + return 0; +} + +static int avrftdi_open(PROGRAMMER * pgm, char *port) +{ + int vid, pid, interface, index, err; + char * serial, *desc; + + avrftdi_t* pdata = to_pdata(pgm); + + /************************ + * parameter validation * + ************************/ + + /* use vid/pid in following priority: config, + * defaults. cmd-line is currently not supported */ + + if (pgm->usbvid) + vid = pgm->usbvid; + else + vid = USB_VENDOR_FTDI; + + LNODEID usbpid = lfirst(pgm->usbpid); + if (usbpid) { + pid = *(int *)(ldata(usbpid)); + if (lnext(usbpid)) + avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n", + progname, pid); + } else + pid = USB_DEVICE_FT2232; + + if (0 == pgm->usbsn[0]) /* we don't care about SN. Use first avail. */ + serial = NULL; + else + serial = pgm->usbsn; + + /* not used yet, but i put them here, just in case someone does needs or + * wants to implement this. + */ + desc = NULL; + index = 0; + + if (pgm->usbdev[0] == 'a' || pgm->usbdev[0] == 'A') + interface = INTERFACE_A; + else if (pgm->usbdev[0] == 'b' || pgm->usbdev[0] == 'B') + interface = INTERFACE_B; + else { + log_warn("Invalid interface '%s'. Setting to Interface A\n", pgm->usbdev); + interface = INTERFACE_A; + } + + /**************** + * Device setup * + ****************/ + + E(ftdi_set_interface(pdata->ftdic, interface) < 0, pdata->ftdic); + + err = ftdi_usb_open_desc_index(pdata->ftdic, vid, pid, desc, serial, index); + if(err) { + log_err("Error %d occurred: %s\n", err, ftdi_get_error_string(pdata->ftdic)); + //stupid hack, because avrdude calls pgm->close() even when pgm->open() fails + //and usb_dev is intialized to the last usb device from probing + pdata->ftdic->usb_dev = NULL; + return err; + } else { + log_info("Using device VID:PID %04x:%04x and SN '%s' on interface %c.\n", + vid, pid, serial, INTERFACE_A == interface? 'A': 'B'); + } + + ftdi_set_latency_timer(pdata->ftdic, 1); + //ftdi_write_data_set_chunksize(pdata->ftdic, 16); + //ftdi_read_data_set_chunksize(pdata->ftdic, 16); + + /* set SPI mode */ + E(ftdi_set_bitmode(pdata->ftdic, 0, BITMODE_RESET) < 0, pdata->ftdic); + E(ftdi_set_bitmode(pdata->ftdic, pdata->pin_direction & 0xff, BITMODE_MPSSE) < 0, pdata->ftdic); + E(ftdi_usb_purge_buffers(pdata->ftdic), pdata->ftdic); + + write_flush(pdata); + + if (pgm->baudrate) { + set_frequency(pdata, pgm->baudrate); + } else if(pgm->bitclock) { + set_frequency(pdata, (uint32_t)(1.0f/pgm->bitclock)); + } else { + set_frequency(pdata, pgm->baudrate ? pgm->baudrate : 150000); + } + + /* set pin limit depending on chip type */ + switch(pdata->ftdic->type) { + case TYPE_AM: + case TYPE_BM: + case TYPE_R: + log_err("Found unsupported device type AM, BM or R. avrftdi "); + log_err("cannot work with your chip. Try the 'synbb' programmer.\n"); + return -1; + case TYPE_2232C: + pdata->pin_limit = 12; + pdata->rx_buffer_size = 384; + pdata->tx_buffer_size = 128; + break; + case TYPE_2232H: + pdata->pin_limit = 16; + pdata->rx_buffer_size = 4096; + pdata->tx_buffer_size = 4096; + break; +#ifdef HAVE_LIBFTDI_TYPE_232H + case TYPE_232H: + pdata->pin_limit = 16; + pdata->rx_buffer_size = 1024; + pdata->tx_buffer_size = 1024; + break; +#else +#warning No support for 232H, use a newer libftdi, version >= 0.20 +#endif + case TYPE_4232H: + pdata->pin_limit = 8; + pdata->rx_buffer_size = 2048; + pdata->tx_buffer_size = 2048; + break; + default: + log_warn("Found unknown device %x. I will do my ", pdata->ftdic->type); + log_warn("best to work with it, but no guarantees ...\n"); + pdata->pin_limit = 8; + pdata->rx_buffer_size = pdata->ftdic->max_packet_size; + pdata->tx_buffer_size = pdata->ftdic->max_packet_size; + break; + } + + if(avrftdi_pin_setup(pgm)) + return -1; + + /********************************************** + * set the ready LED and set our direction up * + **********************************************/ + + set_led_rdy(pgm,0); + set_led_pgm(pgm,1); + + return 0; +} + +static void avrftdi_close(PROGRAMMER * pgm) +{ + avrftdi_t* pdata = to_pdata(pgm); + + if(pdata->ftdic->usb_dev) { + set_pin(pgm, PIN_AVR_RESET, ON); + + /* Stop driving the pins - except for the LEDs */ + log_info("LED Mask=0x%04x value =0x%04x &=0x%04x\n", + pdata->led_mask, pdata->pin_value, pdata->led_mask & pdata->pin_value); + + pdata->pin_direction = pdata->led_mask; + pdata->pin_value &= pdata->led_mask; + write_flush(pdata); + /* reset state recommended by FTDI */ + ftdi_set_bitmode(pdata->ftdic, 0, BITMODE_RESET); + E_VOID(ftdi_usb_close(pdata->ftdic), pdata->ftdic); + } + + return; +} + +static int avrftdi_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + avrftdi_powerup(pgm); + + if(p->flags & AVRPART_HAS_TPI) + { + /* see avrftdi_tpi.c */ + avrftdi_tpi_initialize(pgm, p); + } + else + { + set_pin(pgm, PIN_AVR_RESET, OFF); + set_pin(pgm, PIN_AVR_SCK, OFF); + /*use speed optimization with CAUTION*/ + usleep(20 * 1000); + + /* giving rst-pulse of at least 2 avr-clock-cycles, for + * security (2us @ 1MHz) */ + set_pin(pgm, PIN_AVR_RESET, ON); + usleep(20 * 1000); + + /*setting rst back to 0 */ + set_pin(pgm, PIN_AVR_RESET, OFF); + /*wait at least 20ms bevor issuing spi commands to avr */ + usleep(20 * 1000); + } + + return pgm->program_enable(pgm, p); +} + +static void avrftdi_display(PROGRAMMER * pgm, const char *p) +{ + // print the full pin definitiions as in ft245r ? + return; +} + + +static int avrftdi_cmd(PROGRAMMER * pgm, const unsigned char *cmd, unsigned char *res) +{ + return avrftdi_transmit(pgm, MPSSE_DO_READ | MPSSE_DO_WRITE, cmd, res, 4); +} + + +static int avrftdi_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + int i; + unsigned char buf[4]; + + memset(buf, 0, sizeof(buf)); + + if (p->op[AVR_OP_PGM_ENABLE] == NULL) { + log_err("AVR_OP_PGM_ENABLE command not defined for %s\n", p->desc); + return -1; + } + + avr_set_bits(p->op[AVR_OP_PGM_ENABLE], buf); + + for(i = 0; i < 4; i++) { + pgm->cmd(pgm, buf, buf); + if (buf[p->pollindex-1] != p->pollvalue) { + log_warn("Program enable command not successful. Retrying.\n"); + set_pin(pgm, PIN_AVR_RESET, ON); + usleep(20); + set_pin(pgm, PIN_AVR_RESET, OFF); + avr_set_bits(p->op[AVR_OP_PGM_ENABLE], buf); + } else + return 0; + } + + log_err("Device is not responding to program enable. Check connection.\n"); + + return -1; +} + + +static int avrftdi_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char cmd[4]; + unsigned char res[4]; + + if (p->op[AVR_OP_CHIP_ERASE] == NULL) { + log_err("AVR_OP_CHIP_ERASE command not defined for %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; +} + + +/* Load extended address byte command */ +static int +avrftdi_lext(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, unsigned int address) +{ + unsigned char buf[] = { 0x00, 0x00, 0x00, 0x00 }; + + avr_set_bits(m->op[AVR_OP_LOAD_EXT_ADDR], buf); + avr_set_addr(m->op[AVR_OP_LOAD_EXT_ADDR], buf, address); + + if(verbose > TRACE) + buf_dump(buf, sizeof(buf), + "load extended address command", 0, 16 * 3); + + if (0 > avrftdi_transmit(pgm, MPSSE_DO_WRITE, buf, buf, 4)) + return -1; + + return 0; +} + +static int avrftdi_eeprom_write(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, + unsigned int page_size, unsigned int addr, unsigned int len) +{ + unsigned char cmd[] = { 0x00, 0x00, 0x00, 0x00 }; + unsigned char *data = &m->buf[addr]; + unsigned int add; + + avr_set_bits(m->op[AVR_OP_WRITE], cmd); + + for (add = addr; add < addr + len; add++) + { + avr_set_addr(m->op[AVR_OP_WRITE], cmd, add); + avr_set_input(m->op[AVR_OP_WRITE], cmd, *data++); + + if (0 > avrftdi_transmit(pgm, MPSSE_DO_WRITE, cmd, cmd, 4)) + return -1; + usleep((m->max_write_delay)); + + } + return len; +} + +static int avrftdi_eeprom_read(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, + unsigned int page_size, unsigned int addr, unsigned int len) +{ + unsigned char cmd[4]; + unsigned char buffer[len], *bufptr = buffer; + unsigned int add; + + memset(buffer, 0, sizeof(buffer)); + for (add = addr; add < addr + len; add++) + { + memset(cmd, 0, sizeof(cmd)); + avr_set_bits(m->op[AVR_OP_READ], cmd); + avr_set_addr(m->op[AVR_OP_READ], cmd, add); + + if (0 > avrftdi_transmit(pgm, MPSSE_DO_READ | MPSSE_DO_WRITE, cmd, cmd, 4)) + return -1; + + avr_get_output(m->op[AVR_OP_READ], cmd, bufptr++); + } + + memcpy(m->buf + addr, buffer, len); + return len; +} + +static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int addr, unsigned int len) +{ + int use_lext_address = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL; + + unsigned int word; + unsigned int poll_index; + unsigned int buf_size; + + unsigned char poll_byte; + unsigned char *buffer = &m->buf[addr]; + unsigned char buf[4*len+4], *bufptr = buf; + + memset(buf, 0, sizeof(buf)); + + /* pre-check opcodes */ + if (m->op[AVR_OP_LOADPAGE_LO] == NULL) { + log_err("AVR_OP_LOADPAGE_LO command not defined for %s\n", p->desc); + return -1; + } + if (m->op[AVR_OP_LOADPAGE_HI] == NULL) { + log_err("AVR_OP_LOADPAGE_HI command not defined for %s\n", p->desc); + return -1; + } + + if(page_size != m->page_size) { + log_warn("Parameter page_size is %d, ", page_size); + log_warn("but m->page_size is %d. Using the latter.\n", m->page_size); + } + + page_size = m->page_size; + + /* if we do cross a 64k word boundary (or write the + * first page), we need to issue a 'load extended + * address byte' command, which is defined as 0x4d + * 0x00
          0x00. As far as i know, this + * is only available on 256k parts. 64k word is 128k + * bytes. + * write the command only once. + */ + if(use_lext_address && (((addr/2) & 0xffff0000))) { + if (0 > avrftdi_lext(pgm, p, m, addr/2)) + return -1; + } + + /* prepare the command stream for the whole page */ + /* addr is in bytes, but we program in words. addr/2 should be something + * like addr >> WORD_SHIFT, though */ + for(word = addr/2; word < (len + addr)/2; word++) + { + log_debug("-< bytes = %d of %d\n", word * 2, len + addr); + + /*setting word*/ + avr_set_bits(m->op[AVR_OP_LOADPAGE_LO], bufptr); + /* here is the second byte increment, just if you're wondering */ + avr_set_addr(m->op[AVR_OP_LOADPAGE_LO], bufptr, word); + avr_set_input(m->op[AVR_OP_LOADPAGE_LO], bufptr, *buffer++); + bufptr += 4; + avr_set_bits(m->op[AVR_OP_LOADPAGE_HI], bufptr); + avr_set_addr(m->op[AVR_OP_LOADPAGE_HI], bufptr, word); + avr_set_input(m->op[AVR_OP_LOADPAGE_HI], bufptr, *buffer++); + bufptr += 4; + } + + /* issue write page command, if available */ + if (m->op[AVR_OP_WRITEPAGE] == NULL) { + log_err("AVR_OP_WRITEPAGE command not defined for %s\n", p->desc); + return -1; + } else { + avr_set_bits(m->op[AVR_OP_WRITEPAGE], bufptr); + /* setting page address highbyte */ + avr_set_addr(m->op[AVR_OP_WRITEPAGE], + bufptr, addr/2); + bufptr += 4; + } + + buf_size = bufptr - buf; + + if(verbose > TRACE) + buf_dump(buf, buf_size, "command buffer", 0, 16*2); + + log_info("Transmitting buffer of size: %d\n", buf_size); + if (0 > avrftdi_transmit(pgm, MPSSE_DO_WRITE, buf, buf, buf_size)) + return -1; + + bufptr = buf; + /* find a poll byte. we cannot poll a value of 0xff, so look + * for a value != 0xff + */ + for(poll_index = addr+len-1; poll_index > addr-1; poll_index--) + if(m->buf[poll_index] != 0xff) + break; + + if((poll_index < addr + len) && m->buf[poll_index] != 0xff) + { + log_info("Using m->buf[%d] = 0x%02x as polling value ", poll_index, + m->buf[poll_index]); + /* poll page write ready */ + do { + log_info("."); + + pgm->read_byte(pgm, p, m, poll_index, &poll_byte); + } while (m->buf[poll_index] != poll_byte); + + log_info("\n"); + } + else + { + log_warn("No suitable byte (!=0xff) for polling found.\n"); + log_warn("Trying to sleep instead, but programming errors may occur.\n"); + log_warn("Be sure to verify programmed memory (no -V option)\n"); + /* TODO sync write */ + /* sleep */ + usleep((m->max_write_delay)); + } + + return len; +} + +/* + *Reading from flash + */ +static int avrftdi_flash_read(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int addr, unsigned int len) +{ + OPCODE * readop; + int byte, word; + int use_lext_address = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL; + unsigned int address = addr/2; + + unsigned char o_buf[4*len+4]; + unsigned char i_buf[4*len+4]; + unsigned int index; + + + memset(o_buf, 0, sizeof(o_buf)); + memset(i_buf, 0, sizeof(i_buf)); + + /* pre-check opcodes */ + if (m->op[AVR_OP_READ_LO] == NULL) { + log_err("AVR_OP_READ_LO command not defined for %s\n", p->desc); + return -1; + } + if (m->op[AVR_OP_READ_HI] == NULL) { + log_err("AVR_OP_READ_HI command not defined for %s\n", p->desc); + return -1; + } + + if(use_lext_address && ((address & 0xffff0000))) { + if (0 > avrftdi_lext(pgm, p, m, address)) + return -1; + } + + /* word addressing! */ + for(word = addr/2, index = 0; word < (addr + len)/2; word++) + { + /* one byte is transferred via a 4-byte opcode. + * TODO: reduce magic numbers + */ + avr_set_bits(m->op[AVR_OP_READ_LO], &o_buf[index*4]); + avr_set_addr(m->op[AVR_OP_READ_LO], &o_buf[index*4], word); + index++; + avr_set_bits(m->op[AVR_OP_READ_HI], &o_buf[index*4]); + avr_set_addr(m->op[AVR_OP_READ_HI], &o_buf[index*4], word); + index++; + } + + /* transmit, + * if there was an error, we did not see, memory validation will + * subsequently fail. + */ + if(verbose > TRACE) { + buf_dump(o_buf, sizeof(o_buf), "o_buf", 0, 32); + } + + if (0 > avrftdi_transmit(pgm, MPSSE_DO_READ | MPSSE_DO_WRITE, o_buf, i_buf, len * 4)) + return -1; + + if(verbose > TRACE) { + buf_dump(i_buf, sizeof(i_buf), "i_buf", 0, 32); + } + + memset(&m->buf[addr], 0, page_size); + + /* every (read) op is 4 bytes in size and yields one byte of memory data */ + for(byte = 0; byte < page_size; byte++) { + if(byte & 1) + readop = m->op[AVR_OP_READ_HI]; + else + readop = m->op[AVR_OP_READ_LO]; + + /* take 4 bytes and put the memory byte in the buffer at + * offset addr + offset of the current byte + */ + avr_get_output(readop, &i_buf[byte*4], &m->buf[addr+byte]); + } + + if(verbose > TRACE) + buf_dump(&m->buf[addr], page_size, "page:", 0, 32); + + return len; +} + +static int avrftdi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + if (strcmp(m->desc, "flash") == 0) + return avrftdi_flash_write(pgm, p, m, page_size, addr, n_bytes); + else if (strcmp(m->desc, "eeprom") == 0) + return avrftdi_eeprom_write(pgm, p, m, page_size, addr, n_bytes); + else + return -2; +} + +static int avrftdi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + if (strcmp(m->desc, "flash") == 0) + return avrftdi_flash_read(pgm, p, m, page_size, addr, n_bytes); + else if(strcmp(m->desc, "eeprom") == 0) + return avrftdi_eeprom_read(pgm, p, m, page_size, addr, n_bytes); + else + return -2; +} + +static void +avrftdi_setup(PROGRAMMER * pgm) +{ + avrftdi_t* pdata; + + pgm->cookie = malloc(sizeof(avrftdi_t)); + pdata = to_pdata(pgm); + + pdata->ftdic = ftdi_new(); + if(!pdata->ftdic) + { + log_err("Error allocating memory.\n"); + exit(1); + } + E_VOID(ftdi_init(pdata->ftdic), pdata->ftdic); + + pdata->pin_value = 0; + pdata->pin_direction = 0; + pdata->led_mask = 0; +} + +static void +avrftdi_teardown(PROGRAMMER * pgm) +{ + avrftdi_t* pdata = to_pdata(pgm); + + if(pdata) { + ftdi_deinit(pdata->ftdic); + ftdi_free(pdata->ftdic); + free(pdata); + } +} + +void avrftdi_initpgm(PROGRAMMER * pgm) +{ + + strcpy(pgm->type, "avrftdi"); + + /* + * mandatory functions + */ + + pgm->initialize = avrftdi_initialize; + pgm->display = avrftdi_display; + pgm->enable = avrftdi_enable; + pgm->disable = avrftdi_disable; + pgm->powerup = avrftdi_powerup; + pgm->powerdown = avrftdi_powerdown; + pgm->program_enable = avrftdi_program_enable; + pgm->chip_erase = avrftdi_chip_erase; + pgm->cmd = avrftdi_cmd; + pgm->open = avrftdi_open; + pgm->close = avrftdi_close; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; + + /* + * optional functions + */ + + pgm->paged_write = avrftdi_paged_write; + pgm->paged_load = avrftdi_paged_load; + + pgm->setpin = set_pin; + + pgm->setup = avrftdi_setup; + pgm->teardown = avrftdi_teardown; + + pgm->rdy_led = set_led_rdy; + pgm->err_led = set_led_err; + pgm->pgm_led = set_led_pgm; + pgm->vfy_led = set_led_vfy; +} + +#endif /* DO_NOT_BUILD_AVRFTDI */ + + +const char avrftdi_desc[] = "Interface to the MPSSE Engine of FTDI Chips using libftdi."; + diff --git a/xs/src/avrdude/avrftdi.h b/xs/src/avrdude/avrftdi.h new file mode 100644 index 000000000..af3233528 --- /dev/null +++ b/xs/src/avrdude/avrftdi.h @@ -0,0 +1,40 @@ +/* + * avrftdi - extension for avrdude, Wolfgang Moser, Ville Voipio + * Copyright (C) 2011 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 + * 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 avrftdi_h +#define avrftdi_h + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +extern const char avrftdi_desc[]; +void avrftdi_initpgm (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/xs/src/avrdude/avrftdi_private.h b/xs/src/avrdude/avrftdi_private.h new file mode 100644 index 000000000..e89d250e7 --- /dev/null +++ b/xs/src/avrdude/avrftdi_private.h @@ -0,0 +1,86 @@ +#pragma once +#include "ac_cfg.h" + +#include + +#if defined(HAVE_LIBFTDI1) && defined(HAVE_LIBUSB_1_0) +# if defined(HAVE_LIBUSB_1_0_LIBUSB_H) +# include +# else +# include +# endif +# include +# undef HAVE_LIBFTDI_TYPE_232H +# define HAVE_LIBFTDI_TYPE_232H 1 +#elif defined(HAVE_LIBFTDI) && defined(HAVE_USB_H) +/* ftdi.h includes usb.h */ +#include +#else +#warning No libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again. +#define DO_NOT_BUILD_AVRFTDI +#endif + +#ifndef DO_NOT_BUILD_AVRFTDI + +enum { ERR, WARN, INFO, DEBUG, TRACE }; + +#define __log(lvl, fmt, ...) \ + do { \ + avrftdi_log(lvl, __func__, __LINE__, fmt, ##__VA_ARGS__); \ + } while(0) + + +#define log_err(fmt, ...) __log(ERR, fmt, ##__VA_ARGS__) +#define log_warn(fmt, ...) __log(WARN, fmt, ##__VA_ARGS__) +#define log_info(fmt, ...) __log(INFO, fmt, ##__VA_ARGS__) +#define log_debug(fmt, ...) __log(DEBUG, fmt, ##__VA_ARGS__) +#define log_trace(fmt, ...) __log(TRACE, fmt, ##__VA_ARGS__) + +#define E(x, ftdi) \ + do { \ + if ((x)) \ + { \ + avrdude_message(MSG_INFO, "%s:%d %s() %s: %s (%d)\n\t%s\n", \ + __FILE__, __LINE__, __FUNCTION__, \ + #x, strerror(errno), errno, ftdi_get_error_string(ftdi)); \ + return -1; \ + } \ + } while(0) + +#define E_VOID(x, ftdi) \ + do { \ + if ((x)) \ + { \ + avrdude_message(MSG_INFO, "%s:%d %s() %s: %s (%d)\n\t%s\n", \ + __FILE__, __LINE__, __FUNCTION__, \ + #x, strerror(errno), errno, ftdi_get_error_string(ftdi)); \ + } \ + } while(0) + + +#define to_pdata(pgm) \ + ((avrftdi_t *)((pgm)->cookie)) + +typedef struct avrftdi_s { + /* pointer to struct maintained by libftdi to identify the device */ + struct ftdi_context* ftdic; + /* bitmask of values for pins. bit 0 represents pin 0 ([A|B]DBUS0) */ + uint16_t pin_value; + /* bitmask of pin direction. a '1' make a pin an output. + * bit 0 corresponds to pin 0. */ + uint16_t pin_direction; + /* don't know. not useful. someone put it in. */ + uint16_t led_mask; + /* total number of pins supported by a programmer. varies with FTDI chips */ + int pin_limit; + /* internal RX buffer of the device. needed for INOUT transfers */ + int rx_buffer_size; + int tx_buffer_size; + /* use bitbanging instead of mpsse spi */ + bool use_bitbanging; +} avrftdi_t; + +void avrftdi_log(int level, const char * func, int line, const char * fmt, ...); + +#endif /* DO_NOT_BUILD_AVRFDTI */ + diff --git a/xs/src/avrdude/avrftdi_tpi.c b/xs/src/avrdude/avrftdi_tpi.c new file mode 100644 index 000000000..d82444e89 --- /dev/null +++ b/xs/src/avrdude/avrftdi_tpi.c @@ -0,0 +1,254 @@ +#include "ac_cfg.h" + +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "usbasp.h" + +#include "avrftdi_tpi.h" +#include "avrftdi_private.h" + +#ifndef DO_NOT_BUILD_AVRFTDI + +static void avrftdi_tpi_disable(PROGRAMMER *); +static int avrftdi_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p); + +#ifdef notyet +static void +avrftdi_debug_frame(uint16_t frame) +{ + static char bit_name[] = "IDLES01234567PSS"; + //static char bit_name[] = "SSP76543210SELDI"; + char line0[34], line1[34], line2[34]; + int bit, pos; + + for(bit = 0; bit < 16; bit++) + { + pos = 16 - bit - 1; + if(frame & (1 << pos)) + { + line0[2*pos] = '_'; + line0[2*pos+1] = ' '; + + line2[2*pos] = ' '; + line2[2*pos+1] = ' '; + } + else + { + line0[2*pos] = ' '; + line0[2*pos+1] = ' '; + + line2[2*pos] = '-'; + line2[2*pos+1] = ' '; + } + + line1[2*pos] = bit_name[pos]; + line1[2*pos+1] = ' '; + + } + + line0[32] = 0; + line1[32] = 0; + line2[32] = 0; + + log_debug("%s\n", line0); + log_debug("%s\n", line1); + //log_debug("%s\n", line2); +} +#endif /* notyet */ + +int +avrftdi_tpi_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + int ret; + + avrftdi_t* pdata = to_pdata(pgm); + unsigned char buf[] = { MPSSE_DO_WRITE | MPSSE_WRITE_NEG | MPSSE_LSB, 0x01, 0x00, 0xff, 0xff }; + + log_info("Using TPI interface\n"); + + pgm->program_enable = avrftdi_tpi_program_enable; + pgm->cmd_tpi = avrftdi_cmd_tpi; + pgm->chip_erase = avr_tpi_chip_erase; + pgm->disable = avrftdi_tpi_disable; + + pgm->paged_load = NULL; + pgm->paged_write = NULL; + + log_info("Setting /Reset pin low\n"); + pgm->setpin(pgm, PIN_AVR_RESET, OFF); + pgm->setpin(pgm, PIN_AVR_SCK, OFF); + pgm->setpin(pgm, PIN_AVR_MOSI, ON); + usleep(20 * 1000); + + pgm->setpin(pgm, PIN_AVR_RESET, ON); + /* worst case 128ms */ + usleep(2 * 128 * 1000); + + /*setting rst back to 0 */ + pgm->setpin(pgm, PIN_AVR_RESET, OFF); + /*wait at least 20ms bevor issuing spi commands to avr */ + usleep(20 * 1000); + + log_info("Sending 16 init clock cycles ...\n"); + ret = ftdi_write_data(pdata->ftdic, buf, sizeof(buf)); + + return ret; +} + +#define TPI_PARITY_MASK 0x2000 + +static uint16_t +tpi_byte2frame(uint8_t byte) +{ + uint16_t frame = 0xc00f; + int parity = __builtin_popcount(byte) & 1; + + frame |= ((byte << 5) & 0x1fe0); + + if(parity) + frame |= TPI_PARITY_MASK; + + return frame; +} + +static int +tpi_frame2byte(uint16_t frame, uint8_t * byte) +{ + /* drop idle and start bit(s) */ + *byte = (frame >> 5) & 0xff; + + int parity = __builtin_popcount(*byte) & 1; + int parity_rcvd = (frame & TPI_PARITY_MASK) ? 1 : 0; + + return parity != parity_rcvd; +} + +#ifdef notyet +static int +avrftdi_tpi_break(PROGRAMMER * pgm) +{ + unsigned char buffer[] = { MPSSE_DO_WRITE | MPSSE_WRITE_NEG | MPSSE_LSB, 1, 0, 0, 0 }; + E(ftdi_write_data(to_pdata(pgm)->ftdic, buffer, sizeof(buffer)) != sizeof(buffer), to_pdata(pgm)->ftdic); + + return 0; +} +#endif /* notyet */ + +static int +avrftdi_tpi_write_byte(PROGRAMMER * pgm, unsigned char byte) +{ + uint16_t frame; + + struct ftdi_context* ftdic = to_pdata(pgm)->ftdic; + + unsigned char buffer[] = { MPSSE_DO_WRITE | MPSSE_WRITE_NEG | MPSSE_LSB, 1, 0, 0, 0 }; + + frame = tpi_byte2frame(byte); + + buffer[3] = frame & 0xff; + buffer[4] = frame >> 8; + + log_trace("Byte %02x, frame: %04x, MPSSE: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", + byte, frame, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4]); + + //avrftdi_debug_frame(frame); + + E(ftdi_write_data(ftdic, buffer, sizeof(buffer)) != sizeof(buffer), ftdic); + + return 0; +} + +#define TPI_FRAME_SIZE 12 +#define TPI_IDLE_BITS 2 + +static int +avrftdi_tpi_read_byte(PROGRAMMER * pgm, unsigned char * byte) +{ + uint16_t frame; + + /* use 2 guard bits, 2 default idle bits + 12 frame bits = 16 bits total */ + const int bytes = 3; + int err, i = 0; + + unsigned char buffer[4]; + + buffer[0] = MPSSE_DO_READ | MPSSE_LSB; + buffer[1] = (bytes-1) & 0xff; + buffer[2] = ((bytes-1) >> 8) & 0xff; + buffer[3] = SEND_IMMEDIATE; + + log_trace("MPSSE: 0x%02x 0x%02x 0x%02x 0x%02x (Read frame)\n", + buffer[0], buffer[1], buffer[2], buffer[3]); + + ftdi_write_data(to_pdata(pgm)->ftdic, buffer, 4); + + memset(buffer, 0, sizeof(buffer)); + + i = 0; + do { + int err = ftdi_read_data(to_pdata(pgm)->ftdic, &buffer[i], bytes - i); + E(err < 0, to_pdata(pgm)->ftdic); + i += err; + } while(i < bytes); + + + log_trace("MPSSE: 0x%02x 0x%02x 0x%02x 0x%02x (Read frame)\n", + buffer[0], buffer[1], buffer[2], buffer[3]); + + + frame = buffer[0] | (buffer[1] << 8); + + err = tpi_frame2byte(frame, byte); + log_trace("Frame: 0x%04x, byte: 0x%02x\n", frame, *byte); + + //avrftdi_debug_frame(frame); + + return err; +} + +static int +avrftdi_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + return avr_tpi_program_enable(pgm, p, TPIPCR_GT_2b); +} + +int +avrftdi_cmd_tpi(PROGRAMMER * pgm, const unsigned char *cmd, int cmd_len, + unsigned char *res, int res_len) +{ + int i, err = 0; + + for(i = 0; i < cmd_len; i++) + { + err = avrftdi_tpi_write_byte(pgm, cmd[i]); + if(err) + return err; + } + + for(i = 0; i < res_len; i++) + { + err = avrftdi_tpi_read_byte(pgm, &res[i]); + if(err) + return err; + } + + return 0; +} + +static void +avrftdi_tpi_disable(PROGRAMMER * pgm) +{ + unsigned char cmd[] = {TPI_OP_SSTCS(TPIPCR), 0}; + pgm->cmd_tpi(pgm, cmd, sizeof(cmd), NULL, 0); + + log_info("Leaving Programming mode.\n"); +} + +#endif /* DO_NOT_BUILD_AVRFTDI */ + diff --git a/xs/src/avrdude/avrftdi_tpi.h b/xs/src/avrdude/avrftdi_tpi.h new file mode 100644 index 000000000..6082a379d --- /dev/null +++ b/xs/src/avrdude/avrftdi_tpi.h @@ -0,0 +1,9 @@ +#pragma once + +//int avrftdi_tpi_write_byte(PROGRAMMER * pgm, unsigned char byte); +//int avrftdi_tpi_read_byte(PROGRAMMER * pgm, unsigned char * byte); +int avrftdi_cmd_tpi(PROGRAMMER * pgm, const unsigned char *cmd, int cmd_len, + unsigned char *res, int res_len); +int avrftdi_tpi_initialize(PROGRAMMER * pgm, AVRPART * p); + + diff --git a/xs/src/avrdude/avrpart.c b/xs/src/avrdude/avrpart.c new file mode 100644 index 000000000..621a85b98 --- /dev/null +++ b/xs/src/avrdude/avrpart.c @@ -0,0 +1,680 @@ + +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2000-2004 Brian S. Dean + * 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 + * 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 "avrdude.h" +#include "libavrdude.h" + +/*** + *** Elementary functions dealing with OPCODE structures + ***/ + +OPCODE * avr_new_opcode(void) +{ + OPCODE * m; + + m = (OPCODE *)malloc(sizeof(*m)); + if (m == NULL) { + avrdude_message(MSG_INFO, "avr_new_opcode(): out of memory\n"); + exit(1); + } + + memset(m, 0, sizeof(*m)); + + return m; +} + +static OPCODE * avr_dup_opcode(OPCODE * op) +{ + OPCODE * m; + + /* this makes life easier */ + if (op == NULL) { + return NULL; + } + + m = (OPCODE *)malloc(sizeof(*m)); + if (m == NULL) { + avrdude_message(MSG_INFO, "avr_dup_opcode(): out of memory\n"); + exit(1); + } + + memcpy(m, op, sizeof(*m)); + + return m; +} + +void avr_free_opcode(OPCODE * op) +{ + free(op); +} + +/* + * avr_set_bits() + * + * Set instruction bits in the specified command based on the opcode. + */ +int avr_set_bits(OPCODE * op, unsigned char * cmd) +{ + int i, j, bit; + unsigned char mask; + + for (i=0; i<32; i++) { + if (op->bit[i].type == AVR_CMDBIT_VALUE) { + j = 3 - i / 8; + bit = i % 8; + mask = 1 << bit; + if (op->bit[i].value) + cmd[j] = cmd[j] | mask; + else + cmd[j] = cmd[j] & ~mask; + } + } + + return 0; +} + + +/* + * avr_set_addr() + * + * Set address bits in the specified command based on the opcode, and + * the address. + */ +int avr_set_addr(OPCODE * op, unsigned char * cmd, unsigned long addr) +{ + int i, j, bit; + unsigned long value; + unsigned char mask; + + for (i=0; i<32; i++) { + if (op->bit[i].type == AVR_CMDBIT_ADDRESS) { + j = 3 - i / 8; + bit = i % 8; + mask = 1 << bit; + value = addr >> op->bit[i].bitno & 0x01; + if (value) + cmd[j] = cmd[j] | mask; + else + cmd[j] = cmd[j] & ~mask; + } + } + + return 0; +} + + +/* + * avr_set_input() + * + * Set input data bits in the specified command based on the opcode, + * and the data byte. + */ +int avr_set_input(OPCODE * op, unsigned char * cmd, unsigned char data) +{ + int i, j, bit; + unsigned char value; + unsigned char mask; + + for (i=0; i<32; i++) { + if (op->bit[i].type == AVR_CMDBIT_INPUT) { + j = 3 - i / 8; + bit = i % 8; + mask = 1 << bit; + value = data >> op->bit[i].bitno & 0x01; + if (value) + cmd[j] = cmd[j] | mask; + else + cmd[j] = cmd[j] & ~mask; + } + } + + return 0; +} + + +/* + * avr_get_output() + * + * Retreive output data bits from the command results based on the + * opcode data. + */ +int avr_get_output(OPCODE * op, unsigned char * res, unsigned char * data) +{ + int i, j, bit; + unsigned char value; + unsigned char mask; + + for (i=0; i<32; i++) { + if (op->bit[i].type == AVR_CMDBIT_OUTPUT) { + j = 3 - i / 8; + bit = i % 8; + mask = 1 << bit; + value = ((res[j] & mask) >> bit) & 0x01; + value = value << op->bit[i].bitno; + if (value) + *data = *data | value; + else + *data = *data & ~value; + } + } + + return 0; +} + + +/* + * avr_get_output_index() + * + * Calculate the byte number of the output data based on the + * opcode data. + */ +int avr_get_output_index(OPCODE * op) +{ + int i, j; + + for (i=0; i<32; i++) { + if (op->bit[i].type == AVR_CMDBIT_OUTPUT) { + j = 3 - i / 8; + return j; + } + } + + return -1; +} + + +static char * avr_op_str(int op) +{ + switch (op) { + case AVR_OP_READ : return "READ"; break; + case AVR_OP_WRITE : return "WRITE"; break; + case AVR_OP_READ_LO : return "READ_LO"; break; + case AVR_OP_READ_HI : return "READ_HI"; break; + case AVR_OP_WRITE_LO : return "WRITE_LO"; break; + case AVR_OP_WRITE_HI : return "WRITE_HI"; break; + case AVR_OP_LOADPAGE_LO : return "LOADPAGE_LO"; break; + case AVR_OP_LOADPAGE_HI : return "LOADPAGE_HI"; break; + case AVR_OP_LOAD_EXT_ADDR : return "LOAD_EXT_ADDR"; break; + case AVR_OP_WRITEPAGE : return "WRITEPAGE"; break; + case AVR_OP_CHIP_ERASE : return "CHIP_ERASE"; break; + case AVR_OP_PGM_ENABLE : return "PGM_ENABLE"; break; + default : return ""; break; + } +} + + +static char * bittype(int type) +{ + switch (type) { + case AVR_CMDBIT_IGNORE : return "IGNORE"; break; + case AVR_CMDBIT_VALUE : return "VALUE"; break; + case AVR_CMDBIT_ADDRESS : return "ADDRESS"; break; + case AVR_CMDBIT_INPUT : return "INPUT"; break; + case AVR_CMDBIT_OUTPUT : return "OUTPUT"; break; + default : return ""; break; + } +} + + + +/*** + *** Elementary functions dealing with AVRMEM structures + ***/ + +AVRMEM * avr_new_memtype(void) +{ + AVRMEM * m; + + m = (AVRMEM *)malloc(sizeof(*m)); + if (m == NULL) { + avrdude_message(MSG_INFO, "avr_new_memtype(): out of memory\n"); + exit(1); + } + + memset(m, 0, sizeof(*m)); + + return m; +} + + +/* + * Allocate and initialize memory buffers for each of the device's + * defined memory regions. + */ +int avr_initmem(AVRPART * p) +{ + LNODEID ln; + AVRMEM * m; + + for (ln=lfirst(p->mem); ln; ln=lnext(ln)) { + m = ldata(ln); + m->buf = (unsigned char *) malloc(m->size); + if (m->buf == NULL) { + avrdude_message(MSG_INFO, "%s: can't alloc buffer for %s size of %d bytes\n", + progname, m->desc, m->size); + return -1; + } + m->tags = (unsigned char *) malloc(m->size); + if (m->tags == NULL) { + avrdude_message(MSG_INFO, "%s: can't alloc buffer for %s size of %d bytes\n", + progname, m->desc, m->size); + return -1; + } + } + + return 0; +} + + +AVRMEM * avr_dup_mem(AVRMEM * m) +{ + AVRMEM * n; + int i; + + n = avr_new_memtype(); + + *n = *m; + + if (m->buf != NULL) { + n->buf = (unsigned char *)malloc(n->size); + if (n->buf == NULL) { + avrdude_message(MSG_INFO, "avr_dup_mem(): out of memory (memsize=%d)\n", + n->size); + exit(1); + } + memcpy(n->buf, m->buf, n->size); + } + + if (m->tags != NULL) { + n->tags = (unsigned char *)malloc(n->size); + if (n->tags == NULL) { + avrdude_message(MSG_INFO, "avr_dup_mem(): out of memory (memsize=%d)\n", + n->size); + exit(1); + } + memcpy(n->tags, m->tags, n->size); + } + + for (i = 0; i < AVR_OP_MAX; i++) { + n->op[i] = avr_dup_opcode(n->op[i]); + } + + return n; +} + +void avr_free_mem(AVRMEM * m) +{ + int i; + if (m->buf != NULL) { + free(m->buf); + m->buf = NULL; + } + if (m->tags != NULL) { + free(m->tags); + m->tags = NULL; + } + for(i=0;iop)/sizeof(m->op[0]);i++) + { + if (m->op[i] != NULL) + { + avr_free_opcode(m->op[i]); + m->op[i] = NULL; + } + } + free(m); +} + +AVRMEM * avr_locate_mem(AVRPART * p, char * desc) +{ + AVRMEM * m, * match; + LNODEID ln; + int matches; + int l; + + l = strlen(desc); + matches = 0; + match = NULL; + for (ln=lfirst(p->mem); ln; ln=lnext(ln)) { + m = ldata(ln); + if (strncmp(desc, m->desc, l) == 0) { + match = m; + matches++; + } + } + + if (matches == 1) + return match; + + return NULL; +} + + +void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, int type, + int verbose) +{ + int i, j; + char * optr; + + if (m == NULL) { + fprintf(f, + "%s Block Poll Page Polled\n" + "%sMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n" + "%s----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n", + prefix, prefix, prefix); + } + else { + if (verbose > 2) { + fprintf(f, + "%s Block Poll Page Polled\n" + "%sMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n" + "%s----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n", + prefix, prefix, prefix); + } + fprintf(f, + "%s%-11s %4d %5d %5d %4d %-6s %6d %4d %6d %5d %5d 0x%02x 0x%02x\n", + prefix, m->desc, m->mode, m->delay, m->blocksize, m->pollindex, + m->paged ? "yes" : "no", + m->size, + m->page_size, + m->num_pages, + m->min_write_delay, + m->max_write_delay, + m->readback[0], + m->readback[1]); + if (verbose > 4) { + avrdude_message(MSG_TRACE2, "%s Memory Ops:\n" + "%s Oeration Inst Bit Bit Type Bitno Value\n" + "%s ----------- -------- -------- ----- -----\n", + prefix, prefix, prefix); + for (i=0; iop[i]) { + for (j=31; j>=0; j--) { + if (j==31) + optr = avr_op_str(i); + else + optr = " "; + fprintf(f, + "%s %-11s %8d %8s %5d %5d\n", + prefix, optr, j, + bittype(m->op[i]->bit[j].type), + m->op[i]->bit[j].bitno, + m->op[i]->bit[j].value); + } + } + } + } + } +} + + + +/* + * Elementary functions dealing with AVRPART structures + */ + + +AVRPART * avr_new_part(void) +{ + AVRPART * p; + + p = (AVRPART *)malloc(sizeof(AVRPART)); + if (p == NULL) { + avrdude_message(MSG_INFO, "new_part(): out of memory\n"); + exit(1); + } + + memset(p, 0, sizeof(*p)); + + p->id[0] = 0; + p->desc[0] = 0; + p->reset_disposition = RESET_DEDICATED; + p->retry_pulse = PIN_AVR_SCK; + p->flags = AVRPART_SERIALOK | AVRPART_PARALLELOK | AVRPART_ENABLEPAGEPROGRAMMING; + p->config_file[0] = 0; + p->lineno = 0; + memset(p->signature, 0xFF, 3); + p->ctl_stack_type = CTL_STACK_NONE; + p->ocdrev = -1; + + p->mem = lcreat(NULL, 0); + + return p; +} + + +AVRPART * avr_dup_part(AVRPART * d) +{ + AVRPART * p; + LISTID save; + LNODEID ln; + int i; + + p = avr_new_part(); + save = p->mem; + + *p = *d; + + p->mem = save; + + for (ln=lfirst(d->mem); ln; ln=lnext(ln)) { + ladd(p->mem, avr_dup_mem(ldata(ln))); + } + + for (i = 0; i < AVR_OP_MAX; i++) { + p->op[i] = avr_dup_opcode(p->op[i]); + } + + return p; +} + +void avr_free_part(AVRPART * d) +{ +int i; + ldestroy_cb(d->mem, (void(*)(void *))avr_free_mem); + d->mem = NULL; + for(i=0;iop)/sizeof(d->op[0]);i++) + { + if (d->op[i] != NULL) + { + avr_free_opcode(d->op[i]); + d->op[i] = NULL; + } + } + free(d); +} + +AVRPART * locate_part(LISTID parts, char * partdesc) +{ + LNODEID ln1; + AVRPART * p = NULL; + int found; + + found = 0; + + for (ln1=lfirst(parts); ln1 && !found; ln1=lnext(ln1)) { + p = ldata(ln1); + if ((strcasecmp(partdesc, p->id) == 0) || + (strcasecmp(partdesc, p->desc) == 0)) + found = 1; + } + + if (found) + return p; + + return NULL; +} + +AVRPART * locate_part_by_avr910_devcode(LISTID parts, int devcode) +{ + LNODEID ln1; + AVRPART * p = NULL; + + for (ln1=lfirst(parts); ln1; ln1=lnext(ln1)) { + p = ldata(ln1); + if (p->avr910_devcode == devcode) + return p; + } + + return NULL; +} + +AVRPART * locate_part_by_signature(LISTID parts, unsigned char * sig, + int sigsize) +{ + LNODEID ln1; + AVRPART * p = NULL; + int i; + + if (sigsize == 3) { + for (ln1=lfirst(parts); ln1; ln1=lnext(ln1)) { + p = ldata(ln1); + for (i=0; i<3; i++) + if (p->signature[i] != sig[i]) + break; + if (i == 3) + return p; + } + } + + return NULL; +} + +/* + * Iterate over the list of avrparts given as "avrparts", and + * call the callback function cb for each entry found. cb is being + * passed the following arguments: + * . the name of the avrpart (for -p) + * . the descriptive text given in the config file + * . the name of the config file this avrpart has been defined in + * . the line number of the config file this avrpart has been defined at + * . the "cookie" passed into walk_avrparts() (opaque client data) + */ +void walk_avrparts(LISTID avrparts, walk_avrparts_cb cb, void *cookie) +{ + LNODEID ln1; + AVRPART * p; + + for (ln1 = lfirst(avrparts); ln1; ln1 = lnext(ln1)) { + p = ldata(ln1); + cb(p->id, p->desc, p->config_file, p->lineno, cookie); + } +} + +/* + * Compare function to sort the list of programmers + */ +static int sort_avrparts_compare(AVRPART * p1,AVRPART * p2) +{ + if(p1 == NULL || p2 == NULL) { + return 0; + } + return strncasecmp(p1->desc,p2->desc,AVR_DESCLEN); +} + +/* + * Sort the list of programmers given as "programmers" + */ +void sort_avrparts(LISTID avrparts) +{ + lsort(avrparts,(int (*)(void*, void*)) sort_avrparts_compare); +} + + +static char * reset_disp_str(int r) +{ + switch (r) { + case RESET_DEDICATED : return "dedicated"; + case RESET_IO : return "possible i/o"; + default : return ""; + } +} + + +void avr_display(FILE * f, AVRPART * p, const char * prefix, int verbose) +{ + int i; + char * buf; + const char * px; + LNODEID ln; + AVRMEM * m; + + fprintf(f, + "%sAVR Part : %s\n" + "%sChip Erase delay : %d us\n" + "%sPAGEL : P%02X\n" + "%sBS2 : P%02X\n" + "%sRESET disposition : %s\n" + "%sRETRY pulse : %s\n" + "%sserial program mode : %s\n" + "%sparallel program mode : %s\n" + "%sTimeout : %d\n" + "%sStabDelay : %d\n" + "%sCmdexeDelay : %d\n" + "%sSyncLoops : %d\n" + "%sByteDelay : %d\n" + "%sPollIndex : %d\n" + "%sPollValue : 0x%02x\n" + "%sMemory Detail :\n\n", + prefix, p->desc, + prefix, p->chip_erase_delay, + prefix, p->pagel, + prefix, p->bs2, + prefix, reset_disp_str(p->reset_disposition), + prefix, avr_pin_name(p->retry_pulse), + prefix, (p->flags & AVRPART_SERIALOK) ? "yes" : "no", + prefix, (p->flags & AVRPART_PARALLELOK) ? + ((p->flags & AVRPART_PSEUDOPARALLEL) ? "psuedo" : "yes") : "no", + prefix, p->timeout, + prefix, p->stabdelay, + prefix, p->cmdexedelay, + prefix, p->synchloops, + prefix, p->bytedelay, + prefix, p->pollindex, + prefix, p->pollvalue, + prefix); + + px = prefix; + i = strlen(prefix) + 5; + buf = (char *)malloc(i); + if (buf == NULL) { + /* ugh, this is not important enough to bail, just ignore it */ + } + else { + strcpy(buf, prefix); + strcat(buf, " "); + px = buf; + } + + if (verbose <= 2) { + avr_mem_display(px, f, NULL, 0, verbose); + } + for (ln=lfirst(p->mem); ln; ln=lnext(ln)) { + m = ldata(ln); + avr_mem_display(px, f, m, i, verbose); + } + + if (buf) + free(buf); +} diff --git a/xs/src/avrdude/bitbang.c b/xs/src/avrdude/bitbang.c new file mode 100644 index 000000000..b943c3cea --- /dev/null +++ b/xs/src/avrdude/bitbang.c @@ -0,0 +1,655 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean + * Copyright (C) 2005 Michael Holzt + * 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 + * 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 "ac_cfg.h" + +#include +#include +#include +#include +#include +#include + +#if !defined(WIN32NATIVE) +# include +# include +#endif + +#include "avrdude.h" +#include "libavrdude.h" + +#include "par.h" +#include "serbb.h" +#include "tpi.h" +#include "bitbang.h" + +static int delay_decrement; + +#if defined(WIN32NATIVE) +static int has_perfcount; +static LARGE_INTEGER 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); +} +#endif /* WIN32NATIVE */ + +/* + * Calibrate the microsecond delay loop below. + */ +static void bitbang_calibrate_delay(void) +{ +#if defined(WIN32NATIVE) + /* + * If the hardware supports a high-resolution performance counter, + * we ultimately prefer that one, as it gives quite accurate delays + * on modern high-speed CPUs. + */ + if (QueryPerformanceFrequency(&freq)) + { + has_perfcount = 1; + avrdude_message(MSG_NOTICE2, "%s: Using performance counter for bitbang delays\n", + progname); + } + else + { + /* + * If a high-resolution performance counter is not available, we + * don't have any Win32 implementation for setting up the + * per-microsecond delay count, so we can only run on a + * preconfigured delay stepping there. The figure below should at + * least be correct within an order of magnitude, judging from the + * auto-calibration figures seen on various Unix systems on + * comparable hardware. + */ + avrdude_message(MSG_NOTICE2, "%s: Using guessed per-microsecond delay count for bitbang delays\n", + progname); + delay_decrement = 100; + } +#else /* !WIN32NATIVE */ + struct itimerval itv; + volatile int i; + + avrdude_message(MSG_NOTICE2, "%s: Calibrating delay loop...", + progname); + i = 0; + done = 0; + saved_alarmhandler = 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 + * accumulating over 100 ms should give us a rather realistic + * picture, without annoying the user by a lengthy startup time (as + * an alarm(1) would do). Of course, if heavy system activity + * happens just during calibration but stops before the remaining + * part of AVRDUDE runs, this will yield wrong values. There's not + * much we can do about this. + */ + itv.it_value.tv_sec = 0; + itv.it_value.tv_usec = 100000; + itv.it_interval.tv_sec = itv.it_interval.tv_usec = 0; + setitimer(ITIMER_REAL, &itv, 0); + while (!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; + avrdude_message(MSG_NOTICE2, " calibrated to %d cycles per us\n", + delay_decrement); +#endif /* WIN32NATIVE */ +} + +/* + * Delay for approximately the number of microseconds specified. + * usleep()'s granularity is usually like 1 ms or 10 ms, so it's not + * really suitable for short delays in bit-bang algorithms. + */ +void bitbang_delay(unsigned int us) +{ +#if defined(WIN32NATIVE) + LARGE_INTEGER countNow, countEnd; + + if (has_perfcount) + { + QueryPerformanceCounter(&countNow); + countEnd.QuadPart = countNow.QuadPart + freq.QuadPart * us / 1000000ll; + + while (countNow.QuadPart < countEnd.QuadPart) + QueryPerformanceCounter(&countNow); + } + else /* no performance counters -- run normal uncalibrated delay */ + { +#endif /* WIN32NATIVE */ + volatile unsigned int del = us * delay_decrement; + + while (del > 0) + del--; +#if defined(WIN32NATIVE) + } +#endif /* WIN32NATIVE */ +} + +/* + * transmit and receive a byte of data to/from the AVR device + */ +static unsigned char bitbang_txrx(PROGRAMMER * pgm, unsigned char byte) +{ + int i; + unsigned char r, b, rbyte; + + rbyte = 0; + for (i=7; i>=0; i--) { + /* + * Write and read one bit on SPI. + * Some notes on timing: Let T be the time it takes to do + * one pgm->setpin()-call resp. par clrpin()-call, then + * - SCK is high for 2T + * - SCK is low for 2T + * - MOSI setuptime is 1T + * - MOSI holdtime is 3T + * - SCK low to MISO read is 2T to 3T + * So we are within programming specs (expect for AT90S1200), + * if and only if T>t_CLCL (t_CLCL=clock period of target system). + * + * Due to the delay introduced by "IN" and "OUT"-commands, + * T is greater than 1us (more like 2us) on x86-architectures. + * So programming works safely down to 1MHz target clock. + */ + + b = (byte >> i) & 0x01; + + /* set the data input line as desired */ + pgm->setpin(pgm, PIN_AVR_MOSI, b); + + pgm->setpin(pgm, PIN_AVR_SCK, 1); + + /* + * read the result bit (it is either valid from a previous falling + * edge or it is ignored in the current context) + */ + r = pgm->getpin(pgm, PIN_AVR_MISO); + + pgm->setpin(pgm, PIN_AVR_SCK, 0); + + rbyte |= r << i; + } + + return rbyte; +} + +static int bitbang_tpi_clk(PROGRAMMER * pgm) +{ + unsigned char r = 0; + pgm->setpin(pgm, PIN_AVR_SCK, 1); + + r = pgm->getpin(pgm, PIN_AVR_MISO); + + pgm->setpin(pgm, PIN_AVR_SCK, 0); + + return r; +} + +void bitbang_tpi_tx(PROGRAMMER * pgm, unsigned char byte) +{ + int i; + unsigned char b, parity; + + /* start bit */ + pgm->setpin(pgm, PIN_AVR_MOSI, 0); + bitbang_tpi_clk(pgm); + + parity = 0; + for (i = 0; i <= 7; i++) { + b = (byte >> i) & 0x01; + parity ^= b; + + /* set the data input line as desired */ + pgm->setpin(pgm, PIN_AVR_MOSI, b); + bitbang_tpi_clk(pgm); + } + + /* parity bit */ + pgm->setpin(pgm, PIN_AVR_MOSI, parity); + bitbang_tpi_clk(pgm); + + /* 2 stop bits */ + pgm->setpin(pgm, PIN_AVR_MOSI, 1); + bitbang_tpi_clk(pgm); + bitbang_tpi_clk(pgm); +} + +int bitbang_tpi_rx(PROGRAMMER * pgm) +{ + int i; + unsigned char b, rbyte, parity; + + /* make sure pin is on for "pullup" */ + pgm->setpin(pgm, PIN_AVR_MOSI, 1); + + /* wait for start bit (up to 10 bits) */ + b = 1; + for (i = 0; i < 10; i++) { + b = bitbang_tpi_clk(pgm); + if (b == 0) + break; + } + if (b != 0) { + avrdude_message(MSG_INFO, "bitbang_tpi_rx: start bit not received correctly\n"); + return -1; + } + + rbyte = 0; + parity = 0; + for (i=0; i<=7; i++) { + b = bitbang_tpi_clk(pgm); + parity ^= b; + + rbyte |= b << i; + } + + /* parity bit */ + if (bitbang_tpi_clk(pgm) != parity) { + avrdude_message(MSG_INFO, "bitbang_tpi_rx: parity bit is wrong\n"); + return -1; + } + + /* 2 stop bits */ + b = 1; + b &= bitbang_tpi_clk(pgm); + b &= bitbang_tpi_clk(pgm); + if (b != 1) { + avrdude_message(MSG_INFO, "bitbang_tpi_rx: stop bits not received correctly\n"); + return -1; + } + + return rbyte; +} + +int bitbang_rdy_led(PROGRAMMER * pgm, int value) +{ + pgm->setpin(pgm, PIN_LED_RDY, !value); + return 0; +} + +int bitbang_err_led(PROGRAMMER * pgm, int value) +{ + pgm->setpin(pgm, PIN_LED_ERR, !value); + return 0; +} + +int bitbang_pgm_led(PROGRAMMER * pgm, int value) +{ + pgm->setpin(pgm, PIN_LED_PGM, !value); + return 0; +} + +int bitbang_vfy_led(PROGRAMMER * pgm, int value) +{ + pgm->setpin(pgm, PIN_LED_VFY, !value); + return 0; +} + + +/* + * transmit an AVR device command and return the results; 'cmd' and + * 'res' must point to at least a 4 byte data buffer + */ +int bitbang_cmd(PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res) +{ + int i; + + for (i=0; i<4; i++) { + res[i] = bitbang_txrx(pgm, cmd[i]); + } + + if(verbose >= 2) + { + avrdude_message(MSG_NOTICE2, "bitbang_cmd(): [ "); + for(i = 0; i < 4; i++) + avrdude_message(MSG_NOTICE2, "%02X ", cmd[i]); + avrdude_message(MSG_NOTICE2, "] [ "); + for(i = 0; i < 4; i++) + { + avrdude_message(MSG_NOTICE2, "%02X ", res[i]); + } + avrdude_message(MSG_NOTICE2, "]\n"); + } + + return 0; +} + +int bitbang_cmd_tpi(PROGRAMMER * pgm, const unsigned char *cmd, + int cmd_len, unsigned char *res, int res_len) +{ + int i, r; + + pgm->pgm_led(pgm, ON); + + for (i=0; i= 2) + { + avrdude_message(MSG_NOTICE2, "bitbang_cmd_tpi(): [ "); + for(i = 0; i < cmd_len; i++) + avrdude_message(MSG_NOTICE2, "%02X ", cmd[i]); + avrdude_message(MSG_NOTICE2, "] [ "); + for(i = 0; i < res_len; i++) + { + avrdude_message(MSG_NOTICE2, "%02X ", res[i]); + } + avrdude_message(MSG_NOTICE2, "]\n"); + } + + pgm->pgm_led(pgm, OFF); + if (r == -1) + return -1; + return 0; +} + +/* + * transmit bytes via SPI and return the results; 'cmd' and + * 'res' must point to data buffers + */ +int bitbang_spi(PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res, int count) +{ + int i; + + pgm->setpin(pgm, PIN_LED_PGM, 0); + + for (i=0; isetpin(pgm, PIN_LED_PGM, 1); + + if(verbose >= 2) + { + avrdude_message(MSG_NOTICE2, "bitbang_cmd(): [ "); + for(i = 0; i < count; i++) + avrdude_message(MSG_NOTICE2, "%02X ", cmd[i]); + avrdude_message(MSG_NOTICE2, "] [ "); + for(i = 0; i < count; i++) + { + avrdude_message(MSG_NOTICE2, "%02X ", res[i]); + } + avrdude_message(MSG_NOTICE2, "]\n"); + } + + return 0; +} + + +/* + * issue the 'chip erase' command to the AVR device + */ +int bitbang_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char cmd[4]; + unsigned char res[4]; + AVRMEM *mem; + + if (p->flags & AVRPART_HAS_TPI) { + pgm->pgm_led(pgm, ON); + + while (avr_tpi_poll_nvmbsy(pgm)); + + /* NVMCMD <- CHIP_ERASE */ + bitbang_tpi_tx(pgm, TPI_CMD_SOUT | TPI_SIO_ADDR(TPI_IOREG_NVMCMD)); + bitbang_tpi_tx(pgm, TPI_NVMCMD_CHIP_ERASE); /* CHIP_ERASE */ + + /* Set Pointer Register */ + mem = avr_locate_mem(p, "flash"); + if (mem == NULL) { + avrdude_message(MSG_INFO, "No flash memory to erase for part %s\n", + p->desc); + return -1; + } + bitbang_tpi_tx(pgm, TPI_CMD_SSTPR | 0); + bitbang_tpi_tx(pgm, (mem->offset & 0xFF) | 1); /* high byte */ + bitbang_tpi_tx(pgm, TPI_CMD_SSTPR | 1); + bitbang_tpi_tx(pgm, (mem->offset >> 8) & 0xFF); + + /* write dummy value to start erase */ + bitbang_tpi_tx(pgm, TPI_CMD_SST); + bitbang_tpi_tx(pgm, 0xFF); + + while (avr_tpi_poll_nvmbsy(pgm)); + + pgm->pgm_led(pgm, OFF); + + return 0; + } + + if (p->op[AVR_OP_CHIP_ERASE] == NULL) { + avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n", + p->desc); + return -1; + } + + pgm->pgm_led(pgm, ON); + + 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); + + pgm->pgm_led(pgm, OFF); + + return 0; +} + +/* + * issue the 'program enable' command to the AVR device + */ +int bitbang_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char cmd[4]; + unsigned char res[4]; + int i; + + if (p->flags & AVRPART_HAS_TPI) { + /* enable NVM programming */ + bitbang_tpi_tx(pgm, TPI_CMD_SKEY); + for (i = sizeof(tpi_skey) - 1; i >= 0; i--) + bitbang_tpi_tx(pgm, tpi_skey[i]); + + /* check NVMEN bit */ + bitbang_tpi_tx(pgm, TPI_CMD_SLDCS | TPI_REG_TPISR); + i = bitbang_tpi_rx(pgm); + return (i != -1 && (i & TPI_REG_TPISR_NVMEN)) ? 0 : -2; + } + + if (p->op[AVR_OP_PGM_ENABLE] == NULL) { + avrdude_message(MSG_INFO, "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); + pgm->cmd(pgm, cmd, res); + + if (res[2] != cmd[1]) + return -2; + + return 0; +} + +/* + * initialize the AVR device and prepare it to accept commands + */ +int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + int rc; + int tries; + int i; + + bitbang_calibrate_delay(); + + pgm->powerup(pgm); + usleep(20000); + + /* TPIDATA is a single line, so MISO & MOSI should be connected */ + if (p->flags & AVRPART_HAS_TPI) { + /* make sure cmd_tpi() is defined */ + if (pgm->cmd_tpi == NULL) { + avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n", + progname, pgm->type); + return -1; + } + + /* bring RESET high first */ + pgm->setpin(pgm, PIN_AVR_RESET, 1); + usleep(1000); + + avrdude_message(MSG_NOTICE2, "doing MOSI-MISO link check\n"); + + pgm->setpin(pgm, PIN_AVR_MOSI, 0); + if (pgm->getpin(pgm, PIN_AVR_MISO) != 0) { + avrdude_message(MSG_INFO, "MOSI->MISO 0 failed\n"); + return -1; + } + pgm->setpin(pgm, PIN_AVR_MOSI, 1); + if (pgm->getpin(pgm, PIN_AVR_MISO) != 1) { + avrdude_message(MSG_INFO, "MOSI->MISO 1 failed\n"); + return -1; + } + + avrdude_message(MSG_NOTICE2, "MOSI-MISO link present\n"); + } + + pgm->setpin(pgm, PIN_AVR_SCK, 0); + pgm->setpin(pgm, PIN_AVR_RESET, 0); + usleep(20000); + + if (p->flags & AVRPART_HAS_TPI) { + /* keep TPIDATA high for 16 clock cycles */ + pgm->setpin(pgm, PIN_AVR_MOSI, 1); + for (i = 0; i < 16; i++) + pgm->highpulsepin(pgm, PIN_AVR_SCK); + + /* remove extra guard timing bits */ + bitbang_tpi_tx(pgm, TPI_CMD_SSTCS | TPI_REG_TPIPCR); + bitbang_tpi_tx(pgm, 0x7); + + /* read TPI ident reg */ + bitbang_tpi_tx(pgm, TPI_CMD_SLDCS | TPI_REG_TPIIR); + rc = bitbang_tpi_rx(pgm); + if (rc != 0x80) { + avrdude_message(MSG_INFO, "TPIIR not correct\n"); + return -1; + } + } else { + pgm->highpulsepin(pgm, PIN_AVR_RESET); + } + + usleep(20000); /* 20 ms XXX should be a per-chip parameter */ + + /* + * Enable programming mode. If we are programming an AT90S1200, we + * can only issue the command and hope it worked. If we are using + * one of the other chips, the chip will echo 0x53 when issuing the + * third byte of the command. In this case, try up to 32 times in + * order to possibly get back into sync with the chip if we are out + * of sync. + */ + if (p->flags & AVRPART_IS_AT90S1200) { + pgm->program_enable(pgm, p); + } + else { + tries = 0; + do { + rc = pgm->program_enable(pgm, p); + if ((rc == 0)||(rc == -1)) + break; + pgm->highpulsepin(pgm, p->retry_pulse/*PIN_AVR_SCK*/); + tries++; + } while (tries < 65); + + /* + * can't sync with the device, maybe it's not attached? + */ + if (rc) { + avrdude_message(MSG_INFO, "%s: AVR device not responding\n", progname); + return -1; + } + } + + return 0; +} + +static int verify_pin_assigned(PROGRAMMER * pgm, int pin, char * desc) +{ + if (pgm->pinno[pin] == 0) { + avrdude_message(MSG_INFO, "%s: error: no pin has been assigned for %s\n", + progname, desc); + return -1; + } + return 0; +} + + +/* + * Verify all prerequisites for a bit-bang programmer are present. + */ +int bitbang_check_prerequisites(PROGRAMMER *pgm) +{ + + if (verify_pin_assigned(pgm, PIN_AVR_RESET, "AVR RESET") < 0) + return -1; + if (verify_pin_assigned(pgm, PIN_AVR_SCK, "AVR SCK") < 0) + return -1; + if (verify_pin_assigned(pgm, PIN_AVR_MISO, "AVR MISO") < 0) + return -1; + if (verify_pin_assigned(pgm, PIN_AVR_MOSI, "AVR MOSI") < 0) + return -1; + + if (pgm->cmd == NULL) { + avrdude_message(MSG_INFO, "%s: error: no cmd() method defined for bitbang programmer\n", + progname); + return -1; + } + return 0; +} diff --git a/xs/src/avrdude/bitbang.h b/xs/src/avrdude/bitbang.h new file mode 100644 index 000000000..300f52fd5 --- /dev/null +++ b/xs/src/avrdude/bitbang.h @@ -0,0 +1,58 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean + * Copyright (C) 2005 Michael Holzt + * 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 + * 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 bitbang_h +#define bitbang_h + +#ifdef __cplusplus +extern "C" { +#endif + +int bitbang_setpin(int fd, int pin, int value); +int bitbang_getpin(int fd, int pin); +int bitbang_highpulsepin(int fd, int pin); +void bitbang_delay(unsigned int us); + +int bitbang_check_prerequisites(PROGRAMMER *pgm); + +int bitbang_rdy_led (PROGRAMMER * pgm, int value); +int bitbang_err_led (PROGRAMMER * pgm, int value); +int bitbang_pgm_led (PROGRAMMER * pgm, int value); +int bitbang_vfy_led (PROGRAMMER * pgm, int value); +int bitbang_cmd (PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res); +int bitbang_cmd_tpi (PROGRAMMER * pgm, const unsigned char *cmd, + int cmd_len, unsigned char *res, int res_len); +int bitbang_spi (PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res, int count); +int bitbang_chip_erase (PROGRAMMER * pgm, AVRPART * p); +int bitbang_program_enable (PROGRAMMER * pgm, AVRPART * p); +void bitbang_powerup (PROGRAMMER * pgm); +void bitbang_powerdown (PROGRAMMER * pgm); +int bitbang_initialize (PROGRAMMER * pgm, AVRPART * p); +void bitbang_disable (PROGRAMMER * pgm); +void bitbang_enable (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/xs/src/avrdude/bootstrap b/xs/src/avrdude/bootstrap new file mode 100755 index 000000000..0c1f84cc7 --- /dev/null +++ b/xs/src/avrdude/bootstrap @@ -0,0 +1,21 @@ +#! /bin/sh + +: ${AUTOHEADER="autoheader${AC_VER}"} +: ${AUTOCONF="autoconf${AC_VER}"} +: ${ACLOCAL="aclocal${AM_VER}"} +: ${AUTOMAKE="automake${AM_VER}"} + +export ACLOCAL AUTOHEADER AUTOCONF AUTOMAKE + +# Bootstrap the build system. + +set -x + +rm -rf autom4te.cache + +libtoolize + +${ACLOCAL} +${AUTOHEADER} +${AUTOCONF} +${AUTOMAKE} -a -c diff --git a/xs/src/avrdude/buspirate.c b/xs/src/avrdude/buspirate.c new file mode 100644 index 000000000..435c4ce53 --- /dev/null +++ b/xs/src/avrdude/buspirate.c @@ -0,0 +1,1371 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * + * avrdude support for The Bus Pirate - universal serial interface + * + * Copyright (C) 2009 Michal Ludvig + * + * 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 . + */ + +/* + * BusPirate AVR Chip + * --------- -------- + * GND <-> GND + * +5V <-> Vcc + * CS <-> RESET + * MOSI <-> MOSI + * MISO <-> MISO + * SCL/CLK <-> SCK + * ( AUX <-> XTAL1 ) + * + * Tested with BusPirate PTH, firmware version 2.1 programming ATmega328P + */ + +/* $Id$ */ + +#include "ac_cfg.h" + +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "bitbang.h" +#include "buspirate.h" + +/* ====== Private data structure ====== */ +/* CS and AUX pin bitmasks in + * 0100wxyz - Configure peripherals command */ +#define BP_RESET_CS 0x01 +#define BP_RESET_AUX 0x02 +#define BP_RESET_AUX2 0x04 + +#define BP_FLAG_IN_BINMODE (1<<0) +#define BP_FLAG_XPARM_FORCE_ASCII (1<<1) +#define BP_FLAG_XPARM_RESET (1<<2) +#define BP_FLAG_XPARM_SPIFREQ (1<<3) +#define BP_FLAG_NOPAGEDWRITE (1<<4) +#define BP_FLAG_XPARM_CPUFREQ (1<<5) +#define BP_FLAG_XPARM_RAWFREQ (1<<6) +#define BP_FLAG_NOPAGEDREAD (1<<7) + +struct pdata +{ + int binmode_version; + int submode_version; + int current_peripherals_config; + int spifreq; /* For "set speed" commands */ + int cpufreq; /* (125)..4000 kHz - see buspirate manual */ + int serial_recv_timeout; /* timeout in ms, default 100 */ + int reset; /* See BP_RESET_* above */ + unsigned char pin_dir; /* Last written pin direction for bitbang mode */ + unsigned char pin_val; /* Last written pin values for bitbang mode */ + int unread_bytes; /* How many bytes we expected, but ignored */ +}; +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) + +/* ====== Feature checks ====== */ +static inline int +buspirate_uses_ascii(struct programmer_t *pgm) +{ + return (pgm->flag & BP_FLAG_XPARM_FORCE_ASCII); +} + +/* ====== Serial talker functions - binmode ====== */ + +static void dump_mem(const int msglvl, const unsigned char *buf, size_t len) +{ + size_t i; + + for (i = 0; ifd, data, len); + + return rc; +} + +static int buspirate_recv_bin(struct programmer_t *pgm, unsigned char *buf, size_t len) +{ + int rc; + + rc = serial_recv(&pgm->fd, buf, len); + if (rc < 0) + return EOF; + + avrdude_message(MSG_DEBUG, "%s: buspirate_recv_bin():\n", progname); + dump_mem(MSG_DEBUG, buf, len); + + return len; +} + +static int buspirate_expect_bin(struct programmer_t *pgm, + unsigned char *send_data, size_t send_len, + unsigned char *expect_data, size_t expect_len) +{ + unsigned char *recv_buf = alloca(expect_len); + if ((pgm->flag & BP_FLAG_IN_BINMODE) == 0) { + avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send_bin() called from ascii mode\n"); + return -1; + } + + buspirate_send_bin(pgm, send_data, send_len); + buspirate_recv_bin(pgm, recv_buf, expect_len); + if (memcmp(expect_data, recv_buf, expect_len) != 0) + return 0; + return 1; +} + +static int buspirate_expect_bin_byte(struct programmer_t *pgm, + unsigned char send_byte, unsigned char expect_byte) +{ + return buspirate_expect_bin(pgm, &send_byte, 1, &expect_byte, 1); +} + +/* ====== Serial talker functions - ascii mode ====== */ + +static int buspirate_getc(struct programmer_t *pgm) +{ + int rc; + unsigned char ch = 0; + + if (pgm->flag & BP_FLAG_IN_BINMODE) { + avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_getc() called from binmode\n"); + return EOF; + } + + rc = serial_recv(&pgm->fd, &ch, 1); + if (rc < 0) + return EOF; + return ch; +} + +static char *buspirate_readline_noexit(struct programmer_t *pgm, char *buf, size_t len) +{ + char *buf_p; + long orig_serial_recv_timeout = serial_recv_timeout; + + /* Static local buffer - this may come handy at times */ + static char buf_local[100]; + + if (buf == NULL) { + buf = buf_local; + len = sizeof(buf_local); + } + buf_p = buf; + memset(buf, 0, len); + while (buf_p < (buf + len - 1)) { /* keep the very last byte == 0 */ + *buf_p = buspirate_getc(pgm); + if (*buf_p == '\r') + continue; + if (*buf_p == '\n') + break; + if (*buf_p == EOF) { + *buf_p = '\0'; + break; + } + buf_p++; + serial_recv_timeout = PDATA(pgm)->serial_recv_timeout; + } + serial_recv_timeout = orig_serial_recv_timeout; + avrdude_message(MSG_DEBUG, "%s: buspirate_readline(): %s%s", + progname, buf, + buf[strlen(buf) - 1] == '\n' ? "" : "\n"); + if (! buf[0]) + return NULL; + + return buf; +} + +static char *buspirate_readline(struct programmer_t *pgm, char *buf, size_t len) +{ + char *ret; + + ret = buspirate_readline_noexit(pgm, buf, len); + if (! ret) { + avrdude_message(MSG_INFO, "%s: buspirate_readline(): programmer is not responding\n", + progname); + return NULL; + } + return ret; +} +static int buspirate_send(struct programmer_t *pgm, const char *str) +{ + int rc; + const char * readline; + + avrdude_message(MSG_DEBUG, "%s: buspirate_send(): %s", progname, str); + + if (pgm->flag & BP_FLAG_IN_BINMODE) { + avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send() called from binmode\n"); + return -1; + } + + rc = serial_send(&pgm->fd, (const unsigned char*)str, strlen(str)); + if (rc) + return rc; + do { + readline = buspirate_readline(pgm, NULL, 0); + if (readline == NULL) + return -1; + /* keep reading until we get what we sent there */ + } while (strcmp(readline, str) != 0); + + /* by now we should be in sync */ + return 0; +} + +static int buspirate_is_prompt(const char *str) +{ + int strlen_str = strlen(str); + /* Prompt ends with '>' or '> ' + * all other input probably ends with '\n' */ + return (str[strlen_str - 1] == '>' || str[strlen_str - 2] == '>'); +} + +static int buspirate_expect(struct programmer_t *pgm, char *send, + char *expect, int wait_for_prompt) +{ + int got_it = 0; + size_t expect_len = strlen(expect); + char *rcvd; + + buspirate_send(pgm, send); + while (1) { + rcvd = buspirate_readline(pgm, NULL, 0); + if (rcvd == NULL) { + return -1; + } + if (strncmp(rcvd, expect, expect_len) == 0) { + if (! wait_for_prompt) { + serial_drain(&pgm->fd, 0); + return 1; + } else { + got_it = 1; + } + } + + if (buspirate_is_prompt(rcvd)) + break; + } + return got_it; +} + +/* ====== Do-nothing functions ====== */ +static void buspirate_dummy_6(struct programmer_t *pgm, const char *p) +{ +} + +/* ====== Config / parameters handling functions ====== */ +static int +buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms) +{ + LNODEID ln; + const char *extended_param; + char reset[10]; + char *preset = reset; /* for strtok() */ + unsigned int spifreq; + unsigned int rawfreq; + unsigned int cpufreq; + int serial_recv_timeout; + + for (ln = lfirst(extparms); ln; ln = lnext(ln)) { + extended_param = ldata(ln); + if (strcmp(extended_param, "ascii") == 0) { + pgm->flag |= BP_FLAG_XPARM_FORCE_ASCII; + continue; + } + + if (sscanf(extended_param, "spifreq=%u", &spifreq) == 1) { + if (spifreq & (~0x07)) { + avrdude_message(MSG_INFO, "BusPirate: spifreq must be between 0 and 7.\n"); + avrdude_message(MSG_INFO, "BusPirate: see BusPirate manual for details.\n"); + return -1; + } + if (pgm->flag & BP_FLAG_XPARM_RAWFREQ) { + avrdude_message(MSG_INFO, "BusPirate: set either spifreq or rawfreq\n"); + return -1; + } + pgm->flag |= BP_FLAG_XPARM_SPIFREQ; + PDATA(pgm)->spifreq = spifreq; + continue; + } + + if (sscanf(extended_param, "rawfreq=%u", &rawfreq) == 1) { + if (rawfreq >= 4) { + avrdude_message(MSG_INFO, "BusPirate: rawfreq must be " + "between 0 and 3.\n"); + return -1; + } + if (pgm->flag & BP_FLAG_XPARM_SPIFREQ) { + avrdude_message(MSG_INFO, "BusPirate: set either spifreq or rawfreq\n"); + return -1; + } + pgm->flag |= BP_FLAG_XPARM_RAWFREQ; + PDATA(pgm)->spifreq = rawfreq; + continue; + } + + if (sscanf(extended_param, "cpufreq=%u", &cpufreq) == 1) { + /* lower limit comes from 'cpufreq > 4 * spifreq', spifreq in ascii mode is 30kHz. */ + if (cpufreq < 125 || cpufreq > 4000) { + avrdude_message(MSG_INFO, "BusPirate: cpufreq must be between 125 and 4000 kHz.\n"); + avrdude_message(MSG_INFO, "BusPirate: see BusPirate manual for details.\n"); + return -1; + } + PDATA(pgm)->cpufreq = cpufreq; + pgm->flag |= BP_FLAG_XPARM_CPUFREQ; + continue; + } + + if (sscanf(extended_param, "reset=%9s", reset) == 1) { + char *resetpin; + while ((resetpin = strtok(preset, ","))) { + preset = NULL; /* for subsequent strtok() calls */ + if (strcasecmp(resetpin, "cs") == 0) + PDATA(pgm)->reset |= BP_RESET_CS; + else if (strcasecmp(resetpin, "aux") == 0 || strcasecmp(reset, "aux1") == 0) + PDATA(pgm)->reset |= BP_RESET_AUX; + else if (strcasecmp(resetpin, "aux2") == 0) + PDATA(pgm)->reset |= BP_RESET_AUX2; + else { + avrdude_message(MSG_INFO, "BusPirate: reset must be either CS or AUX.\n"); + return -1; + } + } + pgm->flag |= BP_FLAG_XPARM_RESET; + continue; + } + + if (strcmp(extended_param, "nopagedwrite") == 0) { + pgm->flag |= BP_FLAG_NOPAGEDWRITE; + continue; + } + + if (strcmp(extended_param, "nopagedread") == 0) { + pgm->flag |= BP_FLAG_NOPAGEDREAD; + continue; + } + + if (sscanf(extended_param, "serial_recv_timeout=%d", &serial_recv_timeout) == 1) { + if (serial_recv_timeout < 1) { + avrdude_message(MSG_INFO, "BusPirate: serial_recv_timeout must be greater 0.\n"); + return -1; + } + PDATA(pgm)->serial_recv_timeout = serial_recv_timeout; + continue; + } + + avrdude_message(MSG_INFO, "BusPirate: do not understand extended param '%s'.\n", extended_param); + return -1; + } + + return 0; +} + +static int +buspirate_verifyconfig(struct programmer_t *pgm) +{ + /* Default reset pin is CS */ + if (PDATA(pgm)->reset == 0x00) + PDATA(pgm)->reset |= BP_RESET_CS; + + if ((PDATA(pgm)->reset != BP_RESET_CS) && buspirate_uses_ascii(pgm)) { + avrdude_message(MSG_INFO, "BusPirate: RESET pin other than CS is not supported in ASCII mode\n"); + return -1; + } + + if ( ((pgm->flag & BP_FLAG_XPARM_SPIFREQ) || (pgm->flag & BP_FLAG_XPARM_RAWFREQ)) + && buspirate_uses_ascii(pgm)) { + avrdude_message(MSG_INFO, "BusPirate: SPI speed selection is not supported in ASCII mode\n"); + return -1; + } + + return 0; +} + +/* ====== Programmer methods ======= */ +static int buspirate_open(struct programmer_t *pgm, char * port) +{ + union pinfo pinfo; + /* BusPirate runs at 115200 by default */ + if(pgm->baudrate == 0) + pgm->baudrate = 115200; + + pinfo.baud = pgm->baudrate; + strcpy(pgm->port, port); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* drain any extraneous input */ + serial_drain(&pgm->fd, 0); + + return 0; +} + +static void buspirate_close(struct programmer_t *pgm) +{ + serial_close(&pgm->fd); + pgm->fd.ifd = -1; +} + +static void buspirate_reset_from_binmode(struct programmer_t *pgm) +{ + unsigned char buf[10]; + + buf[0] = 0x00; /* BinMode: revert to raw bitbang mode */ + buspirate_send_bin(pgm, buf, 1); + buspirate_recv_bin(pgm, buf, 5); + + if (pgm->flag & BP_FLAG_XPARM_CPUFREQ) { + /* disable pwm */ + if (buspirate_expect_bin_byte(pgm, 0x13, 0x01) != 1) { + avrdude_message(MSG_INFO, "%s: warning: did not get a response to stop PWM command.\n", progname); + } + } + /* 0b0100wxyz - Configure peripherals w=power, x=pull-ups, y=AUX, z=CS + * we want everything off -- 0b01000000 = 0x40 */ + if (buspirate_expect_bin_byte(pgm, 0x40, 0x00) == 1) { + avrdude_message(MSG_INFO, "%s: warning: did not get a response to power off command.\n", progname); + } + + buf[0] = 0x0F; /* BinMode: reset */ + buspirate_send_bin(pgm, buf, 1); + + /* read back all output */ + memset(buf, '\0', sizeof(buf)); + for (;;) { + int rc; + rc = buspirate_recv_bin(pgm, buf, sizeof(buf) - 1); + + if (buspirate_is_prompt((const char*)buf)) { + pgm->flag &= ~BP_FLAG_IN_BINMODE; + break; + } + if (rc == EOF) + break; + memset(buf, '\0', sizeof(buf)); + } + + if (pgm->flag & BP_FLAG_IN_BINMODE) { + avrdude_message(MSG_INFO, "BusPirate reset failed. You may need to powercycle it.\n"); + return; + } + + avrdude_message(MSG_NOTICE, "BusPirate is back in the text mode\n"); +} + +static int buspirate_start_mode_bin(struct programmer_t *pgm) +{ + const struct submode { + const char *name; /* Name of mode for user messages */ + char enter; /* Command to enter from base binary mode */ + const char *entered_format; /* Response, for "scanf" */ + char config; /* Command to setup submode parameters */ + } *submode; + + if (pgm->flag & BP_FLAG_XPARM_RAWFREQ) { + submode = &(const struct submode){ + .name = "Raw-wire", + .enter = 0x05, + .entered_format = "RAW%1d", + .config = 0x8C, + }; + pgm->flag |= BP_FLAG_NOPAGEDWRITE; + pgm->flag |= BP_FLAG_NOPAGEDREAD; + } else { + submode = &(const struct submode){ + .name = "SPI", + .enter = 0x01, + .entered_format = "SPI%1d", + + /* 1000wxyz - SPI config, w=HiZ(0)/3.3v(1), x=CLK idle, y=CLK edge, z=SMP sample + * we want: 3.3V(1), idle low(0), data change on + * trailing edge (1), sample in the middle + * of the pulse (0) + * => 0b10001010 = 0x8a */ + .config = 0x8A, + }; + } + + unsigned char buf[20] = { '\0' }; + + /* == Switch to binmode - send 20x '\0' == */ + buspirate_send_bin(pgm, buf, sizeof(buf)); + + /* Expecting 'BBIOx' reply */ + memset(buf, 0, sizeof(buf)); + buspirate_recv_bin(pgm, buf, 5); + if (sscanf((const char*)buf, "BBIO%1d", &PDATA(pgm)->binmode_version) != 1) { + avrdude_message(MSG_INFO, "Binary mode not confirmed: '%s'\n", buf); + buspirate_reset_from_binmode(pgm); + return -1; + } + avrdude_message(MSG_NOTICE, "BusPirate binmode version: %d\n", + PDATA(pgm)->binmode_version); + + pgm->flag |= BP_FLAG_IN_BINMODE; + + if (pgm->flag & BP_FLAG_XPARM_CPUFREQ) { + unsigned short pwm_duty; + unsigned short pwm_period; + + pwm_period = 16000/(PDATA(pgm)->cpufreq) - 1; // oscillator runs at 32MHz, we don't use a prescaler + pwm_duty = pwm_period/2; // 50% duty cycle + + avrdude_message(MSG_NOTICE, "Setting up PWM for cpufreq\n"); + avrdude_message(MSG_DEBUG, "PWM settings: Prescaler=1, Duty Cycle=%hd, Period=%hd\n", pwm_duty, pwm_period); + + buf[0] = 0x12; // pwm setup + buf[1] = 0; // prescaler 1 + buf[2] = (char) ((pwm_duty >> 8) & 0xff); // duty cycle register, high byte + buf[3] = (char) pwm_duty & 0xff; // duty cycle register, low byte + buf[4] = (char) ((pwm_period >> 8) & 0xff); // period register, high byte + buf[5] = (char) pwm_period & 0xff; // period register, low byte + buspirate_send_bin(pgm, buf, 6); + + buspirate_recv_bin(pgm, buf, 1); + if (buf[0] != 0x01) + avrdude_message(MSG_INFO, "cpufreq (PWM) setup failed\n"); + } + + /* == Set protocol sub-mode of binary mode == */ + buf[0] = submode->enter; + buspirate_send_bin(pgm, buf, 1); + memset(buf, 0, sizeof(buf)); + buspirate_recv_bin(pgm, buf, 4); + if (sscanf((const char*)buf, submode->entered_format, &PDATA(pgm)->submode_version) != 1) { + avrdude_message(MSG_INFO, "%s mode not confirmed: '%s'\n", + submode->name, buf); + buspirate_reset_from_binmode(pgm); + return -1; + } + avrdude_message(MSG_NOTICE, "BusPirate %s version: %d\n", + submode->name, PDATA(pgm)->submode_version); + + if (pgm->flag & BP_FLAG_NOPAGEDWRITE) { + avrdude_message(MSG_NOTICE, "%s: Paged flash write disabled.\n", progname); + pgm->paged_write = NULL; + } else { + /* Check for write-then-read without !CS/CS and disable paged_write if absent: */ + static const unsigned char buf2[] = {5,0,0,0,0}; + buspirate_send_bin(pgm, buf2, sizeof(buf2)); + buspirate_recv_bin(pgm, buf, 1); + if (buf[0] != 0x01) { + + /* Disable paged write: */ + pgm->flag |= BP_FLAG_NOPAGEDWRITE; + pgm->paged_write = NULL; + + /* Return to SPI mode (0x00s have landed us back in binary bitbang mode): */ + buf[0] = 0x1; + buspirate_send_bin(pgm, buf, 1); + + avrdude_message(MSG_NOTICE, "%s: Disabling paged flash write. (Need BusPirate firmware >=v5.10.)\n", progname); + + /* Flush serial buffer: */ + serial_drain(&pgm->fd, 0); + } else { + avrdude_message(MSG_INFO, "%s: Paged flash write enabled.\n", progname); + } + } + + /* 0b0100wxyz - Configure peripherals w=power, x=pull-ups/aux2, y=AUX, z=CS + * we want power (0x48) and all reset pins high. */ + PDATA(pgm)->current_peripherals_config = 0x48 | PDATA(pgm)->reset; + if (buspirate_expect_bin_byte(pgm, PDATA(pgm)->current_peripherals_config, 0x01) < 0) + return -1; + usleep(50000); // sleep for 50ms after power up + + /* 01100xxx - Set speed */ + if (buspirate_expect_bin_byte(pgm, 0x60 | PDATA(pgm)->spifreq, 0x01) < 0) + return -1; + + /* Submode config */ + if (buspirate_expect_bin_byte(pgm, submode->config, 0x01) < 0) + return -1; + + /* AVR Extended Commands - test for existence */ + if (pgm->flag & BP_FLAG_NOPAGEDREAD) { + avrdude_message(MSG_NOTICE, "%s: Paged flash read disabled.\n", progname); + pgm->paged_load = NULL; + } else { + int rv = buspirate_expect_bin_byte(pgm, 0x06, 0x01); + if (rv < 0) + return -1; + if (rv) { + unsigned int ver = 0; + static const unsigned char buf2[] = {1}; + buspirate_send_bin(pgm, buf2, sizeof(buf2)); + buspirate_recv_bin(pgm, buf, 3); + ver = buf[1] << 8 | buf[2]; + avrdude_message(MSG_NOTICE, "AVR Extended Commands version %d\n", ver); + } else { + avrdude_message(MSG_NOTICE, "AVR Extended Commands not found.\n"); + pgm->flag |= BP_FLAG_NOPAGEDREAD; + pgm->paged_load = NULL; + } + } + + return 0; +} + +static int buspirate_start_spi_mode_ascii(struct programmer_t *pgm) +{ + int spi_cmd = -1; + int cmd; + char *rcvd; + char buf[5]; + char mode[11]; + + buspirate_send(pgm, "m\n"); + while(1) { + rcvd = buspirate_readline(pgm, NULL, 0); + if (rcvd == NULL) { + return -1; + } + if (spi_cmd == -1 && sscanf(rcvd, "%2d. %10s", &cmd, mode)) { + if (strcmp(mode, "SPI") == 0) + spi_cmd = cmd; + } + if (buspirate_is_prompt(rcvd)) + break; + } + if (spi_cmd == -1) { + avrdude_message(MSG_INFO, "%s: SPI mode number not found. Does your BusPirate support SPI?\n", + progname); + avrdude_message(MSG_INFO, "%s: Try powercycling your BusPirate and try again.\n", + progname); + return -1; + } + snprintf(buf, sizeof(buf), "%d\n", spi_cmd); + buspirate_send(pgm, buf); + buf[0] = '\0'; + while (1) { + rcvd = buspirate_readline(pgm, NULL, 0); + if (rcvd == NULL) { + return -1; + } + if (strstr(rcvd, "Normal (H=3.3V, L=GND)")) { + /* BP firmware 2.1 defaults to Open-drain output. + * That doesn't work on my board, even with pull-up + * resistors. Select 3.3V output mode instead. */ + sscanf(rcvd, " %2d.", &cmd); + snprintf(buf, sizeof(buf), "%d\n", cmd); + } + if (buspirate_is_prompt(rcvd)) { + if (strncmp(rcvd, "SPI>", 4) == 0) { + avrdude_message(MSG_INFO, "BusPirate is now configured for SPI\n"); + break; + } + /* Not yet 'SPI>' prompt */ + if (buf[0]) { + buspirate_send(pgm, buf); + buf[0] = '\0'; + } else + buspirate_send(pgm, "\n"); + } + } + return 0; +} + +static void buspirate_enable(struct programmer_t *pgm) +{ + static const char *reset_str = "#\n"; + static const char *accept_str = "y\n"; + char *rcvd; + int rc, print_banner = 0; + + /* Ensure configuration is self-consistant: */ + if (buspirate_verifyconfig(pgm)<0) + return; /* XXX should handle error */ + + /* Attempt to start binary SPI mode unless explicitly told otherwise: */ + if (!buspirate_uses_ascii(pgm)) { + avrdude_message(MSG_INFO, "Attempting to initiate BusPirate binary mode...\n"); + + /* Send two CRs to ensure we're not in a sub-menu of the UI if we're in ASCII mode: */ + buspirate_send_bin(pgm, (const unsigned char*)"\n\n", 2); + + /* Clear input buffer: */ + serial_drain(&pgm->fd, 0); + + /* Attempt to enter binary mode: */ + if (buspirate_start_mode_bin(pgm) >= 0) + return; + else + avrdude_message(MSG_INFO, "%s: Failed to start binary mode, falling back to ASCII...\n", progname); + } + + avrdude_message(MSG_INFO, "Attempting to initiate BusPirate ASCII mode...\n"); + + /* Call buspirate_send_bin() instead of buspirate_send() + * because we don't know if BP is in text or bin mode */ + rc = buspirate_send_bin(pgm, (const unsigned char*)reset_str, strlen(reset_str)); + if (rc) { + avrdude_message(MSG_INFO, "BusPirate is not responding. Serial port error: %d\n", rc); + return; + } + + while(1) { + rcvd = buspirate_readline_noexit(pgm, NULL, 0); + if (! rcvd) { + avrdude_message(MSG_INFO, "%s: Fatal: Programmer is not responding.\n", progname); + return; + } + if (strncmp(rcvd, "Are you sure?", 13) == 0) { + buspirate_send_bin(pgm, (const unsigned char*)accept_str, strlen(accept_str)); + } + if (strncmp(rcvd, "RESET", 5) == 0) { + print_banner = 1; + continue; + } + if (buspirate_is_prompt(rcvd)) { + avrdude_message(MSG_DEBUG, "**\n"); + break; + } + if (print_banner) + avrdude_message(MSG_DEBUG, "** %s", rcvd); + } + + if (!(pgm->flag & BP_FLAG_IN_BINMODE)) { + avrdude_message(MSG_INFO, "BusPirate: using ASCII mode\n"); + if (buspirate_start_spi_mode_ascii(pgm) < 0) { + avrdude_message(MSG_INFO, "%s: Failed to start ascii SPI mode\n", progname); + return; + } + } +} + +static void buspirate_disable(struct programmer_t *pgm) +{ + if (pgm->flag & BP_FLAG_IN_BINMODE) { + serial_recv_timeout = 100; + buspirate_reset_from_binmode(pgm); + } else { + buspirate_expect(pgm, "#\n", "RESET", 1); + } +} + +static int buspirate_initialize(struct programmer_t *pgm, AVRPART * p) +{ + pgm->powerup(pgm); + + return pgm->program_enable(pgm, p); +} + +static void buspirate_powerup(struct programmer_t *pgm) +{ + if (pgm->flag & BP_FLAG_IN_BINMODE) { + /* Powerup in BinMode is handled in binary mode init */ + return; + } else { + if (buspirate_expect(pgm, "W\n", "POWER SUPPLIES ON", 1)) { + if (pgm->flag & BP_FLAG_XPARM_CPUFREQ) { + char buf[25]; + int ok = 0; + snprintf(buf, sizeof(buf), "%d\n", PDATA(pgm)->cpufreq); + if (buspirate_expect(pgm, "g\n", "Frequency in KHz", 1)) { + if (buspirate_expect(pgm, buf, "Duty cycle in %", 1)) { + if (buspirate_expect(pgm, "50\n", "PWM active", 1)) { + ok = 1; + } + } + } + if(!ok) { + avrdude_message(MSG_INFO, "%s: warning: did not get a response to start PWM command.\n", progname); + } + } + return; + } + } + + avrdude_message(MSG_INFO, "%s: warning: did not get a response to PowerUp command.\n", progname); + avrdude_message(MSG_INFO, "%s: warning: Trying to continue anyway...\n", progname); +} + +static void buspirate_powerdown(struct programmer_t *pgm) +{ + if (pgm->flag & BP_FLAG_IN_BINMODE) { + /* Powerdown in BinMode is handled in binary mode init */ + return; + } else { + if (pgm->flag & BP_FLAG_XPARM_CPUFREQ) { + if (!buspirate_expect(pgm, "g\n", "PWM disabled", 1)) { + avrdude_message(MSG_INFO, "%s: warning: did not get a response to stop PWM command.\n", progname); + } + } + if (buspirate_expect(pgm, "w\n", "POWER SUPPLIES OFF", 1)) + return; + } + + avrdude_message(MSG_INFO, "%s: warning: did not get a response to PowerDown command.\n", progname); +} + +static int buspirate_cmd_bin(struct programmer_t *pgm, + const unsigned char *cmd, + unsigned char *res) +{ + /* 0001xxxx - Bulk transfer, send/read 1-16 bytes (0=1byte!) + * we are sending 4 bytes -> 0x13 */ + int rv = buspirate_expect_bin_byte(pgm, 0x13, 0x01); + if (rv < 0) + return -1; + if (rv == 0) + return -1; + + buspirate_send_bin(pgm, cmd, 4); + buspirate_recv_bin(pgm, res, 4); + + return 0; +} + +static int buspirate_cmd_ascii(struct programmer_t *pgm, + const unsigned char *cmd, + unsigned char *res) +{ + char buf[25]; + char *rcvd; + int spi_write, spi_read, i = 0; + + snprintf(buf, sizeof(buf), "0x%02x 0x%02x 0x%02x 0x%02x\n", + cmd[0], cmd[1], cmd[2], cmd[3]); + buspirate_send(pgm, buf); + while (i < 4) { + rcvd = buspirate_readline(pgm, NULL, 0); + if (rcvd == NULL) { + return -1; + } + /* WRITE: 0xAC READ: 0x04 */ + if (sscanf(rcvd, "WRITE: 0x%2x READ: 0x%2x", &spi_write, &spi_read) == 2) { + res[i++] = spi_read; + } + if (buspirate_is_prompt(rcvd)) + break; + } + + if (i != 4) { + avrdude_message(MSG_INFO, "%s: error: SPI has not read 4 bytes back\n", progname); + return -1; + } + + /* wait for prompt */ + while (buspirate_getc(pgm) != '>') + /* do nothing */; + + return 0; +} + +static int buspirate_cmd(struct programmer_t *pgm, + const unsigned char *cmd, + unsigned char *res) +{ + if (pgm->flag & BP_FLAG_IN_BINMODE) + return buspirate_cmd_bin(pgm, cmd, res); + else + return buspirate_cmd_ascii(pgm, cmd, res); +} + +/* Paged load function which utilizes the AVR Extended Commands set */ +static int buspirate_paged_load( + PROGRAMMER *pgm, + AVRPART *p, + AVRMEM *m, + unsigned int page_size, + unsigned int address, + unsigned int n_bytes) +{ + unsigned char commandbuf[10]; + unsigned char buf[275]; + unsigned int addr = 0; + + avrdude_message(MSG_NOTICE, "BusPirate: buspirate_paged_load(..,%s,%d,%d,%d)\n",m->desc,m->page_size,address,n_bytes); + + // This should never happen, but still... + if (pgm->flag & BP_FLAG_NOPAGEDREAD) { + avrdude_message(MSG_INFO, "BusPirate: buspirate_paged_load() called while in nopagedread mode!\n"); + return -1; + } + + // determine what type of memory to read, only flash is supported + if (strcmp(m->desc, "flash") != 0) { + return -1; + } + + // send command to read data + commandbuf[0] = 6; + commandbuf[1] = 2; + + // send start address (in WORDS, not bytes!) + commandbuf[2] = (address >> 1 >> 24) & 0xff; + commandbuf[3] = (address >> 1>> 16) & 0xff; + commandbuf[4] = (address >> 1 >> 8) & 0xff; + commandbuf[5] = (address >> 1) & 0xff; + + // send number of bytes to fetch (in BYTES) + commandbuf[6] = (n_bytes >> 24) & 0xff; + commandbuf[7] = (n_bytes >> 16) & 0xff; + commandbuf[8] = (n_bytes >> 8) & 0xff; + commandbuf[9] = (n_bytes) & 0xff; + + buspirate_send_bin(pgm, commandbuf, 10); + buspirate_recv_bin(pgm, buf, 1); + buspirate_recv_bin(pgm, buf, 1); + + if (buf[0] != 0x01) { + avrdude_message(MSG_INFO, "BusPirate: Paged Read command returned zero.\n"); + return -1; + } + + for (addr = 0; addr < n_bytes; addr++) { + buspirate_recv_bin(pgm, &m->buf[addr+address], 1); + } + + return n_bytes; +} +/* Paged write function which utilizes the Bus Pirate's "Write then Read" binary SPI instruction */ +static int buspirate_paged_write(struct programmer_t *pgm, + AVRPART *p, + AVRMEM *m, + unsigned int page_size, + unsigned int base_addr, + unsigned int n_data_bytes) +{ + int page, i; + int addr = base_addr; + int n_page_writes; + int this_page_size; + unsigned char cmd_buf[4096] = {'\0'}; + unsigned char send_byte, recv_byte; + + if (!(pgm->flag & BP_FLAG_IN_BINMODE)) { + /* Return if we are not in binary mode. */ + return -1; + } + + if (pgm->flag & BP_FLAG_NOPAGEDWRITE) { + /* Return if we've nominated not to use paged writes. */ + return -1; + } + + if (page_size>1024) { + /* Page sizes greater than 1kB not yet supported. */ + return -1; + } + + if (strcmp(m->desc,"flash") != 0) { + /* Only flash memory currently supported. */ + return -1; + } + + /* pre-check opcodes */ + if (m->op[AVR_OP_LOADPAGE_LO] == NULL) { + avrdude_message(MSG_INFO, "%s failure: %s command not defined for %s\n", + progname, "AVR_OP_LOADPAGE_LO", p->desc); + return -1; + } + if (m->op[AVR_OP_LOADPAGE_HI] == NULL) { + avrdude_message(MSG_INFO, "%s failure: %s command not defined for %s\n", + progname, "AVR_OP_LOADPAGE_HI", p->desc); + return -1; + } + + /* Calculate total number of page writes needed: */ + n_page_writes = n_data_bytes/page_size; + if (n_data_bytes%page_size >0) + n_page_writes++; + + /* Ensure error LED is off: */ + pgm->err_led(pgm, OFF); + + /* Loop over pages: */ + for (page=0; pageop[AVR_OP_LOADPAGE_LO], &(cmd_buf[4*i])); + avr_set_addr(m->op[AVR_OP_LOADPAGE_LO], &(cmd_buf[4*i]), addr/2); + avr_set_input(m->op[AVR_OP_LOADPAGE_LO], &(cmd_buf[4*i]), m->buf[addr]); + } else { + avr_set_bits(m->op[AVR_OP_LOADPAGE_HI], &(cmd_buf[4*i])); + avr_set_addr(m->op[AVR_OP_LOADPAGE_HI], &(cmd_buf[4*i]), addr/2); + avr_set_input(m->op[AVR_OP_LOADPAGE_HI], &(cmd_buf[4*i]), m->buf[addr]); + } + } + + /* 00000100 - Write then read */ + send_byte = 0x05; + buspirate_send_bin(pgm, &send_byte, 1); + + /* Number of bytes to write: */ + send_byte = (4*this_page_size)/0x100; + buspirate_send_bin(pgm, &send_byte, 1); /* High byte */ + send_byte = (4*this_page_size)%0x100; + buspirate_send_bin(pgm, &send_byte, 1); /* Low byte */ + + /* Number of bytes to read: */ + send_byte = 0x0; + buspirate_send_bin(pgm, &send_byte, 1); /* High byte */ + buspirate_send_bin(pgm, &send_byte, 1); /* Low byte */ + + /* Set programming LED: */ + pgm->pgm_led(pgm, ON); + + /* Send command buffer: */ + buspirate_send_bin(pgm, cmd_buf, 4*this_page_size); + + /* Check for write failure: */ + if ((buspirate_recv_bin(pgm, &recv_byte, 1) == EOF) || (recv_byte != 0x01)) { + avrdude_message(MSG_INFO, "BusPirate: Fatal error: Write Then Read did not succeed.\n"); + pgm->pgm_led(pgm, OFF); + pgm->err_led(pgm, ON); + return -1; + } + + /* Unset programming LED: */ + pgm->pgm_led(pgm, OFF); + + /* Write loaded page to flash: */ + avr_write_page(pgm, p, m, addr); + } + + return n_data_bytes; +} + +static int buspirate_program_enable(struct programmer_t *pgm, AVRPART * p) +{ + unsigned char cmd[4]; + unsigned char res[4]; + + if (pgm->flag & BP_FLAG_IN_BINMODE) { + /* Clear configured reset pin(s): CS and/or AUX and/or AUX2 */ + PDATA(pgm)->current_peripherals_config &= ~PDATA(pgm)->reset; + if (buspirate_expect_bin_byte(pgm, PDATA(pgm)->current_peripherals_config, 0x01) < 0) + return -1; + } + else + buspirate_expect(pgm, "{\n", "CS ENABLED", 1); + + if (p->op[AVR_OP_PGM_ENABLE] == NULL) { + avrdude_message(MSG_INFO, "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); + pgm->cmd(pgm, cmd, res); + + if (res[2] != cmd[1]) + return -2; + + return 0; +} + +static int buspirate_chip_erase(struct programmer_t *pgm, AVRPART * p) +{ + unsigned char cmd[4]; + unsigned char res[4]; + + if (p->op[AVR_OP_CHIP_ERASE] == NULL) { + avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n", + p->desc); + return -1; + } + + pgm->pgm_led(pgm, ON); + + 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); + + pgm->pgm_led(pgm, OFF); + + return 0; +} + +/* Interface - management */ +static void buspirate_setup(struct programmer_t *pgm) +{ + /* Allocate private data */ + if ((pgm->cookie = calloc(1, sizeof(struct pdata))) == 0) { + avrdude_message(MSG_INFO, "%s: buspirate_initpgm(): Out of memory allocating private data\n", + progname); + exit(1); + } + PDATA(pgm)->serial_recv_timeout = 100; +} + +static void buspirate_teardown(struct programmer_t *pgm) +{ + free(pgm->cookie); +} +const char buspirate_desc[] = "Using the Bus Pirate's SPI interface for programming"; + +void buspirate_initpgm(struct programmer_t *pgm) +{ + strcpy(pgm->type, "BusPirate"); + + pgm->display = buspirate_dummy_6; + + /* BusPirate itself related methods */ + pgm->open = buspirate_open; + pgm->close = buspirate_close; + pgm->enable = buspirate_enable; + pgm->disable = buspirate_disable; + pgm->initialize = buspirate_initialize; + + /* Chip related methods */ + pgm->powerup = buspirate_powerup; + pgm->powerdown = buspirate_powerdown; + pgm->program_enable = buspirate_program_enable; + pgm->chip_erase = buspirate_chip_erase; + pgm->cmd = buspirate_cmd; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; + + pgm->paged_write = buspirate_paged_write; + pgm->paged_load = buspirate_paged_load; + + /* Support functions */ + pgm->parseextparams = buspirate_parseextparms; + + pgm->setup = buspirate_setup; + pgm->teardown = buspirate_teardown; +} + +/* Bitbang support */ + +static void buspirate_bb_enable(struct programmer_t *pgm) +{ + unsigned char buf[20] = { '\0' }; + + if (bitbang_check_prerequisites(pgm) < 0) + return; /* XXX should treat as error */ + + avrdude_message(MSG_INFO, "Attempting to initiate BusPirate bitbang binary mode...\n"); + + /* Send two CRs to ensure we're not in a sub-menu of the UI if we're in ASCII mode: */ + buspirate_send_bin(pgm, (const unsigned char*)"\n\n", 2); + + /* Clear input buffer: */ + serial_drain(&pgm->fd, 0); + + /* == Switch to binmode - send 20x '\0' == */ + buspirate_send_bin(pgm, buf, sizeof(buf)); + + /* Expecting 'BBIOx' reply */ + memset(buf, 0, sizeof(buf)); + buspirate_recv_bin(pgm, buf, 5); + if (sscanf((char*)buf, "BBIO%1d", &PDATA(pgm)->binmode_version) != 1) { + avrdude_message(MSG_INFO, "Binary mode not confirmed: '%s'\n", buf); + buspirate_reset_from_binmode(pgm); + return; + } + avrdude_message(MSG_INFO, "BusPirate binmode version: %d\n", + PDATA(pgm)->binmode_version); + + pgm->flag |= BP_FLAG_IN_BINMODE; + + /* Set pin directions and an initial pin status (all high) */ + PDATA(pgm)->pin_dir = 0x12; /* AUX, MISO input; everything else output */ + buf[0] = PDATA(pgm)->pin_dir | 0x40; + buspirate_send_bin(pgm, buf, 1); + buspirate_recv_bin(pgm, buf, 1); + + PDATA(pgm)->pin_val = 0x3f; /* PULLUP, AUX, MOSI, CLK, MISO, CS high */ + buf[0] = PDATA(pgm)->pin_val | 0x80; + buspirate_send_bin(pgm, buf, 1); + buspirate_recv_bin(pgm, buf, 1); + + /* Done */ + return; +} + +/* + Direction: + 010xxxxx + Input (1) or output (0): + AUX|MOSI|CLK|MISO|CS + + Output value: + 1xxxxxxx + High (1) or low(0): + 1|POWER|PULLUP|AUX|MOSI|CLK|MISO|CS + + Both respond with a byte with current status: + 0|POWER|PULLUP|AUX|MOSI|CLK|MISO|CS +*/ +static int buspirate_bb_getpin(struct programmer_t *pgm, int pinfunc) +{ + unsigned char buf[10]; + int value = 0; + int pin = pgm->pinno[pinfunc]; + + if (pin & PIN_INVERSE) { + pin &= PIN_MASK; + value = 1; + } + + if (pin < 1 || pin > 5) + return -1; + + buf[0] = PDATA(pgm)->pin_dir | 0x40; + if (buspirate_send_bin(pgm, buf, 1) < 0) + return -1; + /* Read all of the previously-expected-but-unread bytes */ + while (PDATA(pgm)->unread_bytes > 0) { + if (buspirate_recv_bin(pgm, buf, 1) < 0) + return -1; + PDATA(pgm)->unread_bytes--; + } + + /* Now read the actual response */ + if (buspirate_recv_bin(pgm, buf, 1) < 0) + return -1; + + if (buf[0] & (1 << (pin - 1))) + value ^= 1; + + avrdude_message(MSG_DEBUG, "get pin %d = %d\n", pin, value); + + return value; +} + +static int buspirate_bb_setpin_internal(struct programmer_t *pgm, int pin, int value) +{ + unsigned char buf[10]; + + if (pin & PIN_INVERSE) { + value = !value; + pin &= PIN_MASK; + } + + if ((pin < 1 || pin > 5) && (pin != 7)) // 7 is POWER + return -1; + + avrdude_message(MSG_DEBUG, "set pin %d = %d\n", pin, value); + + if (value) + PDATA(pgm)->pin_val |= (1 << (pin - 1)); + else + PDATA(pgm)->pin_val &= ~(1 << (pin - 1)); + + buf[0] = PDATA(pgm)->pin_val | 0x80; + if (buspirate_send_bin(pgm, buf, 1) < 0) + return -1; + /* We'll get a byte back, but we don't need to read it now. + This is just a quick optimization that saves some USB + round trips, improving read times by a factor of 3. */ + PDATA(pgm)->unread_bytes++; + + return 0; +} + +static int buspirate_bb_setpin(struct programmer_t *pgm, int pinfunc, int value) +{ + return buspirate_bb_setpin_internal(pgm, pgm->pinno[pinfunc], value); +} + + +static int buspirate_bb_highpulsepin(struct programmer_t *pgm, int pinfunc) +{ + int ret; + ret = buspirate_bb_setpin(pgm, pinfunc, 1); + if (ret < 0) + return ret; + return buspirate_bb_setpin(pgm, pinfunc, 0); +} + +static void buspirate_bb_powerup(struct programmer_t *pgm) +{ + buspirate_bb_setpin_internal(pgm, 7, 1); +} + +static void buspirate_bb_powerdown(struct programmer_t *pgm) +{ + buspirate_bb_setpin_internal(pgm, 7, 0); +} + +const char buspirate_bb_desc[] = "Using the Bus Pirate's bitbang interface for programming"; + +void buspirate_bb_initpgm(struct programmer_t *pgm) +{ + strcpy(pgm->type, "BusPirate_BB"); + + pgm_fill_old_pins(pgm); // TODO to be removed if old pin data no longer needed + + pgm->display = buspirate_dummy_6; + + /* BusPirate itself related methods */ + pgm->setup = buspirate_setup; + pgm->teardown = buspirate_teardown; + pgm->open = buspirate_open; + pgm->close = buspirate_close; + pgm->enable = buspirate_bb_enable; + pgm->disable = buspirate_disable; + + /* Chip related methods */ + pgm->initialize = bitbang_initialize; + pgm->rdy_led = bitbang_rdy_led; + pgm->err_led = bitbang_err_led; + pgm->pgm_led = bitbang_pgm_led; + pgm->vfy_led = bitbang_vfy_led; + pgm->program_enable = bitbang_program_enable; + pgm->chip_erase = bitbang_chip_erase; + pgm->cmd = bitbang_cmd; + pgm->cmd_tpi = bitbang_cmd_tpi; + pgm->powerup = buspirate_bb_powerup; + pgm->powerdown = buspirate_bb_powerdown; + pgm->setpin = buspirate_bb_setpin; + pgm->getpin = buspirate_bb_getpin; + pgm->highpulsepin = buspirate_bb_highpulsepin; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; +} diff --git a/xs/src/avrdude/buspirate.h b/xs/src/avrdude/buspirate.h new file mode 100644 index 000000000..835334a20 --- /dev/null +++ b/xs/src/avrdude/buspirate.h @@ -0,0 +1,32 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * + * avrdude support for The Bus Pirate - universal serial interface + * + * Copyright (C) 2009 Michal Ludvig + * + * 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 buspirate_h +#define buspirate_h + +extern const char buspirate_desc[]; +extern const char buspirate_bb_desc[]; +void buspirate_initpgm (struct programmer_t *pgm); +void buspirate_bb_initpgm (struct programmer_t *pgm); + +#endif diff --git a/xs/src/avrdude/butterfly.c b/xs/src/avrdude/butterfly.c new file mode 100644 index 000000000..de9a3175f --- /dev/null +++ b/xs/src/avrdude/butterfly.c @@ -0,0 +1,762 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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$ */ + +/* + * avrdude interface for the serial programming mode of the Atmel butterfly + * evaluation board. This board features a bootloader which uses a protocol + * very similar, but not identical, to the one described in application note + * avr910. + * + * Actually, the butterfly uses a predecessor of the avr910 protocol + * which is described in application notes avr109 (generic AVR + * bootloader) and avr911 (opensource programmer). This file now + * fully handles the features present in avr109. It should probably + * be renamed to avr109, but we rather stick with the old name inside + * the file. We'll provide aliases for "avr109" and "avr911" in + * avrdude.conf so users could call it by these name as well. + */ + + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "butterfly.h" + +/* + * Private data for this programmer. + */ +struct pdata +{ + char has_auto_incr_addr; + unsigned int buffersize; +}; + +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) + +static void butterfly_setup(PROGRAMMER * pgm) +{ + if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + avrdude_message(MSG_INFO, "%s: butterfly_setup(): Out of memory allocating private data\n", + progname); + exit(1); + } + memset(pgm->cookie, 0, sizeof(struct pdata)); +} + +static void butterfly_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); +} + +static int butterfly_send(PROGRAMMER * pgm, char * buf, size_t len) +{ + return serial_send(&pgm->fd, (unsigned char *)buf, len); +} + + +static int butterfly_recv(PROGRAMMER * pgm, char * buf, size_t len) +{ + int rv; + + rv = serial_recv(&pgm->fd, (unsigned char *)buf, len); + if (rv < 0) { + avrdude_message(MSG_INFO, "%s: butterfly_recv(): programmer is not responding\n", + progname); + return -1; + } + return 0; +} + + +static int butterfly_drain(PROGRAMMER * pgm, int display) +{ + return serial_drain(&pgm->fd, display); +} + + +static int butterfly_vfy_cmd_sent(PROGRAMMER * pgm, char * errmsg) +{ + char c; + + butterfly_recv(pgm, &c, 1); + if (c != '\r') { + avrdude_message(MSG_INFO, "%s: error: programmer did not respond to command: %s\n", + progname, errmsg); + return -1; + } + return 0; +} + + +static int butterfly_rdy_led(PROGRAMMER * pgm, int value) +{ + /* Do nothing. */ + + return 0; +} + + +static int butterfly_err_led(PROGRAMMER * pgm, int value) +{ + /* Do nothing. */ + + return 0; +} + + +static int butterfly_pgm_led(PROGRAMMER * pgm, int value) +{ + /* Do nothing. */ + + return 0; +} + + +static int butterfly_vfy_led(PROGRAMMER * pgm, int value) +{ + /* Do nothing. */ + + return 0; +} + + +/* + * issue the 'chip erase' command to the butterfly board + */ +static int butterfly_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + butterfly_send(pgm, "e", 1); + if (butterfly_vfy_cmd_sent(pgm, "chip erase") < 0) + return -1; + + return 0; +} + + +static void butterfly_enter_prog_mode(PROGRAMMER * pgm) +{ + butterfly_send(pgm, "P", 1); + butterfly_vfy_cmd_sent(pgm, "enter prog mode"); +} + + +static void butterfly_leave_prog_mode(PROGRAMMER * pgm) +{ + butterfly_send(pgm, "L", 1); + butterfly_vfy_cmd_sent(pgm, "leave prog mode"); +} + + +/* + * issue the 'program enable' command to the AVR device + */ +static int butterfly_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + return -1; +} + + +/* + * apply power to the AVR processor + */ +static void butterfly_powerup(PROGRAMMER * pgm) +{ + /* Do nothing. */ + + return; +} + + +/* + * remove power from the AVR processor + */ +static void butterfly_powerdown(PROGRAMMER * pgm) +{ + /* Do nothing. */ + + return; +} + +#define IS_BUTTERFLY_MK 0x0001 + +/* + * initialize the AVR device and prepare it to accept commands + */ +static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + char id[8]; + char sw[2]; + char hw[2]; + char buf[10]; + char type; + char c, devtype_1st; + + /* + * Send some ESC to activate butterfly bootloader. This is not needed + * for plain avr109 bootloaders but does not harm there either. + */ + avrdude_message(MSG_INFO, "Connecting to programmer: "); + if (pgm->flag & IS_BUTTERFLY_MK) + { + char mk_reset_cmd[6] = {"#aR@S\r"}; + unsigned char mk_timeout = 0; + + putc('.', stderr); + butterfly_send(pgm, mk_reset_cmd, sizeof(mk_reset_cmd)); + usleep(20000); + + do + { + c = 27; + butterfly_send(pgm, &c, 1); + usleep(20000); + c = 0xaa; + usleep(80000); + butterfly_send(pgm, &c, 1); + if (mk_timeout % 10 == 0) putc('.', stderr); + } while (mk_timeout++ < 10); + + butterfly_recv(pgm, &c, 1); + if ( c != 'M' && c != '?') + { + avrdude_message(MSG_INFO, "\nConnection FAILED."); + return -1; + } + else + { + id[0] = 'M'; id[1] = 'K'; id[2] = '2'; id[3] = 0; + } + } + else + { + do { + putc('.', stderr); + butterfly_send(pgm, "\033", 1); + butterfly_drain(pgm, 0); + butterfly_send(pgm, "S", 1); + butterfly_recv(pgm, &c, 1); + if (c != '?') { + putc('\n', stderr); + /* + * Got a useful response, continue getting the programmer + * identifier. Programmer returns exactly 7 chars _without_ + * the null. + */ + id[0] = c; + butterfly_recv(pgm, &id[1], sizeof(id)-2); + id[sizeof(id)-1] = '\0'; + } + } while (c == '?'); + } + + /* Get the HW and SW versions to see if the programmer is present. */ + butterfly_drain(pgm, 0); + + butterfly_send(pgm, "V", 1); + butterfly_recv(pgm, sw, sizeof(sw)); + + butterfly_send(pgm, "v", 1); + butterfly_recv(pgm, hw, 1); /* first, read only _one_ byte */ + if (hw[0]!='?') { + butterfly_recv(pgm, &hw[1], 1);/* now, read second byte */ + }; + + /* Get the programmer type (serial or parallel). Expect serial. */ + + butterfly_send(pgm, "p", 1); + butterfly_recv(pgm, &type, 1); + + avrdude_message(MSG_INFO, "Found programmer: Id = \"%s\"; type = %c\n", id, type); + avrdude_message(MSG_INFO, " Software Version = %c.%c; ", sw[0], sw[1]); + if (hw[0]=='?') { + avrdude_message(MSG_INFO, "No Hardware Version given.\n"); + } else { + avrdude_message(MSG_INFO, "Hardware Version = %c.%c\n", hw[0], hw[1]); + }; + + /* See if programmer supports autoincrement of address. */ + + butterfly_send(pgm, "a", 1); + butterfly_recv(pgm, &PDATA(pgm)->has_auto_incr_addr, 1); + if (PDATA(pgm)->has_auto_incr_addr == 'Y') + avrdude_message(MSG_INFO, "Programmer supports auto addr increment.\n"); + + /* Check support for buffered memory access, abort if not available */ + + butterfly_send(pgm, "b", 1); + butterfly_recv(pgm, &c, 1); + if (c != 'Y') { + avrdude_message(MSG_INFO, "%s: error: buffered memory access not supported. Maybe it isn't\n"\ + "a butterfly/AVR109 but a AVR910 device?\n", progname); + return -1; + }; + butterfly_recv(pgm, &c, 1); + PDATA(pgm)->buffersize = (unsigned int)(unsigned char)c<<8; + butterfly_recv(pgm, &c, 1); + PDATA(pgm)->buffersize += (unsigned int)(unsigned char)c; + avrdude_message(MSG_INFO, "Programmer supports buffered memory access with buffersize=%i bytes.\n", + PDATA(pgm)->buffersize); + + /* Get list of devices that the programmer supports. */ + + butterfly_send(pgm, "t", 1); + avrdude_message(MSG_INFO, "\nProgrammer supports the following devices:\n"); + devtype_1st = 0; + while (1) { + butterfly_recv(pgm, &c, 1); + if (devtype_1st == 0) + devtype_1st = c; + + if (c == 0) + break; + avrdude_message(MSG_INFO, " Device code: 0x%02x\n", (unsigned int)(unsigned char)c); + }; + avrdude_message(MSG_INFO, "\n"); + + /* Tell the programmer which part we selected. + According to the AVR109 code, this is ignored by the bootloader. As + some early versions might not properly ignore it, rather pick up the + first device type as reported above than anything out of avrdude.conf, + so to avoid a potential conflict. There appears to be no general + agreement on AVR910 device IDs beyond the ones from the original + appnote 910. */ + + buf[0] = 'T'; + buf[1] = devtype_1st; + + butterfly_send(pgm, buf, 2); + if (butterfly_vfy_cmd_sent(pgm, "select device") < 0) + return -1; + + if (verbose) + avrdude_message(MSG_INFO, "%s: devcode selected: 0x%02x\n", + progname, (unsigned)buf[1]); + + butterfly_enter_prog_mode(pgm); + butterfly_drain(pgm, 0); + + return 0; +} + + + +static void butterfly_disable(PROGRAMMER * pgm) +{ + butterfly_leave_prog_mode(pgm); + + return; +} + + +static void butterfly_enable(PROGRAMMER * pgm) +{ + return; +} + + +static int butterfly_open(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + strcpy(pgm->port, port); + /* + * If baudrate was not specified use 19200 Baud + */ + if(pgm->baudrate == 0) { + pgm->baudrate = 19200; + } + pinfo.baud = pgm->baudrate; + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + butterfly_drain (pgm, 0); + + return 0; +} + + +static void butterfly_close(PROGRAMMER * pgm) +{ + /* "exit programmer" */ + butterfly_send(pgm, "E", 1); + butterfly_vfy_cmd_sent(pgm, "exit bootloader"); + + serial_close(&pgm->fd); + pgm->fd.ifd = -1; +} + + +static void butterfly_display(PROGRAMMER * pgm, const char * p) +{ + return; +} + + +static void butterfly_set_addr(PROGRAMMER * pgm, unsigned long addr) +{ + char cmd[3]; + + cmd[0] = 'A'; + cmd[1] = (addr >> 8) & 0xff; + cmd[2] = addr & 0xff; + + butterfly_send(pgm, cmd, sizeof(cmd)); + butterfly_vfy_cmd_sent(pgm, "set addr"); +} + + +static void butterfly_set_extaddr(PROGRAMMER * pgm, unsigned long addr) +{ + char cmd[4]; + + cmd[0] = 'H'; + cmd[1] = (addr >> 16) & 0xff; + cmd[2] = (addr >> 8) & 0xff; + cmd[3] = addr & 0xff; + + butterfly_send(pgm, cmd, sizeof(cmd)); + butterfly_vfy_cmd_sent(pgm, "set extaddr"); +} + + + +static int butterfly_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned long addr, unsigned char value) +{ + char cmd[6]; + int size; + int use_ext_addr = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL; + + if ((strcmp(m->desc, "flash") == 0) || (strcmp(m->desc, "eeprom") == 0)) + { + cmd[0] = 'B'; + cmd[1] = 0; + if ((cmd[3] = toupper((int)(m->desc[0]))) == 'E') { /* write to eeprom */ + cmd[2] = 1; + cmd[4] = value; + size = 5; + } else { /* write to flash */ + /* @@@ not yet implemented */ + cmd[2] = 2; + size = 6; + return -1; + } + if (use_ext_addr) { + butterfly_set_extaddr(pgm, addr); + } else { + butterfly_set_addr(pgm, addr); + } + } + else if (strcmp(m->desc, "lock") == 0) + { + cmd[0] = 'l'; + cmd[1] = value; + size = 2; + } + else + return -1; + + butterfly_send(pgm, cmd, size); + if (butterfly_vfy_cmd_sent(pgm, "write byte") < 0) + return -1; + + return 0; +} + + +static int butterfly_read_byte_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned long addr, unsigned char * value) +{ + static int cached = 0; + static unsigned char cvalue; + static unsigned long caddr; + int use_ext_addr = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL; + + if (cached && ((caddr + 1) == addr)) { + *value = cvalue; + cached = 0; + } + else { + char buf[2]; + + if (use_ext_addr) { + butterfly_set_extaddr(pgm, addr >> 1); + } else { + butterfly_set_addr(pgm, addr >> 1); + } + + butterfly_send(pgm, "g\000\002F", 4); + + /* Read back the program mem word (MSB first) */ + butterfly_recv(pgm, buf, sizeof(buf)); + + if ((addr & 0x01) == 0) { + *value = buf[0]; + cached = 1; + cvalue = buf[1]; + caddr = addr; + } + else { + *value = buf[1]; + } + } + + return 0; +} + + +static int butterfly_read_byte_eeprom(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned long addr, unsigned char * value) +{ + butterfly_set_addr(pgm, addr); + butterfly_send(pgm, "g\000\001E", 4); + butterfly_recv(pgm, (char *)value, 1); + return 0; +} + +static int butterfly_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned int addr) +{ + if (strcmp(m->desc, "flash") == 0) + return -1; /* not supported */ + if (strcmp(m->desc, "eeprom") == 0) + return 0; /* nothing to do */ + avrdude_message(MSG_INFO, "%s: butterfly_page_erase() called on memory type \"%s\"\n", + progname, m->desc); + return -1; +} + +static int butterfly_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned long addr, unsigned char * value) +{ + char cmd; + + if (strcmp(m->desc, "flash") == 0) { + return butterfly_read_byte_flash(pgm, p, m, addr, value); + } + + if (strcmp(m->desc, "eeprom") == 0) { + return butterfly_read_byte_eeprom(pgm, p, m, addr, value); + } + + if (strcmp(m->desc, "lfuse") == 0) { + cmd = 'F'; + } + else if (strcmp(m->desc, "hfuse") == 0) { + cmd = 'N'; + } + else if (strcmp(m->desc, "efuse") == 0) { + cmd = 'Q'; + } + else if (strcmp(m->desc, "lock") == 0) { + cmd = 'r'; + } + else + return -1; + + butterfly_send(pgm, &cmd, 1); + butterfly_recv(pgm, (char *)value, 1); + + return *value == '?'? -1: 0; +} + + + +static int butterfly_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int max_addr = addr + n_bytes; + char *cmd; + unsigned int blocksize = PDATA(pgm)->buffersize; + int use_ext_addr = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL; + unsigned int wr_size = 2; + + if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom")) + return -2; + + if (m->desc[0] == 'e') + wr_size = blocksize = 1; /* Write to eeprom single bytes only */ + + if (use_ext_addr) { + butterfly_set_extaddr(pgm, addr / wr_size); + } else { + butterfly_set_addr(pgm, addr / wr_size); + } + +#if 0 + usleep(1000000); + butterfly_send(pgm, "y", 1); + if (butterfly_vfy_cmd_sent(pgm, "clear LED") < 0) + return -1; +#endif + + cmd = malloc(4+blocksize); + if (!cmd) return -1; + cmd[0] = 'B'; + cmd[3] = toupper((int)(m->desc[0])); + + while (addr < max_addr) { + if ((max_addr - addr) < blocksize) { + blocksize = max_addr - addr; + }; + memcpy(&cmd[4], &m->buf[addr], blocksize); + cmd[1] = (blocksize >> 8) & 0xff; + cmd[2] = blocksize & 0xff; + + butterfly_send(pgm, cmd, 4+blocksize); + if (butterfly_vfy_cmd_sent(pgm, "write block") < 0) + return -1; + + addr += blocksize; + } /* while */ + free(cmd); + + return addr; +} + + + +static int butterfly_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int max_addr = addr + n_bytes; + int rd_size = 2; + int blocksize = PDATA(pgm)->buffersize; + int use_ext_addr = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL; + + /* check parameter syntax: only "flash" or "eeprom" is allowed */ + if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom")) + return -2; + + if (m->desc[0] == 'e') + rd_size = blocksize = 1; /* Read from eeprom single bytes only */ + + { /* use buffered mode */ + char cmd[4]; + + cmd[0] = 'g'; + cmd[3] = toupper((int)(m->desc[0])); + + if (use_ext_addr) { + butterfly_set_extaddr(pgm, addr / rd_size); + } else { + butterfly_set_addr(pgm, addr / rd_size); + } + while (addr < max_addr) { + if ((max_addr - addr) < blocksize) { + blocksize = max_addr - addr; + }; + cmd[1] = (blocksize >> 8) & 0xff; + cmd[2] = blocksize & 0xff; + + butterfly_send(pgm, cmd, 4); + butterfly_recv(pgm, (char *)&m->buf[addr], blocksize); + + addr += blocksize; + } /* while */ + } + + return addr * rd_size; +} + + +/* Signature byte reads are always 3 bytes. */ +static int butterfly_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m) +{ + unsigned char tmp; + + if (m->size < 3) { + avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read", progname); + return -1; + } + + butterfly_send(pgm, "s", 1); + butterfly_recv(pgm, (char *)m->buf, 3); + /* Returned signature has wrong order. */ + tmp = m->buf[2]; + m->buf[2] = m->buf[0]; + m->buf[0] = tmp; + + return 3; +} + +const char butterfly_desc[] = "Atmel Butterfly evaluation board; Atmel AppNotes AVR109, AVR911"; + +void butterfly_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "butterfly"); + + /* + * mandatory functions + */ + pgm->rdy_led = butterfly_rdy_led; + pgm->err_led = butterfly_err_led; + pgm->pgm_led = butterfly_pgm_led; + pgm->vfy_led = butterfly_vfy_led; + pgm->initialize = butterfly_initialize; + pgm->display = butterfly_display; + pgm->enable = butterfly_enable; + pgm->disable = butterfly_disable; + pgm->powerup = butterfly_powerup; + pgm->powerdown = butterfly_powerdown; + pgm->program_enable = butterfly_program_enable; + pgm->chip_erase = butterfly_chip_erase; + pgm->open = butterfly_open; + pgm->close = butterfly_close; + pgm->read_byte = butterfly_read_byte; + pgm->write_byte = butterfly_write_byte; + + /* + * optional functions + */ + + pgm->page_erase = butterfly_page_erase; + pgm->paged_write = butterfly_paged_write; + pgm->paged_load = butterfly_paged_load; + + pgm->read_sig_bytes = butterfly_read_sig_bytes; + + pgm->setup = butterfly_setup; + pgm->teardown = butterfly_teardown; + pgm->flag = 0; +} + +const char butterfly_mk_desc[] = "Mikrokopter.de Butterfly"; + +void butterfly_mk_initpgm(PROGRAMMER * pgm) +{ + butterfly_initpgm(pgm); + strcpy(pgm->type, "butterfly_mk"); + pgm->flag = IS_BUTTERFLY_MK; +} diff --git a/xs/src/avrdude/butterfly.h b/xs/src/avrdude/butterfly.h new file mode 100644 index 000000000..6f6a54c84 --- /dev/null +++ b/xs/src/avrdude/butterfly.h @@ -0,0 +1,37 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 butterfly_h +#define butterfly_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char butterfly_desc[]; +extern const char butterfly_mk_desc[]; +void butterfly_initpgm (PROGRAMMER * pgm); +void butterfly_mk_initpgm (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif /* butterfly_h */ diff --git a/xs/src/avrdude/config.c b/xs/src/avrdude/config.c new file mode 100644 index 000000000..08193cfc5 --- /dev/null +++ b/xs/src/avrdude/config.c @@ -0,0 +1,349 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 "ac_cfg.h" + +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" +#include "config.h" + +#include "config_gram.h" + +char default_programmer[MAX_STR_CONST]; +char default_parallel[PATH_MAX]; +char default_serial[PATH_MAX]; +double default_bitclock; +int default_safemode; + +char string_buf[MAX_STR_CONST]; +char *string_buf_ptr; + +LISTID string_list; +LISTID number_list; +PROGRAMMER * current_prog; +AVRPART * current_part; +AVRMEM * current_mem; +LISTID part_list; +LISTID programmers; + +int lineno; +const char * infile; + +extern char * yytext; + +#define DEBUG 0 + +void cleanup_config(void) +{ + ldestroy_cb(part_list, (void(*)(void*))avr_free_part); + ldestroy_cb(programmers, (void(*)(void*))pgm_free); + ldestroy_cb(string_list, (void(*)(void*))free_token); + ldestroy_cb(number_list, (void(*)(void*))free_token); +} + +int init_config(void) +{ + string_list = lcreat(NULL, 0); + number_list = lcreat(NULL, 0); + current_prog = NULL; + current_part = NULL; + current_mem = NULL; + part_list = lcreat(NULL, 0); + programmers = lcreat(NULL, 0); + + lineno = 1; + infile = NULL; + + return 0; +} + + + +int yywrap() +{ + return 1; +} + + +int yyerror(char * errmsg, ...) +{ + va_list args; + + char message[512]; + + va_start(args, errmsg); + + vsnprintf(message, sizeof(message), errmsg, args); + avrdude_message(MSG_INFO, "%s: error at %s:%d: %s\n", progname, infile, lineno, message); + + va_end(args); + + return 0; +} + + +int yywarning(char * errmsg, ...) +{ + va_list args; + + char message[512]; + + va_start(args, errmsg); + + vsnprintf(message, sizeof(message), errmsg, args); + avrdude_message(MSG_INFO, "%s: warning at %s:%d: %s\n", progname, infile, lineno, message); + + va_end(args); + + return 0; +} + + +TOKEN * new_token(int primary) +{ + TOKEN * tkn; + + tkn = (TOKEN *)malloc(sizeof(TOKEN)); + if (tkn == NULL) { + yyerror("new_token(): out of memory"); + return NULL; + } + + memset(tkn, 0, sizeof(TOKEN)); + + tkn->primary = primary; + + return tkn; +} + + +void free_token(TOKEN * tkn) +{ + if (tkn) { + switch (tkn->value.type) { + case V_STR: + if (tkn->value.string) + free(tkn->value.string); + tkn->value.string = NULL; + break; + } + + free(tkn); + } +} + + +void free_tokens(int n, ...) +{ + TOKEN * t; + va_list ap; + + va_start(ap, n); + while (n--) { + t = va_arg(ap, TOKEN *); + free_token(t); + } + va_end(ap); +} + + + +TOKEN * number(char * text) +{ + struct token_t * tkn; + + tkn = new_token(TKN_NUMBER); + if (tkn == NULL) { + return NULL; /* yyerror already called */ + } + tkn->value.type = V_NUM; + tkn->value.number = atoi(text); + +#if DEBUG + avrdude_message(MSG_INFO, "NUMBER(%d)\n", tkn->value.number); +#endif + + return tkn; +} + +TOKEN * number_real(char * text) +{ + struct token_t * tkn; + + tkn = new_token(TKN_NUMBER); + tkn->value.type = V_NUM_REAL; + tkn->value.number_real = atof(text); + +#if DEBUG + avrdude_message(MSG_INFO, "NUMBER(%g)\n", tkn->value.number_real); +#endif + + return tkn; +} + +TOKEN * hexnumber(char * text) +{ + struct token_t * tkn; + char * e; + + tkn = new_token(TKN_NUMBER); + if (tkn == NULL) { + return NULL; /* yyerror already called */ + } + tkn->value.type = V_NUM; + tkn->value.number = strtoul(text, &e, 16); + if ((e == text) || (*e != 0)) { + yyerror("can't scan hex number \"%s\"", text); + return NULL; + } + +#if DEBUG + avrdude_message(MSG_INFO, "HEXNUMBER(%g)\n", tkn->value.number); +#endif + + return tkn; +} + + +TOKEN * string(char * text) +{ + struct token_t * tkn; + int len; + + tkn = new_token(TKN_STRING); + if (tkn == NULL) { + return NULL; /* yyerror already called */ + } + + len = strlen(text); + + tkn->value.type = V_STR; + tkn->value.string = (char *) malloc(len+1); + if (tkn->value.string == NULL) { + yyerror("string(): out of memory"); + return NULL; + } + strcpy(tkn->value.string, text); + +#if DEBUG + avrdude_message(MSG_INFO, "STRING(%s)\n", tkn->value.string); +#endif + + return tkn; +} + + +TOKEN * keyword(int primary) +{ + struct token_t * tkn; + + tkn = new_token(primary); + + return tkn; +} + + +void print_token(TOKEN * tkn) +{ + if (!tkn) + return; + + avrdude_message(MSG_INFO, "token = %d = ", tkn->primary); + switch (tkn->value.type) { + case V_NUM: + avrdude_message(MSG_INFO, "NUMBER, value=%d", tkn->value.number); + break; + + case V_NUM_REAL: + avrdude_message(MSG_INFO, "NUMBER, value=%g", tkn->value.number_real); + break; + + case V_STR: + avrdude_message(MSG_INFO, "STRING, value=%s", tkn->value.string); + break; + + default: + avrdude_message(MSG_INFO, ""); + break; + } + + avrdude_message(MSG_INFO, "\n"); +} + + +void pyytext(void) +{ +#if DEBUG + avrdude_message(MSG_INFO, "TOKEN: \"%s\"\n", yytext); +#endif +} + + +char * dup_string(const char * str) +{ + char * s; + + s = strdup(str); + if (s == NULL) { + yyerror("dup_string(): out of memory"); + return NULL; + } + + return s; +} + +#ifdef HAVE_YYLEX_DESTROY +/* reset lexer and free any allocated memory */ +extern int yylex_destroy(void); +#endif + +int read_config(const char * file) +{ + FILE * f; + int r; + + f = fopen(file, "r"); + if (f == NULL) { + avrdude_message(MSG_INFO, "%s: can't open config file \"%s\": %s\n", + progname, file, strerror(errno)); + return -1; + } + + lineno = 1; + infile = file; + yyin = f; + + r = yyparse(); + +#ifdef HAVE_YYLEX_DESTROY + /* reset lexer and free any allocated memory */ + yylex_destroy(); +#endif + + fclose(f); + + return r; +} diff --git a/xs/src/avrdude/config.h b/xs/src/avrdude/config.h new file mode 100644 index 000000000..d0d65ae20 --- /dev/null +++ b/xs/src/avrdude/config.h @@ -0,0 +1,103 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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$ */ + +/* These are the internal definitions needed for config parsing */ + +#ifndef config_h +#define config_h + +#include "libavrdude.h" + + +#define MAX_STR_CONST 1024 + +enum { V_NONE, V_NUM, V_NUM_REAL, V_STR }; +typedef struct value_t { + int type; + /*union { TODO: use an anonymous union here ? */ + int number; + double number_real; + char * string; + /*};*/ +} VALUE; + + +typedef struct token_t { + int primary; + VALUE value; +} TOKEN; +typedef struct token_t *token_p; + + +extern FILE * yyin; +extern PROGRAMMER * current_prog; +extern AVRPART * current_part; +extern AVRMEM * current_mem; +extern int lineno; +extern const char * infile; +extern LISTID string_list; +extern LISTID number_list; + + +#if !defined(HAS_YYSTYPE) +#define YYSTYPE token_p +#endif +extern YYSTYPE yylval; + +extern char string_buf[MAX_STR_CONST]; +extern char *string_buf_ptr; + +#ifdef __cplusplus +extern "C" { +#endif + +int yyparse(void); + +int yyerror(char * errmsg, ...); + +int yywarning(char * errmsg, ...); + +TOKEN * new_token(int primary); + +void free_token(TOKEN * tkn); + +void free_tokens(int n, ...); + +TOKEN * number(char * text); + +TOKEN * number_real(char * text); + +TOKEN * hexnumber(char * text); + +TOKEN * string(char * text); + +TOKEN * keyword(int primary); + +void print_token(TOKEN * tkn); + +void pyytext(void); + +char * dup_string(const char * str); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/xs/src/avrdude/config_gram.c b/xs/src/avrdude/config_gram.c new file mode 100644 index 000000000..c1a65b13e --- /dev/null +++ b/xs/src/avrdude/config_gram.c @@ -0,0 +1,3718 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + + 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 3 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 . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.4" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +#line 21 "config_gram.y" /* yacc.c:339 */ + + +#include "ac_cfg.h" + +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" +#include "config.h" + +#if defined(WIN32NATIVE) +#define strtok_r( _s, _sep, _lasts ) \ + ( *(_lasts) = strtok( (_s), (_sep) ) ) +#endif + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +int yylex(void); +int yyerror(char * errmsg, ...); +int yywarning(char * errmsg, ...); + +static int assign_pin(int pinno, TOKEN * v, int invert); +static int assign_pin_list(int invert); +static int which_opcode(TOKEN * opcode); +static int parse_cmdbits(OPCODE * op); + +static int pin_name; + +#line 98 "config_gram.c" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "y.tab.h". */ +#ifndef YY_YY_CONFIG_GRAM_H_INCLUDED +# define YY_YY_CONFIG_GRAM_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + K_READ = 258, + K_WRITE = 259, + K_READ_LO = 260, + K_READ_HI = 261, + K_WRITE_LO = 262, + K_WRITE_HI = 263, + K_LOADPAGE_LO = 264, + K_LOADPAGE_HI = 265, + K_LOAD_EXT_ADDR = 266, + K_WRITEPAGE = 267, + K_CHIP_ERASE = 268, + K_PGM_ENABLE = 269, + K_MEMORY = 270, + K_PAGE_SIZE = 271, + K_PAGED = 272, + K_BAUDRATE = 273, + K_BS2 = 274, + K_BUFF = 275, + K_CHIP_ERASE_DELAY = 276, + K_CONNTYPE = 277, + K_DEDICATED = 278, + K_DEFAULT_BITCLOCK = 279, + K_DEFAULT_PARALLEL = 280, + K_DEFAULT_PROGRAMMER = 281, + K_DEFAULT_SAFEMODE = 282, + K_DEFAULT_SERIAL = 283, + K_DESC = 284, + K_DEVICECODE = 285, + K_STK500_DEVCODE = 286, + K_AVR910_DEVCODE = 287, + K_EEPROM = 288, + K_ERRLED = 289, + K_FLASH = 290, + K_ID = 291, + K_IO = 292, + K_LOADPAGE = 293, + K_MAX_WRITE_DELAY = 294, + K_MCU_BASE = 295, + K_MIN_WRITE_DELAY = 296, + K_MISO = 297, + K_MOSI = 298, + K_NUM_PAGES = 299, + K_NVM_BASE = 300, + K_OCDREV = 301, + K_OFFSET = 302, + K_PAGEL = 303, + K_PARALLEL = 304, + K_PARENT = 305, + K_PART = 306, + K_PGMLED = 307, + K_PROGRAMMER = 308, + K_PSEUDO = 309, + K_PWROFF_AFTER_WRITE = 310, + K_RDYLED = 311, + K_READBACK_P1 = 312, + K_READBACK_P2 = 313, + K_READMEM = 314, + K_RESET = 315, + K_RETRY_PULSE = 316, + K_SERIAL = 317, + K_SCK = 318, + K_SIGNATURE = 319, + K_SIZE = 320, + K_USB = 321, + K_USBDEV = 322, + K_USBSN = 323, + K_USBPID = 324, + K_USBPRODUCT = 325, + K_USBVENDOR = 326, + K_USBVID = 327, + K_TYPE = 328, + K_VCC = 329, + K_VFYLED = 330, + K_NO = 331, + K_YES = 332, + K_TIMEOUT = 333, + K_STABDELAY = 334, + K_CMDEXEDELAY = 335, + K_HVSPCMDEXEDELAY = 336, + K_SYNCHLOOPS = 337, + K_BYTEDELAY = 338, + K_POLLVALUE = 339, + K_POLLINDEX = 340, + K_PREDELAY = 341, + K_POSTDELAY = 342, + K_POLLMETHOD = 343, + K_MODE = 344, + K_DELAY = 345, + K_BLOCKSIZE = 346, + K_READSIZE = 347, + K_HVENTERSTABDELAY = 348, + K_PROGMODEDELAY = 349, + K_LATCHCYCLES = 350, + K_TOGGLEVTG = 351, + K_POWEROFFDELAY = 352, + K_RESETDELAYMS = 353, + K_RESETDELAYUS = 354, + K_HVLEAVESTABDELAY = 355, + K_RESETDELAY = 356, + K_SYNCHCYCLES = 357, + K_HVCMDEXEDELAY = 358, + K_CHIPERASEPULSEWIDTH = 359, + K_CHIPERASEPOLLTIMEOUT = 360, + K_CHIPERASETIME = 361, + K_PROGRAMFUSEPULSEWIDTH = 362, + K_PROGRAMFUSEPOLLTIMEOUT = 363, + K_PROGRAMLOCKPULSEWIDTH = 364, + K_PROGRAMLOCKPOLLTIMEOUT = 365, + K_PP_CONTROLSTACK = 366, + K_HVSP_CONTROLSTACK = 367, + K_ALLOWFULLPAGEBITSTREAM = 368, + K_ENABLEPAGEPROGRAMMING = 369, + K_HAS_JTAG = 370, + K_HAS_DW = 371, + K_HAS_PDI = 372, + K_HAS_TPI = 373, + K_IDR = 374, + K_IS_AT90S1200 = 375, + K_IS_AVR32 = 376, + K_RAMPZ = 377, + K_SPMCR = 378, + K_EECR = 379, + K_FLASH_INSTR = 380, + K_EEPROM_INSTR = 381, + TKN_COMMA = 382, + TKN_EQUAL = 383, + TKN_SEMI = 384, + TKN_TILDE = 385, + TKN_LEFT_PAREN = 386, + TKN_RIGHT_PAREN = 387, + TKN_NUMBER = 388, + TKN_NUMBER_REAL = 389, + TKN_STRING = 390 + }; +#endif +/* Tokens. */ +#define K_READ 258 +#define K_WRITE 259 +#define K_READ_LO 260 +#define K_READ_HI 261 +#define K_WRITE_LO 262 +#define K_WRITE_HI 263 +#define K_LOADPAGE_LO 264 +#define K_LOADPAGE_HI 265 +#define K_LOAD_EXT_ADDR 266 +#define K_WRITEPAGE 267 +#define K_CHIP_ERASE 268 +#define K_PGM_ENABLE 269 +#define K_MEMORY 270 +#define K_PAGE_SIZE 271 +#define K_PAGED 272 +#define K_BAUDRATE 273 +#define K_BS2 274 +#define K_BUFF 275 +#define K_CHIP_ERASE_DELAY 276 +#define K_CONNTYPE 277 +#define K_DEDICATED 278 +#define K_DEFAULT_BITCLOCK 279 +#define K_DEFAULT_PARALLEL 280 +#define K_DEFAULT_PROGRAMMER 281 +#define K_DEFAULT_SAFEMODE 282 +#define K_DEFAULT_SERIAL 283 +#define K_DESC 284 +#define K_DEVICECODE 285 +#define K_STK500_DEVCODE 286 +#define K_AVR910_DEVCODE 287 +#define K_EEPROM 288 +#define K_ERRLED 289 +#define K_FLASH 290 +#define K_ID 291 +#define K_IO 292 +#define K_LOADPAGE 293 +#define K_MAX_WRITE_DELAY 294 +#define K_MCU_BASE 295 +#define K_MIN_WRITE_DELAY 296 +#define K_MISO 297 +#define K_MOSI 298 +#define K_NUM_PAGES 299 +#define K_NVM_BASE 300 +#define K_OCDREV 301 +#define K_OFFSET 302 +#define K_PAGEL 303 +#define K_PARALLEL 304 +#define K_PARENT 305 +#define K_PART 306 +#define K_PGMLED 307 +#define K_PROGRAMMER 308 +#define K_PSEUDO 309 +#define K_PWROFF_AFTER_WRITE 310 +#define K_RDYLED 311 +#define K_READBACK_P1 312 +#define K_READBACK_P2 313 +#define K_READMEM 314 +#define K_RESET 315 +#define K_RETRY_PULSE 316 +#define K_SERIAL 317 +#define K_SCK 318 +#define K_SIGNATURE 319 +#define K_SIZE 320 +#define K_USB 321 +#define K_USBDEV 322 +#define K_USBSN 323 +#define K_USBPID 324 +#define K_USBPRODUCT 325 +#define K_USBVENDOR 326 +#define K_USBVID 327 +#define K_TYPE 328 +#define K_VCC 329 +#define K_VFYLED 330 +#define K_NO 331 +#define K_YES 332 +#define K_TIMEOUT 333 +#define K_STABDELAY 334 +#define K_CMDEXEDELAY 335 +#define K_HVSPCMDEXEDELAY 336 +#define K_SYNCHLOOPS 337 +#define K_BYTEDELAY 338 +#define K_POLLVALUE 339 +#define K_POLLINDEX 340 +#define K_PREDELAY 341 +#define K_POSTDELAY 342 +#define K_POLLMETHOD 343 +#define K_MODE 344 +#define K_DELAY 345 +#define K_BLOCKSIZE 346 +#define K_READSIZE 347 +#define K_HVENTERSTABDELAY 348 +#define K_PROGMODEDELAY 349 +#define K_LATCHCYCLES 350 +#define K_TOGGLEVTG 351 +#define K_POWEROFFDELAY 352 +#define K_RESETDELAYMS 353 +#define K_RESETDELAYUS 354 +#define K_HVLEAVESTABDELAY 355 +#define K_RESETDELAY 356 +#define K_SYNCHCYCLES 357 +#define K_HVCMDEXEDELAY 358 +#define K_CHIPERASEPULSEWIDTH 359 +#define K_CHIPERASEPOLLTIMEOUT 360 +#define K_CHIPERASETIME 361 +#define K_PROGRAMFUSEPULSEWIDTH 362 +#define K_PROGRAMFUSEPOLLTIMEOUT 363 +#define K_PROGRAMLOCKPULSEWIDTH 364 +#define K_PROGRAMLOCKPOLLTIMEOUT 365 +#define K_PP_CONTROLSTACK 366 +#define K_HVSP_CONTROLSTACK 367 +#define K_ALLOWFULLPAGEBITSTREAM 368 +#define K_ENABLEPAGEPROGRAMMING 369 +#define K_HAS_JTAG 370 +#define K_HAS_DW 371 +#define K_HAS_PDI 372 +#define K_HAS_TPI 373 +#define K_IDR 374 +#define K_IS_AT90S1200 375 +#define K_IS_AVR32 376 +#define K_RAMPZ 377 +#define K_SPMCR 378 +#define K_EECR 379 +#define K_FLASH_INSTR 380 +#define K_EEPROM_INSTR 381 +#define TKN_COMMA 382 +#define TKN_EQUAL 383 +#define TKN_SEMI 384 +#define TKN_TILDE 385 +#define TKN_LEFT_PAREN 386 +#define TKN_RIGHT_PAREN 387 +#define TKN_NUMBER 388 +#define TKN_NUMBER_REAL 389 +#define TKN_STRING 390 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_CONFIG_GRAM_H_INCLUDED */ + +/* Copy the second part of user declarations. */ + +#line 419 "config_gram.c" /* yacc.c:358 */ + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 22 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 401 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 136 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 45 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 182 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 418 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 390 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, + 135 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 211, 211, 217, 221, 222, 226, 227, 232, 234, + 236, 242, 248, 254, 259, 270, 303, 313, 335, 393, + 403, 426, 427, 432, 433, 437, 438, 442, 465, 467, + 469, 471, 473, 478, 487, 491, 501, 509, 513, 514, + 515, 519, 526, 532, 533, 540, 547, 557, 572, 585, + 587, 591, 593, 597, 599, 603, 605, 610, 612, 616, + 616, 617, 617, 618, 618, 619, 619, 620, 620, 621, + 621, 622, 622, 623, 623, 624, 624, 625, 625, 629, + 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, + 640, 645, 646, 651, 651, 655, 655, 659, 659, 663, + 670, 677, 685, 692, 699, 710, 717, 748, 779, 809, + 839, 845, 851, 857, 867, 873, 879, 885, 891, 897, + 903, 909, 915, 921, 927, 933, 939, 945, 951, 957, + 963, 969, 975, 981, 987, 993, 999, 1005, 1011, 1017, + 1023, 1029, 1035, 1045, 1055, 1065, 1075, 1085, 1095, 1105, + 1115, 1121, 1127, 1133, 1139, 1145, 1151, 1157, 1167, 1186, + 1210, 1209, 1234, 1261, 1261, 1266, 1267, 1272, 1278, 1285, + 1291, 1297, 1303, 1309, 1315, 1321, 1327, 1334, 1340, 1346, + 1352, 1358, 1365 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "K_READ", "K_WRITE", "K_READ_LO", + "K_READ_HI", "K_WRITE_LO", "K_WRITE_HI", "K_LOADPAGE_LO", + "K_LOADPAGE_HI", "K_LOAD_EXT_ADDR", "K_WRITEPAGE", "K_CHIP_ERASE", + "K_PGM_ENABLE", "K_MEMORY", "K_PAGE_SIZE", "K_PAGED", "K_BAUDRATE", + "K_BS2", "K_BUFF", "K_CHIP_ERASE_DELAY", "K_CONNTYPE", "K_DEDICATED", + "K_DEFAULT_BITCLOCK", "K_DEFAULT_PARALLEL", "K_DEFAULT_PROGRAMMER", + "K_DEFAULT_SAFEMODE", "K_DEFAULT_SERIAL", "K_DESC", "K_DEVICECODE", + "K_STK500_DEVCODE", "K_AVR910_DEVCODE", "K_EEPROM", "K_ERRLED", + "K_FLASH", "K_ID", "K_IO", "K_LOADPAGE", "K_MAX_WRITE_DELAY", + "K_MCU_BASE", "K_MIN_WRITE_DELAY", "K_MISO", "K_MOSI", "K_NUM_PAGES", + "K_NVM_BASE", "K_OCDREV", "K_OFFSET", "K_PAGEL", "K_PARALLEL", + "K_PARENT", "K_PART", "K_PGMLED", "K_PROGRAMMER", "K_PSEUDO", + "K_PWROFF_AFTER_WRITE", "K_RDYLED", "K_READBACK_P1", "K_READBACK_P2", + "K_READMEM", "K_RESET", "K_RETRY_PULSE", "K_SERIAL", "K_SCK", + "K_SIGNATURE", "K_SIZE", "K_USB", "K_USBDEV", "K_USBSN", "K_USBPID", + "K_USBPRODUCT", "K_USBVENDOR", "K_USBVID", "K_TYPE", "K_VCC", "K_VFYLED", + "K_NO", "K_YES", "K_TIMEOUT", "K_STABDELAY", "K_CMDEXEDELAY", + "K_HVSPCMDEXEDELAY", "K_SYNCHLOOPS", "K_BYTEDELAY", "K_POLLVALUE", + "K_POLLINDEX", "K_PREDELAY", "K_POSTDELAY", "K_POLLMETHOD", "K_MODE", + "K_DELAY", "K_BLOCKSIZE", "K_READSIZE", "K_HVENTERSTABDELAY", + "K_PROGMODEDELAY", "K_LATCHCYCLES", "K_TOGGLEVTG", "K_POWEROFFDELAY", + "K_RESETDELAYMS", "K_RESETDELAYUS", "K_HVLEAVESTABDELAY", "K_RESETDELAY", + "K_SYNCHCYCLES", "K_HVCMDEXEDELAY", "K_CHIPERASEPULSEWIDTH", + "K_CHIPERASEPOLLTIMEOUT", "K_CHIPERASETIME", "K_PROGRAMFUSEPULSEWIDTH", + "K_PROGRAMFUSEPOLLTIMEOUT", "K_PROGRAMLOCKPULSEWIDTH", + "K_PROGRAMLOCKPOLLTIMEOUT", "K_PP_CONTROLSTACK", "K_HVSP_CONTROLSTACK", + "K_ALLOWFULLPAGEBITSTREAM", "K_ENABLEPAGEPROGRAMMING", "K_HAS_JTAG", + "K_HAS_DW", "K_HAS_PDI", "K_HAS_TPI", "K_IDR", "K_IS_AT90S1200", + "K_IS_AVR32", "K_RAMPZ", "K_SPMCR", "K_EECR", "K_FLASH_INSTR", + "K_EEPROM_INSTR", "TKN_COMMA", "TKN_EQUAL", "TKN_SEMI", "TKN_TILDE", + "TKN_LEFT_PAREN", "TKN_RIGHT_PAREN", "TKN_NUMBER", "TKN_NUMBER_REAL", + "TKN_STRING", "$accept", "number_real", "configuration", "config", "def", + "prog_def", "prog_decl", "part_def", "part_decl", "string_list", + "num_list", "prog_parms", "prog_parm", "prog_parm_type", + "prog_parm_type_id", "prog_parm_conntype", "prog_parm_conntype_id", + "prog_parm_usb", "usb_pid_list", "pin_number_non_empty", "pin_number", + "pin_list_element", "pin_list_non_empty", "pin_list", "prog_parm_pins", + "$@1", "$@2", "$@3", "$@4", "$@5", "$@6", "$@7", "$@8", "$@9", "$@10", + "opcode", "part_parms", "reset_disposition", "parallel_modes", + "retry_lines", "part_parm", "$@11", "yesno", "mem_specs", "mem_spec", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 388, 389, 390 +}; +# endif + +#define YYPACT_NINF -258 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-258))) + +#define YYTABLE_NINF -1 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = +{ + 23, -119, -83, -82, -68, -50, 2, 31, 82, 23, + -258, -39, 55, -37, 166, -99, -42, -41, -63, -40, + -35, -34, -258, -258, -258, -43, -32, -26, -20, -19, + -18, -15, -14, -12, -11, -9, -8, -7, 3, 5, + 6, 7, 8, 9, 10, 12, 55, 13, -258, -258, + -258, -258, -258, -258, -258, -258, -258, -258, -258, -258, + -258, -258, -258, -258, -258, -3, 15, 17, 18, 20, + 22, 24, 25, 26, 27, 28, 29, 30, 32, 33, + 34, 35, 37, 38, 39, 54, 56, 58, 60, 61, + 62, 63, 64, 65, 66, 71, 72, 73, 76, 77, + 79, 81, 85, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 101, 103, 104, 105, 106, 108, 109, + 110, 111, 112, 113, 114, 115, 127, 128, 166, 129, + -258, -258, 140, 164, 165, -258, -258, 167, 168, -258, + -258, 16, -258, 21, 48, -258, 75, -258, -258, -258, + -258, -258, -258, 122, 160, 169, 163, 170, 171, 4, + -258, -258, 172, -258, -258, 173, 174, 175, 176, 178, + 179, 180, 181, 183, 184, 185, -44, 19, -52, -63, + 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, + 216, 216, -63, -63, -63, -63, -63, -63, 217, -63, + -63, 218, 219, 220, 216, 216, 75, 225, -258, -258, + -258, -258, -258, -258, -258, -76, -258, -258, -258, -258, + -258, -71, -258, 228, -71, -71, -71, -71, -71, -71, + -258, -258, -258, 229, -258, -258, -258, -258, -258, -258, + -76, -71, -258, 14, -258, -258, -258, -258, -258, -258, + -258, -258, -258, -258, -258, -258, -258, -258, -258, -258, + -258, -258, -258, -258, -258, 224, -258, -258, -258, -258, + -258, -258, -258, -258, -258, -258, -258, -258, -258, -258, + -258, -258, -258, -258, -258, -258, -258, -258, -258, -258, + -258, -258, -258, -258, -258, -258, 231, 231, -258, -258, + -258, -258, -258, -258, -258, -258, -258, -258, -258, -258, + 231, 231, 228, -258, -45, -258, -258, -258, 232, -258, + 227, -258, -258, 226, -258, -258, -258, -258, -258, -258, + 230, -258, -258, 234, 236, 237, 238, 239, 240, 241, + 242, 243, 244, 245, 246, 247, 248, 249, 250, 14, + 251, 252, 253, 216, -258, -76, -258, -258, 254, -63, + 255, 256, 257, 258, -63, 259, 260, 261, 262, 263, + 264, 265, 266, 75, 271, -258, -258, -258, -120, -258, + -258, -258, -258, -258, -258, -258, -258, -258, -258, -258, + -258, -258, -258, -258, -258, 228, -258, -258 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 4, 0, 0, 0, 0, 0, 19, 16, 0, 5, + 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 7, 8, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 15, 0, 28, 31, + 30, 29, 9, 79, 80, 81, 82, 83, 84, 85, + 86, 87, 88, 89, 90, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, + 2, 3, 0, 0, 0, 164, 163, 0, 0, 20, + 17, 0, 61, 0, 0, 71, 0, 69, 67, 75, + 73, 63, 65, 0, 0, 0, 0, 0, 0, 0, + 59, 77, 0, 25, 160, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 91, 13, + 11, 10, 14, 12, 33, 58, 38, 39, 40, 37, + 32, 52, 21, 27, 52, 52, 52, 52, 52, 52, + 41, 44, 47, 43, 46, 45, 42, 36, 35, 34, + 58, 52, 26, 0, 112, 110, 100, 101, 102, 103, + 99, 154, 155, 156, 111, 96, 158, 95, 93, 94, + 113, 97, 98, 159, 157, 0, 105, 114, 115, 116, + 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 141, 134, 135, + 136, 137, 138, 139, 140, 23, 106, 107, 148, 149, + 142, 143, 144, 145, 150, 146, 147, 151, 152, 153, + 108, 109, 162, 92, 0, 49, 53, 55, 57, 62, + 0, 51, 72, 0, 70, 68, 76, 74, 64, 66, + 0, 60, 78, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 161, + 0, 0, 0, 0, 50, 0, 22, 48, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 165, 104, 24, 0, 56, + 169, 167, 173, 172, 170, 171, 174, 175, 176, 168, + 181, 177, 178, 179, 180, 182, 166, 54 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -258, -258, -258, -258, 132, -258, -258, -258, -258, -225, + -209, -258, 267, -258, -258, -258, -258, -258, -258, -231, + -181, -228, -258, -109, -258, -258, -258, -258, -258, -258, + -258, -258, -258, -258, -258, -257, -258, -258, -258, -258, + 273, -258, -176, -258, -210 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 132, 8, 9, 10, 11, 12, 13, 14, 243, + 316, 46, 47, 48, 259, 49, 239, 50, 253, 341, + 342, 337, 338, 339, 51, 260, 235, 248, 249, 245, + 244, 241, 247, 246, 261, 127, 128, 280, 276, 283, + 129, 263, 137, 369, 370 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_uint16 yytable[] = +{ + 277, 332, 317, 284, 336, 257, 368, 372, 281, 15, + 275, 282, 417, 135, 136, 330, 331, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 336, + 353, 354, 135, 136, 130, 131, 318, 319, 320, 321, + 322, 323, 278, 325, 326, 16, 17, 1, 2, 3, + 4, 5, 20, 355, 334, 356, 279, 335, 357, 340, + 18, 358, 335, 344, 345, 346, 347, 348, 349, 359, + 236, 360, 361, 25, 6, 26, 7, 27, 19, 362, + 352, 21, 22, 237, 28, 141, 373, 238, 374, 29, + 24, 30, 52, 133, 134, 138, 142, 31, 32, 363, + 139, 140, 143, 364, 365, 366, 367, 33, 144, 145, + 146, 34, 368, 147, 148, 35, 149, 150, 36, 151, + 152, 153, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 154, 164, 155, 156, 157, 158, 159, 160, 258, + 161, 23, 163, 165, 336, 166, 167, 399, 168, 234, + 169, 351, 170, 171, 172, 173, 174, 175, 176, 394, + 177, 178, 179, 180, 398, 181, 182, 183, 415, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 184, 240, 185, 66, 186, 67, 187, 188, + 189, 190, 191, 192, 193, 68, 69, 70, 71, 194, + 195, 196, 72, 401, 197, 198, 73, 199, 406, 200, + 242, 74, 75, 201, 76, 77, 202, 203, 204, 205, + 206, 207, 208, 209, 210, 211, 78, 79, 80, 212, + 81, 213, 214, 215, 216, 82, 217, 218, 219, 220, + 221, 222, 223, 224, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 225, 226, 250, 228, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 229, + 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 125, 126, 230, 231, 251, 232, 233, 254, 0, + 0, 262, 252, 0, 256, 255, 264, 265, 0, 267, + 266, 268, 269, 162, 271, 270, 272, 273, 274, 285, + 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, + 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, + 324, 327, 328, 329, 333, 343, 350, 371, 372, 375, + 374, 376, 378, 377, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 388, 389, 390, 391, 392, 393, 0, + 395, 0, 0, 0, 0, 396, 397, 400, 402, 403, + 404, 405, 407, 408, 409, 410, 411, 412, 413, 414, + 416, 227 +}; + +static const yytype_int16 yycheck[] = +{ + 176, 226, 211, 179, 235, 1, 263, 127, 60, 128, + 54, 63, 132, 76, 77, 224, 225, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 260, + 16, 17, 76, 77, 133, 134, 212, 213, 214, 215, + 216, 217, 23, 219, 220, 128, 128, 24, 25, 26, + 27, 28, 50, 39, 130, 41, 37, 133, 44, 130, + 128, 47, 133, 244, 245, 246, 247, 248, 249, 55, + 49, 57, 58, 18, 51, 20, 53, 22, 128, 65, + 261, 50, 0, 62, 29, 128, 131, 66, 133, 34, + 129, 36, 129, 135, 135, 135, 128, 42, 43, 85, + 135, 135, 128, 89, 90, 91, 92, 52, 128, 128, + 128, 56, 369, 128, 128, 60, 128, 128, 63, 128, + 128, 128, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 128, 135, 128, 128, 128, 128, 128, 128, 135, + 128, 9, 129, 128, 375, 128, 128, 375, 128, 133, + 128, 260, 128, 128, 128, 128, 128, 128, 128, 369, + 128, 128, 128, 128, 373, 128, 128, 128, 393, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 128, 135, 128, 19, 128, 21, 128, 128, + 128, 128, 128, 128, 128, 29, 30, 31, 32, 128, + 128, 128, 36, 379, 128, 128, 40, 128, 384, 128, + 135, 45, 46, 128, 48, 49, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 60, 61, 62, 128, + 64, 128, 128, 128, 128, 69, 128, 128, 128, 128, + 128, 128, 128, 128, 78, 79, 80, 81, 82, 83, + 84, 85, 86, 87, 88, 128, 128, 135, 129, 93, + 94, 95, 96, 97, 98, 99, 100, 101, 102, 129, + 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 125, 126, 129, 129, 135, 129, 129, 135, -1, + -1, 129, 133, -1, 133, 135, 133, 133, -1, 133, + 135, 133, 133, 46, 133, 135, 133, 133, 133, 133, + 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, + 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, + 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, + 133, 133, 133, 133, 129, 127, 127, 133, 127, 127, + 133, 135, 128, 133, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, -1, + 129, -1, -1, -1, -1, 133, 133, 133, 133, 133, + 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, + 129, 128 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 24, 25, 26, 27, 28, 51, 53, 138, 139, + 140, 141, 142, 143, 144, 128, 128, 128, 128, 128, + 50, 50, 0, 140, 129, 18, 20, 22, 29, 34, + 36, 42, 43, 52, 56, 60, 63, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 147, 148, 149, 151, + 153, 160, 129, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 19, 21, 29, 30, + 31, 32, 36, 40, 45, 46, 48, 49, 60, 61, + 62, 64, 69, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 93, 94, 95, 96, 97, 98, + 99, 100, 101, 102, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 171, 172, 176, + 133, 134, 137, 135, 135, 76, 77, 178, 135, 135, + 135, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 148, 129, 135, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 176, 129, 129, + 129, 129, 129, 129, 133, 162, 49, 62, 66, 152, + 135, 167, 135, 145, 166, 165, 169, 168, 163, 164, + 135, 135, 133, 154, 135, 135, 133, 1, 135, 150, + 161, 170, 129, 177, 133, 133, 135, 133, 133, 133, + 135, 133, 133, 133, 133, 54, 174, 178, 23, 37, + 173, 60, 63, 175, 178, 133, 133, 133, 133, 133, + 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, + 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, + 133, 133, 133, 133, 133, 133, 146, 146, 178, 178, + 178, 178, 178, 178, 133, 178, 178, 133, 133, 133, + 146, 146, 145, 129, 130, 133, 155, 157, 158, 159, + 130, 155, 156, 127, 156, 156, 156, 156, 156, 156, + 127, 159, 156, 16, 17, 39, 41, 44, 47, 55, + 57, 58, 65, 85, 89, 90, 91, 92, 171, 179, + 180, 133, 127, 131, 133, 127, 135, 133, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 180, 129, 133, 133, 146, 157, + 133, 178, 133, 133, 133, 133, 178, 133, 133, 133, + 133, 133, 133, 133, 133, 145, 129, 132 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 136, 137, 137, 138, 138, 139, 139, 140, 140, + 140, 140, 140, 140, 140, 141, 142, 142, 143, 144, + 144, 145, 145, 146, 146, 147, 147, 148, 148, 148, + 148, 148, 148, 148, 149, 150, 150, 151, 152, 152, + 152, 153, 153, 153, 153, 153, 153, 154, 154, 155, + 155, 156, 156, 157, 157, 158, 158, 159, 159, 161, + 160, 162, 160, 163, 160, 164, 160, 165, 160, 166, + 160, 167, 160, 168, 160, 169, 160, 170, 160, 171, + 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, + 171, 172, 172, 173, 173, 174, 174, 175, 175, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 177, 176, 176, 178, 178, 179, 179, 180, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, + 180, 180, 180 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 1, 0, 1, 1, 2, 2, 2, + 4, 4, 4, 4, 4, 2, 1, 3, 2, 1, + 3, 1, 3, 1, 3, 2, 3, 3, 1, 1, + 1, 1, 3, 3, 3, 1, 1, 3, 1, 1, + 1, 3, 3, 3, 3, 3, 3, 1, 3, 1, + 2, 1, 0, 1, 4, 1, 3, 1, 0, 0, + 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, + 4, 0, 4, 0, 4, 0, 4, 0, 4, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 3, 1, 1, 1, 1, 1, 1, 3, + 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 0, 4, 3, 1, 1, 2, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +yystpcpy (char *yydest, const char *yysrc) +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 211 "config_gram.y" /* yacc.c:1646 */ + { + (yyval) = (yyvsp[0]); + /* convert value to real */ + (yyval)->value.number_real = (yyval)->value.number; + (yyval)->value.type = V_NUM_REAL; + } +#line 1819 "config_gram.c" /* yacc.c:1646 */ + break; + + case 3: +#line 217 "config_gram.y" /* yacc.c:1646 */ + { + (yyval) = (yyvsp[0]); + } +#line 1827 "config_gram.c" /* yacc.c:1646 */ + break; + + case 10: +#line 236 "config_gram.y" /* yacc.c:1646 */ + { + strncpy(default_programmer, (yyvsp[-1])->value.string, MAX_STR_CONST); + default_programmer[MAX_STR_CONST-1] = 0; + free_token((yyvsp[-1])); + } +#line 1837 "config_gram.c" /* yacc.c:1646 */ + break; + + case 11: +#line 242 "config_gram.y" /* yacc.c:1646 */ + { + strncpy(default_parallel, (yyvsp[-1])->value.string, PATH_MAX); + default_parallel[PATH_MAX-1] = 0; + free_token((yyvsp[-1])); + } +#line 1847 "config_gram.c" /* yacc.c:1646 */ + break; + + case 12: +#line 248 "config_gram.y" /* yacc.c:1646 */ + { + strncpy(default_serial, (yyvsp[-1])->value.string, PATH_MAX); + default_serial[PATH_MAX-1] = 0; + free_token((yyvsp[-1])); + } +#line 1857 "config_gram.c" /* yacc.c:1646 */ + break; + + case 13: +#line 254 "config_gram.y" /* yacc.c:1646 */ + { + default_bitclock = (yyvsp[-1])->value.number_real; + free_token((yyvsp[-1])); + } +#line 1866 "config_gram.c" /* yacc.c:1646 */ + break; + + case 14: +#line 259 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[-1])->primary == K_YES) + default_safemode = 1; + else if ((yyvsp[-1])->primary == K_NO) + default_safemode = 0; + free_token((yyvsp[-1])); + } +#line 1878 "config_gram.c" /* yacc.c:1646 */ + break; + + case 15: +#line 271 "config_gram.y" /* yacc.c:1646 */ + { + PROGRAMMER * existing_prog; + char * id; + if (lsize(current_prog->id) == 0) { + yyerror("required parameter id not specified"); + YYABORT; + } + if (current_prog->initpgm == NULL) { + yyerror("programmer type not specified"); + YYABORT; + } + id = ldata(lfirst(current_prog->id)); + existing_prog = locate_programmer(programmers, id); + if (existing_prog) { + { /* temporarly set lineno to lineno of programmer start */ + int temp = lineno; lineno = current_prog->lineno; + yywarning("programmer %s overwrites previous definition %s:%d.", + id, existing_prog->config_file, existing_prog->lineno); + lineno = temp; + } + lrmv_d(programmers, existing_prog); + pgm_free(existing_prog); + } + PUSH(programmers, current_prog); +// pgm_fill_old_pins(current_prog); // TODO to be removed if old pin data no longer needed +// pgm_display_generic(current_prog, id); + current_prog = NULL; + } +#line 1911 "config_gram.c" /* yacc.c:1646 */ + break; + + case 16: +#line 304 "config_gram.y" /* yacc.c:1646 */ + { current_prog = pgm_new(); + if (current_prog == NULL) { + yyerror("could not create pgm instance"); + YYABORT; + } + strcpy(current_prog->config_file, infile); + current_prog->lineno = lineno; + } +#line 1924 "config_gram.c" /* yacc.c:1646 */ + break; + + case 17: +#line 314 "config_gram.y" /* yacc.c:1646 */ + { + struct programmer_t * pgm = locate_programmer(programmers, (yyvsp[0])->value.string); + if (pgm == NULL) { + yyerror("parent programmer %s not found", (yyvsp[0])->value.string); + free_token((yyvsp[0])); + YYABORT; + } + current_prog = pgm_dup(pgm); + if (current_prog == NULL) { + yyerror("could not duplicate pgm instance"); + free_token((yyvsp[0])); + YYABORT; + } + strcpy(current_prog->config_file, infile); + current_prog->lineno = lineno; + free_token((yyvsp[0])); + } +#line 1946 "config_gram.c" /* yacc.c:1646 */ + break; + + case 18: +#line 336 "config_gram.y" /* yacc.c:1646 */ + { + LNODEID ln; + AVRMEM * m; + AVRPART * existing_part; + + if (current_part->id[0] == 0) { + yyerror("required parameter id not specified"); + YYABORT; + } + + /* + * perform some sanity checking, and compute the number of bits + * to shift a page for constructing the page address for + * page-addressed memories. + */ + for (ln=lfirst(current_part->mem); ln; ln=lnext(ln)) { + m = ldata(ln); + if (m->paged) { + if (m->page_size == 0) { + yyerror("must specify page_size for paged memory"); + YYABORT; + } + if (m->num_pages == 0) { + yyerror("must specify num_pages for paged memory"); + YYABORT; + } + if (m->size != m->page_size * m->num_pages) { + yyerror("page size (%u) * num_pages (%u) = " + "%u does not match memory size (%u)", + m->page_size, + m->num_pages, + m->page_size * m->num_pages, + m->size); + YYABORT; + } + + } + } + + existing_part = locate_part(part_list, current_part->id); + if (existing_part) { + { /* temporarly set lineno to lineno of part start */ + int temp = lineno; lineno = current_part->lineno; + yywarning("part %s overwrites previous definition %s:%d.", + current_part->id, + existing_part->config_file, existing_part->lineno); + lineno = temp; + } + lrmv_d(part_list, existing_part); + avr_free_part(existing_part); + } + PUSH(part_list, current_part); + current_part = NULL; + } +#line 2005 "config_gram.c" /* yacc.c:1646 */ + break; + + case 19: +#line 394 "config_gram.y" /* yacc.c:1646 */ + { + current_part = avr_new_part(); + if (current_part == NULL) { + yyerror("could not create part instance"); + YYABORT; + } + strcpy(current_part->config_file, infile); + current_part->lineno = lineno; + } +#line 2019 "config_gram.c" /* yacc.c:1646 */ + break; + + case 20: +#line 404 "config_gram.y" /* yacc.c:1646 */ + { + AVRPART * parent_part = locate_part(part_list, (yyvsp[0])->value.string); + if (parent_part == NULL) { + yyerror("can't find parent part"); + free_token((yyvsp[0])); + YYABORT; + } + + current_part = avr_dup_part(parent_part); + if (current_part == NULL) { + yyerror("could not duplicate part instance"); + free_token((yyvsp[0])); + YYABORT; + } + strcpy(current_part->config_file, infile); + current_part->lineno = lineno; + + free_token((yyvsp[0])); + } +#line 2043 "config_gram.c" /* yacc.c:1646 */ + break; + + case 21: +#line 426 "config_gram.y" /* yacc.c:1646 */ + { ladd(string_list, (yyvsp[0])); } +#line 2049 "config_gram.c" /* yacc.c:1646 */ + break; + + case 22: +#line 427 "config_gram.y" /* yacc.c:1646 */ + { ladd(string_list, (yyvsp[0])); } +#line 2055 "config_gram.c" /* yacc.c:1646 */ + break; + + case 23: +#line 432 "config_gram.y" /* yacc.c:1646 */ + { ladd(number_list, (yyvsp[0])); } +#line 2061 "config_gram.c" /* yacc.c:1646 */ + break; + + case 24: +#line 433 "config_gram.y" /* yacc.c:1646 */ + { ladd(number_list, (yyvsp[0])); } +#line 2067 "config_gram.c" /* yacc.c:1646 */ + break; + + case 27: +#line 442 "config_gram.y" /* yacc.c:1646 */ + { + { + TOKEN * t; + char *s; + int do_yyabort = 0; + while (lsize(string_list)) { + t = lrmv_n(string_list, 1); + if (!do_yyabort) { + s = dup_string(t->value.string); + if (s == NULL) { + do_yyabort = 1; + } else { + ladd(current_prog->id, s); + } + } + /* if do_yyabort == 1 just make the list empty */ + free_token(t); + } + if (do_yyabort) { + YYABORT; + } + } + } +#line 2095 "config_gram.c" /* yacc.c:1646 */ + break; + + case 32: +#line 473 "config_gram.y" /* yacc.c:1646 */ + { + strncpy(current_prog->desc, (yyvsp[0])->value.string, PGM_DESCLEN); + current_prog->desc[PGM_DESCLEN-1] = 0; + free_token((yyvsp[0])); + } +#line 2105 "config_gram.c" /* yacc.c:1646 */ + break; + + case 33: +#line 478 "config_gram.y" /* yacc.c:1646 */ + { + { + current_prog->baudrate = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } + } +#line 2116 "config_gram.c" /* yacc.c:1646 */ + break; + + case 35: +#line 491 "config_gram.y" /* yacc.c:1646 */ + { + const struct programmer_type_t * pgm_type = locate_programmer_type((yyvsp[0])->value.string); + if (pgm_type == NULL) { + yyerror("programmer type %s not found", (yyvsp[0])->value.string); + free_token((yyvsp[0])); + YYABORT; + } + current_prog->initpgm = pgm_type->initpgm; + free_token((yyvsp[0])); +} +#line 2131 "config_gram.c" /* yacc.c:1646 */ + break; + + case 36: +#line 502 "config_gram.y" /* yacc.c:1646 */ + { + yyerror("programmer type must be written as \"id_type\""); + YYABORT; +} +#line 2140 "config_gram.c" /* yacc.c:1646 */ + break; + + case 38: +#line 513 "config_gram.y" /* yacc.c:1646 */ + { current_prog->conntype = CONNTYPE_PARALLEL; } +#line 2146 "config_gram.c" /* yacc.c:1646 */ + break; + + case 39: +#line 514 "config_gram.y" /* yacc.c:1646 */ + { current_prog->conntype = CONNTYPE_SERIAL; } +#line 2152 "config_gram.c" /* yacc.c:1646 */ + break; + + case 40: +#line 515 "config_gram.y" /* yacc.c:1646 */ + { current_prog->conntype = CONNTYPE_USB; } +#line 2158 "config_gram.c" /* yacc.c:1646 */ + break; + + case 41: +#line 519 "config_gram.y" /* yacc.c:1646 */ + { + { + strncpy(current_prog->usbdev, (yyvsp[0])->value.string, PGM_USBSTRINGLEN); + current_prog->usbdev[PGM_USBSTRINGLEN-1] = 0; + free_token((yyvsp[0])); + } + } +#line 2170 "config_gram.c" /* yacc.c:1646 */ + break; + + case 42: +#line 526 "config_gram.y" /* yacc.c:1646 */ + { + { + current_prog->usbvid = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } + } +#line 2181 "config_gram.c" /* yacc.c:1646 */ + break; + + case 44: +#line 533 "config_gram.y" /* yacc.c:1646 */ + { + { + strncpy(current_prog->usbsn, (yyvsp[0])->value.string, PGM_USBSTRINGLEN); + current_prog->usbsn[PGM_USBSTRINGLEN-1] = 0; + free_token((yyvsp[0])); + } + } +#line 2193 "config_gram.c" /* yacc.c:1646 */ + break; + + case 45: +#line 540 "config_gram.y" /* yacc.c:1646 */ + { + { + strncpy(current_prog->usbvendor, (yyvsp[0])->value.string, PGM_USBSTRINGLEN); + current_prog->usbvendor[PGM_USBSTRINGLEN-1] = 0; + free_token((yyvsp[0])); + } + } +#line 2205 "config_gram.c" /* yacc.c:1646 */ + break; + + case 46: +#line 547 "config_gram.y" /* yacc.c:1646 */ + { + { + strncpy(current_prog->usbproduct, (yyvsp[0])->value.string, PGM_USBSTRINGLEN); + current_prog->usbproduct[PGM_USBSTRINGLEN-1] = 0; + free_token((yyvsp[0])); + } + } +#line 2217 "config_gram.c" /* yacc.c:1646 */ + break; + + case 47: +#line 557 "config_gram.y" /* yacc.c:1646 */ + { + { + /* overwrite pids, so clear the existing entries */ + ldestroy_cb(current_prog->usbpid, free); + current_prog->usbpid = lcreat(NULL, 0); + } + { + int *ip = malloc(sizeof(int)); + if (ip) { + *ip = (yyvsp[0])->value.number; + ladd(current_prog->usbpid, ip); + } + free_token((yyvsp[0])); + } + } +#line 2237 "config_gram.c" /* yacc.c:1646 */ + break; + + case 48: +#line 572 "config_gram.y" /* yacc.c:1646 */ + { + { + int *ip = malloc(sizeof(int)); + if (ip) { + *ip = (yyvsp[0])->value.number; + ladd(current_prog->usbpid, ip); + } + free_token((yyvsp[0])); + } + } +#line 2252 "config_gram.c" /* yacc.c:1646 */ + break; + + case 49: +#line 585 "config_gram.y" /* yacc.c:1646 */ + { if(0 != assign_pin(pin_name, (yyvsp[0]), 0)) YYABORT; } +#line 2258 "config_gram.c" /* yacc.c:1646 */ + break; + + case 50: +#line 587 "config_gram.y" /* yacc.c:1646 */ + { if(0 != assign_pin(pin_name, (yyvsp[0]), 1)) YYABORT; } +#line 2264 "config_gram.c" /* yacc.c:1646 */ + break; + + case 52: +#line 593 "config_gram.y" /* yacc.c:1646 */ + { pin_clear_all(&(current_prog->pin[pin_name])); } +#line 2270 "config_gram.c" /* yacc.c:1646 */ + break; + + case 54: +#line 599 "config_gram.y" /* yacc.c:1646 */ + { if(0 != assign_pin_list(1)) YYABORT; } +#line 2276 "config_gram.c" /* yacc.c:1646 */ + break; + + case 58: +#line 612 "config_gram.y" /* yacc.c:1646 */ + { pin_clear_all(&(current_prog->pin[pin_name])); } +#line 2282 "config_gram.c" /* yacc.c:1646 */ + break; + + case 59: +#line 616 "config_gram.y" /* yacc.c:1646 */ + {pin_name = PPI_AVR_VCC; } +#line 2288 "config_gram.c" /* yacc.c:1646 */ + break; + + case 61: +#line 617 "config_gram.y" /* yacc.c:1646 */ + {pin_name = PPI_AVR_BUFF; } +#line 2294 "config_gram.c" /* yacc.c:1646 */ + break; + + case 63: +#line 618 "config_gram.y" /* yacc.c:1646 */ + {pin_name = PIN_AVR_RESET;} +#line 2300 "config_gram.c" /* yacc.c:1646 */ + break; + + case 64: +#line 618 "config_gram.y" /* yacc.c:1646 */ + { free_token((yyvsp[-3])); } +#line 2306 "config_gram.c" /* yacc.c:1646 */ + break; + + case 65: +#line 619 "config_gram.y" /* yacc.c:1646 */ + {pin_name = PIN_AVR_SCK; } +#line 2312 "config_gram.c" /* yacc.c:1646 */ + break; + + case 66: +#line 619 "config_gram.y" /* yacc.c:1646 */ + { free_token((yyvsp[-3])); } +#line 2318 "config_gram.c" /* yacc.c:1646 */ + break; + + case 67: +#line 620 "config_gram.y" /* yacc.c:1646 */ + {pin_name = PIN_AVR_MOSI; } +#line 2324 "config_gram.c" /* yacc.c:1646 */ + break; + + case 69: +#line 621 "config_gram.y" /* yacc.c:1646 */ + {pin_name = PIN_AVR_MISO; } +#line 2330 "config_gram.c" /* yacc.c:1646 */ + break; + + case 71: +#line 622 "config_gram.y" /* yacc.c:1646 */ + {pin_name = PIN_LED_ERR; } +#line 2336 "config_gram.c" /* yacc.c:1646 */ + break; + + case 73: +#line 623 "config_gram.y" /* yacc.c:1646 */ + {pin_name = PIN_LED_RDY; } +#line 2342 "config_gram.c" /* yacc.c:1646 */ + break; + + case 75: +#line 624 "config_gram.y" /* yacc.c:1646 */ + {pin_name = PIN_LED_PGM; } +#line 2348 "config_gram.c" /* yacc.c:1646 */ + break; + + case 77: +#line 625 "config_gram.y" /* yacc.c:1646 */ + {pin_name = PIN_LED_VFY; } +#line 2354 "config_gram.c" /* yacc.c:1646 */ + break; + + case 99: +#line 664 "config_gram.y" /* yacc.c:1646 */ + { + strncpy(current_part->id, (yyvsp[0])->value.string, AVR_IDLEN); + current_part->id[AVR_IDLEN-1] = 0; + free_token((yyvsp[0])); + } +#line 2364 "config_gram.c" /* yacc.c:1646 */ + break; + + case 100: +#line 671 "config_gram.y" /* yacc.c:1646 */ + { + strncpy(current_part->desc, (yyvsp[0])->value.string, AVR_DESCLEN); + current_part->desc[AVR_DESCLEN-1] = 0; + free_token((yyvsp[0])); + } +#line 2374 "config_gram.c" /* yacc.c:1646 */ + break; + + case 101: +#line 677 "config_gram.y" /* yacc.c:1646 */ + { + { + yyerror("devicecode is deprecated, use " + "stk500_devcode instead"); + YYABORT; + } + } +#line 2386 "config_gram.c" /* yacc.c:1646 */ + break; + + case 102: +#line 685 "config_gram.y" /* yacc.c:1646 */ + { + { + current_part->stk500_devcode = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } + } +#line 2397 "config_gram.c" /* yacc.c:1646 */ + break; + + case 103: +#line 692 "config_gram.y" /* yacc.c:1646 */ + { + { + current_part->avr910_devcode = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } + } +#line 2408 "config_gram.c" /* yacc.c:1646 */ + break; + + case 104: +#line 699 "config_gram.y" /* yacc.c:1646 */ + { + { + current_part->signature[0] = (yyvsp[-2])->value.number; + current_part->signature[1] = (yyvsp[-1])->value.number; + current_part->signature[2] = (yyvsp[0])->value.number; + free_token((yyvsp[-2])); + free_token((yyvsp[-1])); + free_token((yyvsp[0])); + } + } +#line 2423 "config_gram.c" /* yacc.c:1646 */ + break; + + case 105: +#line 710 "config_gram.y" /* yacc.c:1646 */ + { + { + current_part->usbpid = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } + } +#line 2434 "config_gram.c" /* yacc.c:1646 */ + break; + + case 106: +#line 717 "config_gram.y" /* yacc.c:1646 */ + { + { + TOKEN * t; + unsigned nbytes; + int ok; + + current_part->ctl_stack_type = CTL_STACK_PP; + nbytes = 0; + ok = 1; + + memset(current_part->controlstack, 0, CTL_STACK_SIZE); + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + if (nbytes < CTL_STACK_SIZE) + { + current_part->controlstack[nbytes] = t->value.number; + nbytes++; + } + else + { + ok = 0; + } + free_token(t); + } + if (!ok) + { + yywarning("too many bytes in control stack"); + } + } + } +#line 2469 "config_gram.c" /* yacc.c:1646 */ + break; + + case 107: +#line 748 "config_gram.y" /* yacc.c:1646 */ + { + { + TOKEN * t; + unsigned nbytes; + int ok; + + current_part->ctl_stack_type = CTL_STACK_HVSP; + nbytes = 0; + ok = 1; + + memset(current_part->controlstack, 0, CTL_STACK_SIZE); + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + if (nbytes < CTL_STACK_SIZE) + { + current_part->controlstack[nbytes] = t->value.number; + nbytes++; + } + else + { + ok = 0; + } + free_token(t); + } + if (!ok) + { + yywarning("too many bytes in control stack"); + } + } + } +#line 2504 "config_gram.c" /* yacc.c:1646 */ + break; + + case 108: +#line 779 "config_gram.y" /* yacc.c:1646 */ + { + { + TOKEN * t; + unsigned nbytes; + int ok; + + nbytes = 0; + ok = 1; + + memset(current_part->flash_instr, 0, FLASH_INSTR_SIZE); + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + if (nbytes < FLASH_INSTR_SIZE) + { + current_part->flash_instr[nbytes] = t->value.number; + nbytes++; + } + else + { + ok = 0; + } + free_token(t); + } + if (!ok) + { + yywarning("too many bytes in flash instructions"); + } + } + } +#line 2538 "config_gram.c" /* yacc.c:1646 */ + break; + + case 109: +#line 809 "config_gram.y" /* yacc.c:1646 */ + { + { + TOKEN * t; + unsigned nbytes; + int ok; + + nbytes = 0; + ok = 1; + + memset(current_part->eeprom_instr, 0, EEPROM_INSTR_SIZE); + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + if (nbytes < EEPROM_INSTR_SIZE) + { + current_part->eeprom_instr[nbytes] = t->value.number; + nbytes++; + } + else + { + ok = 0; + } + free_token(t); + } + if (!ok) + { + yywarning("too many bytes in EEPROM instructions"); + } + } + } +#line 2572 "config_gram.c" /* yacc.c:1646 */ + break; + + case 110: +#line 840 "config_gram.y" /* yacc.c:1646 */ + { + current_part->chip_erase_delay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2581 "config_gram.c" /* yacc.c:1646 */ + break; + + case 111: +#line 846 "config_gram.y" /* yacc.c:1646 */ + { + current_part->pagel = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2590 "config_gram.c" /* yacc.c:1646 */ + break; + + case 112: +#line 852 "config_gram.y" /* yacc.c:1646 */ + { + current_part->bs2 = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2599 "config_gram.c" /* yacc.c:1646 */ + break; + + case 113: +#line 858 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_DEDICATED) + current_part->reset_disposition = RESET_DEDICATED; + else if ((yyvsp[0])->primary == K_IO) + current_part->reset_disposition = RESET_IO; + + free_tokens(2, (yyvsp[-2]), (yyvsp[0])); + } +#line 2612 "config_gram.c" /* yacc.c:1646 */ + break; + + case 114: +#line 868 "config_gram.y" /* yacc.c:1646 */ + { + current_part->timeout = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2621 "config_gram.c" /* yacc.c:1646 */ + break; + + case 115: +#line 874 "config_gram.y" /* yacc.c:1646 */ + { + current_part->stabdelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2630 "config_gram.c" /* yacc.c:1646 */ + break; + + case 116: +#line 880 "config_gram.y" /* yacc.c:1646 */ + { + current_part->cmdexedelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2639 "config_gram.c" /* yacc.c:1646 */ + break; + + case 117: +#line 886 "config_gram.y" /* yacc.c:1646 */ + { + current_part->hvspcmdexedelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2648 "config_gram.c" /* yacc.c:1646 */ + break; + + case 118: +#line 892 "config_gram.y" /* yacc.c:1646 */ + { + current_part->synchloops = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2657 "config_gram.c" /* yacc.c:1646 */ + break; + + case 119: +#line 898 "config_gram.y" /* yacc.c:1646 */ + { + current_part->bytedelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2666 "config_gram.c" /* yacc.c:1646 */ + break; + + case 120: +#line 904 "config_gram.y" /* yacc.c:1646 */ + { + current_part->pollvalue = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2675 "config_gram.c" /* yacc.c:1646 */ + break; + + case 121: +#line 910 "config_gram.y" /* yacc.c:1646 */ + { + current_part->pollindex = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2684 "config_gram.c" /* yacc.c:1646 */ + break; + + case 122: +#line 916 "config_gram.y" /* yacc.c:1646 */ + { + current_part->predelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2693 "config_gram.c" /* yacc.c:1646 */ + break; + + case 123: +#line 922 "config_gram.y" /* yacc.c:1646 */ + { + current_part->postdelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2702 "config_gram.c" /* yacc.c:1646 */ + break; + + case 124: +#line 928 "config_gram.y" /* yacc.c:1646 */ + { + current_part->pollmethod = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2711 "config_gram.c" /* yacc.c:1646 */ + break; + + case 125: +#line 934 "config_gram.y" /* yacc.c:1646 */ + { + current_part->hventerstabdelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2720 "config_gram.c" /* yacc.c:1646 */ + break; + + case 126: +#line 940 "config_gram.y" /* yacc.c:1646 */ + { + current_part->progmodedelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2729 "config_gram.c" /* yacc.c:1646 */ + break; + + case 127: +#line 946 "config_gram.y" /* yacc.c:1646 */ + { + current_part->latchcycles = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2738 "config_gram.c" /* yacc.c:1646 */ + break; + + case 128: +#line 952 "config_gram.y" /* yacc.c:1646 */ + { + current_part->togglevtg = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2747 "config_gram.c" /* yacc.c:1646 */ + break; + + case 129: +#line 958 "config_gram.y" /* yacc.c:1646 */ + { + current_part->poweroffdelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2756 "config_gram.c" /* yacc.c:1646 */ + break; + + case 130: +#line 964 "config_gram.y" /* yacc.c:1646 */ + { + current_part->resetdelayms = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2765 "config_gram.c" /* yacc.c:1646 */ + break; + + case 131: +#line 970 "config_gram.y" /* yacc.c:1646 */ + { + current_part->resetdelayus = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2774 "config_gram.c" /* yacc.c:1646 */ + break; + + case 132: +#line 976 "config_gram.y" /* yacc.c:1646 */ + { + current_part->hvleavestabdelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2783 "config_gram.c" /* yacc.c:1646 */ + break; + + case 133: +#line 982 "config_gram.y" /* yacc.c:1646 */ + { + current_part->resetdelay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2792 "config_gram.c" /* yacc.c:1646 */ + break; + + case 134: +#line 988 "config_gram.y" /* yacc.c:1646 */ + { + current_part->chiperasepulsewidth = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2801 "config_gram.c" /* yacc.c:1646 */ + break; + + case 135: +#line 994 "config_gram.y" /* yacc.c:1646 */ + { + current_part->chiperasepolltimeout = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2810 "config_gram.c" /* yacc.c:1646 */ + break; + + case 136: +#line 1000 "config_gram.y" /* yacc.c:1646 */ + { + current_part->chiperasetime = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2819 "config_gram.c" /* yacc.c:1646 */ + break; + + case 137: +#line 1006 "config_gram.y" /* yacc.c:1646 */ + { + current_part->programfusepulsewidth = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2828 "config_gram.c" /* yacc.c:1646 */ + break; + + case 138: +#line 1012 "config_gram.y" /* yacc.c:1646 */ + { + current_part->programfusepolltimeout = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2837 "config_gram.c" /* yacc.c:1646 */ + break; + + case 139: +#line 1018 "config_gram.y" /* yacc.c:1646 */ + { + current_part->programlockpulsewidth = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2846 "config_gram.c" /* yacc.c:1646 */ + break; + + case 140: +#line 1024 "config_gram.y" /* yacc.c:1646 */ + { + current_part->programlockpolltimeout = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2855 "config_gram.c" /* yacc.c:1646 */ + break; + + case 141: +#line 1030 "config_gram.y" /* yacc.c:1646 */ + { + current_part->synchcycles = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2864 "config_gram.c" /* yacc.c:1646 */ + break; + + case 142: +#line 1036 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_YES) + current_part->flags |= AVRPART_HAS_JTAG; + else if ((yyvsp[0])->primary == K_NO) + current_part->flags &= ~AVRPART_HAS_JTAG; + + free_token((yyvsp[0])); + } +#line 2877 "config_gram.c" /* yacc.c:1646 */ + break; + + case 143: +#line 1046 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_YES) + current_part->flags |= AVRPART_HAS_DW; + else if ((yyvsp[0])->primary == K_NO) + current_part->flags &= ~AVRPART_HAS_DW; + + free_token((yyvsp[0])); + } +#line 2890 "config_gram.c" /* yacc.c:1646 */ + break; + + case 144: +#line 1056 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_YES) + current_part->flags |= AVRPART_HAS_PDI; + else if ((yyvsp[0])->primary == K_NO) + current_part->flags &= ~AVRPART_HAS_PDI; + + free_token((yyvsp[0])); + } +#line 2903 "config_gram.c" /* yacc.c:1646 */ + break; + + case 145: +#line 1066 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_YES) + current_part->flags |= AVRPART_HAS_TPI; + else if ((yyvsp[0])->primary == K_NO) + current_part->flags &= ~AVRPART_HAS_TPI; + + free_token((yyvsp[0])); + } +#line 2916 "config_gram.c" /* yacc.c:1646 */ + break; + + case 146: +#line 1076 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_YES) + current_part->flags |= AVRPART_IS_AT90S1200; + else if ((yyvsp[0])->primary == K_NO) + current_part->flags &= ~AVRPART_IS_AT90S1200; + + free_token((yyvsp[0])); + } +#line 2929 "config_gram.c" /* yacc.c:1646 */ + break; + + case 147: +#line 1086 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_YES) + current_part->flags |= AVRPART_AVR32; + else if ((yyvsp[0])->primary == K_NO) + current_part->flags &= ~AVRPART_AVR32; + + free_token((yyvsp[0])); + } +#line 2942 "config_gram.c" /* yacc.c:1646 */ + break; + + case 148: +#line 1096 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_YES) + current_part->flags |= AVRPART_ALLOWFULLPAGEBITSTREAM; + else if ((yyvsp[0])->primary == K_NO) + current_part->flags &= ~AVRPART_ALLOWFULLPAGEBITSTREAM; + + free_token((yyvsp[0])); + } +#line 2955 "config_gram.c" /* yacc.c:1646 */ + break; + + case 149: +#line 1106 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_YES) + current_part->flags |= AVRPART_ENABLEPAGEPROGRAMMING; + else if ((yyvsp[0])->primary == K_NO) + current_part->flags &= ~AVRPART_ENABLEPAGEPROGRAMMING; + + free_token((yyvsp[0])); + } +#line 2968 "config_gram.c" /* yacc.c:1646 */ + break; + + case 150: +#line 1116 "config_gram.y" /* yacc.c:1646 */ + { + current_part->idr = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2977 "config_gram.c" /* yacc.c:1646 */ + break; + + case 151: +#line 1122 "config_gram.y" /* yacc.c:1646 */ + { + current_part->rampz = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2986 "config_gram.c" /* yacc.c:1646 */ + break; + + case 152: +#line 1128 "config_gram.y" /* yacc.c:1646 */ + { + current_part->spmcr = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 2995 "config_gram.c" /* yacc.c:1646 */ + break; + + case 153: +#line 1134 "config_gram.y" /* yacc.c:1646 */ + { + current_part->eecr = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3004 "config_gram.c" /* yacc.c:1646 */ + break; + + case 154: +#line 1140 "config_gram.y" /* yacc.c:1646 */ + { + current_part->mcu_base = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3013 "config_gram.c" /* yacc.c:1646 */ + break; + + case 155: +#line 1146 "config_gram.y" /* yacc.c:1646 */ + { + current_part->nvm_base = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3022 "config_gram.c" /* yacc.c:1646 */ + break; + + case 156: +#line 1152 "config_gram.y" /* yacc.c:1646 */ + { + current_part->ocdrev = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3031 "config_gram.c" /* yacc.c:1646 */ + break; + + case 157: +#line 1158 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_YES) + current_part->flags |= AVRPART_SERIALOK; + else if ((yyvsp[0])->primary == K_NO) + current_part->flags &= ~AVRPART_SERIALOK; + + free_token((yyvsp[0])); + } +#line 3044 "config_gram.c" /* yacc.c:1646 */ + break; + + case 158: +#line 1168 "config_gram.y" /* yacc.c:1646 */ + { + if ((yyvsp[0])->primary == K_YES) { + current_part->flags |= AVRPART_PARALLELOK; + current_part->flags &= ~AVRPART_PSEUDOPARALLEL; + } + else if ((yyvsp[0])->primary == K_NO) { + current_part->flags &= ~AVRPART_PARALLELOK; + current_part->flags &= ~AVRPART_PSEUDOPARALLEL; + } + else if ((yyvsp[0])->primary == K_PSEUDO) { + current_part->flags |= AVRPART_PARALLELOK; + current_part->flags |= AVRPART_PSEUDOPARALLEL; + } + + + free_token((yyvsp[0])); + } +#line 3066 "config_gram.c" /* yacc.c:1646 */ + break; + + case 159: +#line 1187 "config_gram.y" /* yacc.c:1646 */ + { + switch ((yyvsp[0])->primary) { + case K_RESET : + current_part->retry_pulse = PIN_AVR_RESET; + break; + case K_SCK : + current_part->retry_pulse = PIN_AVR_SCK; + break; + } + + free_token((yyvsp[-2])); + } +#line 3083 "config_gram.c" /* yacc.c:1646 */ + break; + + case 160: +#line 1210 "config_gram.y" /* yacc.c:1646 */ + { + current_mem = avr_new_memtype(); + if (current_mem == NULL) { + yyerror("could not create mem instance"); + free_token((yyvsp[0])); + YYABORT; + } + strncpy(current_mem->desc, (yyvsp[0])->value.string, AVR_MEMDESCLEN); + current_mem->desc[AVR_MEMDESCLEN-1] = 0; + free_token((yyvsp[0])); + } +#line 3099 "config_gram.c" /* yacc.c:1646 */ + break; + + case 161: +#line 1222 "config_gram.y" /* yacc.c:1646 */ + { + AVRMEM * existing_mem; + + existing_mem = avr_locate_mem(current_part, current_mem->desc); + if (existing_mem != NULL) { + lrmv_d(current_part->mem, existing_mem); + avr_free_mem(existing_mem); + } + ladd(current_part->mem, current_mem); + current_mem = NULL; + } +#line 3115 "config_gram.c" /* yacc.c:1646 */ + break; + + case 162: +#line 1234 "config_gram.y" /* yacc.c:1646 */ + { + { + int opnum; + OPCODE * op; + + opnum = which_opcode((yyvsp[-2])); + if (opnum < 0) YYABORT; + op = avr_new_opcode(); + if (op == NULL) { + yyerror("could not create opcode instance"); + free_token((yyvsp[-2])); + YYABORT; + } + if(0 != parse_cmdbits(op)) YYABORT; + if (current_part->op[opnum] != NULL) { + /*yywarning("operation redefined");*/ + avr_free_opcode(current_part->op[opnum]); + } + current_part->op[opnum] = op; + + free_token((yyvsp[-2])); + } + } +#line 3143 "config_gram.c" /* yacc.c:1646 */ + break; + + case 167: +#line 1273 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->paged = (yyvsp[0])->primary == K_YES ? 1 : 0; + free_token((yyvsp[0])); + } +#line 3152 "config_gram.c" /* yacc.c:1646 */ + break; + + case 168: +#line 1279 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->size = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3161 "config_gram.c" /* yacc.c:1646 */ + break; + + case 169: +#line 1286 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->page_size = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3170 "config_gram.c" /* yacc.c:1646 */ + break; + + case 170: +#line 1292 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->num_pages = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3179 "config_gram.c" /* yacc.c:1646 */ + break; + + case 171: +#line 1298 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->offset = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3188 "config_gram.c" /* yacc.c:1646 */ + break; + + case 172: +#line 1304 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->min_write_delay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3197 "config_gram.c" /* yacc.c:1646 */ + break; + + case 173: +#line 1310 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->max_write_delay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3206 "config_gram.c" /* yacc.c:1646 */ + break; + + case 174: +#line 1316 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->pwroff_after_write = (yyvsp[0])->primary == K_YES ? 1 : 0; + free_token((yyvsp[0])); + } +#line 3215 "config_gram.c" /* yacc.c:1646 */ + break; + + case 175: +#line 1322 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->readback[0] = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3224 "config_gram.c" /* yacc.c:1646 */ + break; + + case 176: +#line 1328 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->readback[1] = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3233 "config_gram.c" /* yacc.c:1646 */ + break; + + case 177: +#line 1335 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->mode = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3242 "config_gram.c" /* yacc.c:1646 */ + break; + + case 178: +#line 1341 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->delay = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3251 "config_gram.c" /* yacc.c:1646 */ + break; + + case 179: +#line 1347 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->blocksize = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3260 "config_gram.c" /* yacc.c:1646 */ + break; + + case 180: +#line 1353 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->readsize = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3269 "config_gram.c" /* yacc.c:1646 */ + break; + + case 181: +#line 1359 "config_gram.y" /* yacc.c:1646 */ + { + current_mem->pollindex = (yyvsp[0])->value.number; + free_token((yyvsp[0])); + } +#line 3278 "config_gram.c" /* yacc.c:1646 */ + break; + + case 182: +#line 1365 "config_gram.y" /* yacc.c:1646 */ + { + { + int opnum; + OPCODE * op; + + opnum = which_opcode((yyvsp[-2])); + if (opnum < 0) YYABORT; + op = avr_new_opcode(); + if (op == NULL) { + yyerror("could not create opcode instance"); + free_token((yyvsp[-2])); + YYABORT; + } + if(0 != parse_cmdbits(op)) YYABORT; + if (current_mem->op[opnum] != NULL) { + /*yywarning("operation redefined");*/ + avr_free_opcode(current_mem->op[opnum]); + } + current_mem->op[opnum] = op; + + free_token((yyvsp[-2])); + } + } +#line 3306 "config_gram.c" /* yacc.c:1646 */ + break; + + +#line 3310 "config_gram.c" /* yacc.c:1646 */ + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} +#line 1391 "config_gram.y" /* yacc.c:1906 */ + + +#if 0 +static char * vtypestr(int type) +{ + switch (type) { + case V_NUM : return "INTEGER"; + case V_NUM_REAL: return "REAL"; + case V_STR : return "STRING"; + default: + return ""; + } +} +#endif + + +static int assign_pin(int pinno, TOKEN * v, int invert) +{ + int value; + + value = v->value.number; + free_token(v); + + if ((value < PIN_MIN) || (value > PIN_MAX)) { + yyerror("pin must be in the range " TOSTRING(PIN_MIN) "-" TOSTRING(PIN_MAX)); + return -1; + } + + pin_set_value(&(current_prog->pin[pinno]), value, invert); + + return 0; +} + +static int assign_pin_list(int invert) +{ + TOKEN * t; + int pin; + int rv = 0; + + current_prog->pinno[pin_name] = 0; + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + if (rv == 0) { + pin = t->value.number; + if ((pin < PIN_MIN) || (pin > PIN_MAX)) { + yyerror("pin must be in the range " TOSTRING(PIN_MIN) "-" TOSTRING(PIN_MAX)); + rv = -1; + /* loop clears list and frees tokens */ + } + pin_set_value(&(current_prog->pin[pin_name]), pin, invert); + } + free_token(t); + } + return rv; +} + +static int which_opcode(TOKEN * opcode) +{ + switch (opcode->primary) { + case K_READ : return AVR_OP_READ; break; + case K_WRITE : return AVR_OP_WRITE; break; + case K_READ_LO : return AVR_OP_READ_LO; break; + case K_READ_HI : return AVR_OP_READ_HI; break; + case K_WRITE_LO : return AVR_OP_WRITE_LO; break; + case K_WRITE_HI : return AVR_OP_WRITE_HI; break; + case K_LOADPAGE_LO : return AVR_OP_LOADPAGE_LO; break; + case K_LOADPAGE_HI : return AVR_OP_LOADPAGE_HI; break; + case K_LOAD_EXT_ADDR : return AVR_OP_LOAD_EXT_ADDR; break; + case K_WRITEPAGE : return AVR_OP_WRITEPAGE; break; + case K_CHIP_ERASE : return AVR_OP_CHIP_ERASE; break; + case K_PGM_ENABLE : return AVR_OP_PGM_ENABLE; break; + default : + yyerror("invalid opcode"); + return -1; + break; + } +} + + +static int parse_cmdbits(OPCODE * op) +{ + TOKEN * t; + int bitno; + char ch; + char * e; + char * q; + int len; + char * s, *brkt = NULL; + int rv = 0; + + bitno = 32; + while (lsize(string_list)) { + + t = lrmv_n(string_list, 1); + + s = strtok_r(t->value.string, " ", &brkt); + while (rv == 0 && s != NULL) { + + bitno--; + if (bitno < 0) { + yyerror("too many opcode bits for instruction"); + rv = -1; + break; + } + + len = strlen(s); + + if (len == 0) { + yyerror("invalid bit specifier \"\""); + rv = -1; + break; + } + + ch = s[0]; + + if (len == 1) { + switch (ch) { + case '1': + op->bit[bitno].type = AVR_CMDBIT_VALUE; + op->bit[bitno].value = 1; + op->bit[bitno].bitno = bitno % 8; + break; + case '0': + op->bit[bitno].type = AVR_CMDBIT_VALUE; + op->bit[bitno].value = 0; + op->bit[bitno].bitno = bitno % 8; + break; + case 'x': + op->bit[bitno].type = AVR_CMDBIT_IGNORE; + op->bit[bitno].value = 0; + op->bit[bitno].bitno = bitno % 8; + break; + case 'a': + op->bit[bitno].type = AVR_CMDBIT_ADDRESS; + op->bit[bitno].value = 0; + op->bit[bitno].bitno = 8*(bitno/8) + bitno % 8; + break; + case 'i': + op->bit[bitno].type = AVR_CMDBIT_INPUT; + op->bit[bitno].value = 0; + op->bit[bitno].bitno = bitno % 8; + break; + case 'o': + op->bit[bitno].type = AVR_CMDBIT_OUTPUT; + op->bit[bitno].value = 0; + op->bit[bitno].bitno = bitno % 8; + break; + default : + yyerror("invalid bit specifier '%c'", ch); + rv = -1; + break; + } + } + else { + if (ch == 'a') { + q = &s[1]; + op->bit[bitno].bitno = strtol(q, &e, 0); + if ((e == q)||(*e != 0)) { + yyerror("can't parse bit number from \"%s\"", q); + rv = -1; + break; + } + op->bit[bitno].type = AVR_CMDBIT_ADDRESS; + op->bit[bitno].value = 0; + } + else { + yyerror("invalid bit specifier \"%s\"", s); + rv = -1; + break; + } + } + + s = strtok_r(NULL, " ", &brkt); + } /* while */ + + free_token(t); + + } /* while */ + + return rv; +} diff --git a/xs/src/avrdude/config_gram.h b/xs/src/avrdude/config_gram.h new file mode 100644 index 000000000..036d67ebe --- /dev/null +++ b/xs/src/avrdude/config_gram.h @@ -0,0 +1,330 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + + 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 3 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 . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_YY_CONFIG_GRAM_H_INCLUDED +# define YY_YY_CONFIG_GRAM_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + K_READ = 258, + K_WRITE = 259, + K_READ_LO = 260, + K_READ_HI = 261, + K_WRITE_LO = 262, + K_WRITE_HI = 263, + K_LOADPAGE_LO = 264, + K_LOADPAGE_HI = 265, + K_LOAD_EXT_ADDR = 266, + K_WRITEPAGE = 267, + K_CHIP_ERASE = 268, + K_PGM_ENABLE = 269, + K_MEMORY = 270, + K_PAGE_SIZE = 271, + K_PAGED = 272, + K_BAUDRATE = 273, + K_BS2 = 274, + K_BUFF = 275, + K_CHIP_ERASE_DELAY = 276, + K_CONNTYPE = 277, + K_DEDICATED = 278, + K_DEFAULT_BITCLOCK = 279, + K_DEFAULT_PARALLEL = 280, + K_DEFAULT_PROGRAMMER = 281, + K_DEFAULT_SAFEMODE = 282, + K_DEFAULT_SERIAL = 283, + K_DESC = 284, + K_DEVICECODE = 285, + K_STK500_DEVCODE = 286, + K_AVR910_DEVCODE = 287, + K_EEPROM = 288, + K_ERRLED = 289, + K_FLASH = 290, + K_ID = 291, + K_IO = 292, + K_LOADPAGE = 293, + K_MAX_WRITE_DELAY = 294, + K_MCU_BASE = 295, + K_MIN_WRITE_DELAY = 296, + K_MISO = 297, + K_MOSI = 298, + K_NUM_PAGES = 299, + K_NVM_BASE = 300, + K_OCDREV = 301, + K_OFFSET = 302, + K_PAGEL = 303, + K_PARALLEL = 304, + K_PARENT = 305, + K_PART = 306, + K_PGMLED = 307, + K_PROGRAMMER = 308, + K_PSEUDO = 309, + K_PWROFF_AFTER_WRITE = 310, + K_RDYLED = 311, + K_READBACK_P1 = 312, + K_READBACK_P2 = 313, + K_READMEM = 314, + K_RESET = 315, + K_RETRY_PULSE = 316, + K_SERIAL = 317, + K_SCK = 318, + K_SIGNATURE = 319, + K_SIZE = 320, + K_USB = 321, + K_USBDEV = 322, + K_USBSN = 323, + K_USBPID = 324, + K_USBPRODUCT = 325, + K_USBVENDOR = 326, + K_USBVID = 327, + K_TYPE = 328, + K_VCC = 329, + K_VFYLED = 330, + K_NO = 331, + K_YES = 332, + K_TIMEOUT = 333, + K_STABDELAY = 334, + K_CMDEXEDELAY = 335, + K_HVSPCMDEXEDELAY = 336, + K_SYNCHLOOPS = 337, + K_BYTEDELAY = 338, + K_POLLVALUE = 339, + K_POLLINDEX = 340, + K_PREDELAY = 341, + K_POSTDELAY = 342, + K_POLLMETHOD = 343, + K_MODE = 344, + K_DELAY = 345, + K_BLOCKSIZE = 346, + K_READSIZE = 347, + K_HVENTERSTABDELAY = 348, + K_PROGMODEDELAY = 349, + K_LATCHCYCLES = 350, + K_TOGGLEVTG = 351, + K_POWEROFFDELAY = 352, + K_RESETDELAYMS = 353, + K_RESETDELAYUS = 354, + K_HVLEAVESTABDELAY = 355, + K_RESETDELAY = 356, + K_SYNCHCYCLES = 357, + K_HVCMDEXEDELAY = 358, + K_CHIPERASEPULSEWIDTH = 359, + K_CHIPERASEPOLLTIMEOUT = 360, + K_CHIPERASETIME = 361, + K_PROGRAMFUSEPULSEWIDTH = 362, + K_PROGRAMFUSEPOLLTIMEOUT = 363, + K_PROGRAMLOCKPULSEWIDTH = 364, + K_PROGRAMLOCKPOLLTIMEOUT = 365, + K_PP_CONTROLSTACK = 366, + K_HVSP_CONTROLSTACK = 367, + K_ALLOWFULLPAGEBITSTREAM = 368, + K_ENABLEPAGEPROGRAMMING = 369, + K_HAS_JTAG = 370, + K_HAS_DW = 371, + K_HAS_PDI = 372, + K_HAS_TPI = 373, + K_IDR = 374, + K_IS_AT90S1200 = 375, + K_IS_AVR32 = 376, + K_RAMPZ = 377, + K_SPMCR = 378, + K_EECR = 379, + K_FLASH_INSTR = 380, + K_EEPROM_INSTR = 381, + TKN_COMMA = 382, + TKN_EQUAL = 383, + TKN_SEMI = 384, + TKN_TILDE = 385, + TKN_LEFT_PAREN = 386, + TKN_RIGHT_PAREN = 387, + TKN_NUMBER = 388, + TKN_NUMBER_REAL = 389, + TKN_STRING = 390 + }; +#endif +/* Tokens. */ +#define K_READ 258 +#define K_WRITE 259 +#define K_READ_LO 260 +#define K_READ_HI 261 +#define K_WRITE_LO 262 +#define K_WRITE_HI 263 +#define K_LOADPAGE_LO 264 +#define K_LOADPAGE_HI 265 +#define K_LOAD_EXT_ADDR 266 +#define K_WRITEPAGE 267 +#define K_CHIP_ERASE 268 +#define K_PGM_ENABLE 269 +#define K_MEMORY 270 +#define K_PAGE_SIZE 271 +#define K_PAGED 272 +#define K_BAUDRATE 273 +#define K_BS2 274 +#define K_BUFF 275 +#define K_CHIP_ERASE_DELAY 276 +#define K_CONNTYPE 277 +#define K_DEDICATED 278 +#define K_DEFAULT_BITCLOCK 279 +#define K_DEFAULT_PARALLEL 280 +#define K_DEFAULT_PROGRAMMER 281 +#define K_DEFAULT_SAFEMODE 282 +#define K_DEFAULT_SERIAL 283 +#define K_DESC 284 +#define K_DEVICECODE 285 +#define K_STK500_DEVCODE 286 +#define K_AVR910_DEVCODE 287 +#define K_EEPROM 288 +#define K_ERRLED 289 +#define K_FLASH 290 +#define K_ID 291 +#define K_IO 292 +#define K_LOADPAGE 293 +#define K_MAX_WRITE_DELAY 294 +#define K_MCU_BASE 295 +#define K_MIN_WRITE_DELAY 296 +#define K_MISO 297 +#define K_MOSI 298 +#define K_NUM_PAGES 299 +#define K_NVM_BASE 300 +#define K_OCDREV 301 +#define K_OFFSET 302 +#define K_PAGEL 303 +#define K_PARALLEL 304 +#define K_PARENT 305 +#define K_PART 306 +#define K_PGMLED 307 +#define K_PROGRAMMER 308 +#define K_PSEUDO 309 +#define K_PWROFF_AFTER_WRITE 310 +#define K_RDYLED 311 +#define K_READBACK_P1 312 +#define K_READBACK_P2 313 +#define K_READMEM 314 +#define K_RESET 315 +#define K_RETRY_PULSE 316 +#define K_SERIAL 317 +#define K_SCK 318 +#define K_SIGNATURE 319 +#define K_SIZE 320 +#define K_USB 321 +#define K_USBDEV 322 +#define K_USBSN 323 +#define K_USBPID 324 +#define K_USBPRODUCT 325 +#define K_USBVENDOR 326 +#define K_USBVID 327 +#define K_TYPE 328 +#define K_VCC 329 +#define K_VFYLED 330 +#define K_NO 331 +#define K_YES 332 +#define K_TIMEOUT 333 +#define K_STABDELAY 334 +#define K_CMDEXEDELAY 335 +#define K_HVSPCMDEXEDELAY 336 +#define K_SYNCHLOOPS 337 +#define K_BYTEDELAY 338 +#define K_POLLVALUE 339 +#define K_POLLINDEX 340 +#define K_PREDELAY 341 +#define K_POSTDELAY 342 +#define K_POLLMETHOD 343 +#define K_MODE 344 +#define K_DELAY 345 +#define K_BLOCKSIZE 346 +#define K_READSIZE 347 +#define K_HVENTERSTABDELAY 348 +#define K_PROGMODEDELAY 349 +#define K_LATCHCYCLES 350 +#define K_TOGGLEVTG 351 +#define K_POWEROFFDELAY 352 +#define K_RESETDELAYMS 353 +#define K_RESETDELAYUS 354 +#define K_HVLEAVESTABDELAY 355 +#define K_RESETDELAY 356 +#define K_SYNCHCYCLES 357 +#define K_HVCMDEXEDELAY 358 +#define K_CHIPERASEPULSEWIDTH 359 +#define K_CHIPERASEPOLLTIMEOUT 360 +#define K_CHIPERASETIME 361 +#define K_PROGRAMFUSEPULSEWIDTH 362 +#define K_PROGRAMFUSEPOLLTIMEOUT 363 +#define K_PROGRAMLOCKPULSEWIDTH 364 +#define K_PROGRAMLOCKPOLLTIMEOUT 365 +#define K_PP_CONTROLSTACK 366 +#define K_HVSP_CONTROLSTACK 367 +#define K_ALLOWFULLPAGEBITSTREAM 368 +#define K_ENABLEPAGEPROGRAMMING 369 +#define K_HAS_JTAG 370 +#define K_HAS_DW 371 +#define K_HAS_PDI 372 +#define K_HAS_TPI 373 +#define K_IDR 374 +#define K_IS_AT90S1200 375 +#define K_IS_AVR32 376 +#define K_RAMPZ 377 +#define K_SPMCR 378 +#define K_EECR 379 +#define K_FLASH_INSTR 380 +#define K_EEPROM_INSTR 381 +#define TKN_COMMA 382 +#define TKN_EQUAL 383 +#define TKN_SEMI 384 +#define TKN_TILDE 385 +#define TKN_LEFT_PAREN 386 +#define TKN_RIGHT_PAREN 387 +#define TKN_NUMBER 388 +#define TKN_NUMBER_REAL 389 +#define TKN_STRING 390 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_CONFIG_GRAM_H_INCLUDED */ diff --git a/xs/src/avrdude/config_gram.y b/xs/src/avrdude/config_gram.y new file mode 100644 index 000000000..0aa95a8e8 --- /dev/null +++ b/xs/src/avrdude/config_gram.y @@ -0,0 +1,1571 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2000-2004 Brian S. Dean + * 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 + * 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 "ac_cfg.h" + +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" +#include "config.h" + +#if defined(WIN32NATIVE) +#define strtok_r( _s, _sep, _lasts ) \ + ( *(_lasts) = strtok( (_s), (_sep) ) ) +#endif + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +int yylex(void); +int yyerror(char * errmsg, ...); +int yywarning(char * errmsg, ...); + +static int assign_pin(int pinno, TOKEN * v, int invert); +static int assign_pin_list(int invert); +static int which_opcode(TOKEN * opcode); +static int parse_cmdbits(OPCODE * op); + +static int pin_name; +%} + +%token K_READ +%token K_WRITE +%token K_READ_LO +%token K_READ_HI +%token K_WRITE_LO +%token K_WRITE_HI +%token K_LOADPAGE_LO +%token K_LOADPAGE_HI +%token K_LOAD_EXT_ADDR +%token K_WRITEPAGE +%token K_CHIP_ERASE +%token K_PGM_ENABLE + +%token K_MEMORY + +%token K_PAGE_SIZE +%token K_PAGED + +%token K_BAUDRATE +%token K_BS2 +%token K_BUFF +%token K_CHIP_ERASE_DELAY +%token K_CONNTYPE +%token K_DEDICATED +%token K_DEFAULT_BITCLOCK +%token K_DEFAULT_PARALLEL +%token K_DEFAULT_PROGRAMMER +%token K_DEFAULT_SAFEMODE +%token K_DEFAULT_SERIAL +%token K_DESC +%token K_DEVICECODE +%token K_STK500_DEVCODE +%token K_AVR910_DEVCODE +%token K_EEPROM +%token K_ERRLED +%token K_FLASH +%token K_ID +%token K_IO +%token K_LOADPAGE +%token K_MAX_WRITE_DELAY +%token K_MCU_BASE +%token K_MIN_WRITE_DELAY +%token K_MISO +%token K_MOSI +%token K_NUM_PAGES +%token K_NVM_BASE +%token K_OCDREV +%token K_OFFSET +%token K_PAGEL +%token K_PARALLEL +%token K_PARENT +%token K_PART +%token K_PGMLED +%token K_PROGRAMMER +%token K_PSEUDO +%token K_PWROFF_AFTER_WRITE +%token K_RDYLED +%token K_READBACK_P1 +%token K_READBACK_P2 +%token K_READMEM +%token K_RESET +%token K_RETRY_PULSE +%token K_SERIAL +%token K_SCK +%token K_SIGNATURE +%token K_SIZE +%token K_USB +%token K_USBDEV +%token K_USBSN +%token K_USBPID +%token K_USBPRODUCT +%token K_USBVENDOR +%token K_USBVID +%token K_TYPE +%token K_VCC +%token K_VFYLED + +%token K_NO +%token K_YES + +/* stk500 v2 xml file parameters */ +/* ISP */ +%token K_TIMEOUT +%token K_STABDELAY +%token K_CMDEXEDELAY +%token K_HVSPCMDEXEDELAY +%token K_SYNCHLOOPS +%token K_BYTEDELAY +%token K_POLLVALUE +%token K_POLLINDEX +%token K_PREDELAY +%token K_POSTDELAY +%token K_POLLMETHOD +%token K_MODE +%token K_DELAY +%token K_BLOCKSIZE +%token K_READSIZE +/* HV mode */ +%token K_HVENTERSTABDELAY +%token K_PROGMODEDELAY +%token K_LATCHCYCLES +%token K_TOGGLEVTG +%token K_POWEROFFDELAY +%token K_RESETDELAYMS +%token K_RESETDELAYUS +%token K_HVLEAVESTABDELAY +%token K_RESETDELAY +%token K_SYNCHCYCLES +%token K_HVCMDEXEDELAY + +%token K_CHIPERASEPULSEWIDTH +%token K_CHIPERASEPOLLTIMEOUT +%token K_CHIPERASETIME +%token K_PROGRAMFUSEPULSEWIDTH +%token K_PROGRAMFUSEPOLLTIMEOUT +%token K_PROGRAMLOCKPULSEWIDTH +%token K_PROGRAMLOCKPOLLTIMEOUT + +%token K_PP_CONTROLSTACK +%token K_HVSP_CONTROLSTACK + +/* JTAG ICE mkII specific parameters */ +%token K_ALLOWFULLPAGEBITSTREAM /* + * Internal parameter for the JTAG + * ICE; describes the internal JTAG + * streaming behaviour inside the MCU. + * 1 for all older chips, 0 for newer + * MCUs. + */ +%token K_ENABLEPAGEPROGRAMMING /* ? yes for mega256*, mega406 */ +%token K_HAS_JTAG /* MCU has JTAG i/f. */ +%token K_HAS_DW /* MCU has debugWire i/f. */ +%token K_HAS_PDI /* MCU has PDI i/f rather than ISP (ATxmega). */ +%token K_HAS_TPI /* MCU has TPI i/f rather than ISP (ATtiny4/5/9/10). */ +%token K_IDR /* address of OCD register in IO space */ +%token K_IS_AT90S1200 /* chip is an AT90S1200 (needs special treatment) */ +%token K_IS_AVR32 /* chip is in the avr32 family */ +%token K_RAMPZ /* address of RAMPZ reg. in IO space */ +%token K_SPMCR /* address of SPMC[S]R in memory space */ +%token K_EECR /* address of EECR in memory space */ +%token K_FLASH_INSTR /* flash instructions */ +%token K_EEPROM_INSTR /* EEPROM instructions */ + +%token TKN_COMMA +%token TKN_EQUAL +%token TKN_SEMI +%token TKN_TILDE +%token TKN_LEFT_PAREN +%token TKN_RIGHT_PAREN +%token TKN_NUMBER +%token TKN_NUMBER_REAL +%token TKN_STRING + +%start configuration + +%% + +number_real : + TKN_NUMBER { + $$ = $1; + /* convert value to real */ + $$->value.number_real = $$->value.number; + $$->value.type = V_NUM_REAL; + } | + TKN_NUMBER_REAL { + $$ = $1; + } + +configuration : + /* empty */ | config +; + +config : + def | + config def +; + + +def : + prog_def TKN_SEMI | + + part_def TKN_SEMI | + + K_DEFAULT_PROGRAMMER TKN_EQUAL TKN_STRING TKN_SEMI { + strncpy(default_programmer, $3->value.string, MAX_STR_CONST); + default_programmer[MAX_STR_CONST-1] = 0; + free_token($3); + } | + + K_DEFAULT_PARALLEL TKN_EQUAL TKN_STRING TKN_SEMI { + strncpy(default_parallel, $3->value.string, PATH_MAX); + default_parallel[PATH_MAX-1] = 0; + free_token($3); + } | + + K_DEFAULT_SERIAL TKN_EQUAL TKN_STRING TKN_SEMI { + strncpy(default_serial, $3->value.string, PATH_MAX); + default_serial[PATH_MAX-1] = 0; + free_token($3); + } | + + K_DEFAULT_BITCLOCK TKN_EQUAL number_real TKN_SEMI { + default_bitclock = $3->value.number_real; + free_token($3); + } | + + K_DEFAULT_SAFEMODE TKN_EQUAL yesno TKN_SEMI { + if ($3->primary == K_YES) + default_safemode = 1; + else if ($3->primary == K_NO) + default_safemode = 0; + free_token($3); + } +; + + +prog_def : + prog_decl prog_parms + { + PROGRAMMER * existing_prog; + char * id; + if (lsize(current_prog->id) == 0) { + yyerror("required parameter id not specified"); + YYABORT; + } + if (current_prog->initpgm == NULL) { + yyerror("programmer type not specified"); + YYABORT; + } + id = ldata(lfirst(current_prog->id)); + existing_prog = locate_programmer(programmers, id); + if (existing_prog) { + { /* temporarly set lineno to lineno of programmer start */ + int temp = lineno; lineno = current_prog->lineno; + yywarning("programmer %s overwrites previous definition %s:%d.", + id, existing_prog->config_file, existing_prog->lineno); + lineno = temp; + } + lrmv_d(programmers, existing_prog); + pgm_free(existing_prog); + } + PUSH(programmers, current_prog); +// pgm_fill_old_pins(current_prog); // TODO to be removed if old pin data no longer needed +// pgm_display_generic(current_prog, id); + current_prog = NULL; + } +; + + +prog_decl : + K_PROGRAMMER + { current_prog = pgm_new(); + if (current_prog == NULL) { + yyerror("could not create pgm instance"); + YYABORT; + } + strcpy(current_prog->config_file, infile); + current_prog->lineno = lineno; + } + | + K_PROGRAMMER K_PARENT TKN_STRING + { + struct programmer_t * pgm = locate_programmer(programmers, $3->value.string); + if (pgm == NULL) { + yyerror("parent programmer %s not found", $3->value.string); + free_token($3); + YYABORT; + } + current_prog = pgm_dup(pgm); + if (current_prog == NULL) { + yyerror("could not duplicate pgm instance"); + free_token($3); + YYABORT; + } + strcpy(current_prog->config_file, infile); + current_prog->lineno = lineno; + free_token($3); + } +; + + +part_def : + part_decl part_parms + { + LNODEID ln; + AVRMEM * m; + AVRPART * existing_part; + + if (current_part->id[0] == 0) { + yyerror("required parameter id not specified"); + YYABORT; + } + + /* + * perform some sanity checking, and compute the number of bits + * to shift a page for constructing the page address for + * page-addressed memories. + */ + for (ln=lfirst(current_part->mem); ln; ln=lnext(ln)) { + m = ldata(ln); + if (m->paged) { + if (m->page_size == 0) { + yyerror("must specify page_size for paged memory"); + YYABORT; + } + if (m->num_pages == 0) { + yyerror("must specify num_pages for paged memory"); + YYABORT; + } + if (m->size != m->page_size * m->num_pages) { + yyerror("page size (%u) * num_pages (%u) = " + "%u does not match memory size (%u)", + m->page_size, + m->num_pages, + m->page_size * m->num_pages, + m->size); + YYABORT; + } + + } + } + + existing_part = locate_part(part_list, current_part->id); + if (existing_part) { + { /* temporarly set lineno to lineno of part start */ + int temp = lineno; lineno = current_part->lineno; + yywarning("part %s overwrites previous definition %s:%d.", + current_part->id, + existing_part->config_file, existing_part->lineno); + lineno = temp; + } + lrmv_d(part_list, existing_part); + avr_free_part(existing_part); + } + PUSH(part_list, current_part); + current_part = NULL; + } +; + +part_decl : + K_PART + { + current_part = avr_new_part(); + if (current_part == NULL) { + yyerror("could not create part instance"); + YYABORT; + } + strcpy(current_part->config_file, infile); + current_part->lineno = lineno; + } | + K_PART K_PARENT TKN_STRING + { + AVRPART * parent_part = locate_part(part_list, $3->value.string); + if (parent_part == NULL) { + yyerror("can't find parent part"); + free_token($3); + YYABORT; + } + + current_part = avr_dup_part(parent_part); + if (current_part == NULL) { + yyerror("could not duplicate part instance"); + free_token($3); + YYABORT; + } + strcpy(current_part->config_file, infile); + current_part->lineno = lineno; + + free_token($3); + } +; + +string_list : + TKN_STRING { ladd(string_list, $1); } | + string_list TKN_COMMA TKN_STRING { ladd(string_list, $3); } +; + + +num_list : + TKN_NUMBER { ladd(number_list, $1); } | + num_list TKN_COMMA TKN_NUMBER { ladd(number_list, $3); } +; + +prog_parms : + prog_parm TKN_SEMI | + prog_parms prog_parm TKN_SEMI +; + +prog_parm : + K_ID TKN_EQUAL string_list { + { + TOKEN * t; + char *s; + int do_yyabort = 0; + while (lsize(string_list)) { + t = lrmv_n(string_list, 1); + if (!do_yyabort) { + s = dup_string(t->value.string); + if (s == NULL) { + do_yyabort = 1; + } else { + ladd(current_prog->id, s); + } + } + /* if do_yyabort == 1 just make the list empty */ + free_token(t); + } + if (do_yyabort) { + YYABORT; + } + } + } | + prog_parm_type + | + prog_parm_pins + | + prog_parm_usb + | + prog_parm_conntype + | + K_DESC TKN_EQUAL TKN_STRING { + strncpy(current_prog->desc, $3->value.string, PGM_DESCLEN); + current_prog->desc[PGM_DESCLEN-1] = 0; + free_token($3); + } | + K_BAUDRATE TKN_EQUAL TKN_NUMBER { + { + current_prog->baudrate = $3->value.number; + free_token($3); + } + } +; + +prog_parm_type: + K_TYPE TKN_EQUAL prog_parm_type_id +; + +prog_parm_type_id: + TKN_STRING { + const struct programmer_type_t * pgm_type = locate_programmer_type($1->value.string); + if (pgm_type == NULL) { + yyerror("programmer type %s not found", $1->value.string); + free_token($1); + YYABORT; + } + current_prog->initpgm = pgm_type->initpgm; + free_token($1); +} + | error +{ + yyerror("programmer type must be written as \"id_type\""); + YYABORT; +} +; + +prog_parm_conntype: + K_CONNTYPE TKN_EQUAL prog_parm_conntype_id +; + +prog_parm_conntype_id: + K_PARALLEL { current_prog->conntype = CONNTYPE_PARALLEL; } | + K_SERIAL { current_prog->conntype = CONNTYPE_SERIAL; } | + K_USB { current_prog->conntype = CONNTYPE_USB; } +; + +prog_parm_usb: + K_USBDEV TKN_EQUAL TKN_STRING { + { + strncpy(current_prog->usbdev, $3->value.string, PGM_USBSTRINGLEN); + current_prog->usbdev[PGM_USBSTRINGLEN-1] = 0; + free_token($3); + } + } | + K_USBVID TKN_EQUAL TKN_NUMBER { + { + current_prog->usbvid = $3->value.number; + free_token($3); + } + } | + K_USBPID TKN_EQUAL usb_pid_list | + K_USBSN TKN_EQUAL TKN_STRING { + { + strncpy(current_prog->usbsn, $3->value.string, PGM_USBSTRINGLEN); + current_prog->usbsn[PGM_USBSTRINGLEN-1] = 0; + free_token($3); + } + } | + K_USBVENDOR TKN_EQUAL TKN_STRING { + { + strncpy(current_prog->usbvendor, $3->value.string, PGM_USBSTRINGLEN); + current_prog->usbvendor[PGM_USBSTRINGLEN-1] = 0; + free_token($3); + } + } | + K_USBPRODUCT TKN_EQUAL TKN_STRING { + { + strncpy(current_prog->usbproduct, $3->value.string, PGM_USBSTRINGLEN); + current_prog->usbproduct[PGM_USBSTRINGLEN-1] = 0; + free_token($3); + } + } +; + +usb_pid_list: + TKN_NUMBER { + { + /* overwrite pids, so clear the existing entries */ + ldestroy_cb(current_prog->usbpid, free); + current_prog->usbpid = lcreat(NULL, 0); + } + { + int *ip = malloc(sizeof(int)); + if (ip) { + *ip = $1->value.number; + ladd(current_prog->usbpid, ip); + } + free_token($1); + } + } | + usb_pid_list TKN_COMMA TKN_NUMBER { + { + int *ip = malloc(sizeof(int)); + if (ip) { + *ip = $3->value.number; + ladd(current_prog->usbpid, ip); + } + free_token($3); + } + } +; + +pin_number_non_empty: + TKN_NUMBER { if(0 != assign_pin(pin_name, $1, 0)) YYABORT; } + | + TKN_TILDE TKN_NUMBER { if(0 != assign_pin(pin_name, $2, 1)) YYABORT; } +; + +pin_number: + pin_number_non_empty + | + /* empty */ { pin_clear_all(&(current_prog->pin[pin_name])); } +; + +pin_list_element: + pin_number_non_empty + | + TKN_TILDE TKN_LEFT_PAREN num_list TKN_RIGHT_PAREN { if(0 != assign_pin_list(1)) YYABORT; } +; + +pin_list_non_empty: + pin_list_element + | + pin_list_non_empty TKN_COMMA pin_list_element +; + + +pin_list: + pin_list_non_empty + | + /* empty */ { pin_clear_all(&(current_prog->pin[pin_name])); } +; + +prog_parm_pins: + K_VCC TKN_EQUAL {pin_name = PPI_AVR_VCC; } pin_list | + K_BUFF TKN_EQUAL {pin_name = PPI_AVR_BUFF; } pin_list | + K_RESET TKN_EQUAL {pin_name = PIN_AVR_RESET;} pin_number { free_token($1); } | + K_SCK TKN_EQUAL {pin_name = PIN_AVR_SCK; } pin_number { free_token($1); } | + K_MOSI TKN_EQUAL {pin_name = PIN_AVR_MOSI; } pin_number | + K_MISO TKN_EQUAL {pin_name = PIN_AVR_MISO; } pin_number | + K_ERRLED TKN_EQUAL {pin_name = PIN_LED_ERR; } pin_number | + K_RDYLED TKN_EQUAL {pin_name = PIN_LED_RDY; } pin_number | + K_PGMLED TKN_EQUAL {pin_name = PIN_LED_PGM; } pin_number | + K_VFYLED TKN_EQUAL {pin_name = PIN_LED_VFY; } pin_number +; + +opcode : + K_READ | + K_WRITE | + K_READ_LO | + K_READ_HI | + K_WRITE_LO | + K_WRITE_HI | + K_LOADPAGE_LO | + K_LOADPAGE_HI | + K_LOAD_EXT_ADDR | + K_WRITEPAGE | + K_CHIP_ERASE | + K_PGM_ENABLE +; + + +part_parms : + part_parm TKN_SEMI | + part_parms part_parm TKN_SEMI +; + + +reset_disposition : + K_DEDICATED | K_IO +; + +parallel_modes : + yesno | K_PSEUDO +; + +retry_lines : + K_RESET | K_SCK +; + +part_parm : + K_ID TKN_EQUAL TKN_STRING + { + strncpy(current_part->id, $3->value.string, AVR_IDLEN); + current_part->id[AVR_IDLEN-1] = 0; + free_token($3); + } | + + K_DESC TKN_EQUAL TKN_STRING + { + strncpy(current_part->desc, $3->value.string, AVR_DESCLEN); + current_part->desc[AVR_DESCLEN-1] = 0; + free_token($3); + } | + + K_DEVICECODE TKN_EQUAL TKN_NUMBER { + { + yyerror("devicecode is deprecated, use " + "stk500_devcode instead"); + YYABORT; + } + } | + + K_STK500_DEVCODE TKN_EQUAL TKN_NUMBER { + { + current_part->stk500_devcode = $3->value.number; + free_token($3); + } + } | + + K_AVR910_DEVCODE TKN_EQUAL TKN_NUMBER { + { + current_part->avr910_devcode = $3->value.number; + free_token($3); + } + } | + + K_SIGNATURE TKN_EQUAL TKN_NUMBER TKN_NUMBER TKN_NUMBER { + { + current_part->signature[0] = $3->value.number; + current_part->signature[1] = $4->value.number; + current_part->signature[2] = $5->value.number; + free_token($3); + free_token($4); + free_token($5); + } + } | + + K_USBPID TKN_EQUAL TKN_NUMBER { + { + current_part->usbpid = $3->value.number; + free_token($3); + } + } | + + K_PP_CONTROLSTACK TKN_EQUAL num_list { + { + TOKEN * t; + unsigned nbytes; + int ok; + + current_part->ctl_stack_type = CTL_STACK_PP; + nbytes = 0; + ok = 1; + + memset(current_part->controlstack, 0, CTL_STACK_SIZE); + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + if (nbytes < CTL_STACK_SIZE) + { + current_part->controlstack[nbytes] = t->value.number; + nbytes++; + } + else + { + ok = 0; + } + free_token(t); + } + if (!ok) + { + yywarning("too many bytes in control stack"); + } + } + } | + + K_HVSP_CONTROLSTACK TKN_EQUAL num_list { + { + TOKEN * t; + unsigned nbytes; + int ok; + + current_part->ctl_stack_type = CTL_STACK_HVSP; + nbytes = 0; + ok = 1; + + memset(current_part->controlstack, 0, CTL_STACK_SIZE); + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + if (nbytes < CTL_STACK_SIZE) + { + current_part->controlstack[nbytes] = t->value.number; + nbytes++; + } + else + { + ok = 0; + } + free_token(t); + } + if (!ok) + { + yywarning("too many bytes in control stack"); + } + } + } | + + K_FLASH_INSTR TKN_EQUAL num_list { + { + TOKEN * t; + unsigned nbytes; + int ok; + + nbytes = 0; + ok = 1; + + memset(current_part->flash_instr, 0, FLASH_INSTR_SIZE); + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + if (nbytes < FLASH_INSTR_SIZE) + { + current_part->flash_instr[nbytes] = t->value.number; + nbytes++; + } + else + { + ok = 0; + } + free_token(t); + } + if (!ok) + { + yywarning("too many bytes in flash instructions"); + } + } + } | + + K_EEPROM_INSTR TKN_EQUAL num_list { + { + TOKEN * t; + unsigned nbytes; + int ok; + + nbytes = 0; + ok = 1; + + memset(current_part->eeprom_instr, 0, EEPROM_INSTR_SIZE); + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + if (nbytes < EEPROM_INSTR_SIZE) + { + current_part->eeprom_instr[nbytes] = t->value.number; + nbytes++; + } + else + { + ok = 0; + } + free_token(t); + } + if (!ok) + { + yywarning("too many bytes in EEPROM instructions"); + } + } + } | + + K_CHIP_ERASE_DELAY TKN_EQUAL TKN_NUMBER + { + current_part->chip_erase_delay = $3->value.number; + free_token($3); + } | + + K_PAGEL TKN_EQUAL TKN_NUMBER + { + current_part->pagel = $3->value.number; + free_token($3); + } | + + K_BS2 TKN_EQUAL TKN_NUMBER + { + current_part->bs2 = $3->value.number; + free_token($3); + } | + + K_RESET TKN_EQUAL reset_disposition + { + if ($3->primary == K_DEDICATED) + current_part->reset_disposition = RESET_DEDICATED; + else if ($3->primary == K_IO) + current_part->reset_disposition = RESET_IO; + + free_tokens(2, $1, $3); + } | + + K_TIMEOUT TKN_EQUAL TKN_NUMBER + { + current_part->timeout = $3->value.number; + free_token($3); + } | + + K_STABDELAY TKN_EQUAL TKN_NUMBER + { + current_part->stabdelay = $3->value.number; + free_token($3); + } | + + K_CMDEXEDELAY TKN_EQUAL TKN_NUMBER + { + current_part->cmdexedelay = $3->value.number; + free_token($3); + } | + + K_HVSPCMDEXEDELAY TKN_EQUAL TKN_NUMBER + { + current_part->hvspcmdexedelay = $3->value.number; + free_token($3); + } | + + K_SYNCHLOOPS TKN_EQUAL TKN_NUMBER + { + current_part->synchloops = $3->value.number; + free_token($3); + } | + + K_BYTEDELAY TKN_EQUAL TKN_NUMBER + { + current_part->bytedelay = $3->value.number; + free_token($3); + } | + + K_POLLVALUE TKN_EQUAL TKN_NUMBER + { + current_part->pollvalue = $3->value.number; + free_token($3); + } | + + K_POLLINDEX TKN_EQUAL TKN_NUMBER + { + current_part->pollindex = $3->value.number; + free_token($3); + } | + + K_PREDELAY TKN_EQUAL TKN_NUMBER + { + current_part->predelay = $3->value.number; + free_token($3); + } | + + K_POSTDELAY TKN_EQUAL TKN_NUMBER + { + current_part->postdelay = $3->value.number; + free_token($3); + } | + + K_POLLMETHOD TKN_EQUAL TKN_NUMBER + { + current_part->pollmethod = $3->value.number; + free_token($3); + } | + + K_HVENTERSTABDELAY TKN_EQUAL TKN_NUMBER + { + current_part->hventerstabdelay = $3->value.number; + free_token($3); + } | + + K_PROGMODEDELAY TKN_EQUAL TKN_NUMBER + { + current_part->progmodedelay = $3->value.number; + free_token($3); + } | + + K_LATCHCYCLES TKN_EQUAL TKN_NUMBER + { + current_part->latchcycles = $3->value.number; + free_token($3); + } | + + K_TOGGLEVTG TKN_EQUAL TKN_NUMBER + { + current_part->togglevtg = $3->value.number; + free_token($3); + } | + + K_POWEROFFDELAY TKN_EQUAL TKN_NUMBER + { + current_part->poweroffdelay = $3->value.number; + free_token($3); + } | + + K_RESETDELAYMS TKN_EQUAL TKN_NUMBER + { + current_part->resetdelayms = $3->value.number; + free_token($3); + } | + + K_RESETDELAYUS TKN_EQUAL TKN_NUMBER + { + current_part->resetdelayus = $3->value.number; + free_token($3); + } | + + K_HVLEAVESTABDELAY TKN_EQUAL TKN_NUMBER + { + current_part->hvleavestabdelay = $3->value.number; + free_token($3); + } | + + K_RESETDELAY TKN_EQUAL TKN_NUMBER + { + current_part->resetdelay = $3->value.number; + free_token($3); + } | + + K_CHIPERASEPULSEWIDTH TKN_EQUAL TKN_NUMBER + { + current_part->chiperasepulsewidth = $3->value.number; + free_token($3); + } | + + K_CHIPERASEPOLLTIMEOUT TKN_EQUAL TKN_NUMBER + { + current_part->chiperasepolltimeout = $3->value.number; + free_token($3); + } | + + K_CHIPERASETIME TKN_EQUAL TKN_NUMBER + { + current_part->chiperasetime = $3->value.number; + free_token($3); + } | + + K_PROGRAMFUSEPULSEWIDTH TKN_EQUAL TKN_NUMBER + { + current_part->programfusepulsewidth = $3->value.number; + free_token($3); + } | + + K_PROGRAMFUSEPOLLTIMEOUT TKN_EQUAL TKN_NUMBER + { + current_part->programfusepolltimeout = $3->value.number; + free_token($3); + } | + + K_PROGRAMLOCKPULSEWIDTH TKN_EQUAL TKN_NUMBER + { + current_part->programlockpulsewidth = $3->value.number; + free_token($3); + } | + + K_PROGRAMLOCKPOLLTIMEOUT TKN_EQUAL TKN_NUMBER + { + current_part->programlockpolltimeout = $3->value.number; + free_token($3); + } | + + K_SYNCHCYCLES TKN_EQUAL TKN_NUMBER + { + current_part->synchcycles = $3->value.number; + free_token($3); + } | + + K_HAS_JTAG TKN_EQUAL yesno + { + if ($3->primary == K_YES) + current_part->flags |= AVRPART_HAS_JTAG; + else if ($3->primary == K_NO) + current_part->flags &= ~AVRPART_HAS_JTAG; + + free_token($3); + } | + + K_HAS_DW TKN_EQUAL yesno + { + if ($3->primary == K_YES) + current_part->flags |= AVRPART_HAS_DW; + else if ($3->primary == K_NO) + current_part->flags &= ~AVRPART_HAS_DW; + + free_token($3); + } | + + K_HAS_PDI TKN_EQUAL yesno + { + if ($3->primary == K_YES) + current_part->flags |= AVRPART_HAS_PDI; + else if ($3->primary == K_NO) + current_part->flags &= ~AVRPART_HAS_PDI; + + free_token($3); + } | + + K_HAS_TPI TKN_EQUAL yesno + { + if ($3->primary == K_YES) + current_part->flags |= AVRPART_HAS_TPI; + else if ($3->primary == K_NO) + current_part->flags &= ~AVRPART_HAS_TPI; + + free_token($3); + } | + + K_IS_AT90S1200 TKN_EQUAL yesno + { + if ($3->primary == K_YES) + current_part->flags |= AVRPART_IS_AT90S1200; + else if ($3->primary == K_NO) + current_part->flags &= ~AVRPART_IS_AT90S1200; + + free_token($3); + } | + + K_IS_AVR32 TKN_EQUAL yesno + { + if ($3->primary == K_YES) + current_part->flags |= AVRPART_AVR32; + else if ($3->primary == K_NO) + current_part->flags &= ~AVRPART_AVR32; + + free_token($3); + } | + + K_ALLOWFULLPAGEBITSTREAM TKN_EQUAL yesno + { + if ($3->primary == K_YES) + current_part->flags |= AVRPART_ALLOWFULLPAGEBITSTREAM; + else if ($3->primary == K_NO) + current_part->flags &= ~AVRPART_ALLOWFULLPAGEBITSTREAM; + + free_token($3); + } | + + K_ENABLEPAGEPROGRAMMING TKN_EQUAL yesno + { + if ($3->primary == K_YES) + current_part->flags |= AVRPART_ENABLEPAGEPROGRAMMING; + else if ($3->primary == K_NO) + current_part->flags &= ~AVRPART_ENABLEPAGEPROGRAMMING; + + free_token($3); + } | + + K_IDR TKN_EQUAL TKN_NUMBER + { + current_part->idr = $3->value.number; + free_token($3); + } | + + K_RAMPZ TKN_EQUAL TKN_NUMBER + { + current_part->rampz = $3->value.number; + free_token($3); + } | + + K_SPMCR TKN_EQUAL TKN_NUMBER + { + current_part->spmcr = $3->value.number; + free_token($3); + } | + + K_EECR TKN_EQUAL TKN_NUMBER + { + current_part->eecr = $3->value.number; + free_token($3); + } | + + K_MCU_BASE TKN_EQUAL TKN_NUMBER + { + current_part->mcu_base = $3->value.number; + free_token($3); + } | + + K_NVM_BASE TKN_EQUAL TKN_NUMBER + { + current_part->nvm_base = $3->value.number; + free_token($3); + } | + + K_OCDREV TKN_EQUAL TKN_NUMBER + { + current_part->ocdrev = $3->value.number; + free_token($3); + } | + + K_SERIAL TKN_EQUAL yesno + { + if ($3->primary == K_YES) + current_part->flags |= AVRPART_SERIALOK; + else if ($3->primary == K_NO) + current_part->flags &= ~AVRPART_SERIALOK; + + free_token($3); + } | + + K_PARALLEL TKN_EQUAL parallel_modes + { + if ($3->primary == K_YES) { + current_part->flags |= AVRPART_PARALLELOK; + current_part->flags &= ~AVRPART_PSEUDOPARALLEL; + } + else if ($3->primary == K_NO) { + current_part->flags &= ~AVRPART_PARALLELOK; + current_part->flags &= ~AVRPART_PSEUDOPARALLEL; + } + else if ($3->primary == K_PSEUDO) { + current_part->flags |= AVRPART_PARALLELOK; + current_part->flags |= AVRPART_PSEUDOPARALLEL; + } + + + free_token($3); + } | + + K_RETRY_PULSE TKN_EQUAL retry_lines + { + switch ($3->primary) { + case K_RESET : + current_part->retry_pulse = PIN_AVR_RESET; + break; + case K_SCK : + current_part->retry_pulse = PIN_AVR_SCK; + break; + } + + free_token($1); + } | + + +/* + K_EEPROM { current_mem = AVR_M_EEPROM; } + mem_specs | + + K_FLASH { current_mem = AVR_M_FLASH; } + mem_specs | +*/ + + K_MEMORY TKN_STRING + { + current_mem = avr_new_memtype(); + if (current_mem == NULL) { + yyerror("could not create mem instance"); + free_token($2); + YYABORT; + } + strncpy(current_mem->desc, $2->value.string, AVR_MEMDESCLEN); + current_mem->desc[AVR_MEMDESCLEN-1] = 0; + free_token($2); + } + mem_specs + { + AVRMEM * existing_mem; + + existing_mem = avr_locate_mem(current_part, current_mem->desc); + if (existing_mem != NULL) { + lrmv_d(current_part->mem, existing_mem); + avr_free_mem(existing_mem); + } + ladd(current_part->mem, current_mem); + current_mem = NULL; + } | + + opcode TKN_EQUAL string_list { + { + int opnum; + OPCODE * op; + + opnum = which_opcode($1); + if (opnum < 0) YYABORT; + op = avr_new_opcode(); + if (op == NULL) { + yyerror("could not create opcode instance"); + free_token($1); + YYABORT; + } + if(0 != parse_cmdbits(op)) YYABORT; + if (current_part->op[opnum] != NULL) { + /*yywarning("operation redefined");*/ + avr_free_opcode(current_part->op[opnum]); + } + current_part->op[opnum] = op; + + free_token($1); + } + } +; + + +yesno : + K_YES | K_NO +; + + +mem_specs : + mem_spec TKN_SEMI | + mem_specs mem_spec TKN_SEMI +; + + +mem_spec : + K_PAGED TKN_EQUAL yesno + { + current_mem->paged = $3->primary == K_YES ? 1 : 0; + free_token($3); + } | + + K_SIZE TKN_EQUAL TKN_NUMBER + { + current_mem->size = $3->value.number; + free_token($3); + } | + + + K_PAGE_SIZE TKN_EQUAL TKN_NUMBER + { + current_mem->page_size = $3->value.number; + free_token($3); + } | + + K_NUM_PAGES TKN_EQUAL TKN_NUMBER + { + current_mem->num_pages = $3->value.number; + free_token($3); + } | + + K_OFFSET TKN_EQUAL TKN_NUMBER + { + current_mem->offset = $3->value.number; + free_token($3); + } | + + K_MIN_WRITE_DELAY TKN_EQUAL TKN_NUMBER + { + current_mem->min_write_delay = $3->value.number; + free_token($3); + } | + + K_MAX_WRITE_DELAY TKN_EQUAL TKN_NUMBER + { + current_mem->max_write_delay = $3->value.number; + free_token($3); + } | + + K_PWROFF_AFTER_WRITE TKN_EQUAL yesno + { + current_mem->pwroff_after_write = $3->primary == K_YES ? 1 : 0; + free_token($3); + } | + + K_READBACK_P1 TKN_EQUAL TKN_NUMBER + { + current_mem->readback[0] = $3->value.number; + free_token($3); + } | + + K_READBACK_P2 TKN_EQUAL TKN_NUMBER + { + current_mem->readback[1] = $3->value.number; + free_token($3); + } | + + + K_MODE TKN_EQUAL TKN_NUMBER + { + current_mem->mode = $3->value.number; + free_token($3); + } | + + K_DELAY TKN_EQUAL TKN_NUMBER + { + current_mem->delay = $3->value.number; + free_token($3); + } | + + K_BLOCKSIZE TKN_EQUAL TKN_NUMBER + { + current_mem->blocksize = $3->value.number; + free_token($3); + } | + + K_READSIZE TKN_EQUAL TKN_NUMBER + { + current_mem->readsize = $3->value.number; + free_token($3); + } | + + K_POLLINDEX TKN_EQUAL TKN_NUMBER + { + current_mem->pollindex = $3->value.number; + free_token($3); + } | + + + opcode TKN_EQUAL string_list { + { + int opnum; + OPCODE * op; + + opnum = which_opcode($1); + if (opnum < 0) YYABORT; + op = avr_new_opcode(); + if (op == NULL) { + yyerror("could not create opcode instance"); + free_token($1); + YYABORT; + } + if(0 != parse_cmdbits(op)) YYABORT; + if (current_mem->op[opnum] != NULL) { + /*yywarning("operation redefined");*/ + avr_free_opcode(current_mem->op[opnum]); + } + current_mem->op[opnum] = op; + + free_token($1); + } + } +; + + +%% + +#if 0 +static char * vtypestr(int type) +{ + switch (type) { + case V_NUM : return "INTEGER"; + case V_NUM_REAL: return "REAL"; + case V_STR : return "STRING"; + default: + return ""; + } +} +#endif + + +static int assign_pin(int pinno, TOKEN * v, int invert) +{ + int value; + + value = v->value.number; + free_token(v); + + if ((value < PIN_MIN) || (value > PIN_MAX)) { + yyerror("pin must be in the range " TOSTRING(PIN_MIN) "-" TOSTRING(PIN_MAX)); + return -1; + } + + pin_set_value(&(current_prog->pin[pinno]), value, invert); + + return 0; +} + +static int assign_pin_list(int invert) +{ + TOKEN * t; + int pin; + int rv = 0; + + current_prog->pinno[pin_name] = 0; + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + if (rv == 0) { + pin = t->value.number; + if ((pin < PIN_MIN) || (pin > PIN_MAX)) { + yyerror("pin must be in the range " TOSTRING(PIN_MIN) "-" TOSTRING(PIN_MAX)); + rv = -1; + /* loop clears list and frees tokens */ + } + pin_set_value(&(current_prog->pin[pin_name]), pin, invert); + } + free_token(t); + } + return rv; +} + +static int which_opcode(TOKEN * opcode) +{ + switch (opcode->primary) { + case K_READ : return AVR_OP_READ; break; + case K_WRITE : return AVR_OP_WRITE; break; + case K_READ_LO : return AVR_OP_READ_LO; break; + case K_READ_HI : return AVR_OP_READ_HI; break; + case K_WRITE_LO : return AVR_OP_WRITE_LO; break; + case K_WRITE_HI : return AVR_OP_WRITE_HI; break; + case K_LOADPAGE_LO : return AVR_OP_LOADPAGE_LO; break; + case K_LOADPAGE_HI : return AVR_OP_LOADPAGE_HI; break; + case K_LOAD_EXT_ADDR : return AVR_OP_LOAD_EXT_ADDR; break; + case K_WRITEPAGE : return AVR_OP_WRITEPAGE; break; + case K_CHIP_ERASE : return AVR_OP_CHIP_ERASE; break; + case K_PGM_ENABLE : return AVR_OP_PGM_ENABLE; break; + default : + yyerror("invalid opcode"); + return -1; + break; + } +} + + +static int parse_cmdbits(OPCODE * op) +{ + TOKEN * t; + int bitno; + char ch; + char * e; + char * q; + int len; + char * s, *brkt = NULL; + int rv = 0; + + bitno = 32; + while (lsize(string_list)) { + + t = lrmv_n(string_list, 1); + + s = strtok_r(t->value.string, " ", &brkt); + while (rv == 0 && s != NULL) { + + bitno--; + if (bitno < 0) { + yyerror("too many opcode bits for instruction"); + rv = -1; + break; + } + + len = strlen(s); + + if (len == 0) { + yyerror("invalid bit specifier \"\""); + rv = -1; + break; + } + + ch = s[0]; + + if (len == 1) { + switch (ch) { + case '1': + op->bit[bitno].type = AVR_CMDBIT_VALUE; + op->bit[bitno].value = 1; + op->bit[bitno].bitno = bitno % 8; + break; + case '0': + op->bit[bitno].type = AVR_CMDBIT_VALUE; + op->bit[bitno].value = 0; + op->bit[bitno].bitno = bitno % 8; + break; + case 'x': + op->bit[bitno].type = AVR_CMDBIT_IGNORE; + op->bit[bitno].value = 0; + op->bit[bitno].bitno = bitno % 8; + break; + case 'a': + op->bit[bitno].type = AVR_CMDBIT_ADDRESS; + op->bit[bitno].value = 0; + op->bit[bitno].bitno = 8*(bitno/8) + bitno % 8; + break; + case 'i': + op->bit[bitno].type = AVR_CMDBIT_INPUT; + op->bit[bitno].value = 0; + op->bit[bitno].bitno = bitno % 8; + break; + case 'o': + op->bit[bitno].type = AVR_CMDBIT_OUTPUT; + op->bit[bitno].value = 0; + op->bit[bitno].bitno = bitno % 8; + break; + default : + yyerror("invalid bit specifier '%c'", ch); + rv = -1; + break; + } + } + else { + if (ch == 'a') { + q = &s[1]; + op->bit[bitno].bitno = strtol(q, &e, 0); + if ((e == q)||(*e != 0)) { + yyerror("can't parse bit number from \"%s\"", q); + rv = -1; + break; + } + op->bit[bitno].type = AVR_CMDBIT_ADDRESS; + op->bit[bitno].value = 0; + } + else { + yyerror("invalid bit specifier \"%s\"", s); + rv = -1; + break; + } + } + + s = strtok_r(NULL, " ", &brkt); + } /* while */ + + free_token(t); + + } /* while */ + + return rv; +} diff --git a/xs/src/avrdude/configure.ac b/xs/src/avrdude/configure.ac new file mode 100644 index 000000000..a23a959f2 --- /dev/null +++ b/xs/src/avrdude/configure.ac @@ -0,0 +1,572 @@ +# +# avrdude - A Downloader/Uploader for AVR device programmers +# 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 +# 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$ +# + +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.60) +AC_INIT(avrdude, 6.3-20160220, avrdude-dev@nongnu.org) + +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +AC_CONFIG_SRCDIR([main.c]) +AM_INIT_AUTOMAKE +AC_CONFIG_HEADERS(ac_cfg.h) +AC_CONFIG_MACRO_DIR([m4]) + +LT_INIT() + +# Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_SED +AC_PROG_YACC +AC_PROG_LEX +AN_MAKEVAR([AR], [AC_PROG_AR]) +AN_PROGRAM([ar], [AC_PROG_AR]) +AC_DEFUN([AC_PROG_AR], [AC_CHECK_TARGET_TOOL(AR, ar, :)]) +AC_PROG_AR +AH_TEMPLATE([HAVE_YYLEX_DESTROY], + [Define if lex/flex has yylex_destroy]) +# flex should have this +if test "x$LEX" == xflex; then + AC_MSG_CHECKING([whether yylex_destroy is generated by flex]) + flex_version=`$LEX -V -v --version 2>/dev/null | $SED -e 's/^.* //'` + case $flex_version in + [[0-1].*)] + AC_MSG_RESULT([version $flex_version => no]) + ;; + [2.[0-4].*)] + AC_MSG_RESULT([version $flex_version => no]) + ;; + [2.5.[0-8])] + AC_MSG_RESULT([version $flex_version => no]) + ;; + [2.5.[0-8][A-Za-z]*)] + AC_MSG_RESULT([version $flex_version => no]) + ;; + *) + AC_MSG_RESULT([version $flex_version => yes]) + AC_DEFINE([HAVE_YYLEX_DESTROY]) + ;; + esac +fi + +dnl Makefile.am:77: compiling `config_gram.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac' +AM_PROG_CC_C_O + +# Checks for libraries. +AC_CHECK_LIB([termcap], [tputs]) +AC_CHECK_LIB([ncurses], [tputs]) +AC_CHECK_LIB([readline], [readline]) +AH_TEMPLATE([HAVE_LIBELF], + [Define if ELF support is enabled via libelf]) +AC_CHECK_LIB([elf], [elf_getshdrstrndx], [have_libelf=yes]) +if test x$have_libelf = xyes; then + case $target in + *) + LIBELF="-lelf" + ;; + esac + AC_DEFINE([HAVE_LIBELF]) + AC_CHECK_HEADERS([libelf.h libelf/libelf.h]) +fi +AC_SUBST(LIBELF, $LIBELF) + +AC_SEARCH_LIBS([gethostent], [nsl]) +AC_SEARCH_LIBS([setsockopt], [socket]) +AH_TEMPLATE([HAVE_LIBUSB], + [Define if USB support is enabled via libusb]) +AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes]) +if test x$have_libusb = xyes; then + case $target in + *-*-darwin*) + LIBUSB="-lusb -framework CoreFoundation -framework IOKit" + ;; + *) + LIBUSB="-lusb" + ;; + esac + AC_DEFINE([HAVE_LIBUSB]) + AC_CHECK_HEADERS([usb.h]) + AC_CHECK_HEADERS([lusb0_usb.h]) +fi +AC_SUBST(LIBUSB, $LIBUSB) + +AH_TEMPLATE([HAVE_LIBUSB_1_0], + [Define if USB support is enabled via libusb 1.0]) +AC_CHECK_LIB([usb-1.0], [libusb_init], [have_libusb_1_0=yes]) +if test x$have_libusb_1_0 = xyes; then + case $target in + *-*-darwin*) + LIBUSB_1_0="-lusb-1.0 -framework CoreFoundation -framework IOKit" + ;; + *) + LIBUSB_1_0="-lusb-1.0" + ;; + esac + AC_DEFINE([HAVE_LIBUSB_1_0]) + AC_CHECK_HEADERS([libusb-1.0/libusb.h]) + AC_CHECK_HEADERS([libusb.h]) +fi +AH_TEMPLATE([HAVE_LIBUSB_1_0], + [Define if USB support is enabled via a libusb-1.0 compatible libusb]) +AC_CHECK_LIB([usb], [libusb_init], [have_libusb_1_0=yes]) +if test x$have_libusb_1_0 = xyes; then + case $target in + *-*-freebsd*) + # FreeBSD 8+ has a native libusb-1.0 API compatible + # library offered by -lusb (which is also libusb-0.1 + # compatible). FreeBSD <8 does not have a libusb-1.0 + # at all so probing will fail but we do not have to + # special-case that. + LIBUSB_1_0="-lusb" + ;; + *) + LIBUSB_1_0="-lusb-1.0" + ;; + esac + AC_DEFINE([HAVE_LIBUSB_1_0]) + AC_CHECK_HEADERS([libusb.h]) +fi +AC_SUBST(LIBUSB_1_0, $LIBUSB_1_0) + +AH_TEMPLATE([HAVE_LIBHIDAPI], + [Define if HID support is enabled via libhidapi]) +AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw], [have_libhidapi=yes]) +if test x$have_libhidapi = xyes; then + case $target in + *-*-darwin*) + LIBHIDAPI="-lhidapi -iframework CoreFoundation -framework IOKit" + ;; + *) + LIBHIDAPI="$ac_cv_lib_hid_init" + ;; + esac + AC_DEFINE([HAVE_LIBHIDAPI]) + AC_CHECK_HEADERS([hidapi/hidapi.h]) +fi +AC_SUBST(LIBHIDAPI, $LIBHIDAPI) + + +AH_TEMPLATE([HAVE_LIBFTDI1], + [Define if FTDI support is enabled via libftdi1]) +AH_TEMPLATE([HAVE_LIBFTDI], + [Define if FTDI support is enabled via libftdi]) +AH_TEMPLATE([HAVE_LIBFTDI_TYPE_232H], + [Define if libftdi supports FT232H, libftdi version >= 0.20]) +AC_CHECK_LIB([ftdi1], [ftdi_new], [have_libftdi1=yes], [], [$LIBUSB_1_0]) +AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings], [have_libftdi=yes], [], [-lusb]) +if test x$have_libftdi1 = xyes; then + LIBFTDI1="-lftdi1" + AC_DEFINE([HAVE_LIBFTDI1]) + AC_SUBST(LIBFTDI1, $LIBFTDI1) +else + if test x$have_libftdi = xyes; then + LIBFTDI="-lftdi -lusb" + AC_DEFINE([HAVE_LIBFTDI]) + AC_SUBST(LIBFTDI, $LIBFTDI) + AC_CHECK_DECL(TYPE_232H,[have_libftdi_FT232H=yes], [], [[#include ]]) + if test x$have_libftdi_FT232H = xyes; then + AC_DEFINE([HAVE_LIBFTDI_TYPE_232H]) + fi + fi +fi +AC_CHECK_HEADERS([pthread.h]) +# as there exits header file only pthread implementations for Windows, check if we have a library +AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes]) +if test x$have_pthread = xyes; then + LIBPTHREAD="-lpthread" +fi +AC_SUBST(LIBPTHREAD, $LIBPTHREAD) +# Checks for header files. +AC_CHECK_HEADERS([limits.h stdlib.h string.h]) +AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/time.h termios.h unistd.h]) +AC_CHECK_HEADERS([ddk/hidsdi.h],,,[#include +#include ]) + + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_HEADER_TIME + +# WinSock2 +AC_CHECK_LIB([ws2_32], [puts]) + +# Checks for library functions. +AC_CHECK_FUNCS([memset select strcasecmp strdup strerror strncasecmp strtol strtoul gettimeofday usleep]) + +AC_MSG_CHECKING([for a Win32 HID libray]) +SAVED_LIBS="${LIBS}" +case $target in + *-*-mingw32* | *-*-cygwin* | *-*-windows*) + LIBHID="-lhid -lsetupapi" + if test $ac_cv_header_ddk_hidsdi_h = yes + then + HIDINCLUDE="#include " + else + HIDINCLUDE="#include \"my_ddk_hidsdi.h\"" + fi + ;; + *) + LIBHID="" + ;; +esac +LIBS="${LIBS} ${LIBHID}" + +AH_TEMPLATE([HAVE_LIBHID], + [Define if HID support is enabled via the Win32 DDK]) +AC_TRY_LINK([#include +#include +$HIDINCLUDE], +[int +main(void) +{ + GUID hidGuid; + HidD_GetHidGuid(&hidGuid); + + return 0; +} +], [have_libhid=yes], [have_libhid=no]) +AC_MSG_RESULT([$have_libhid]) +if test x$have_libhid = xyes; then + AC_DEFINE([HAVE_LIBHID]) +else + LIBHID="" +fi +LIBS="${SAVED_LIBS}" +AC_SUBST(LIBHID, $LIBHID) + +# Check for types + +# Solaris has uint_t and ulong_t typedefs in , avoid +# the redeclaration in usbtiny.c. +AC_CHECK_TYPES([uint_t], [], [], [#include ]) +AC_CHECK_TYPES([ulong_t], [], [], [#include ]) + +# Checks for misc stuff. + +AC_ARG_ENABLE( + [versioned-doc], + AC_HELP_STRING( + [--enable-versioned-doc], + [install docs in directory with version name (default)]), + [case "${enableval}" in + yes) versioned_doc=yes ;; + no) versioned_doc=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for versioned-doc option) ;; + esac], + [versioned_doc=yes]) + +if test "$versioned_doc" = "yes"; then + DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude-$(VERSION)' +else + DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude' +fi + +AC_ARG_ENABLE( + [doc], + AC_HELP_STRING( + [--enable-doc], + [Enable building documents]), + [case "${enableval}" in + yes) enabled_doc=yes ;; + no) enabled_doc=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for disable-doc option) ;; + esac], + [enabled_doc=no]) + +AC_ARG_ENABLE( + [parport], + AC_HELP_STRING( + [--enable-parport], + [Enable accessing parallel ports(default)]), + [case "${enableval}" in + yes) enabled_parport=yes ;; + no) enabled_parport=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for enable-parport option) ;; + esac], + [enabled_parport=yes]) + +AC_ARG_ENABLE( + [linuxgpio], + AC_HELP_STRING( + [--enable-linuxgpio], + [Enable the Linux sysfs GPIO interface programmer type]), + [case "${enableval}" in + yes) enabled_linuxgpio=yes ;; + no) enabled_linuxgpio=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for enable-linuxgpio option) ;; + esac], + [enabled_linuxgpio=no]) + +DIST_SUBDIRS_AC='doc windows' + +if test "$enabled_doc" = "yes"; then + SUBDIRS_AC='doc' +else + SUBDIRS_AC='' +fi + +AC_SUBST(DOC_INST_DIR, $DOC_INST_DIR) +AC_SUBST(SUBDIRS_AC, $SUBDIRS_AC) +AC_SUBST(DIST_SUBDIRS_AC, $DIST_SUBDIRS_AC) + + +# Find the parallel serial device files based on target system +# If a system doesn't have a PC style parallel, mark it as unknown. +case $target in + i[[3456]]86-*-linux*|x86_64-*-linux*) + DEFAULT_PAR_PORT="/dev/parport0" + DEFAULT_SER_PORT="/dev/ttyS0" + ;; + *-*-linux*) + DEFAULT_PAR_PORT="unknown" + DEFAULT_SER_PORT="/dev/ttyS0" + ;; + i[[3456]]86-*-*freebsd*|amd64-*-*freebsd*) + DEFAULT_PAR_PORT="/dev/ppi0" + DEFAULT_SER_PORT="/dev/cuad0" + ;; + *-*-*freebsd*) + DEFAULT_PAR_PORT="unknown" + DEFAULT_SER_PORT="/dev/cuad0" + ;; + *-*-solaris*) + DEFAULT_PAR_PORT="/dev/printers/0" + DEFAULT_SER_PORT="/dev/term/a" + ;; + *-*-msdos* | *-*-mingw32* | *-*-cygwin* | *-*-windows*) + DEFAULT_PAR_PORT="lpt1" + DEFAULT_SER_PORT="com1" + ;; + *) + DEFAULT_PAR_PORT="unknown" + DEFAULT_SER_PORT="unknown" + ;; +esac + +if test "$enabled_parport" = "yes"; then + AC_MSG_CHECKING([for parallel device]) + if test "$DEFAULT_PAR_PORT" = "unknown"; then + AC_MSG_NOTICE([parallel port access disabled for this system]) + enabled_parport=no + else + AC_MSG_RESULT([$DEFAULT_PAR_PORT]) + fi + AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT) +fi + +AC_MSG_CHECKING([for serial device]) +AC_MSG_RESULT([$DEFAULT_SER_PORT]) +AC_SUBST(DEFAULT_SER_PORT, $DEFAULT_SER_PORT) + +if test "$enabled_parport" = "yes"; then + AC_DEFINE(HAVE_PARPORT, 1, [parallel port access enabled]) + confsubst="-e /^@HAVE_PARPORT_/d" +else + confsubst="-e /^@HAVE_PARPORT_BEGIN@/,/^@HAVE_PARPORT_END@/d" +fi + + +if test "$enabled_linuxgpio" = "yes"; then + AC_DEFINE(HAVE_LINUXGPIO, 1, [Linux sysfs GPIO support enabled]) + confsubst="$confsubst -e /^@HAVE_LINUXGPIO_/d" +else + confsubst="$confsubst -e /^@HAVE_LINUXGPIO_BEGIN@/,/^@HAVE_LINUXGPIO_END@/d" +fi + + +# If we are compiling with gcc, enable all warning and make warnings errors. +if test "$GCC" = yes; then + ENABLE_WARNINGS="-Wall" + + # does this compiler support -Wno-pointer-sign ? + AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign ]) + + safe_CFLAGS=$CFLAGS + CFLAGS="$ENABLE_WARNINGS -Wno-pointer-sign" + + AC_TRY_COMPILE(, [ int main () { return 0 ; } ], [ + no_pointer_sign=yes + AC_MSG_RESULT([yes]) + ], [ + no_pointer_sign=no + AC_MSG_RESULT([no]) + ]) + CFLAGS=$safe_CFLAGS + + if test x$no_pointer_sign = xyes; then + ENABLE_WARNINGS="$ENABLE_WARNINGS -Wno-pointer-sign" + fi +fi +AC_SUBST(ENABLE_WARNINGS,$ENABLE_WARNINGS) + +# See if we need to drop into the windows subdir. +case $target in + *-*-mingw32* | *-*-cygwin* | *-*-windows*) + if test "$GCC" = yes -a \( "$CC" = "cc" -o "$CC" = "gcc" \); then + # does this compiler support -mno-cygwin? + AC_MSG_CHECKING([if $CC accepts -mno-cygwin]) + + safe_CFLAGS="$CFLAGS" + CFLAGS="$ENABLE_WARNINGS -mno-cygwin" + + AC_TRY_COMPILE(, [ int main () { return 0 ; } ], [ + no_cygwin=yes + AC_MSG_RESULT([yes]) + ], [ + no_cygwin=no + AC_MSG_RESULT([no]) + ]) + CFLAGS="$safe_CFLAGS" + + if test x$no_cygwin = xyes; then + CFLAGS="${CFLAGS} -mno-cygwin" + else + AC_MSG_NOTICE([Your compiler does not understand the -mno-cygwin option.]) + AC_MSG_NOTICE([You might want to select an alternative compiler, like]) + AC_MSG_NOTICE([]) + AC_MSG_NOTICE([CC=mingw32-gcc ./configure]) + AC_MSG_NOTICE([]) + fi + fi + + AC_MSG_CHECKING([if linker accepts -static]) + + safe_LDFLAGS="$LDFLAGS" + LDFLAGS="${LDFLAGS} -static" + AC_TRY_LINK(, [ int main () { return 0 ; } ], [ + can_link_static=yes + AC_MSG_RESULT([yes]) + ], [ + can_link_static_cygwin=no + AC_MSG_RESULT([no]) + ]) + LDFLAGS="$safe_LDFLAGS" + + if test x$can_link_static = xyes; then + LDFLAGS="${LDFLAGS} -static" + fi + + WINDOWS_DIRS="windows" + CFLAGS="${CFLAGS} -DWIN32NATIVE" + ;; +esac +AC_SUBST(WINDOWS_DIRS,$WINDOWS_DIRS) + +AC_CONFIG_FILES([ + doc/Makefile + windows/Makefile + avrdude.spec + Makefile +]) + +# The procedure to create avrdude.conf involves two steps. First, +# normal autoconf substitution will be applied, resulting in +# avrdude.conf.tmp. Finally, a sed command will be applied to filter +# out unwanted parts (currently the parallel port programmer types) +# based on previous configuration results, thereby producing the final +# avrdude.conf file. + +AC_CONFIG_FILES([avrdude.conf.tmp:avrdude.conf.in], + [sed $confsubst avrdude.conf.tmp > avrdude.conf], + [confsubst="$confsubst"]) + +AC_OUTPUT + +echo "" +echo "" +echo "Configuration summary:" +echo "----------------------" + +if test x$have_libelf = xyes; then + echo "DO HAVE libelf" +else + echo "DON'T HAVE libelf" +fi + +if test x$have_libusb = xyes; then + echo "DO HAVE libusb" +else + echo "DON'T HAVE libusb" +fi + +if test x$have_libusb_1_0 = xyes; then + echo "DO HAVE libusb_1_0" +else + echo "DON'T HAVE libusb_1_0" +fi + +if test x$have_libftdi1 = xyes; then + echo "DO HAVE libftdi1" +else + echo "DON'T HAVE libftdi1" +fi + +if test x$have_libftdi = xyes; then + if test x$have_libftdi1 = xyes; then + echo "DO HAVE libftdi (but prefer to use libftdi1)" + else + echo "DO HAVE libftdi" + fi +else + echo "DON'T HAVE libftdi" +fi + +if test x$have_libhid = xyes; then + echo "DO HAVE libhid" +else + echo "DON'T HAVE libhid" +fi + +if test x$have_libhidapi = xyes; then + echo "DO HAVE libhidapi" +else + echo "DON'T HAVE libhidapi" +fi + +if test x$have_pthread = xyes; then + echo "DO HAVE pthread" +else + echo "DON'T HAVE pthread" +fi + +if test x$enabled_doc = xyes; then + echo "ENABLED doc" +else + echo "DISABLED doc" +fi + +if test x$enabled_parport = xyes; then + echo "ENABLED parport" +else + echo "DISABLED parport" +fi + +if test x$enabled_linuxgpio = xyes; then + echo "ENABLED linuxgpio" +else + echo "DISABLED linuxgpio" +fi + diff --git a/xs/src/avrdude/confwin.c b/xs/src/avrdude/confwin.c new file mode 100644 index 000000000..95446156d --- /dev/null +++ b/xs/src/avrdude/confwin.c @@ -0,0 +1,54 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2003-2004 Eric B. Weddington + * + * 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 "avrdude.h" +#include "libavrdude.h" + +#if defined(WIN32NATIVE) + +#include +#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, "avrdude.conf", 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, "avrdude.rc", NULL, PATH_MAX, usr_config, &filename); + return; +} + + +#endif + + diff --git a/xs/src/avrdude/crc16.c b/xs/src/avrdude/crc16.c new file mode 100644 index 000000000..0177c9dab --- /dev/null +++ b/xs/src/avrdude/crc16.c @@ -0,0 +1,83 @@ +/* + * Derived from CRC algorithm for JTAG ICE mkII, published in Atmel + * Appnote AVR067. Converted from C++ to C. + */ +#include "crc16.h" + +/* CRC16 Definitions */ +static const unsigned short crc_table[256] = { + 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, + 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, + 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, + 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, + 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, + 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, + 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, + 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, + 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, + 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, + 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, + 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, + 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, + 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, + 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, + 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, + 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, + 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, + 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, + 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, + 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, + 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, + 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, + 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, + 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, + 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, + 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, + 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, + 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, + 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, + 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, + 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 +}; + +/* CRC calculation macros */ +#define CRC_INIT 0xFFFF +#define CRC(crcval,newchar) crcval = (crcval >> 8) ^ \ + crc_table[(crcval ^ newchar) & 0x00ff] + +unsigned short +crcsum(const unsigned char* message, unsigned long length, + unsigned short crc) +{ + unsigned long i; + + for(i = 0; i < length; i++) + { + CRC(crc, message[i]); + } + return crc; +} + +int +crcverify(const unsigned char* message, unsigned long length) +{ + /* + * Returns true if the last two bytes in a message is the crc of the + * preceding bytes. + */ + unsigned short expected; + + expected = crcsum(message, length - 2, CRC_INIT); + return (expected & 0xff) == message[length - 2] && + ((expected >> 8) & 0xff) == message[length - 1]; +} + +void +crcappend(unsigned char* message, unsigned long length) +{ + unsigned long crc; + + crc = crcsum(message, length, CRC_INIT); + message[length] = (unsigned char)(crc & 0xff); + message[length+1] = (unsigned char)((crc >> 8) & 0xff); +} diff --git a/xs/src/avrdude/crc16.h b/xs/src/avrdude/crc16.h new file mode 100644 index 000000000..db10131de --- /dev/null +++ b/xs/src/avrdude/crc16.h @@ -0,0 +1,34 @@ +#ifndef CRC16_H +#define CRC16_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Derived from CRC algorithm for JTAG ICE mkII, published in Atmel + * Appnote AVR067. Converted from C++ to C. + */ + +extern unsigned short crcsum(const unsigned char* message, + unsigned long length, + unsigned short crc); +/* + * Verify that the last two bytes is a (LSB first) valid CRC of the + * message. + */ +extern int crcverify(const unsigned char* message, + unsigned long length); +/* + * Append a two byte CRC (LSB first) to message. length is size of + * message excluding crc. Space for the CRC bytes must be allocated + * in advance! + */ +extern void crcappend(unsigned char* message, + unsigned long length); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/xs/src/avrdude/dfu.c b/xs/src/avrdude/dfu.c new file mode 100644 index 000000000..8e014e3c0 --- /dev/null +++ b/xs/src/avrdude/dfu.c @@ -0,0 +1,516 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2012 Kirill Levchenko + * + * 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 "ac_cfg.h" + +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "dfu.h" + +#include "usbdevs.h" /* for USB_VENDOR_ATMEL */ + +/* If we don't have LibUSB, define dummy functions that report an error. */ + +#ifndef HAVE_LIBUSB + +struct dfu_dev *dfu_open(char *port_name) { + avrdude_message(MSG_INFO, "%s: Error: No USB support in this compile of avrdude\n", + progname); + return NULL; +} + +int dfu_init(struct dfu_dev *dfu, unsigned short usb_vid, unsigned short usb_pid) { + return -1; +} + +void dfu_close(struct dfu_dev *dfu) { + /* nothing */ +} + +int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status) +{ + return -1; +} + +int dfu_clrstatus(struct dfu_dev *dfu) { + return -1; +} + +int dfu_download(struct dfu_dev *dfu, void * ptr, int size) { + return -1; +} + +int dfu_upload(struct dfu_dev *dfu, void * ptr, int size) { + return -1; +} + +#else + +/* If we DO have LibUSB, we can define the real functions. */ + +/* DFU data structures and constants. + */ + +#define DFU_TIMEOUT 200 /* ms */ + +#define DFU_DNLOAD 1 +#define DFU_UPLOAD 2 +#define DFU_GETSTATUS 3 +#define DFU_CLRSTATUS 4 +#define DFU_GETSTATE 5 /* FLIPv1 only; not used */ +#define DFU_ABORT 6 /* FLIPv1 only */ + +/* Block counter global variable. Incremented each time a DFU_DNLOAD command + * is sent to the device. + */ + +static uint16_t wIndex = 0; + +/* INTERNAL FUNCTION PROTOTYPES + */ + +static char * get_usb_string(usb_dev_handle * dev_handle, int index); + +/* EXPORTED FUNCTION DEFINITIONS + */ + +struct dfu_dev * dfu_open(char *port_spec) +{ + struct dfu_dev *dfu; + char *bus_name = NULL; + char *dev_name = NULL; + + /* The following USB device spec parsing code was copied from usbtiny.c. The + * expected format is "usb:BUS:DEV" where BUS and DEV are the bus and device + * names. We stash these away in the dfu_dev structure for the dfu_init() + * function, where we actually open the device. + */ + + if (strncmp(port_spec, "usb", 3) != 0) { + avrdude_message(MSG_INFO, "%s: Error: " + "Invalid port specification \"%s\" for USB device\n", + progname, port_spec); + return NULL; + } + + if(':' == port_spec[3]) { + bus_name = strdup(port_spec + 3 + 1); + if (bus_name == NULL) { + avrdude_message(MSG_INFO, "%s: Out of memory in strdup\n", progname); + return NULL; + } + + dev_name = strchr(bus_name, ':'); + if(NULL != dev_name) + *dev_name++ = '\0'; + } + + /* Allocate the dfu_dev structure and save the bus_name and dev_name + * strings for use in dfu_initialize(). + */ + + dfu = calloc(1, sizeof(struct dfu_dev)); + + if (dfu == NULL) + { + avrdude_message(MSG_INFO, "%s: out of memory\n", progname); + free(bus_name); + return NULL; + } + + dfu->bus_name = bus_name; + dfu->dev_name = dev_name; + dfu->timeout = DFU_TIMEOUT; + + /* LibUSB initialization. */ + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + return dfu; +} + +int dfu_init(struct dfu_dev *dfu, unsigned short vid, unsigned short pid) +{ + struct usb_device *found = NULL; + struct usb_device *dev; + struct usb_bus *bus; + + /* At last, we reach out through the USB bus to the part. There are three + * ways to specify the part: by USB address, by USB vendor and product id, + * and by part name. To specify the part by USB address, the user specifies + * a port parameter in the form "usb:BUS:DEV" (see dfu_open()). To specify + * the part by vendor and product, the user must specify a usbvid and usbpid + * in the configuration file. Finally, if the user specifies the part only, + * we use the default vendor and product id. + */ + + if (pid == 0 && dfu->dev_name == NULL) { + avrdude_message(MSG_INFO, "%s: Error: No DFU support for part; " + "specify PID in config or USB address (via -P) to override.\n", + progname); + return -1; + } + + /* Scan through all the devices for the part. The matching rules are: + * + * 1. If the user specified a USB bus name, it must match. + * 2. If the user specified a USB device name, it must match. + * 3. If the user didn't specify a USB device name and specified a vendor + * id, the vendor id must match. + * 4. If the user didn't specify a USB device name and specified a product + * id, the product id must match. + */ + + for (bus = usb_busses; !found && bus != NULL; bus = bus->next) { + for (dev = bus->devices; !found && dev != NULL; dev = dev->next) { + if (dfu->bus_name != NULL && strcmp(bus->dirname, dfu->bus_name)) + continue; + if (dfu->dev_name != NULL) { + if (strcmp(dev->filename, dfu->dev_name)) + continue; + } else if (vid != dev->descriptor.idVendor) + continue; + else if (pid != 0 && pid != dev->descriptor.idProduct) + continue; + + found = dev; + } + } + + if (found == NULL) { + /* We could try to be more informative here. For example, we could report + * why the match failed, and if we came across another DFU-capable part. + */ + + avrdude_message(MSG_INFO, "%s: Error: No matching USB device found\n", progname); + return -1; + } + + if(verbose) + avrdude_message(MSG_INFO, "%s: Found VID=0x%04x PID=0x%04x at %s:%s\n", + progname, found->descriptor.idVendor, found->descriptor.idProduct, + found->bus->dirname, found->filename); + + dfu->dev_handle = usb_open(found); + + if (dfu->dev_handle == NULL) { + avrdude_message(MSG_INFO, "%s: Error: USB device at %s:%s: %s\n", + progname, found->bus->dirname, found->filename, usb_strerror()); + return -1; + } + + /* Save device, configuration, interface and endpoint descriptors. */ + + memcpy(&dfu->dev_desc, &found->descriptor, sizeof(dfu->dev_desc)); + memcpy(&dfu->conf_desc, found->config, sizeof(dfu->conf_desc)); + dfu->conf_desc.interface = NULL; + + memcpy(&dfu->intf_desc, found->config->interface->altsetting, + sizeof(dfu->intf_desc)); + dfu->intf_desc.endpoint = &dfu->endp_desc; + + if (found->config->interface->altsetting->endpoint != 0) + memcpy(&dfu->endp_desc, found->config->interface->altsetting->endpoint, + sizeof(dfu->endp_desc)); + + /* Get strings. */ + + dfu->manf_str = get_usb_string(dfu->dev_handle, + dfu->dev_desc.iManufacturer); + + dfu->prod_str = get_usb_string(dfu->dev_handle, + dfu->dev_desc.iProduct); + + dfu->serno_str = get_usb_string(dfu->dev_handle, + dfu->dev_desc.iSerialNumber); + + return 0; +} + +void dfu_close(struct dfu_dev *dfu) +{ + if (dfu->dev_handle != NULL) + usb_close(dfu->dev_handle); + if (dfu->bus_name != NULL) + free(dfu->bus_name); + if (dfu->manf_str != NULL) + free(dfu->manf_str); + if (dfu->prod_str != NULL) + free(dfu->prod_str); + if (dfu->serno_str != NULL) + free(dfu->serno_str); +} + +int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status) +{ + int result; + + avrdude_message(MSG_TRACE, "%s: dfu_getstatus(): issuing control IN message\n", + progname); + + result = usb_control_msg(dfu->dev_handle, + 0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_GETSTATUS, 0, 0, + (char*) status, sizeof(struct dfu_status), dfu->timeout); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: Error: Failed to get DFU status: %s\n", + progname, usb_strerror()); + return -1; + } + + if (result < sizeof(struct dfu_status)) { + avrdude_message(MSG_INFO, "%s: Error: Failed to get DFU status: %s\n", + progname, "short read"); + return -1; + } + + if (result > sizeof(struct dfu_status)) { + avrdude_message(MSG_INFO, "%s: Error: Oversize read (should not happen); " + "exiting\n", progname); + exit(1); + } + + avrdude_message(MSG_TRACE, "%s: dfu_getstatus(): bStatus 0x%02x, bwPollTimeout %d, bState 0x%02x, iString %d\n", + progname, + status->bStatus, + status->bwPollTimeout[0] | (status->bwPollTimeout[1] << 8) | (status->bwPollTimeout[2] << 16), + status->bState, + status->iString); + + return 0; +} + +int dfu_clrstatus(struct dfu_dev *dfu) +{ + int result; + + avrdude_message(MSG_TRACE, "%s: dfu_clrstatus(): issuing control OUT message\n", + progname); + + result = usb_control_msg(dfu->dev_handle, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_CLRSTATUS, 0, 0, + NULL, 0, dfu->timeout); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: Error: Failed to clear DFU status: %s\n", + progname, usb_strerror()); + return -1; + } + + return 0; +} + +int dfu_abort(struct dfu_dev *dfu) +{ + int result; + + avrdude_message(MSG_TRACE, "%s: dfu_abort(): issuing control OUT message\n", + progname); + + result = usb_control_msg(dfu->dev_handle, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_ABORT, 0, 0, + NULL, 0, dfu->timeout); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: Error: Failed to reset DFU state: %s\n", + progname, usb_strerror()); + return -1; + } + + return 0; +} + + +int dfu_dnload(struct dfu_dev *dfu, void *ptr, int size) +{ + int result; + + avrdude_message(MSG_TRACE, "%s: dfu_dnload(): issuing control OUT message, wIndex = %d, ptr = %p, size = %d\n", + progname, wIndex, ptr, size); + + result = usb_control_msg(dfu->dev_handle, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_DNLOAD, wIndex++, 0, + ptr, size, dfu->timeout); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: Error: DFU_DNLOAD failed: %s\n", + progname, usb_strerror()); + return -1; + } + + if (result < size) { + avrdude_message(MSG_INFO, "%s: Error: DFU_DNLOAD failed: %s\n", + progname, "short write"); + return -1; + } + + if (result > size) { + avrdude_message(MSG_INFO, "%s: Error: Oversize write (should not happen); " \ + "exiting\n", progname); + exit(1); + } + + return 0; +} + +int dfu_upload(struct dfu_dev *dfu, void *ptr, int size) +{ + int result; + + avrdude_message(MSG_TRACE, "%s: dfu_upload(): issuing control IN message, wIndex = %d, ptr = %p, size = %d\n", + progname, wIndex, ptr, size); + + result = usb_control_msg(dfu->dev_handle, + 0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_UPLOAD, wIndex++, 0, + ptr, size, dfu->timeout); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: Error: DFU_UPLOAD failed: %s\n", + progname, usb_strerror()); + return -1; + } + + if (result < size) { + avrdude_message(MSG_INFO, "%s: Error: DFU_UPLOAD failed: %s\n", + progname, "short read"); + return -1; + } + + if (result > size) { + avrdude_message(MSG_INFO, "%s: Error: Oversize read (should not happen); " + "exiting\n", progname); + exit(1); + } + + return 0; +} + +void dfu_show_info(struct dfu_dev *dfu) +{ + if (dfu->manf_str != NULL) + avrdude_message(MSG_INFO, " USB Vendor : %s (0x%04hX)\n", + dfu->manf_str, (unsigned short) dfu->dev_desc.idVendor); + else + avrdude_message(MSG_INFO, " USB Vendor : 0x%04hX\n", + (unsigned short) dfu->dev_desc.idVendor); + + if (dfu->prod_str != NULL) + avrdude_message(MSG_INFO, " USB Product : %s (0x%04hX)\n", + dfu->prod_str, (unsigned short) dfu->dev_desc.idProduct); + else + avrdude_message(MSG_INFO, " USB Product : 0x%04hX\n", + (unsigned short) dfu->dev_desc.idProduct); + + avrdude_message(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); + + if (dfu->serno_str != NULL) + avrdude_message(MSG_INFO, " USB Serial No : %s\n", dfu->serno_str); +} + +/* INTERNAL FUNCTION DEFINITIONS + */ + +char * get_usb_string(usb_dev_handle * dev_handle, int index) { + char buffer[256]; + char * str; + int result; + + if (index == 0) + return NULL; + + result = usb_get_string_simple(dev_handle, index, buffer, sizeof(buffer)-1); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: Warning: Failed to read USB device string %d: %s\n", + progname, index, usb_strerror()); + return NULL; + } + + str = malloc(result+1); + + if (str == NULL) { + avrdude_message(MSG_INFO, "%s: Out of memory allocating a string\n", progname); + return 0; + } + + memcpy(str, buffer, result); + str[result] = '\0'; + return str; +} + +#endif /* defined(HAVE_LIBUSB) */ + +/* EXPORTED FUNCTIONS THAT DO NO REQUIRE LIBUSB + */ + +const char * dfu_status_str(int bStatus) +{ + switch (bStatus) { + case DFU_STATUS_OK: return "OK"; + case DFU_STATUS_ERR_TARGET: return "ERR_TARGET"; + case DFU_STATUS_ERR_FILE: return "ERR_FILE"; + case DFU_STATUS_ERR_WRITE: return "ERR_WRITE"; + case DFU_STATUS_ERR_ERASE: return "ERR_ERASE"; + case DFU_STATUS_ERR_CHECK_ERASED: return "ERR_CHECK_ERASED"; + case DFU_STATUS_ERR_PROG: return "ERR_PROG"; + case DFU_STATUS_ERR_VERIFY: return "ERR_VERIFY"; + case DFU_STATUS_ERR_ADDRESS: return "ERR_ADDRESS"; + case DFU_STATUS_ERR_NOTDONE: return "ERR_NOTDONE"; + case DFU_STATUS_ERR_FIRMWARE: return "ERR_FIRMWARE"; + case DFU_STATUS_ERR_VENDOR: return "ERR_VENDOR"; + case DFU_STATUS_ERR_USBR: return "ERR_USBR"; + case DFU_STATUS_ERR_POR: return "ERR_POR"; + case DFU_STATUS_ERR_UNKNOWN: return "ERR_UNKNOWN"; + case DFU_STATUS_ERR_STALLEDPKT: return "ERR_STALLEDPKT"; + default: return "Unknown"; + } +} + +const char * dfu_state_str(int bState) +{ + switch (bState) { + case DFU_STATE_APP_IDLE: return "APP_IDLE"; + case DFU_STATE_APP_DETACH: return "APP_DETACH"; + case DFU_STATE_DFU_IDLE: return "DFU_IDLE"; + case DFU_STATE_DFU_DLOAD_SYNC: return "DFU_DLOAD_SYNC"; + case DFU_STATE_DFU_DNBUSY: return "DFU_DNBUSY"; + case DFU_STATE_DFU_DNLOAD_IDLE: return "DFU_DNLOAD_IDLE"; + case DFU_STATE_DFU_MANIFEST_SYNC: return "DFU_MANIFEST_SYNC"; + case DFU_STATE_DFU_MANIFEST: return "DFU_MANIFEST"; + case DFU_STATE_DFU_MANIFEST_WAIT_RESET: return "DFU_MANIFEST_WAIT_RESET"; + case DFU_STATE_DFU_UPLOAD_IDLE: return "DFU_UPLOAD_IDLE"; + case DFU_STATE_DFU_ERROR: return "DFU_ERROR"; + default: return "Unknown"; + } +} + diff --git a/xs/src/avrdude/dfu.h b/xs/src/avrdude/dfu.h new file mode 100644 index 000000000..020a75f2e --- /dev/null +++ b/xs/src/avrdude/dfu.h @@ -0,0 +1,137 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2012 Kirill Levchenko + * + * 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 dfu_h +#define dfu_h + +#include "ac_cfg.h" + +#ifdef HAVE_LIBUSB +#if defined(HAVE_USB_H) +# include +#elif defined(HAVE_LUSB0_USB_H) +# include +#else +# error "libusb needs either or " +#endif +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* If we have LIBUSB, define the dfu_dev struct normally. Otherwise, declare + * it as an empty struct so that code compiles, but we generate an error at + * run time. + */ + +#ifdef HAVE_LIBUSB + +struct dfu_dev +{ + char *bus_name, *dev_name; + usb_dev_handle *dev_handle; + struct usb_device_descriptor dev_desc; + struct usb_config_descriptor conf_desc; + struct usb_interface_descriptor intf_desc; + struct usb_endpoint_descriptor endp_desc; + char *manf_str, *prod_str, *serno_str; + unsigned int timeout; +}; + +#else + +struct dfu_dev { + // empty +}; + +#endif + +/* We assume unsigned char is 1 byte. */ + +#if UCHAR_MAX != 255 +#error UCHAR_MAX != 255 +#endif + +struct dfu_status { + unsigned char bStatus; + unsigned char bwPollTimeout[3]; + unsigned char bState; + unsigned char iString; +}; + +// Values of bStatus field. + +#define DFU_STATUS_OK 0x0 +#define DFU_STATUS_ERR_TARGET 0x1 +#define DFU_STATUS_ERR_FILE 0x2 +#define DFU_STATUS_ERR_WRITE 0x3 +#define DFU_STATUS_ERR_ERASE 0x4 +#define DFU_STATUS_ERR_CHECK_ERASED 0x5 +#define DFU_STATUS_ERR_PROG 0x6 +#define DFU_STATUS_ERR_VERIFY 0x7 +#define DFU_STATUS_ERR_ADDRESS 0x8 +#define DFU_STATUS_ERR_NOTDONE 0x9 +#define DFU_STATUS_ERR_FIRMWARE 0xA +#define DFU_STATUS_ERR_VENDOR 0xB +#define DFU_STATUS_ERR_USBR 0xC +#define DFU_STATUS_ERR_POR 0xD +#define DFU_STATUS_ERR_UNKNOWN 0xE +#define DFU_STATUS_ERR_STALLEDPKT 0xF + +// Values of bState field. + +#define DFU_STATE_APP_IDLE 0 +#define DFU_STATE_APP_DETACH 1 +#define DFU_STATE_DFU_IDLE 2 +#define DFU_STATE_DFU_DLOAD_SYNC 3 +#define DFU_STATE_DFU_DNBUSY 4 +#define DFU_STATE_DFU_DNLOAD_IDLE 5 +#define DFU_STATE_DFU_MANIFEST_SYNC 6 +#define DFU_STATE_DFU_MANIFEST 7 +#define DFU_STATE_DFU_MANIFEST_WAIT_RESET 8 +#define DFU_STATE_DFU_UPLOAD_IDLE 9 +#define DFU_STATE_DFU_ERROR 10 + +// FUNCTIONS + +extern struct dfu_dev * dfu_open(char *port_spec); +extern int dfu_init(struct dfu_dev *dfu, + unsigned short vid, unsigned short pid); +extern void dfu_close(struct dfu_dev *dfu); + +extern int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status); +extern int dfu_clrstatus(struct dfu_dev *dfu); +extern int dfu_dnload(struct dfu_dev *dfu, void *ptr, int size); +extern int dfu_upload(struct dfu_dev *dfu, void *ptr, int size); +extern int dfu_abort(struct dfu_dev *dfu); + +extern void dfu_show_info(struct dfu_dev *dfu); + +extern const char * dfu_status_str(int bStatus); +extern const char * dfu_state_str(int bState); + +#ifdef __cplusplus +} +#endif + +#endif /* dfu_h */ diff --git a/xs/src/avrdude/doc/.cvsignore b/xs/src/avrdude/doc/.cvsignore new file mode 100644 index 000000000..afe95fe92 --- /dev/null +++ b/xs/src/avrdude/doc/.cvsignore @@ -0,0 +1,25 @@ +.cvsignore +Makefile +Makefile.in +avrdude-html +avrdude.aux +avrdude.cp +avrdude.cps +avrdude.dvi +avrdude.fn +avrdude.info +avrdude.ky +avrdude.log +avrdude.pdf +avrdude.pg +avrdude.ps +avrdude.toc +avrdude.tp +avrdude.vr +mdate-sh +stamp-vti +texinfo.tex +version.texi +programmer_types.texi +parts.texi +programmers.texi diff --git a/xs/src/avrdude/doc/Makefile.am b/xs/src/avrdude/doc/Makefile.am new file mode 100644 index 000000000..bee799f74 --- /dev/null +++ b/xs/src/avrdude/doc/Makefile.am @@ -0,0 +1,94 @@ +# +# avrdude - A Downloader/Uploader for AVR device programmers +# 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 +# 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$ +# + +GENERATED_TEXINFOS = \ + $(builddir)/programmers.texi \ + $(builddir)/parts.texi \ + $(builddir)/programmer_types.texi \ + $(builddir)/version.texi + +CLEANFILES = \ + $(GENERATED_TEXINFOS) \ + $(builddir)/stamp-vti + +info_TEXINFOS = avrdude.texi + +EXTRA_DIST = \ + parts_comments.txt + +all-local: info html ps pdf + +html: avrdude-html/avrdude.html + +avrdude-html/avrdude.html: $(srcdir)/$(info_TEXINFOS) $(GENERATED_TEXINFOS) + texi2html -split_node $(srcdir)/$(info_TEXINFOS) + if [ -e ./avrdude.html -o -e ./avrdude_1.html ]; then \ + mkdir -p avrdude-html ; \ + mv -f *.html avrdude-html ; \ + else \ + mv -f avrdude avrdude-html; \ + fi; + +$(builddir)/avrdude.info: $(GENERATED_TEXINFOS) +$(builddir)/avrdude.dvi: $(GENERATED_TEXINFOS) +$(builddir)/avrdude.pdf: $(GENERATED_TEXINFOS) + +# if it does not exist make this first +../avrdude$(EXEEXT): + $(MAKE) -C .. avrdude$(EXEEXT) + +$(builddir)/programmers.texi: ../avrdude$(EXEEXT) ../avrdude.conf Makefile + ../avrdude$(EXEEXT) -C ../avrdude.conf -c \? 2>&1 \ + | $(AWK) '$$2 ~ /^=$$/ {printf("@item @code{%s} @tab %s\n",$$1,gensub("[^=]+=[ \t]*","",1))}' \ + | sed "s# *,\? *<\?\(http://[^ \t>]*\)>\?#,@*\n@url{\1}#g" \ + >programmers.texi + +$(builddir)/programmer_types.texi: ../avrdude$(EXEEXT) ../avrdude.conf Makefile + ../avrdude$(EXEEXT) -C ../avrdude.conf -c \?type 2>&1 \ + | $(AWK) '$$2 ~ /^=$$/ {printf("@item @code{%s} @tab %s\n",$$1,gensub("[^=]+=[ \t]*","",1))}' \ + | sed "s#<\?\(http://[^ \t,>]*\)>\?#@url{\1}#g" \ + >programmer_types.texi + +$(builddir)/parts.texi: ../avrdude$(EXEEXT) ../avrdude.conf parts_comments.txt Makefile + ../avrdude$(EXEEXT) -C ../avrdude.conf -p \? 2>&1 \ + | $(AWK) '$$2 ~ /^=$$/ {printf("@item @code{%s} @tab %s\n",$$1,$$3)}' \ + | sed -e "`sed 's:\([^ \t]*\)[ \t]*\(.*\):s/\1$$/\1 \2/g:g' parts.texi + +clean-local: + rm -rf avrdude-html *.info + +install-data-local: install-docs + +install-docs: html ps pdf + $(mkinstalldirs) $(DOC_INST_DIR) + $(INSTALL_DATA) avrdude.ps $(DOC_INST_DIR)/avrdude.ps + $(INSTALL_DATA) avrdude.pdf $(DOC_INST_DIR)/avrdude.pdf + $(mkinstalldirs) $(DOC_INST_DIR)/avrdude-html + @list=`echo avrdude-html/*.html`; \ + for file in $$list; \ + do \ + $(INSTALL_DATA) $$file $(DOC_INST_DIR)/$$file; \ + done + +uninstall-local: + rm -rf $(DOC_INST_DIR) diff --git a/xs/src/avrdude/doc/TODO b/xs/src/avrdude/doc/TODO new file mode 100644 index 000000000..6c57c5ade --- /dev/null +++ b/xs/src/avrdude/doc/TODO @@ -0,0 +1,26 @@ + +- Man page needs updated for avr910 info. + +- Website needs to link to docs: + http://savannah.nongnu.org/download/avrdude/doc/avrdude-html/ + +- Add "skip empty pages" optimization on avr910 paged write. The stk500 has + this optimization already. + +- Fix "overfull \hbox" issues in building documentation. + +- FIXME: term.c: terminal_get_input(): strip newlines in non-readline input + code. + +- FIXME: avr910.c: avr910_cmd(): Insert version check here. + +- FIXME: ser_posix.c: serial_close(): Should really restore the terminal to + original state here. + +- FIXME: main.c, par.c: exitspecs don't work if RESET-pin is controlled over + PPICTRL. + +- transfer ppi-speedtuning to the windows version (CAVEAT: This will make + programming too fast for chips with 500kHz clock) + +- make SCK-period configurable for PPI-programmers diff --git a/xs/src/avrdude/doc/avrdude.texi b/xs/src/avrdude/doc/avrdude.texi new file mode 100644 index 000000000..6941389df --- /dev/null +++ b/xs/src/avrdude/doc/avrdude.texi @@ -0,0 +1,2586 @@ +%% -*-texinfo-*- +\input texinfo + +@c $Id$ + +@setfilename avrdude.info +@settitle AVRDUDE +@finalout + +@include version.texi + +@c +@c These are set in version.texi which is automatically generated by automake. +@c +@c @set UPDATED 26 Febuary 2003 +@c @set EDITION 3.2.0 +@c @set VERSION 3.2.0 + +@c This is a dir.info fragment to support semi-automated addition of +@c manuals to an info tree. +@dircategory AVR Programming & development tools. +@direntry +* AvrDude: (avrdude). AVR program downloader/uploader. +@end direntry + +@ifinfo +This file documents the avrdude program. + +For avrdude version @value{VERSION}, @value{UPDATED}. + +Copyright @copyright{} 2003, 2005 Brian Dean + +Copyright @copyright{} 2006 - 2016 J@"org Wunsch + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. + +Alternatively, this documentation may be copied and distributed under +the terms of the GNU Free Documentation License (FDL), version 1.3. +@end ifinfo + +@titlepage +@title AVRDUDE +@subtitle A program for download/uploading AVR microcontroller flash and eeprom. +@subtitle For AVRDUDE, Version @value{VERSION}, @value{UPDATED}. +@author by Brian S. Dean + +@page +Send comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}. + +Use @uref{http://savannah.nongnu.org/bugs/?group=avrdude} to report bugs. + +Copyright @copyright{} 2003,2005 Brian S. Dean + +Copyright @copyright{} 2006 - 2013 J@"org Wunsch +@sp 2 + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. +@end titlepage + +@contents + +@c +@c Top Node +@c +@node Top, Introduction, (dir), (dir) +@comment node-name, next, previous, up + +@ifinfo +This file documents the avrdude program for downloading/uploading +programs to Atmel AVR microcontrollers. + +For avrdude version @value{VERSION}, @value{UPDATED}. + +Send comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}. + +Use @uref{http://savannah.nongnu.org/bugs/?group=avrdude} to report bugs. + +Copyright @copyright{} 2003,2005 Brian S. Dean + +Copyright @copyright{} 2006 J@"org Wunsch +@end ifinfo + +@menu +* Introduction:: +* Command Line Options:: +* Terminal Mode Operation:: +* Configuration File:: +* Programmer Specific Information:: +* Platform Dependent Information:: +* Troubleshooting:: +@end menu + +@c +@c Node +@c +@node Introduction, Command Line Options, Top, Top +@comment node-name, next, previous, up +@chapter Introduction +@cindex introduction + +AVRDUDE - AVR Downloader Uploader - is a program for downloading and +uploading the on-chip memories of Atmel's AVR microcontrollers. It can +program the Flash and EEPROM, and where supported by the serial +programming protocol, it can program fuse and lock bits. AVRDUDE also +supplies a direct instruction mode allowing one to issue any programming +instruction to the AVR chip regardless of whether AVRDUDE implements +that specific feature of a particular chip. + +AVRDUDE can be used effectively via the command line to read or write +all chip memory types (eeprom, flash, fuse bits, lock bits, signature +bytes) or via an interactive (terminal) mode. Using AVRDUDE from the +command line works well for programming the entire memory of the chip +from the contents of a file, while interactive mode is useful for +exploring memory contents, modifying individual bytes of eeprom, +programming fuse/lock bits, etc. + +AVRDUDE supports the following basic programmer types: Atmel's STK500, +Atmel's AVRISP and AVRISP mkII devices, +Atmel's STK600, +Atmel's JTAG ICE (the original one, mkII, and 3, the latter two also in ISP mode), appnote +avr910, appnote avr109 (including the AVR Butterfly), +serial bit-bang adapters, +and the PPI (parallel port interface). PPI represents a class +of simple programmers where the programming lines are directly +connected to the PC parallel port. Several pin configurations exist +for several variations of the PPI programmers, and AVRDUDE can be +configured to work with them by either specifying the appropriate +programmer on the command line or by creating a new entry in its +configuration file. All that's usually required for a new entry is to +tell AVRDUDE which pins to use for each programming function. + +A number of equally simple bit-bang programming adapters that connect +to a serial port are supported as well, among them the popular +Ponyprog serial adapter, and the DASA and DASA3 adapters that used to +be supported by uisp(1). Note that these adapters are meant to be +attached to a physical serial port. Connecting to a serial port +emulated on top of USB is likely to not work at all, or to work +abysmally slow. + +If you happen to have a Linux system with at least 4 hardware GPIOs +available (like almost all embedded Linux boards) you can do without +any additional hardware - just connect them to the MOSI, MISO, RESET +and SCK pins on the AVR and use the linuxgpio programmer type. It bitbangs +the lines using the Linux sysfs GPIO interface. Of course, care should +be taken about voltage level compatibility. Also, although not strictly +required, it is strongly advisable to protect the GPIO pins from +overcurrent situations in some way. The simplest would be to just put +some resistors in series or better yet use a 3-state buffer driver like +the 74HC244. Have a look at http://kolev.info/avrdude-linuxgpio for a more +detailed tutorial about using this programmer type. + +The STK500, JTAG ICE, avr910, and avr109/butterfly use the serial port to communicate with the PC. +The STK600, JTAG ICE mkII/3, AVRISP mkII, USBasp, avrftdi (and derivatives), and USBtinyISP +programmers communicate through the USB, using @code{libusb} as a +platform abstraction layer. +The avrftdi adds support for the FT2232C/D, FT2232H, and FT4232H devices. These all use +the MPSSE mode, which has a specific pin mapping. Bit 1 (the lsb of the byte in the config +file) is SCK. Bit 2 is MOSI, and Bit 3 is MISO. Bit 4 usually reset. The 2232C/D parts +are only supported on interface A, but the H parts can be either A or B (specified by the +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 +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 +simplistic and can easily be used as the basis for a simple, home made +programmer since the firmware is available online. On the other hand, +the STK500 protocol is more robust and complicated and the firmware is +not openly available. +The JTAG ICE also uses a serial communication protocol which is similar +to the STK500 firmware version 2 one. However, as the JTAG ICE is +intended to allow on-chip debugging as well as memory programming, the +protocol is more sophisticated. +(The JTAG ICE mkII protocol can also be run on top of USB.) +Only the memory programming functionality of the JTAG ICE is supported +by AVRDUDE. +For the JTAG ICE mkII/3, JTAG, debugWire and ISP mode are supported, provided +it has a firmware revision of at least 4.14 (decimal). +See below for the limitations of debugWire. +For ATxmega devices, the JTAG ICE mkII/3 is supported in PDI mode, provided it +has a revision 1 hardware and firmware version of at least 5.37 (decimal). + +The Atmel-ICE (ARM/AVR) is supported (JTAG, PDI for Xmega, debugWIRE, ISP modes). + +Atmel's XplainedPro boards, using EDBG protocol (CMSIS-DAP compliant), are +supported by the ``jtag3'' programmer type. + +Atmel's XplainedMini boards, using mEDBG protocol, are also +supported by the ``jtag3'' programmer type. + +The AVR Dragon is supported in all modes (ISP, JTAG, PDI, HVSP, PP, debugWire). +When used in JTAG and debugWire mode, the AVR Dragon behaves similar to a +JTAG ICE mkII, so all device-specific comments for that device +will apply as well. +When used in ISP and PDI mode, the AVR Dragon behaves similar to an +AVRISP mkII (or JTAG ICE mkII in ISP mode), so all device-specific +comments will apply there. +In particular, the Dragon starts out with a rather fast ISP clock +frequency, so the @code{-B @var{bitclock}} +option might be required to achieve a stable ISP communication. +For ATxmega devices, the AVR Dragon is supported in PDI mode, provided it +has a firmware version of at least 6.11 (decimal). + +Wiring boards are supported, utilizing STK500 V2.x protocol, but +a simple DTR/RTS toggle to set the boards into programming mode. +The programmer type is ``wiring''. + +The Arduino (which is very similar to the STK500 1.x) is supported via +its own programmer type specification ``arduino''. + +The BusPirate is a versatile tool that can also be used as an AVR programmer. +A single BusPirate can be connected to up to 3 independent AVRs. See +the section on +@emph{extended parameters} +below for details. + +The USBasp ISP and USBtinyISP adapters are also supported, provided AVRDUDE +has been compiled with libusb support. +They both feature simple firmware-only USB implementations, running on +an ATmega8 (or ATmega88), or ATtiny2313, respectively. + +The Atmel DFU bootloader is supported in both, FLIP protocol version 1 +(AT90USB* and ATmega*U* devices), as well as version 2 (Xmega devices). +See below for some hints about FLIP version 1 protocol behaviour. + + +@menu +* History:: +@end menu + +@c +@c Node +@c +@node History, , Introduction, Introduction +@section History and Credits + +AVRDUDE was written by Brian S. Dean under the name of AVRPROG to run on +the FreeBSD Operating System. Brian renamed the software to be called +AVRDUDE when interest grew in a Windows port of the software so that the +name did not conflict with AVRPROG.EXE which is the name of Atmel's +Windows programming software. + +The AVRDUDE source now resides in the public CVS repository on +savannah.gnu.org (@url{http://savannah.gnu.org/projects/avrdude/}), +where it continues to be enhanced and ported to other systems. In +addition to FreeBSD, AVRDUDE now runs on Linux and Windows. The +developers behind the porting effort primarily were Ted Roth, Eric +Weddington, and Joerg Wunsch. + +And in the spirit of many open source projects, this manual also draws +on the work of others. The initial revision was composed of parts of +the original Unix manual page written by Joerg Wunsch, the original web +site documentation by Brian Dean, and from the comments describing the +fields in the AVRDUDE configuration file by Brian Dean. The texi +formatting was modeled after that of the Simulavr documentation by Ted +Roth. + + +@c +@c Node +@c +@node Command Line Options, Terminal Mode Operation, Introduction, Top +@chapter Command Line Options +@cindex options + +@menu +* Option Descriptions:: +* Programmers accepting extended parameters:: +* Example Command Line Invocations:: +@end menu + +@c +@c Node +@c +@node Option Descriptions, Programmers accepting extended parameters, Command Line Options, Command Line Options +@section Option Descriptions + +@noindent +AVRDUDE is a command line tool, used as follows: + +@smallexample +avrdude -p partno @var{options} @dots{} +@end smallexample + +@noindent +Command line options are used to control AVRDUDE's behaviour. The +following options are recognized: + +@table @code +@item -p @var{partno} +This is the only mandatory option and it tells AVRDUDE what type of part +(MCU) that is connected to the programmer. The @var{partno} parameter +is the part's id listed in the configuration file. Specify -p ? to list +all parts in the configuration file. If a part is unknown +to AVRDUDE, it means that there is no config file entry for that part, +but it can be added to the configuration file if you have the Atmel +datasheet so that you can enter the programming specifications. +Currently, the following MCU types are understood: + +@multitable @columnfractions .15 .3 +@include parts.texi +@end multitable + +(*) The AT90S2323 and ATtiny22 use the same algorithm. + +(**) Flash addressing above 128 KB is not supported by all +programming hardware. Known to work are jtag2, stk500v2, +and bit-bang programmers. + +(***) +The ATtiny11 can only be +programmed in high-voltage serial mode. + +(****) +The ISP programming protocol of the AT90S1200 differs in subtle ways +from that of other AVRs. Thus, not all programmers support this +device. Known to work are all direct bitbang programmers, and all +programmers talking the STK500v2 protocol. + +@item -b @var{baudrate} +Override the RS-232 connection baud rate specified in the respective +programmer's entry of the configuration file. + +@item -B @var{bitclock} +Specify the bit clock period for the JTAG interface or the ISP clock (JTAG ICE only). +The value is a floating-point number in microseconds. +Alternatively, the value might be suffixed with "Hz", "kHz", or "MHz", +in order to specify the bit clock frequency, rather than a period. +The default value of the JTAG ICE results in about 1 microsecond bit +clock period, suitable for target MCUs running at 4 MHz clock and +above. +Unlike certain parameters in the STK500, the JTAG ICE resets all its +parameters to default values when the programming software signs +off from the ICE, so for MCUs running at lower clock speeds, this +parameter must be specified on the command-line. +It can also be set in the configuration file by using the 'default_bitclock' +keyword. + +@item -c @var{programmer-id} +Specify the programmer to be used. AVRDUDE knows about several common +programmers. Use this option to specify which one to use. The +@var{programmer-id} parameter is the programmer's id listed in the +configuration file. Specify -c ? to list all programmers in the +configuration file. If you have a programmer that is unknown to +AVRDUDE, and the programmer is controlled via the PC parallel port, +there's a good chance that it can be easily added to the configuration +file without any code changes to AVRDUDE. Simply copy an existing entry +and change the pin definitions to match that of the unknown programmer. +Currently, the following programmer ids are understood and supported: + +@multitable @columnfractions .2 .6 +@include programmers.texi +@end multitable + + + +@item -C @var{config-file} +Use the specified config file for configuration data. This file +contains all programmer and part definitions that AVRDUDE knows about. +If not +specified, AVRDUDE reads the configuration file from +/usr/local/etc/avrdude.conf (FreeBSD and Linux). See Appendix A for +the method of searching for the configuration file for Windows. + +If @var{config-file} is written as @var{+filename} +then this file is read after the system wide and user configuration +files. This can be used to add entries to the configuration +without patching your system wide configuration file. It can be used +several times, the files are read in same order as given on the command +line. + + +@item -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. + +@item -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. +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 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{}] +By default, AVRDUDE leaves the parallel port in the same state at exit +as it has been found at startup. This option modifies the state of the +`/RESET' and `Vcc' lines the parallel port is left at, according to +the exitspec arguments provided, as follows: + +@table @code +@item reset +The `/RESET' signal will be left activated at program exit, that is it +will be held low, in order to keep the MCU in reset state afterwards. +Note in particular that the programming algorithm for the AT90S1200 +device mandates that the `/RESET' signal is active before powering up +the MCU, so in case an external power supply is used for this MCU type, +a previous invocation of AVRDUDE with this option specified is one of +the possible ways to guarantee this condition. + +@item noreset +The `/RESET' line will be deactivated at program exit, thus allowing the +MCU target program to run while the programming hardware remains +connected. + +@item vcc +This option will leave those parallel port pins active (i. e. high) that +can be used to supply `Vcc' power to the MCU. + +@item novcc +This option will pull the `Vcc' pins of the parallel port down at +program exit. + +@item d_high +This option will leave the 8 data pins on the parallel port active +(i. e. high). + +@item d_low +This option will leave the 8 data pins on the parallel port inactive +(i. e. low). + +@end table + +Multiple @var{exitspec} arguments can be separated with commas. + + +@item -F +Normally, AVRDUDE tries to verify that the device signature read from +the part is reasonable before continuing. Since it can happen from time +to time that a device has a broken (erased or overwritten) device +signature but is otherwise operating normally, this options is provided +to override the check. +Also, for programmers like the Atmel STK500 and STK600 which can +adjust parameters local to the programming tool (independent of an +actual connection to a target controller), this option can be used +together with @option{-t} to continue in terminal mode. + +@item -i @var{delay} +For bitbang-type programmers, delay for approximately +@var{delay} +microseconds between each bit state change. +If the host system is very fast, or the target runs off a slow clock +(like a 32 kHz crystal, or the 128 kHz internal RC oscillator), this +can become necessary to satisfy the requirement that the ISP clock +frequency must not be higher than 1/4 of the CPU clock frequency. +This is implemented as a spin-loop delay to allow even for very +short delays. +On Unix-style operating systems, the spin loop is initially calibrated +against a system timer, so the number of microseconds might be rather +realistic, assuming a constant system load while AVRDUDE is running. +On Win32 operating systems, a preconfigured number of cycles per +microsecond is assumed that might be off a bit for very fast or very +slow machines. + +@item -l @var{logfile} +Use @var{logfile} rather than @var{stderr} for diagnostics output. +Note that initial diagnostic messages (during option parsing) are still +written to @var{stderr} anyway. + +@item -n +No-write - disables actually writing data to the MCU (useful for +debugging AVRDUDE). + +@item -O +Perform a RC oscillator run-time calibration according to Atmel +application note AVR053. +This is only supported on the STK500v2, AVRISP mkII, and JTAG ICE mkII +hardware. +Note that the result will be stored in the EEPROM cell at address 0. + +@item -P @var{port} +Use port to identify the device to which the programmer is attached. +Normally, the default parallel port is used, but if the programmer type +normally connects to the serial port, the default serial port will be +used. See Appendix A, Platform Dependent Information, to find out the +default port names for your platform. If you need to use a different +parallel or serial port, use this option to specify the alternate port name. + +On Win32 operating systems, the parallel ports are referred to as lpt1 +through lpt3, referring to the addresses 0x378, 0x278, and 0x3BC, +respectively. If the parallel port can be accessed through a different +address, this address can be specified directly, using the common C +language notation (i. e., hexadecimal values are prefixed by @var{0x}). + +For the JTAG ICE mkII, if AVRDUDE has been built with libusb support, +@var{port} may alternatively be specified as +@code{usb}[:@var{serialno}]. In that case, the JTAG ICE mkII will be +looked up on USB. If @var{serialno} is also specified, it will be +matched against the serial number read from any JTAG ICE mkII found on +USB. The match is done after stripping any existing colons from the +given serial number, and right-to-left, so only the least significant +bytes from the serial number need to be given. +For a trick how to find out the serial numbers of all JTAG ICEs +attached to USB, see @ref{Example Command Line Invocations}. + +As the AVRISP mkII device can only be talked to over USB, the very +same method of specifying the port is required there. + +For the USB programmer "AVR-Doper" running in HID mode, the port must +be specified as @var{avrdoper}. Libusb support is required on Unix +but not on Windows. For more information about AVR-Doper see +@url{http://www.obdev.at/avrusb/avrdoper.html}. + +For the USBtinyISP, which is a simplistic device not implementing +serial numbers, multiple devices can be distinguished by their +location in the USB hierarchy. +@xref{Troubleshooting}, for examples. + +For programmers that attach to a serial port using some kind of +higher level protocol (as opposed to bit-bang style programmers), +@var{port} can be specified as @code{net}:@var{host}:@var{port}. +In this case, instead of trying to open a local device, a TCP +network connection to (TCP) @var{port} on @var{host} +is established. +The remote endpoint is assumed to be a terminal or console server +that connects the network stream to a local serial port where the +actual programmer has been attached to. +The port is assumed to be properly configured, for example using a +transparent 8-bit data connection without parity at 115200 Baud +for a STK500. + + +@item -q +Disable (or quell) output of the progress bar while reading or writing +to the device. Specify it a second time for even quieter operation. + +@item -u +Disables the default behaviour of reading out the fuses three times before +programming, then verifying at the end of programming that the fuses have not +changed. If you want to change fuses you will need to specify this option, +as avrdude will see the fuses have changed (even though you wanted to) and +will change them back for your "safety". This option was designed to +prevent cases of fuse bits magically changing (usually called @emph{safemode}). + +If one of the configuration files contains a line + +@code{default_safemode = no;} + +safemode is disabled by default. +The @option{-u} option's effect is negated in that case, i. e. it +@emph{enables} safemode. + +Safemode is always disabled for AVR32, Xmega and TPI devices. + +@item -s +Disable safemode prompting. When safemode discovers that one or more +fuse bits have unintentionally changed, it will prompt for +confirmation regarding whether or not it should attempt to recover the +fuse bit(s). Specifying this flag disables the prompt and assumes +that the fuse bit(s) should be recovered without asking for +confirmation first. + +@item -t +Tells AVRDUDE to enter the interactive ``terminal'' mode instead of up- +or downloading files. See below for a detailed description of the +terminal mode. + +@item -U @var{memtype}:@var{op}:@var{filename}[:@var{format}] +Perform a memory operation. +Multiple @option{-U} options can be specified in order to operate on +multiple memories on the same command-line invocation. The +@var{memtype} field specifies the memory type to operate on. Use +the @option{-v} option on the command line or the @code{part} command from +terminal mode to display all the memory types supported by a particular +device. +Typically, a device's memory configuration at least contains +the memory types +@code{flash} +and +@code{eeprom}. +All memory types currently known are: +@table @code +@item calibration +One or more bytes of RC oscillator calibration data. +@item eeprom +The EEPROM of the device. +@item efuse +The extended fuse byte. +@item flash +The flash ROM of the device. +@item fuse +The fuse byte in devices that have only a single fuse byte. +@item hfuse +The high fuse byte. +@item lfuse +The low fuse byte. +@item lock +The lock byte. +@item signature +The three device signature bytes (device ID). +@item fuse@emph{N} +The fuse bytes of ATxmega devices, @emph{N} is an integer number +for each fuse supported by the device. +@item application +The application flash area of ATxmega devices. +@item apptable +The application table flash area of ATxmega devices. +@item boot +The boot flash area of ATxmega devices. +@item prodsig +The production signature (calibration) area of ATxmega devices. +@item usersig +The user signature area of ATxmega devices. +@end table + +The @var{op} field specifies what operation to perform: + +@table @code +@item r +read the specified device memory and write to the specified file + +@item w +read the specified file and write it to the specified device memory + +@item v +read the specified device memory and the specified file and perform a verify operation + +@end table + +The @var{filename} field indicates the name of the file to read or +write. The @var{format} field is optional and contains the format of +the file to read or write. Possible values are: + +@table @code +@item i +Intel Hex + +@item s +Motorola S-record + +@item r +raw binary; little-endian byte order, in the case of the flash ROM data + +@item e +ELF (Executable and Linkable Format), the final output file from the +linker; currently only accepted as an input file + +@item m +immediate mode; actual byte values specified on the command line, +separated by commas or spaces in place of the @var{filename} field of +the @option{-U} option. This is useful +for programming fuse bytes without having to create a single-byte file +or enter terminal mode. If the number specified begins with @code{0x}, +it is treated as a hex value. If the number otherwise begins with a +leading zero (@code{0}) it is treated as octal. Otherwise, the value is +treated as decimal. + +@item a +auto detect; valid for input only, and only if the input is not provided +at stdin. + +@item d +decimal; this and the following formats are only valid on output. +They generate one line of output for the respective memory section, +forming a comma-separated list of the values. +This can be particularly useful for subsequent processing, like for +fuse bit settings. + +@item h +hexadecimal; each value will get the string @emph{0x} prepended. + +@item o +octal; each value will get a @emph{0} +prepended unless it is less than 8 in which case it gets no prefix. + +@item b +binary; each value will get the string @emph{0b} prepended. + +@end table + +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, the @var{format} field is +no longer optional since the filename part following the colon 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 +trailing 0xFF bytes which indicate unprogrammed (erased) memory. +Thus, if the entire memory is unprogrammed, this will result in an output +file that has no contents at all. + +As an abbreviation, the form @code{-U} @var{filename} +is equivalent to specifying +@code{-U} @emph{flash:w:}@var{filename}@emph{:a}. +This will only work if @var{filename} does not have a colon in it. + +@item -v +Enable verbose output. +More @code{-v} options increase verbosity level. + +@item -V +Disable automatic verify check when uploading data. + +@item -x @var{extended_param} +Pass @var{extended_param} to the chosen programmer implementation as +an extended parameter. The interpretation of the extended parameter +depends on the programmer itself. See below for a list of programmers +accepting extended parameters. + +@end table + +@page +@c +@c Node +@c +@node Programmers accepting extended parameters, Example Command Line Invocations, Option Descriptions, Command Line Options +@section Programmers accepting extended parameters + +@table @code + +@item JTAG ICE mkII/3 +@itemx AVR Dragon + +When using the JTAG ICE mkII/3 or AVR Dragon in JTAG mode, the +following extended parameter is accepted: +@table @code +@item @samp{jtagchain=UB,UA,BB,BA} +Setup the JTAG scan chain for @var{UB} units before, @var{UA} units +after, @var{BB} bits before, and @var{BA} bits after the target AVR, +respectively. +Each AVR unit within the chain shifts by 4 bits. +Other JTAG units might require a different bit shift count. +@end table + +@item AVR910 + +The AVR910 programmer type accepts the following extended parameter: +@table @code +@item @samp{devcode=VALUE} +Override the device code selection by using @var{VALUE} +as the device code. +The programmer is not queried for the list of supported +device codes, and the specified @var{VALUE} +is not verified but used directly within the +@code{T} command sent to the programmer. +@var{VALUE} can be specified using the conventional number notation of the +C programming language. +@item @samp{no_blockmode} +Disables the default checking for block transfer capability. +Use +@samp{no_blockmode} only if your @samp{AVR910} +programmer creates errors during initial sequence. +@end table + +@item BusPirate + +The BusPirate programmer type accepts the following extended parameters: +@table @code +@item @samp{reset=cs,aux,aux2} +The default setup assumes the BusPirate's CS output pin connected to +the RESET pin on AVR side. It is however possible to have multiple AVRs +connected to the same BP with MISO, MOSI and SCK lines common for all of them. +In such a case one AVR should have its RESET connected to BusPirate's +@emph{CS} +pin, second AVR's RESET connected to BusPirate's +@emph{AUX} +pin and if your BusPirate has an +@emph{AUX2} +pin (only available on BusPirate version v1a with firmware 3.0 or newer) +use that to activate RESET on the third AVR. + +It may be a good idea to decouple the BusPirate and the AVR's SPI buses from +each other using a 3-state bus buffer. For example 74HC125 or 74HC244 are some +good candidates with the latches driven by the appropriate reset pin (cs, +aux or aux2). Otherwise the SPI traffic in one active circuit may interfere +with programming the AVR in the other design. + +@item @samp{spifreq=@var{0..7}} +@multitable @columnfractions .05 .3 +@item @code{0} @tab 30 kHz (default) +@item @code{1} @tab 125 kHz +@item @code{2} @tab 250 kHz +@item @code{3} @tab 1 MHz +@item @code{4} @tab 2 MHz +@item @code{5} @tab 2.6 MHz +@item @code{6} @tab 4 MHz +@item @code{7} @tab 8 MHz +@end multitable + +@item @samp{rawfreq=0..3} +Sets the SPI speed and uses the Bus Pirate's binary ``raw-wire'' mode instead +of the default binary SPI mode: + +@multitable @columnfractions .05 .3 +@item @code{0} @tab 5 kHz +@item @code{1} @tab 50 kHz +@item @code{2} @tab 100 kHz (Firmware v4.2+ only) +@item @code{3} @tab 400 kHz (v4.2+) +@end multitable + +The only advantage of the ``raw-wire'' mode is that different SPI frequencies +are available. Paged writing is not implemented in this mode. + +@item @samp{ascii} +Attempt to use ASCII mode even when the firmware supports BinMode (binary +mode). +BinMode is supported in firmware 2.7 and newer, older FW's either don't +have BinMode or their BinMode is buggy. ASCII mode is slower and makes +the above +@samp{reset=}, @samp{spifreq=} +and +@samp{rawfreq=} +parameters unavailable. Be aware that ASCII mode is not guaranteed to work +with newer firmware versions, and is retained only to maintain compatibility +with older firmware versions. + +@item @samp{nopagedwrite} +Firmware versions 5.10 and newer support a binary mode SPI command that enables +whole pages to be written to AVR flash memory at once, resulting in a +significant write speed increase. If use of this mode is not desirable for some +reason, this option disables it. + +@item @samp{nopagedread} +Newer firmware versions support in binary mode SPI command some AVR Extended +Commands. Using the ``Bulk Memory Read from Flash'' results in a +significant read speed increase. If use of this mode is not desirable for some +reason, this option disables it. + +@item @samp{cpufreq=@var{125..4000}} +This sets the @emph{AUX} pin to output a frequency of @var{n} kHz. Connecting +the @emph{AUX} pin to the XTAL1 pin of your MCU, you can provide it a clock, +for example when it needs an external clock because of wrong fuses settings. +Make sure the CPU frequency is at least four times the SPI frequency. + +@item @samp{serial_recv_timeout=@var{1...}} +This sets the serial receive timeout to the given value. +The timeout happens every time avrdude waits for the BusPirate prompt. +Especially in ascii mode this happens very often, so setting a smaller value +can speed up programming a lot. +The default value is 100ms. Using 10ms might work in most cases. + +@end table + +@item Wiring + +When using the Wiring programmer type, the +following optional extended parameter is accepted: +@table @code +@item @samp{snooze=@var{0..32767}} +After performing the port open phase, AVRDUDE will wait/snooze for +@var{snooze} milliseconds before continuing to the protocol sync phase. +No toggling of DTR/RTS is performed if @var{snooze} > 0. +@end table + +@item PICkit2 +Connection to the PICkit2 programmer: +@multitable @columnfractions .05 .3 +@item @code{(AVR)} @tab @code{(PICkit2)} +@item @code{RST} @tab @code{VPP/MCLR (1) } +@item @code{VDD} @tab @code{VDD Target (2) -- possibly optional if AVR self powered } +@item @code{GND} @tab @code{GND (3) } +@item @code{MISO} @tab @code{PGD (4) } +@item @code{SCLK} @tab @code{PDC (5) } +@item @code{OSI} @tab @code{AUX (6) } +@end multitable + +Extended command line parameters: +@table @code +@item @samp{clockrate=@var{rate}} +Sets the SPI clocking rate in Hz (default is 100kHz). Alternately the -B or -i options can be used to set the period. +@item @samp{timeout=@var{usb-transaction-timeout}} +Sets the timeout for USB reads and writes in milliseconds (default is 1500 ms). +@end table + +@end table + +@page +@c +@c Node +@c +@node Example Command Line Invocations, , Programmers accepting extended parameters, Command Line Options +@section Example Command Line Invocations + +@noindent +Download the file @code{diag.hex} to the ATmega128 chip using the +STK500 programmer connected to the default serial port: + +@smallexample +@cartouche +% avrdude -p m128 -c stk500 -e -U flash:w:diag.hex + +avrdude: AVR device initialized and ready to accept instructions + +Reading | ################################################## | 100% 0.03s + +avrdude: Device signature = 0x1e9702 +avrdude: erasing chip +avrdude: done. +avrdude: performing op: 1, flash, 0, diag.hex +avrdude: reading input file "diag.hex" +avrdude: input file diag.hex auto detected as Intel Hex +avrdude: writing flash (19278 bytes): + +Writing | ################################################## | 100% 7.60s + +avrdude: 19456 bytes of flash written +avrdude: verifying flash memory against diag.hex: +avrdude: load data flash data from input file diag.hex: +avrdude: input file diag.hex auto detected as Intel Hex +avrdude: input file diag.hex contains 19278 bytes +avrdude: reading on-chip flash data: + +Reading | ################################################## | 100% 6.83s + +avrdude: verifying ... +avrdude: 19278 bytes of flash verified + +avrdude: safemode: Fuses OK + +avrdude done. Thank you. + +% +@end cartouche +@end smallexample + +@page +@noindent +Upload the flash memory from the ATmega128 connected to the STK500 +programmer and save it in raw binary format in the file named +@code{c:/diag flash.bin}: + +@smallexample +@cartouche +% avrdude -p m128 -c stk500 -U flash:r:"c:/diag flash.bin":r + +avrdude: AVR device initialized and ready to accept instructions + +Reading | ################################################## | 100% 0.03s + +avrdude: Device signature = 0x1e9702 +avrdude: reading flash memory: + +Reading | ################################################## | 100% 46.10s + +avrdude: writing output file "c:/diag flash.bin" + +avrdude: safemode: Fuses OK + +avrdude done. Thank you. + +% +@end cartouche +@end smallexample + +@page +@noindent +Using the default programmer, download the file @code{diag.hex} to +flash, @code{eeprom.hex} to EEPROM, and set the Extended, High, and Low +fuse bytes to 0xff, 0x89, and 0x2e respectively: + +@smallexample +@cartouche + +% avrdude -p m128 -u -U flash:w:diag.hex \ +> -U eeprom:w:eeprom.hex \ +> -U efuse:w:0xff:m \ +> -U hfuse:w:0x89:m \ +> -U lfuse:w:0x2e:m + +avrdude: AVR device initialized and ready to accept instructions + +Reading | ################################################## | 100% 0.03s + +avrdude: Device signature = 0x1e9702 +avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed + To disable this feature, specify the -D option. +avrdude: erasing chip +avrdude: reading input file "diag.hex" +avrdude: input file diag.hex auto detected as Intel Hex +avrdude: writing flash (19278 bytes): + +Writing | ################################################## | 100% 7.60s + +avrdude: 19456 bytes of flash written +avrdude: verifying flash memory against diag.hex: +avrdude: load data flash data from input file diag.hex: +avrdude: input file diag.hex auto detected as Intel Hex +avrdude: input file diag.hex contains 19278 bytes +avrdude: reading on-chip flash data: + +Reading | ################################################## | 100% 6.84s + +avrdude: verifying ... +avrdude: 19278 bytes of flash verified + +[ ... other memory status output skipped for brevity ... ] + +avrdude done. Thank you. + +% +@end cartouche +@end smallexample + +@page +@noindent +Connect to the JTAG ICE mkII which serial number ends up in 1C37 via +USB, and enter terminal mode: + +@smallexample +@cartouche + +% avrdude -c jtag2 -p m649 -P usb:1c:37 -t + +avrdude: AVR device initialized and ready to accept instructions + +Reading | ################################################## | 100% 0.03s + +avrdude: Device signature = 0x1e9603 + +[ ... terminal mode output skipped for brevity ... ] + +avrdude done. Thank you. + +@end cartouche +@end smallexample + +@noindent +List the serial numbers of all JTAG ICEs attached to USB. This is +done by specifying an invalid serial number, and increasing the +verbosity level. + +@smallexample +@cartouche + +% avrdude -c jtag2 -p m128 -P usb:xx -v +[...] + Using Port : usb:xxx + Using Programmer : jtag2 +avrdude: usbdev_open(): Found JTAG ICE, serno: 00A000001C6B +avrdude: usbdev_open(): Found JTAG ICE, serno: 00A000001C3A +avrdude: usbdev_open(): Found JTAG ICE, serno: 00A000001C30 +avrdude: usbdev_open(): did not find any (matching) USB device "usb:xxx" + +@end cartouche +@end smallexample + + +@c +@c Node +@c +@node Terminal Mode Operation, Configuration File, Command Line Options, Top +@chapter Terminal Mode Operation + +AVRDUDE has an interactive mode called @var{terminal mode} that is +enabled by the @option{-t} option. This mode allows one to enter +interactive commands to display and modify the various device memories, +perform a chip erase, display the device signature bytes and part +parameters, and to send raw programming commands. Commands and +parameters may be abbreviated to their shortest unambiguous form. +Terminal mode also supports a command history so that previously entered +commands can be recalled and edited. + +@menu +* Terminal Mode Commands:: +* Terminal Mode Examples:: +@end menu + +@node Terminal Mode Commands, Terminal Mode Examples, Terminal Mode Operation, Terminal Mode Operation +@section Terminal Mode Commands + +@noindent +The following commands are implemented: + +@table @code + +@item dump @var{memtype} @var{addr} @var{nbytes} +Read @var{nbytes} from the specified memory area, and display them in +the usual hexadecimal and ASCII form. + +@item dump +Continue dumping the memory contents for another @var{nbytes} where the +previous dump command left off. + +@item write @var{memtype} @var{addr} @var{byte1} @dots{} @var{byteN} +Manually program the respective memory cells, starting at address addr, +using the values @var{byte1} through @var{byteN}. This feature is not +implemented for bank-addressed memories such as the flash memory of +ATMega devices. + +@item erase +Perform a chip erase. + +@item 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 +command. When using direct SPI mode, up to 3 bytes +can be omitted. + +@item sig +Display the device signature bytes. + +@item spi +Enter direct SPI mode. The @emph{pgmled} pin acts as slave select. +@emph{Only supported on parallel bitbang programmers.} + +@item part +Display the current part settings and parameters. Includes chip +specific information including all memory types supported by the +device, read/write timing, etc. + +@item pgm +Return to programming mode (from direct SPI mode). + +@item 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 ? +@itemx help +Give a short on-line summary of the available commands. + +@item quit +Leave terminal mode and thus AVRDUDE. + +@end table + +@noindent +In addition, the following commands are supported on the STK500 +and STK600 programmer: + +@table @code + +@item vtarg @var{voltage} +Set the target's supply voltage to @var{voltage} Volts. + +@item 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. +The STK600 offers two reference voltages, which can be +selected by the optional parameter @var{channel} (either +0 or 1). + +@item fosc @var{freq}[@code{M}|@code{k}] +Set the master oscillator to @var{freq} Hz. +An optional trailing letter @code{M} +multiplies by 1E6, a trailing letter @code{k} by 1E3. + +@item fosc off +Turn the master oscillator off. + +@item sck @var{period} +@emph{STK500 and STK600 only:} +Set the SCK clock period to @var{period} microseconds. + +@emph{JTAG ICE only:} +Set the JTAG ICE bit clock period to @var{period} microseconds. +Note that unlike STK500 settings, this setting will be reverted to +its default value (approximately 1 microsecond) when the programming +software signs off from the JTAG ICE. +This parameter can also be used on the JTAG ICE mkII/3 to specify the +ISP clock period when operating the ICE in ISP mode. + +@item parms +@emph{STK500 and STK600 only:} +Display the current voltage and master oscillator parameters. + +@emph{JTAG ICE only:} +Display the current target supply voltage and JTAG bit clock rate/period. + +@end table + +@c +@c Node +@c +@node Terminal Mode Examples, , Terminal Mode Commands, Terminal Mode Operation +@section Terminal Mode Examples + +@noindent +Display part parameters, modify eeprom cells, perform a chip erase: + +@smallexample +@cartouche +% avrdude -p m128 -c stk500 -t + +avrdude: AVR device initialized and ready to accept instructions +avrdude: Device signature = 0x1e9702 +avrdude: current erase-rewrite cycle count is 52 (if being tracked) +avrdude> part +>>> part + +AVR Part : ATMEGA128 +Chip Erase delay : 9000 us +PAGEL : PD7 +BS2 : PA0 +RESET disposition : dedicated +RETRY pulse : SCK +serial program mode : yes +parallel program mode : yes +Memory Detail : + + Page Polled + Memory Type Paged Size Size #Pages MinW MaxW ReadBack + ----------- ------ ------ ---- ------ ----- ----- --------- + eeprom no 4096 8 0 9000 9000 0xff 0xff + flash yes 131072 256 512 4500 9000 0xff 0x00 + lfuse no 1 0 0 0 0 0x00 0x00 + hfuse no 1 0 0 0 0 0x00 0x00 + efuse no 1 0 0 0 0 0x00 0x00 + lock no 1 0 0 0 0 0x00 0x00 + calibration no 1 0 0 0 0 0x00 0x00 + signature no 3 0 0 0 0 0x00 0x00 + +avrdude> dump eeprom 0 16 +>>> dump eeprom 0 16 +0000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| + +avrdude> write eeprom 0 1 2 3 4 +>>> write eeprom 0 1 2 3 4 + +avrdude> dump eeprom 0 16 +>>> dump eeprom 0 16 +0000 01 02 03 04 ff ff ff ff ff ff ff ff ff ff ff ff |................| + +avrdude> erase +>>> erase +avrdude: erasing chip +avrdude> dump eeprom 0 16 +>>> dump eeprom 0 16 +0000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| + +avrdude> +@end cartouche +@end smallexample + + +@noindent +Program the fuse bits of an ATmega128 (disable M103 compatibility, +enable high speed external crystal, enable brown-out detection, slowly +rising power). Note since we are working with fuse bits the -u (unsafe) +option is specified, which allows you to modify the fuse bits. First +display the factory defaults, then reprogram: + +@smallexample +@cartouche +% avrdude -p m128 -u -c stk500 -t + +avrdude: AVR device initialized and ready to accept instructions +avrdude: Device signature = 0x1e9702 +avrdude: current erase-rewrite cycle count is 52 (if being tracked) +avrdude> d efuse +>>> d efuse +0000 fd |. | + +avrdude> d hfuse +>>> d hfuse +0000 99 |. | + +avrdude> d lfuse +>>> d lfuse +0000 e1 |. | + +avrdude> w efuse 0 0xff +>>> w efuse 0 0xff + +avrdude> w hfuse 0 0x89 +>>> w hfuse 0 0x89 + +avrdude> w lfuse 0 0x2f +>>> w lfuse 0 0x2f + +avrdude> +@end cartouche +@end smallexample + + +@c +@c Node +@c +@node Configuration File, Programmer Specific Information, Terminal Mode Operation, Top +@chapter Configuration File + +@noindent +AVRDUDE reads a configuration file upon startup which describes all of +the parts and programmers that it knows about. The advantage of this is +that if you have a chip that is not currently supported by AVRDUDE, you +can add it to the configuration file without waiting for a new release +of AVRDUDE. Likewise, if you have a parallel port programmer that is +not supported by AVRDUDE, chances are good that you can copy and +existing programmer definition, and with only a few changes, make your +programmer work with AVRDUDE. + +AVRDUDE first looks for a system wide configuration file in a platform +dependent location. On Unix, this is usually +@code{/usr/local/etc/avrdude.conf}, while on Windows it is usually in the +same location as the executable file. The name of this file can be +changed using the @option{-C} command line option. After the system wide +configuration file is parsed, AVRDUDE looks for a per-user configuration +file to augment or override the system wide defaults. On Unix, the +per-user file is @code{.avrduderc} within the user's home directory. On +Windows, this file is the @code{avrdude.rc} file located in the same +directory as the executable. + +@menu +* AVRDUDE Defaults:: +* Programmer Definitions:: +* Part Definitions:: +* Other Notes:: +@end menu + +@c +@c Node +@c +@node AVRDUDE Defaults, Programmer Definitions, Configuration File, Configuration File +@section AVRDUDE Defaults + +@table @code + +@item default_parallel = "@var{default-parallel-device}"; +Assign the default parallel port device. Can be overridden using the +@option{-P} option. + +@item default_serial = "@var{default-serial-device}"; +Assign the default serial port device. Can be overridden using the +@option{-P} option. + +@item default_programmer = "@var{default-programmer-id}"; +Assign the default programmer id. Can be overridden using the @option{-c} +option. + +@item default_bitclock = "@var{default-bitclock}"; +Assign the default bitclock value. Can be overridden using the @option{-B} +option. + +@end table + + +@c +@c Node +@c +@node Programmer Definitions, Part Definitions, AVRDUDE Defaults, Configuration File +@section Programmer Definitions + +@noindent +The format of the programmer definition is as follows: + +@smallexample +programmer + parent # is a quoted string + id = [, [, ] ...] ; # are quoted strings + desc = ; # quoted string + type = "par" | "stk500" | ... ; # programmer type (see below for a list) + baudrate = ; # baudrate for serial ports + vcc = [, ... ] ; # pin number(s) + buff = [, ... ] ; # pin number(s) + reset = ; # pin number + sck = ; # pin number + mosi = ; # pin number + miso = ; # pin number + errled = ; # pin number + rdyled = ; # pin number + pgmled = ; # pin number + vfyled = ; # pin number + usbvid = ; # USB VID (Vendor ID) + usbpid = [, ...]; # USB PID (Product ID) + usbdev = ; # USB interface or other device info + usbvendor = ; # USB Vendor Name + usbproduct = ; # USB Product Name + usbsn = ; # USB Serial Number + ; +@end smallexample + +@noindent +If a parent is specified, all settings of it (except its ids) are used for the new +programmer. These values can be changed by new setting them for the new programmer. + +@noindent +To invert a bit in the pin definitions, use @code{= ~ }. + +@noindent +Not all programmer types can handle a list of USB PIDs. + +@noindent +Following programmer types are currently implemented: + +@multitable @columnfractions .25 .6 +@include programmer_types.texi +@end multitable + +@c +@c Node +@c +@node Part Definitions, Other Notes, Programmer Definitions, Configuration File +@section Part Definitions + +@smallexample +part + id = ; # quoted string + desc = ; # quoted string + has_jtag = ; # part has JTAG i/f + has_debugwire = ; # part has debugWire i/f + has_pdi = ; # part has PDI i/f + has_tpi = ; # part has TPI i/f + devicecode = ; # numeric + stk500_devcode = ; # numeric + avr910_devcode = ; # numeric + signature = ; # signature bytes + usbpid = ; # DFU USB PID + reset = dedicated | io; + retry_pulse = reset | sck; + pgm_enable = ; + chip_erase = ; + chip_erase_delay = ; # micro-seconds + # STK500 parameters (parallel programming IO lines) + pagel = ; # pin name in hex, i.e., 0xD7 + bs2 = ; # pin name in hex, i.e., 0xA0 + serial = ; # can use serial downloading + parallel = ; # can use par. programming + # STK500v2 parameters, to be taken from Atmel's XML files + timeout = ; + stabdelay = ; + cmdexedelay = ; + synchloops = ; + bytedelay = ; + pollvalue = ; + pollindex = ; + predelay = ; + postdelay = ; + pollmethod = ; + mode = ; + delay = ; + blocksize = ; + readsize = ; + hvspcmdexedelay = ; + # STK500v2 HV programming parameters, from XML + pp_controlstack = , , ...; # PP only + hvsp_controlstack = , , ...; # HVSP only + hventerstabdelay = ; + progmodedelay = ; # PP only + latchcycles = ; + togglevtg = ; + poweroffdelay = ; + resetdelayms = ; + resetdelayus = ; + hvleavestabdelay = ; + resetdelay = ; + synchcycles = ; # HVSP only + chiperasepulsewidth = ; # PP only + chiperasepolltimeout = ; + chiperasetime = ; # HVSP only + programfusepulsewidth = ; # PP only + programfusepolltimeout = ; + programlockpulsewidth = ; # PP only + programlockpolltimeout = ; + # JTAG ICE mkII parameters, also from XML files + allowfullpagebitstream = ; + enablepageprogramming = ; + idr = ; # IO addr of IDR (OCD) reg. + rampz = ; # IO addr of RAMPZ reg. + spmcr = ; # mem addr of SPMC[S]R reg. + eecr = ; # mem addr of EECR reg. + # (only when != 0x3c) + is_at90s1200 = ; # AT90S1200 part + is_avr32 = ; # AVR32 part + + memory + paged = ; # yes / no + size = ; # bytes + page_size = ; # bytes + num_pages = ; # numeric + min_write_delay = ; # micro-seconds + max_write_delay = ; # micro-seconds + readback_p1 = ; # byte value + readback_p2 = ; # byte value + pwroff_after_write = ; # yes / no + read = ; + write = ; + read_lo = ; + read_hi = ; + write_lo = ; + write_hi = ; + loadpage_lo = ; + loadpage_hi = ; + writepage = ; + ; + ; +@end smallexample + +@menu +* Parent Part:: +* Instruction Format:: +@end menu + +@c +@c Node +@c +@node Parent Part, Instruction Format, Part Definitions, Part Definitions +@subsection Parent Part + +@noindent +Parts can also inherit parameters from previously defined parts +using the following syntax. In this case specified integer and +string values override parameter values from the parent part. New +memory definitions are added to the definitions inherited from the +parent. + +@smallexample + part parent # quoted string + id = ; # quoted string + + ; +@end smallexample + +@c +@c Node +@c +@node Instruction Format, , Parent Part, Part Definitions +@subsection Instruction Format + +@noindent +Instruction formats are specified as a comma separated list of string +values containing information (bit specifiers) about each of the 32 bits +of the instruction. Bit specifiers may be one of the following formats: + +@table @code + +@item 1 +The bit is always set on input as well as output + +@item 0 +the bit is always clear on input as well as output + +@item x +the bit is ignored on input and output + +@item a +the bit is an address bit, the bit-number matches this bit specifier's +position within the current instruction byte + +@item a@var{N} +the bit is the @var{N}th address bit, bit-number = N, i.e., @code{a12} +is address bit 12 on input, @code{a0} is address bit 0. + +@item i +the bit is an input data bit + +@item o +the bit is an output data bit + +@end table + +Each instruction must be composed of 32 bit specifiers. The instruction +specification closely follows the instruction data provided in Atmel's +data sheets for their parts. For example, the EEPROM read and write +instruction for an AT90S2313 AVR part could be encoded as: + +@smallexample + +read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; + +write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; + +@end smallexample + + + +@c +@c Node +@c +@node Other Notes, , Part Definitions, Configuration File +@section Other Notes + + +@itemize @bullet +@item +The @code{devicecode} parameter is the device code used by the STK500 +and is obtained from the software section (@code{avr061.zip}) of +Atmel's AVR061 application note available from +@url{http://www.atmel.com/dyn/resources/prod_documents/doc2525.pdf}. + +@item +Not all memory types will implement all instructions. + +@item +AVR Fuse bits and Lock bits are implemented as a type of memory. + +@item +Example memory types are: @code{flash}, @code{eeprom}, @code{fuse}, +@code{lfuse} (low fuse), @code{hfuse} (high fuse), @code{efuse} +(extended fuse), @code{signature}, @code{calibration}, @code{lock}. + +@item +The memory type specified on the AVRDUDE command line must match one of +the memory types defined for the specified chip. + +@item +The @code{pwroff_after_write} flag causes AVRDUDE to attempt to power +the device off and back on after an unsuccessful write to the affected +memory area if VCC programmer pins are defined. If VCC pins are not +defined for the programmer, a message indicating that the device needs a +power-cycle is printed out. This flag was added to work around a +problem with the at90s4433/2333's; see the at90s4433 errata at: + + @url{http://www.atmel.com/dyn/resources/prod_documents/doc1280.pdf} + +@item +The boot loader from application note AVR109 (and thus also the AVR +Butterfly) does not support writing of fuse bits. Writing lock bits +is supported, but is restricted to the boot lock bits (BLBxx). These +are restrictions imposed by the underlying SPM instruction that is used +to program the device from inside the boot loader. Note that programming +the boot lock bits can result in a ``shoot-into-your-foot'' scenario as +the only way to unprogram these bits is a chip erase, which will also +erase the boot loader code. + +The boot loader implements the ``chip erase'' function by erasing the +flash pages of the application section. + +Reading fuse and lock bits is fully supported. + +Note that due to the inability to write the fuse bits, the safemode +functionality does not make sense for these boot loaders. + +@end itemize + +@c +@c Node +@c +@node Programmer Specific Information, Platform Dependent Information, Configuration File, Top +@chapter Programmer Specific Information + +@menu +* Atmel STK600:: +* Atmel DFU bootloader using FLIP version 1:: +@end menu + +@c +@c Node +@c +@node Atmel STK600, Atmel DFU bootloader using FLIP version 1, Programmer Specific Information, Programmer Specific Information +@section Atmel STK600 + +@c +@c Update the table below by running the tools/get-stk600-devices.xsl +@c XSLT transformation on targetboard.xml as shipped by the latest +@c release of AVR Studio. +@c +The following devices are supported by the respective STK600 routing +and socket card: + +@multitable @columnfractions .25 .25 .5 +@headitem Routing card @tab Socket card @tab Devices +@item @code{} @tab @code{STK600-ATTINY10} @tab ATtiny4 ATtiny5 ATtiny9 ATtiny10 +@item @code{STK600-RC008T-2} @tab @code{STK600-DIP} @tab ATtiny11 ATtiny12 ATtiny13 ATtiny13A ATtiny25 ATtiny45 ATtiny85 +@item @code{STK600-RC008T-7} @tab @code{STK600-DIP} @tab ATtiny15 +@item @code{STK600-RC014T-42} @tab @code{STK600-SOIC} @tab ATtiny20 +@item @code{STK600-RC020T-1} @tab @code{STK600-DIP} @tab ATtiny2313 ATtiny2313A ATtiny4313 +@item @code{} @tab @code{STK600-TinyX3U} @tab ATtiny43U +@item @code{STK600-RC014T-12} @tab @code{STK600-DIP} @tab ATtiny24 ATtiny44 ATtiny84 ATtiny24A ATtiny44A +@item @code{STK600-RC020T-8} @tab @code{STK600-DIP} @tab ATtiny26 ATtiny261 ATtiny261A ATtiny461 ATtiny861 ATtiny861A +@item @code{STK600-RC020T-43} @tab @code{STK600-SOIC} @tab ATtiny261 ATtiny261A ATtiny461 ATtiny461A ATtiny861 ATtiny861A +@item @code{STK600-RC020T-23} @tab @code{STK600-SOIC} @tab ATtiny87 ATtiny167 +@item @code{STK600-RC028T-3} @tab @code{STK600-DIP} @tab ATtiny28 +@item @code{STK600-RC028M-6} @tab @code{STK600-DIP} @tab ATtiny48 ATtiny88 ATmega8 ATmega8A ATmega48 ATmega88 ATmega168 ATmega48P ATmega48PA ATmega88P ATmega88PA ATmega168P ATmega168PA ATmega328P +@item @code{} @tab @code{QT600-ATTINY88-QT8} @tab ATtiny88 +@item @code{STK600-RC040M-4} @tab @code{STK600-DIP} @tab ATmega8515 ATmega162 +@item @code{STK600-RC044M-30} @tab @code{STK600-TQFP44} @tab ATmega8515 ATmega162 +@item @code{STK600-RC040M-5} @tab @code{STK600-DIP} @tab ATmega8535 ATmega16 ATmega16A ATmega32 ATmega32A ATmega164P ATmega164PA ATmega324P ATmega324PA ATmega644 ATmega644P ATmega644PA ATmega1284P +@item @code{STK600-RC044M-31} @tab @code{STK600-TQFP44} @tab ATmega8535 ATmega16 ATmega16A ATmega32 ATmega32A ATmega164P ATmega164PA ATmega324P ATmega324PA ATmega644 ATmega644P ATmega644PA ATmega1284P +@item @code{} @tab @code{QT600-ATMEGA324-QM64} @tab ATmega324PA +@item @code{STK600-RC032M-29} @tab @code{STK600-TQFP32} @tab ATmega8 ATmega8A ATmega48 ATmega88 ATmega168 ATmega48P ATmega48PA ATmega88P ATmega88PA ATmega168P ATmega168PA ATmega328P +@item @code{STK600-RC064M-9} @tab @code{STK600-TQFP64} @tab ATmega64 ATmega64A ATmega128 ATmega128A ATmega1281 ATmega2561 AT90CAN32 AT90CAN64 AT90CAN128 +@item @code{STK600-RC064M-10} @tab @code{STK600-TQFP64} @tab ATmega165 ATmega165P ATmega169 ATmega169P ATmega169PA ATmega325 ATmega325P ATmega329 ATmega329P ATmega645 ATmega649 ATmega649P +@item @code{STK600-RC100M-11} @tab @code{STK600-TQFP100} @tab ATmega640 ATmega1280 ATmega2560 +@item @code{} @tab @code{STK600-ATMEGA2560} @tab ATmega2560 +@item @code{STK600-RC100M-18} @tab @code{STK600-TQFP100} @tab ATmega3250 ATmega3250P ATmega3290 ATmega3290P ATmega6450 ATmega6490 +@item @code{STK600-RC032U-20} @tab @code{STK600-TQFP32} @tab AT90USB82 AT90USB162 ATmega8U2 ATmega16U2 ATmega32U2 +@item @code{STK600-RC044U-25} @tab @code{STK600-TQFP44} @tab ATmega16U4 ATmega32U4 +@item @code{STK600-RC064U-17} @tab @code{STK600-TQFP64} @tab ATmega32U6 AT90USB646 AT90USB1286 AT90USB647 AT90USB1287 +@item @code{STK600-RCPWM-22} @tab @code{STK600-TQFP32} @tab ATmega32C1 ATmega64C1 ATmega16M1 ATmega32M1 ATmega64M1 +@item @code{STK600-RCPWM-19} @tab @code{STK600-SOIC} @tab AT90PWM2 AT90PWM3 AT90PWM2B AT90PWM3B AT90PWM216 AT90PWM316 +@item @code{STK600-RCPWM-26} @tab @code{STK600-SOIC} @tab AT90PWM81 +@item @code{STK600-RC044M-24} @tab @code{STK600-TSSOP44} @tab ATmega16HVB ATmega32HVB +@item @code{} @tab @code{STK600-HVE2} @tab ATmega64HVE +@item @code{} @tab @code{STK600-ATMEGA128RFA1} @tab ATmega128RFA1 +@item @code{STK600-RC100X-13} @tab @code{STK600-TQFP100} @tab ATxmega64A1 ATxmega128A1 ATxmega128A1_revD ATxmega128A1U +@item @code{} @tab @code{STK600-ATXMEGA1281A1} @tab ATxmega128A1 +@item @code{} @tab @code{QT600-ATXMEGA128A1-QT16} @tab ATxmega128A1 +@item @code{STK600-RC064X-14} @tab @code{STK600-TQFP64} @tab ATxmega64A3 ATxmega128A3 ATxmega256A3 ATxmega64D3 ATxmega128D3 ATxmega192D3 ATxmega256D3 +@item @code{STK600-RC064X-14} @tab @code{STK600-MLF64} @tab ATxmega256A3B +@item @code{STK600-RC044X-15} @tab @code{STK600-TQFP44} @tab ATxmega32A4 ATxmega16A4 ATxmega16D4 ATxmega32D4 +@item @code{} @tab @code{STK600-ATXMEGAT0} @tab ATxmega32T0 +@item @code{} @tab @code{STK600-uC3-144} @tab AT32UC3A0512 AT32UC3A0256 AT32UC3A0128 +@item @code{STK600-RCUC3A144-33} @tab @code{STK600-TQFP144} @tab AT32UC3A0512 AT32UC3A0256 AT32UC3A0128 +@item @code{STK600-RCuC3A100-28} @tab @code{STK600-TQFP100} @tab AT32UC3A1512 AT32UC3A1256 AT32UC3A1128 +@item @code{STK600-RCuC3B0-21} @tab @code{STK600-TQFP64-2} @tab AT32UC3B0256 AT32UC3B0512RevC AT32UC3B0512 AT32UC3B0128 AT32UC3B064 AT32UC3D1128 +@item @code{STK600-RCuC3B48-27} @tab @code{STK600-TQFP48} @tab AT32UC3B1256 AT32UC3B164 +@item @code{STK600-RCUC3A144-32} @tab @code{STK600-TQFP144} @tab AT32UC3A3512 AT32UC3A3256 AT32UC3A3128 AT32UC3A364 AT32UC3A3256S AT32UC3A3128S AT32UC3A364S +@item @code{STK600-RCUC3C0-36} @tab @code{STK600-TQFP144} @tab AT32UC3C0512 AT32UC3C0256 AT32UC3C0128 AT32UC3C064 +@item @code{STK600-RCUC3C1-38} @tab @code{STK600-TQFP100} @tab AT32UC3C1512 AT32UC3C1256 AT32UC3C1128 AT32UC3C164 +@item @code{STK600-RCUC3C2-40} @tab @code{STK600-TQFP64-2} @tab AT32UC3C2512 AT32UC3C2256 AT32UC3C2128 AT32UC3C264 +@item @code{STK600-RCUC3C0-37} @tab @code{STK600-TQFP144} @tab AT32UC3C0512 AT32UC3C0256 AT32UC3C0128 AT32UC3C064 +@item @code{STK600-RCUC3C1-39} @tab @code{STK600-TQFP100} @tab AT32UC3C1512 AT32UC3C1256 AT32UC3C1128 AT32UC3C164 +@item @code{STK600-RCUC3C2-41} @tab @code{STK600-TQFP64-2} @tab AT32UC3C2512 AT32UC3C2256 AT32UC3C2128 AT32UC3C264 +@item @code{STK600-RCUC3L0-34} @tab @code{STK600-TQFP48} @tab AT32UC3L064 AT32UC3L032 AT32UC3L016 +@item @code{} @tab @code{QT600-AT32UC3L-QM64} @tab AT32UC3L064 +@end multitable + +Ensure the correct socket and routing card are mounted @emph{before} +powering on the STK600. While the STK600 firmware ensures the socket +and routing card mounted match each other (using a table stored +internally in nonvolatile memory), it cannot handle the case where a +wrong routing card is used, e. g. the routing card +@code{STK600-RC040M-5} (which is meant for 40-pin DIP AVRs that have +an ADC, with the power supply pins in the center of the package) was +used but an ATmega8515 inserted (which uses the ``industry standard'' +pinout with Vcc and GND at opposite corners). + +Note that for devices that use the routing card @code{STK600-RC008T-2}, +in order to use ISP mode, the jumper for @code{AREF0} must be removed +as it would otherwise block one of the ISP signals. High-voltage +serial programming can be used even with that jumper installed. + +The ISP system of the STK600 contains a detection against shortcuts +and other wiring errors. AVRDUDE initiates a connection check before +trying to enter ISP programming mode, and display the result if the +target is not found ready to be ISP programmed. + +High-voltage programming requires the target voltage to be set to at +least 4.5 V in order to work. This can be done using +@emph{Terminal Mode}, see @ref{Terminal Mode Operation}. + +@c +@c Node +@c +@node Atmel DFU bootloader using FLIP version 1, , Atmel STK600, Programmer Specific Information +@section Atmel DFU bootloader using FLIP version 1 + +Bootloaders using the FLIP protocol version 1 experience some very +specific behaviour. + +These bootloaders have no option to access memory areas other than +Flash and EEPROM. + +When the bootloader is started, it enters a @emph{security mode} where +the only acceptable access is to query the device configuration +parameters (which are used for the signature on AVR devices). The +only way to leave this mode is a @emph{chip erase}. As a chip erase +is normally implied by the @option{-U} option when reprogramming the +flash, this peculiarity might not be very obvious immediately. + +Sometimes, a bootloader with security mode already disabled seems to +no longer respond with sensible configuration data, but only 0xFF for +all queries. As these queries are used to obtain the equivalent of a +signature, AVRDUDE can only continue in that situation by forcing the +signature check to be overridden with the @option{-F} option. + +A @emph{chip erase} might leave the EEPROM unerased, at least on some +versions of the bootloader. + +@c +@c Node +@c +@node Platform Dependent Information, Troubleshooting, Programmer Specific Information, Top +@appendix Platform Dependent Information + +@menu +* Unix:: +* Windows:: +@end menu + +@c +@c Node +@c +@node Unix, Windows, Platform Dependent Information, Platform Dependent Information +@section Unix + +@menu +* Unix Installation:: +* Unix Configuration Files:: +* Unix Port Names:: +* Unix Documentation:: +@end menu + +@c +@c Node +@c +@node Unix Installation, Unix Configuration Files, Unix, Unix +@subsection Unix Installation + +@noindent +To build and install from the source tarball on Unix like systems: + +@example +$ gunzip -c avrdude-@value{VERSION}.tar.gz | tar xf - +$ cd avrdude-@value{VERSION} +$ ./configure +$ make +$ su root -c 'make install' +@end example + +The default location of the install is into @code{/usr/local} so you +will need to be sure that @code{/usr/local/bin} is in your @code{PATH} +environment variable. + +If you do not have root access to your system, you can do the +following instead: + +@example +$ gunzip -c avrdude-@value{VERSION}.tar.gz | tar xf - +$ cd avrdude-@value{VERSION} +$ ./configure --prefix=$HOME/local +$ make +$ make install +@end example + +@menu +* FreeBSD Installation:: +* Linux Installation:: +@end menu + +@c +@c Node +@c +@node FreeBSD Installation, Linux Installation, Unix Installation, Unix Installation +@subsubsection FreeBSD Installation + +@noindent +AVRDUDE is installed via the FreeBSD Ports Tree as follows: + +@example +% su - root +# cd /usr/ports/devel/avrdude +# make install +@end example + +If you wish to install from a pre-built package instead of the source, +you can use the following instead: + +@example +% su - root +# pkg_add -r avrdude +@end example + +Of course, you must be connected to the Internet for these methods to +work, since that is where the source as well as the pre-built package is +obtained. + +@c +@c Node +@c +@node Linux Installation, , FreeBSD Installation, Unix Installation +@subsubsection Linux Installation + +@noindent +On rpm based Linux systems (such as RedHat, SUSE, Mandrake, etc.), you +can build and install the rpm binaries directly from the tarball: + +@example +$ su - root +# rpmbuild -tb avrdude-@value{VERSION}.tar.gz +# rpm -Uvh /usr/src/redhat/RPMS/i386/avrdude-@value{VERSION}-1.i386.rpm +@end example + +Note that the path to the resulting rpm package, differs from system +to system. The above example is specific to RedHat. + +@c +@c Node +@c +@node Unix Configuration Files, Unix Port Names, Unix Installation, Unix +@subsection Unix Configuration Files + +@noindent +When AVRDUDE is build using the default @option{--prefix} configure +option, the default configuration file for a Unix system is located at +@code{/usr/local/etc/avrdude.conf}. This can be overridden by using the +@option{-C} command line option. Additionally, the user's home directory +is searched for a file named @code{.avrduderc}, and if found, is used to +augment the system default configuration file. + +@menu +* FreeBSD Configuration Files:: +* Linux Configuration Files:: +@end menu + +@c +@c Node +@c +@node FreeBSD Configuration Files, Linux Configuration Files, Unix Configuration Files, Unix Configuration Files +@subsubsection FreeBSD Configuration Files + +@noindent +When AVRDUDE is installed using the FreeBSD ports system, the system +configuration file is always @code{/usr/local/etc/avrdude.conf}. + +@c +@c Node +@c +@node Linux Configuration Files, , FreeBSD Configuration Files, Unix Configuration Files +@subsubsection Linux Configuration Files + +@noindent +When AVRDUDE is installed using from an rpm package, the system +configuration file will be always be @code{/etc/avrdude.conf}. + +@c +@c Node +@c +@node Unix Port Names, Unix Documentation, Unix Configuration Files, Unix +@subsection Unix Port Names + +@noindent +The parallel and serial port device file names are system specific. +The following table lists the default names for a given system. + +@multitable @columnfractions .30 .30 .30 +@item @strong{System} + @tab @strong{Default Parallel Port} + @tab @strong{Default Serial Port} +@item FreeBSD + @tab @code{/dev/ppi0} + @tab @code{/dev/cuad0} +@item Linux + @tab @code{/dev/parport0} + @tab @code{/dev/ttyS0} +@item Solaris + @tab @code{/dev/printers/0} + @tab @code{/dev/term/a} +@end multitable + +On FreeBSD systems, AVRDUDE uses the ppi(4) interface for +accessing the parallel port and the sio(4) driver for serial port +access. + +On Linux systems, AVRDUDE uses the ppdev interface for +accessing the parallel port and the tty driver for serial port +access. + +On Solaris systems, AVRDUDE uses the ecpp(7D) driver for +accessing the parallel port and the asy(7D) driver for serial port +access. + +@c +@c Node +@c +@node Unix Documentation, , Unix Port Names, Unix +@subsection Unix Documentation + +@noindent +AVRDUDE installs a manual page as well as info, HTML and PDF +documentation. The manual page is installed in +@code{/usr/local/man/man1} area, while the HTML and PDF documentation +is installed in @code{/usr/local/share/doc/avrdude} directory. The +info manual is installed in @code{/usr/local/info/avrdude.info}. + +Note that these locations can be altered by various configure options +such as @option{--prefix}. + +@c +@c Node +@c +@node Windows, , Unix, Platform Dependent Information +@section Windows + +@menu +* Windows Installation:: +* Windows Configuration Files:: +* Windows Port Names:: +* Using the parallel port:: +* Documentation:: +* Credits.:: +@end menu + +@c +@c Node +@c +@node Windows Installation, Windows Configuration Files, Windows, Windows +@subsection Installation + +@noindent +A Windows executable of avrdude is included in WinAVR which can be found at +@url{http://sourceforge.net/projects/winavr}. WinAVR is a suite of executable, +open source software development tools for the AVR for the Windows platform. + +There are two options to build avrdude from source under Windows. +The first one is to use Cygwin (@url{http://www.cygwin.com/}). + +To build and install from the source tarball for Windows (using Cygwin): + +@example +$ set PREFIX= +$ export PREFIX +$ gunzip -c avrdude-@value{VERSION}.tar.gz | tar xf - +$ cd avrdude-@value{VERSION} +$ ./configure LDFLAGS="-static" --prefix=$PREFIX --datadir=$PREFIX +--sysconfdir=$PREFIX/bin --enable-versioned-doc=no +$ make +$ make install +@end example + +Note that recent versions of Cygwin (starting with 1.7) removed the +MinGW support from the compiler that is needed in order to build a +native Win32 API binary that does not require to install the Cygwin +library @code{cygwin1.dll} at run-time. Either try using an older +compiler version that still supports MinGW builds, or use MinGW +(@url{http://www.mingw.org/}) directly. + +@c +@c XXX Please add more detailed instructions here. +@c + + +@c +@c Node +@c +@node Windows Configuration Files, Windows Port Names, Windows Installation, Windows +@subsection Configuration Files + +@menu +* Configuration file names:: +* How AVRDUDE finds the configuration files.:: +@end menu + +@c +@c Node +@c +@node Configuration file names, How AVRDUDE finds the configuration files., Windows Configuration Files, Windows Configuration Files +@subsubsection Configuration file names + +@noindent +AVRDUDE on Windows looks for a system configuration file name of +@code{avrdude.conf} and looks for a user override configuration file of +@code{avrdude.rc}. + +@c +@c Node +@c +@node How AVRDUDE finds the configuration files., , Configuration file names, Windows Configuration Files +@subsubsection How AVRDUDE finds the configuration files. + +@noindent +AVRDUDE on Windows has a different way of searching for the system and +user configuration files. Below is the search method for locating the +configuration files: + +@enumerate + +@item +The directory from which the application loaded. + +@item +The current directory. + +@item +The Windows system directory. On Windows NT, the name of this directory +is @code{SYSTEM32}. + +@item +Windows NT: The 16-bit Windows system directory. The name of this +directory is @code{SYSTEM}. + +@item +The Windows directory. + +@item +The directories that are listed in the PATH environment variable. + +@end enumerate + + +@c +@c Node +@c +@node Windows Port Names, Using the parallel port, Windows Configuration Files, Windows +@subsection Port Names + +@menu +* Serial Ports:: +* Parallel Ports:: +@end menu + +@c +@c Node +@c +@node Serial Ports, Parallel Ports, Windows Port Names, Windows Port Names +@subsubsection Serial Ports + +@noindent +When you select a serial port (i.e. when using an STK500) use the +Windows serial port device names such as: com1, com2, etc. + +@c +@c Node +@c +@node Parallel Ports, , Serial Ports, Windows Port Names +@subsubsection Parallel Ports + +@noindent +AVRDUDE will accept 3 Windows parallel port names: lpt1, lpt2, or +lpt3. Each of these names corresponds to a fixed parallel port base +address: + +@table @code +@item lpt1 +0x378 + +@item lpt2 +0x278 + +@item lpt3 +0x3BC + +@end table + +On your desktop PC, lpt1 will be the most common choice. If you are +using a laptop, you might have to use lpt3 instead of lpt1. Select the +name of the port the corresponds to the base address of the parallel +port that you want. + +If the parallel port can be accessed through a different +address, this address can be specified directly, using the common C +language notation (i. e., hexadecimal values are prefixed by @code{0x}). + +@c +@c Node +@c +@node Using the parallel port, Documentation, Windows Port Names, Windows +@subsection Using the parallel port + +@menu +* Windows NT/2K/XP:: +* Windows 95/98:: +@end menu + +@c +@c Node +@c +@node Windows NT/2K/XP, Windows 95/98, Using the parallel port, Using the parallel port +@subsubsection Windows NT/2K/XP + +@noindent +On Windows NT, 2000, and XP user applications cannot directly access the +parallel port. However, kernel mode drivers can access the parallel port. +giveio.sys is a driver that can allow user applications to set the state +of the parallel port pins. + +Before using AVRDUDE, the giveio.sys driver must be loaded. The +accompanying command-line program, loaddrv.exe, can do just that. + +To make things even easier there are 3 batch files that are also +included: + +@enumerate +@item install_giveio.bat +Install and start the giveio driver. + +@item status_giveio.bat +Check on the status of the giveio driver. + +@item remove_giveio.bat +Stop and remove the giveio driver from memory. +@end enumerate + +These 3 batch files calls the loaddrv program with various options to +install, start, stop, and remove the driver. + +When you first execute install_giveio.bat, loaddrv.exe and giveio.sys +must be in the current directory. When install_giveio.bat is executed it +will copy giveio.sys from your current directory to your Windows +directory. It will then load the driver from the Windows directory. This +means that after the first time install_giveio is executed, you should +be able to subsequently execute the batch file from any directory and have +it successfully start the driver. + +Note that you must have administrator privilege to load the giveio driver. + +@c +@c Node +@c +@node Windows 95/98, , Windows NT/2K/XP, Using the parallel port +@subsubsection Windows 95/98 + +@noindent +On Windows 95 and 98 the giveio.sys driver is not needed. + + +@c +@c Node +@c +@node Documentation, Credits., Using the parallel port, Windows +@subsection Documentation + +@noindent +AVRDUDE installs a manual page as well as info, HTML and PDF +documentation. The manual page is installed in +@code{/usr/local/man/man1} area, while the HTML and PDF documentation +is installed in @code{/usr/local/share/doc/avrdude} directory. The +info manual is installed in @code{/usr/local/info/avrdude.info}. + +Note that these locations can be altered by various configure options +such as @option{--prefix} and @option{--datadir}. + + +@c +@c Node +@c +@node Credits., , Documentation, Windows +@subsection Credits. + +@noindent +Thanks to: + +@itemize @bullet +@item +Dale Roberts for the giveio driver. + +@item +Paula Tomlinson for the loaddrv sources. + +@item +Chris Liechti for modifying loaddrv to be command +line driven and for writing the batch files. + +@end itemize + +@c +@c Node +@c +@node Troubleshooting, ,Platform Dependent Information ,Top +@appendix Troubleshooting + +@noindent +In general, please report any bugs encountered via +@* +@url{http://savannah.nongnu.org/bugs/?group=avrdude}. + + +@itemize @bullet + +@item +Problem: I'm using a serial programmer under Windows and get the following +error: + +@code{avrdude: serial_open(): can't set attributes for device "com1"}, + +Solution: This problem seems to appear with certain versions of Cygwin. Specifying +@code{"/dev/com1"} instead of @code{"com1"} should help. + + +@item +Problem: I'm using Linux and my AVR910 programmer is really slow. + +Solution (short): @code{setserial @var{port} low_latency} + +Solution (long): +There are two problems here. First, the system may wait some time before it +passes data from the serial port to the program. Under Linux the following +command works around this (you may need root privileges for this). + +@code{setserial @var{port} low_latency} + +Secondly, the serial interface chip may delay the interrupt for some time. +This behaviour can be changed by setting the FIFO-threshold to one. Under Linux this +can only be done by changing the kernel source in @code{drivers/char/serial.c}. +Search the file for @code{UART_FCR_TRIGGER_8} and replace it with @code{UART_FCR_TRIGGER_1}. Note that overall performance might suffer if there +is high throughput on serial lines. Also note that you are modifying the kernel at +your own risk. + + +@item +Problem: I'm not using Linux and my AVR910 programmer is really slow. + +Solutions: The reasons for this are the same as above. +If you know how to work around this on your OS, please let us know. + +@item +Problem: Updating the flash ROM from terminal mode does not work with the +JTAG ICEs. + +Solution: None at this time. Currently, the JTAG ICE code cannot +write to the flash ROM one byte at a time. + +@item +Problem: Page-mode programming the EEPROM (using the -U option) does +not erase EEPROM cells before writing, and thus cannot overwrite any +previous value != 0xff. + +Solution: None. This is an inherent feature of the way JTAG EEPROM +programming works, and is documented that way in the Atmel AVR +datasheets. +In order to successfully program the EEPROM that way, a prior chip +erase (with the EESAVE fuse unprogrammed) is required. +This also applies to the STK500 and STK600 in high-voltage programming mode. + +@item +Problem: How do I turn off the @var{DWEN} fuse? + +Solution: If the @var{DWEN} (debugWire enable) fuse is activated, +the @var{/RESET} pin is not functional anymore, so normal ISP +communication cannot be established. +There are two options to deactivate that fuse again: high-voltage +programming, or getting the JTAG ICE mkII talk debugWire, and +prepare the target AVR to accept normal ISP communication again. + +The first option requires a programmer that is capable of high-voltage +programming (either serial or parallel, depending on the AVR device), +for example the STK500. In high-voltage programming mode, the +@var{/RESET} pin is activated initially using a 12 V pulse (thus the +name @emph{high voltage}), so the target AVR can subsequently be +reprogrammed, and the @var{DWEN} fuse can be cleared. Typically, this +operation cannot be performed while the AVR is located in the target +circuit though. + +The second option requires a JTAG ICE mkII that can talk the debugWire +protocol. The ICE needs to be connected to the target using the +JTAG-to-ISP adapter, so the JTAG ICE mkII can be used as a debugWire +initiator as well as an ISP programmer. AVRDUDE will then be activated +using the @var{jtag2isp} programmer type. The initial ISP +communication attempt will fail, but AVRDUDE then tries to initiate a +debugWire reset. When successful, this will leave the target AVR in a +state where it can accept standard ISP communication. The ICE is then +signed off (which will make it signing off from the USB as well), so +AVRDUDE has to be called again afterwards. This time, standard ISP +communication can work, so the @var{DWEN} fuse can be cleared. + +The pin mapping for the JTAG-to-ISP adapter is: + +@multitable @columnfractions .2 .2 +@item @strong{JTAG pin} @tab @strong{ISP pin} +@item 1 @tab 3 +@item 2 @tab 6 +@item 3 @tab 1 +@item 4 @tab 2 +@item 6 @tab 5 +@item 9 @tab 4 +@end multitable + +@item +Problem: Multiple USBasp or USBtinyISP programmers connected simultaneously are not +found. + +Solution: The USBtinyISP code supports distinguishing multiple +programmers based on their bus:device connection tuple that describes +their place in the USB hierarchy on a specific host. This tuple can +be added to the @var{-P usb} option, similar to adding a serial number +on other USB-based programmers. + +The actual naming convention for the bus and device names is +operating-system dependent; AVRDUDE will print out what it found +on the bus when running it with (at least) one @var{-v} option. +By specifying a string that cannot match any existing device +(for example, @var{-P usb:xxx}), the scan will list all possible +candidate devices found on the bus. + +Examples: +@example +avrdude -c usbtiny -p atmega8 -P usb:003:025 (Linux) +avrdude -c usbtiny -p atmega8 -P usb:/dev/usb:/dev/ugen1.3 (FreeBSD 8+) +avrdude -c usbtiny -p atmega8 \ + -P usb:bus-0:\\.\libusb0-0001--0x1781-0x0c9f (Windows) +@end example + +@item +Problem: I cannot do @dots{} when the target is in debugWire mode. + +Solution: debugWire mode imposes several limitations. + +The debugWire protocol is Atmel's proprietary one-wire (plus ground) +protocol to allow an in-circuit emulation of the smaller AVR devices, +using the @var{/RESET} line. +DebugWire mode is initiated by activating the @var{DWEN} +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. +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. +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 +debugWire mode will be temporarily disabled, and the target can +be accessed using normal ISP programming. +This sequence is automatically initiated by using the JTAG ICE mkII +or AVR Dragon in ISP mode, when they detect that ISP mode cannot be +entered. + +@item +Problem: I want to use my JTAG ICE mkII to program an +Xmega device through PDI. The documentation tells me to use the +@emph{XMEGA PDI adapter for JTAGICE mkII} that is supposed to ship +with the kit, yet I don't have it. + +Solution: Use the following pin mapping: + +@multitable @columnfractions .2 .2 .2 .2 +@item @strong{JTAGICE} @tab @strong{Target} @tab @strong{Squid cab-} @tab @strong{PDI} +@item @strong{mkII probe} @tab @strong{pins} @tab @strong{le colors} @tab @strong{header} +@item 1 (TCK) @tab @tab Black @tab +@item 2 (GND) @tab GND @tab White @tab 6 +@item 3 (TDO) @tab @tab Grey @tab +@item 4 (VTref) @tab VTref @tab Purple @tab 2 +@item 5 (TMS) @tab @tab Blue @tab +@item 6 (nSRST) @tab PDI_CLK @tab Green @tab 5 +@item 7 (N.C.) @tab @tab Yellow @tab +@item 8 (nTRST) @tab @tab Orange @tab +@item 9 (TDI) @tab PDI_DATA @tab Red @tab 1 +@item 10 (GND) @tab @tab Brown @tab +@end multitable + +@item +Problem: I want to use my AVR Dragon to program an +Xmega device through PDI. + +Solution: Use the 6 pin ISP header on the Dragon and the following pin mapping: + +@multitable @columnfractions .2 .2 +@item @strong{Dragon} @tab @strong{Target} +@item @strong{ISP Header} @tab @strong{pins} +@item 1 (MISO) @tab PDI_DATA +@item 2 (VCC) @tab VCC +@item 3 (SCK) @tab +@item 4 (MOSI) @tab +@item 5 (RESET) @tab PDI_CLK / RST +@item 6 (GND) @tab GND +@end multitable + +@item +Problem: I want to use my AVRISP mkII to program an +ATtiny4/5/9/10 device through TPI. How to connect the pins? + +Solution: Use the following pin mapping: + +@multitable @columnfractions .2 .2 .2 +@item @strong{AVRISP} @tab @strong{Target} @tab @strong{ATtiny} +@item @strong{connector} @tab @strong{pins} @tab @strong{pin #} +@item 1 (MISO) @tab TPIDATA @tab 1 +@item 2 (VTref) @tab Vcc @tab 5 +@item 3 (SCK) @tab TPICLK @tab 3 +@item 4 (MOSI) @tab @tab +@item 5 (RESET) @tab /RESET @tab 6 +@item 6 (GND) @tab GND @tab 2 +@end multitable + +@item +Problem: I want to program an ATtiny4/5/9/10 device using a serial/parallel +bitbang programmer. How to connect the pins? + +Solution: Since TPI has only 1 pin for bi-directional data transfer, both +@var{MISO} and @var{MOSI} pins should be connected to the @var{TPIDATA} pin +on the ATtiny device. +However, a 1K resistor should be placed between the @var{MOSI} and @var{TPIDATA}. +The @var{MISO} pin connects to @var{TPIDATA} directly. +The @var{SCK} pin is connected to @var{TPICLK}. + +In addition, the @var{Vcc}, @var{/RESET} and @var{GND} pins should +be connected to their respective ports on the ATtiny device. + +@item +Problem: How can I use a FTDI FT232R USB-to-Serial device for bitbang programming? + +Solution: When connecting the FT232 directly to the pins of the target Atmel device, +the polarity of the pins defined in the @code{programmer} definition should be +inverted by prefixing a tilde. For example, the @var{dasa} programmer would +look like this when connected via a FT232R device (notice the tildes in +front of pins 7, 4, 3 and 8): + +@example +programmer + id = "dasa_ftdi"; + desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts"; + type = serbb; + reset = ~7; + sck = ~4; + mosi = ~3; + miso = ~8; +; +@end example + +Note that this uses the FT232 device as a normal serial port, not using the +FTDI drivers in the special bitbang mode. + +@item +Problem: My ATtiny4/5/9/10 reads out fine, but any attempt to program +it (through TPI) fails. Instead, the memory retains the old contents. + +Solution: Mind the limited programming supply voltage range of these +devices. + +In-circuit programming through TPI is only guaranteed by the datasheet +at Vcc = 5 V. + +@item +Problem: My ATxmega@dots{}A1/A2/A3 cannot be programmed through PDI with +my AVR Dragon. Programming through a JTAG ICE mkII works though, as does +programming through JTAG. + +Solution: None by this time (2010 Q1). + +It is said that the AVR Dragon can only program devices from the A4 +Xmega sub-family. + +@item +Problem: when programming with an AVRISPmkII or STK600, AVRDUDE hangs +when programming files of a certain size (e.g. 246 bytes). Other +(larger or smaller) sizes work though. + +Solution: This is a bug caused by an incorrect handling of zero-length +packets (ZLPs) in some versions of the libusb 0.1 API wrapper that ships +with libusb 1.x in certain Linux distributions. All Linux systems with +kernel versions < 2.6.31 and libusb >= 1.0.0 < 1.0.3 are reported to be +affected by this. + +See also: @url{http://www.libusb.org/ticket/6} + +@item +Problem: after flashing a firmware that reduces the target's clock +speed (e.g. through the @code{CLKPR} register), further ISP connection +attempts fail. + +Solution: Even though ISP starts with pulling @var{/RESET} low, the +target continues to run at the internal clock speed as defined by the +firmware running before. Therefore, the ISP clock speed must be +reduced appropriately (to less than 1/4 of the internal clock speed) +using the -B option before the ISP initialization sequence will +succeed. + +As that slows down the entire subsequent ISP session, it might make +sense to just issue a @emph{chip erase} using the slow ISP clock +(option @code{-e}), and then start a new session at higher speed. +Option @code{-D} might be used there, to prevent another unneeded +erase cycle. + +@end itemize + + + +@bye + diff --git a/xs/src/avrdude/doc/parts_comments.txt b/xs/src/avrdude/doc/parts_comments.txt new file mode 100644 index 000000000..d83bb4312 --- /dev/null +++ b/xs/src/avrdude/doc/parts_comments.txt @@ -0,0 +1,5 @@ +AT90S1200 (****) +AT90S2343 (*) +ATmega2560 (**) +ATmega2561 (**) +ATtiny11 (***) diff --git a/xs/src/avrdude/fileio.c b/xs/src/avrdude/fileio.c new file mode 100644 index 000000000..f2d617823 --- /dev/null +++ b/xs/src/avrdude/fileio.c @@ -0,0 +1,1604 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 "ac_cfg.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_LIBELF +#ifdef HAVE_LIBELF_H +#include +#elif defined(HAVE_LIBELF_LIBELF_H) +#include +#endif +#define EM_AVR32 0x18ad /* inofficial */ +#endif + +#include "avrdude.h" +#include "libavrdude.h" + + +#define IHEX_MAXDATA 256 + +#define MAX_LINE_LEN 256 /* max line length for ASCII format input files */ + + +struct ihexrec { + unsigned char reclen; + unsigned int loadofs; + unsigned char rectyp; + unsigned char data[IHEX_MAXDATA]; + unsigned char cksum; +}; + + +static int b2ihex(unsigned char * inbuf, int bufsize, + int recsize, int startaddr, + char * outfile, FILE * outf); + +static int ihex2b(char * infile, FILE * inf, + AVRMEM * mem, int bufsize, unsigned int fileoffset); + +static int b2srec(unsigned char * inbuf, int bufsize, + int recsize, int startaddr, + char * outfile, FILE * outf); + +static int srec2b(char * infile, FILE * inf, + AVRMEM * mem, int bufsize, unsigned int fileoffset); + +static int ihex_readrec(struct ihexrec * ihex, char * rec); + +static int srec_readrec(struct ihexrec * srec, char * rec); + +static int fileio_rbin(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, int size); + +static int fileio_ihex(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, int size); + +static int fileio_srec(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, int size); + +#ifdef HAVE_LIBELF +static int elf2b(char * infile, FILE * inf, + AVRMEM * mem, struct avrpart * p, + int bufsize, unsigned int fileoffset); + +static int fileio_elf(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, + struct avrpart * p, int size); +#endif + +static int fileio_num(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, int size, + FILEFMT fmt); + +static int fmt_autodetect(char * fname); + + + +char * fmtstr(FILEFMT format) +{ + switch (format) { + case FMT_AUTO : return "auto-detect"; break; + case FMT_SREC : return "Motorola S-Record"; break; + case FMT_IHEX : return "Intel Hex"; break; + case FMT_RBIN : return "raw binary"; break; + case FMT_ELF : return "ELF"; break; + default : return "invalid format"; break; + }; +} + + + +static int b2ihex(unsigned char * inbuf, int bufsize, + int recsize, int startaddr, + char * outfile, FILE * outf) +{ + unsigned char * buf; + unsigned int nextaddr; + int n, nbytes, n_64k; + int i; + unsigned char cksum; + + if (recsize > 255) { + avrdude_message(MSG_INFO, "%s: recsize=%d, must be < 256\n", + progname, recsize); + return -1; + } + + n_64k = 0; + nextaddr = startaddr; + buf = inbuf; + nbytes = 0; + + while (bufsize) { + n = recsize; + if (n > bufsize) + n = bufsize; + + if ((nextaddr + n) > 0x10000) + n = 0x10000 - nextaddr; + + if (n) { + cksum = 0; + fprintf(outf, ":%02X%04X00", n, nextaddr); + cksum += n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff); + for (i=0; i= 0x10000) { + int lo, hi; + /* output an extended address record */ + n_64k++; + lo = n_64k & 0xff; + hi = (n_64k >> 8) & 0xff; + cksum = 0; + fprintf(outf, ":02000004%02X%02X", hi, lo); + cksum += 2 + 0 + 4 + hi + lo; + cksum = -cksum; + fprintf(outf, "%02X\n", cksum); + nextaddr = 0; + } + + /* advance to next 'recsize' bytes */ + buf += n; + bufsize -= n; + } + + /*----------------------------------------------------------------- + add the end of record data line + -----------------------------------------------------------------*/ + cksum = 0; + n = 0; + nextaddr = 0; + fprintf(outf, ":%02X%04X01", n, nextaddr); + cksum += n + ((nextaddr >> 8) & 0x0ff) + (nextaddr & 0x0ff) + 1; + cksum = -cksum; + fprintf(outf, "%02X\n", cksum); + + return nbytes; +} + + +static int ihex_readrec(struct ihexrec * ihex, char * rec) +{ + int i, j; + char buf[8]; + int offset, len; + char * e; + unsigned char cksum; + int rc; + + len = strlen(rec); + offset = 1; + cksum = 0; + + /* reclen */ + if (offset + 2 > len) + return -1; + for (i=0; i<2; i++) + buf[i] = rec[offset++]; + buf[i] = 0; + ihex->reclen = strtoul(buf, &e, 16); + if (e == buf || *e != 0) + return -1; + + /* load offset */ + if (offset + 4 > len) + return -1; + for (i=0; i<4; i++) + buf[i] = rec[offset++]; + buf[i] = 0; + ihex->loadofs = strtoul(buf, &e, 16); + if (e == buf || *e != 0) + return -1; + + /* record type */ + if (offset + 2 > len) + return -1; + for (i=0; i<2; i++) + buf[i] = rec[offset++]; + buf[i] = 0; + ihex->rectyp = strtoul(buf, &e, 16); + if (e == buf || *e != 0) + return -1; + + cksum = ihex->reclen + ((ihex->loadofs >> 8) & 0x0ff) + + (ihex->loadofs & 0x0ff) + ihex->rectyp; + + /* data */ + for (j=0; jreclen; j++) { + if (offset + 2 > len) + return -1; + for (i=0; i<2; i++) + buf[i] = rec[offset++]; + buf[i] = 0; + ihex->data[j] = strtoul(buf, &e, 16); + if (e == buf || *e != 0) + return -1; + cksum += ihex->data[j]; + } + + /* cksum */ + if (offset + 2 > len) + return -1; + for (i=0; i<2; i++) + buf[i] = rec[offset++]; + buf[i] = 0; + ihex->cksum = strtoul(buf, &e, 16); + if (e == buf || *e != 0) + return -1; + + rc = -cksum & 0x000000ff; + + return rc; +} + + + +/* + * Intel Hex to binary buffer + * + * Given an open file 'inf' which contains Intel Hex formated data, + * parse the file and lay it out within the memory buffer pointed to + * by outbuf. The size of outbuf, 'bufsize' is honored; if data would + * fall outsize of the memory buffer outbuf, an error is generated. + * + * Return the maximum memory address within 'outbuf' that was written. + * If an error occurs, return -1. + * + * */ +static int ihex2b(char * infile, FILE * inf, + AVRMEM * mem, int bufsize, unsigned int fileoffset) +{ + char buffer [ MAX_LINE_LEN ]; + unsigned int nextaddr, baseaddr, maxaddr; + int i; + int lineno; + int len; + struct ihexrec ihex; + int rc; + + lineno = 0; + baseaddr = 0; + maxaddr = 0; + nextaddr = 0; + + while (fgets((char *)buffer,MAX_LINE_LEN,inf)!=NULL) { + lineno++; + len = strlen(buffer); + if (buffer[len-1] == '\n') + buffer[--len] = 0; + if (buffer[0] != ':') + continue; + rc = ihex_readrec(&ihex, buffer); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: invalid record at line %d of \"%s\"\n", + progname, lineno, infile); + return -1; + } + else if (rc != ihex.cksum) { + avrdude_message(MSG_INFO, "%s: ERROR: checksum mismatch at line %d of \"%s\"\n", + progname, lineno, infile); + avrdude_message(MSG_INFO, "%s: checksum=0x%02x, computed checksum=0x%02x\n", + progname, ihex.cksum, rc); + return -1; + } + + switch (ihex.rectyp) { + case 0: /* data record */ + if (fileoffset != 0 && baseaddr < fileoffset) { + avrdude_message(MSG_INFO, "%s: ERROR: address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n", + progname, baseaddr, fileoffset, lineno, infile); + return -1; + } + nextaddr = ihex.loadofs + baseaddr - fileoffset; + if (nextaddr + ihex.reclen > bufsize) { + avrdude_message(MSG_INFO, "%s: ERROR: address 0x%04x out of range at line %d of %s\n", + progname, nextaddr+ihex.reclen, lineno, infile); + return -1; + } + for (i=0; ibuf[nextaddr+i] = ihex.data[i]; + mem->tags[nextaddr+i] = TAG_ALLOCATED; + } + if (nextaddr+ihex.reclen > maxaddr) + maxaddr = nextaddr+ihex.reclen; + break; + + case 1: /* end of file record */ + return maxaddr; + break; + + case 2: /* extended segment address record */ + baseaddr = (ihex.data[0] << 8 | ihex.data[1]) << 4; + break; + + case 3: /* start segment address record */ + /* we don't do anything with the start address */ + break; + + case 4: /* extended linear address record */ + baseaddr = (ihex.data[0] << 8 | ihex.data[1]) << 16; + break; + + case 5: /* start linear address record */ + /* we don't do anything with the start address */ + break; + + default: + avrdude_message(MSG_INFO, "%s: don't know how to deal with rectype=%d " + "at line %d of %s\n", + progname, ihex.rectyp, lineno, infile); + return -1; + break; + } + + } /* while */ + + if (maxaddr == 0) { + avrdude_message(MSG_INFO, "%s: ERROR: No valid record found in Intel Hex " + "file \"%s\"\n", + progname, infile); + + return -1; + } + else { + avrdude_message(MSG_INFO, "%s: WARNING: no end of file record found for Intel Hex " + "file \"%s\"\n", + progname, infile); + + return maxaddr; + } +} + +static int b2srec(unsigned char * inbuf, int bufsize, + int recsize, int startaddr, + char * outfile, FILE * outf) +{ + unsigned char * buf; + unsigned int nextaddr; + int n, nbytes, addr_width; + int i; + unsigned char cksum; + + char * tmpl=0; + + if (recsize > 255) { + avrdude_message(MSG_INFO, "%s: ERROR: recsize=%d, must be < 256\n", + progname, recsize); + return -1; + } + + nextaddr = startaddr; + buf = inbuf; + nbytes = 0; + + addr_width = 0; + + while (bufsize) { + + n = recsize; + + if (n > bufsize) + n = bufsize; + + if (n) { + cksum = 0; + if (nextaddr + n <= 0xffff) { + addr_width = 2; + tmpl="S1%02X%04X"; + } + else if (nextaddr + n <= 0xffffff) { + addr_width = 3; + tmpl="S2%02X%06X"; + } + else if (nextaddr + n <= 0xffffffff) { + addr_width = 4; + tmpl="S3%02X%08X"; + } + else { + avrdude_message(MSG_INFO, "%s: ERROR: address=%d, out of range\n", + progname, nextaddr); + return -1; + } + + fprintf(outf, tmpl, n + addr_width + 1, nextaddr); + + cksum += n + addr_width + 1; + + for (i=addr_width; i>0; i--) + cksum += (nextaddr >> (i-1) * 8) & 0xff; + + for (i=nextaddr; i0; i--) + cksum += (nextaddr >> (i - 1) * 8) & 0xff; + cksum = 0xff - cksum; + fprintf(outf, "%02X\n", cksum); + + return nbytes; +} + + +static int srec_readrec(struct ihexrec * srec, char * rec) +{ + int i, j; + char buf[8]; + int offset, len, addr_width; + char * e; + unsigned char cksum; + int rc; + + len = strlen(rec); + offset = 1; + cksum = 0; + addr_width = 2; + + /* record type */ + if (offset + 1 > len) + return -1; + srec->rectyp = rec[offset++]; + if (srec->rectyp == 0x32 || srec->rectyp == 0x38) + addr_width = 3; /* S2,S8-record */ + else if (srec->rectyp == 0x33 || srec->rectyp == 0x37) + addr_width = 4; /* S3,S7-record */ + + /* reclen */ + if (offset + 2 > len) + return -1; + for (i=0; i<2; i++) + buf[i] = rec[offset++]; + buf[i] = 0; + srec->reclen = strtoul(buf, &e, 16); + cksum += srec->reclen; + srec->reclen -= (addr_width+1); + if (e == buf || *e != 0) + return -1; + + /* load offset */ + if (offset + addr_width > len) + return -1; + for (i=0; iloadofs = strtoull(buf, &e, 16); + if (e == buf || *e != 0) + return -1; + + for (i=addr_width; i>0; i--) + cksum += (srec->loadofs >> (i - 1) * 8) & 0xff; + + /* data */ + for (j=0; jreclen; j++) { + if (offset+2 > len) + return -1; + for (i=0; i<2; i++) + buf[i] = rec[offset++]; + buf[i] = 0; + srec->data[j] = strtoul(buf, &e, 16); + if (e == buf || *e != 0) + return -1; + cksum += srec->data[j]; + } + + /* cksum */ + if (offset + 2 > len) + return -1; + for (i=0; i<2; i++) + buf[i] = rec[offset++]; + buf[i] = 0; + srec->cksum = strtoul(buf, &e, 16); + if (e == buf || *e != 0) + return -1; + + rc = 0xff - cksum; + return rc; +} + + +static int srec2b(char * infile, FILE * inf, + AVRMEM * mem, int bufsize, unsigned int fileoffset) +{ + char buffer [ MAX_LINE_LEN ]; + unsigned int nextaddr, maxaddr; + int i; + int lineno; + int len; + struct ihexrec srec; + int rc; + int reccount; + unsigned char datarec; + + char * msg = 0; + + lineno = 0; + maxaddr = 0; + reccount = 0; + + while (fgets((char *)buffer,MAX_LINE_LEN,inf)!=NULL) { + lineno++; + len = strlen(buffer); + if (buffer[len-1] == '\n') + buffer[--len] = 0; + if (buffer[0] != 0x53) + continue; + rc = srec_readrec(&srec, buffer); + + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: ERROR: invalid record at line %d of \"%s\"\n", + progname, lineno, infile); + return -1; + } + else if (rc != srec.cksum) { + avrdude_message(MSG_INFO, "%s: ERROR: checksum mismatch at line %d of \"%s\"\n", + progname, lineno, infile); + avrdude_message(MSG_INFO, "%s: checksum=0x%02x, computed checksum=0x%02x\n", + progname, srec.cksum, rc); + return -1; + } + + datarec=0; + switch (srec.rectyp) { + case 0x30: /* S0 - header record*/ + /* skip */ + break; + + case 0x31: /* S1 - 16 bit address data record */ + datarec=1; + msg="%s: ERROR: address 0x%04x out of range %sat line %d of %s\n"; + break; + + case 0x32: /* S2 - 24 bit address data record */ + datarec=1; + msg="%s: ERROR: address 0x%06x out of range %sat line %d of %s\n"; + break; + + case 0x33: /* S3 - 32 bit address data record */ + datarec=1; + msg="%s: ERROR: address 0x%08x out of range %sat line %d of %s\n"; + break; + + case 0x34: /* S4 - symbol record (LSI extension) */ + avrdude_message(MSG_INFO, "%s: ERROR: not supported record at line %d of %s\n", + progname, lineno, infile); + return -1; + + case 0x35: /* S5 - count of S1,S2 and S3 records previously tx'd */ + if (srec.loadofs != reccount){ + avrdude_message(MSG_INFO, "%s: ERROR: count of transmitted data records mismatch " + "at line %d of \"%s\"\n", + progname, lineno, infile); + avrdude_message(MSG_INFO, "%s: transmitted data records= %d, expected " + "value= %d\n", + progname, reccount, srec.loadofs); + return -1; + } + break; + + case 0x37: /* S7 Record - end record for 32 bit address data */ + case 0x38: /* S8 Record - end record for 24 bit address data */ + case 0x39: /* S9 Record - end record for 16 bit address data */ + return maxaddr; + + default: + avrdude_message(MSG_INFO, "%s: ERROR: don't know how to deal with rectype S%d " + "at line %d of %s\n", + progname, srec.rectyp, lineno, infile); + return -1; + } + + if (datarec == 1) { + nextaddr = srec.loadofs; + if (nextaddr < fileoffset) { + avrdude_message(MSG_INFO, msg, progname, nextaddr, + "(below fileoffset) ", + lineno, infile); + return -1; + } + nextaddr -= fileoffset; + if (nextaddr + srec.reclen > bufsize) { + avrdude_message(MSG_INFO, msg, progname, nextaddr+srec.reclen, "", + lineno, infile); + return -1; + } + for (i=0; ibuf[nextaddr+i] = srec.data[i]; + mem->tags[nextaddr+i] = TAG_ALLOCATED; + } + if (nextaddr+srec.reclen > maxaddr) + maxaddr = nextaddr+srec.reclen; + reccount++; + } + + } + + avrdude_message(MSG_INFO, "%s: WARNING: no end of file record found for Motorola S-Records " + "file \"%s\"\n", + progname, infile); + + return maxaddr; +} + +#ifdef HAVE_LIBELF +/* + * Determine whether the ELF file section pointed to by `sh' fits + * completely into the program header segment pointed to by `ph'. + * + * Assumes the section has been checked already before to actually + * contain data (SHF_ALLOC, SHT_PROGBITS, sh_size > 0). + * + * Sometimes, program header segments might be larger than the actual + * file sections. On VM architectures, this is used to allow mmapping + * 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) +{ + if (sh->sh_offset < ph->p_offset) + return 0; + if (sh->sh_offset + sh->sh_size > ph->p_offset + ph->p_filesz) + return 0; + return 1; +} + +/* + * Return the ELF section descriptor that corresponds to program + * header `ph'. The program header is expected to be of p_type + * PT_LOAD, and to have a nonzero p_filesz. (PT_LOAD sections with a + * zero p_filesz are typically RAM sections that are not initialized + * by file data, e.g. ".bss".) + */ +static Elf_Scn *elf_get_scn(Elf *e, Elf32_Phdr *ph, Elf32_Shdr **shptr) +{ + Elf_Scn *s = NULL; + + while ((s = elf_nextscn(e, s)) != NULL) { + Elf32_Shdr *sh; + size_t ndx = elf_ndxscn(s); + if ((sh = elf32_getshdr(s)) == NULL) { + avrdude_message(MSG_INFO, "%s: ERROR: Error reading section #%u header: %s\n", + progname, (unsigned int)ndx, elf_errmsg(-1)); + continue; + } + if ((sh->sh_flags & SHF_ALLOC) == 0 || + sh->sh_type != SHT_PROGBITS) + /* we are only interested in PROGBITS, ALLOC sections */ + continue; + if (sh->sh_size == 0) + /* we are not interested in empty sections */ + continue; + if (is_section_in_segment(sh, ph)) { + /* yeah, we found it */ + *shptr = sh; + return s; + } + } + + avrdude_message(MSG_INFO, "%s: ERROR: Cannot find a matching section for " + "program header entry @p_vaddr 0x%x\n", + progname, ph->p_vaddr); + return NULL; +} + +static int elf_mem_limits(AVRMEM *mem, struct avrpart * p, + unsigned int *lowbound, + unsigned int *highbound, + unsigned int *fileoff) +{ + int rv = 0; + + if (p->flags & AVRPART_AVR32) { + if (strcmp(mem->desc, "flash") == 0) { + *lowbound = 0x80000000; + *highbound = 0xffffffff; + *fileoff = 0; + } else { + rv = -1; + } + } else { + if (strcmp(mem->desc, "flash") == 0 || + strcmp(mem->desc, "boot") == 0 || + strcmp(mem->desc, "application") == 0 || + strcmp(mem->desc, "apptable") == 0) { + *lowbound = 0; + *highbound = 0x7ffff; /* max 8 MiB */ + *fileoff = 0; + } else if (strcmp(mem->desc, "eeprom") == 0) { + *lowbound = 0x810000; + *highbound = 0x81ffff; /* max 64 KiB */ + *fileoff = 0; + } else if (strcmp(mem->desc, "lfuse") == 0) { + *lowbound = 0x820000; + *highbound = 0x82ffff; + *fileoff = 0; + } else if (strcmp(mem->desc, "hfuse") == 0) { + *lowbound = 0x820000; + *highbound = 0x82ffff; + *fileoff = 1; + } else if (strcmp(mem->desc, "efuse") == 0) { + *lowbound = 0x820000; + *highbound = 0x82ffff; + *fileoff = 2; + } else if (strncmp(mem->desc, "fuse", 4) == 0 && + (mem->desc[4] >= '0' && mem->desc[4] <= '9')) { + /* Xmega fuseN */ + *lowbound = 0x820000; + *highbound = 0x82ffff; + *fileoff = mem->desc[4] - '0'; + } else if (strncmp(mem->desc, "lock", 4) == 0) { + *lowbound = 0x830000; + *highbound = 0x83ffff; + *fileoff = 0; + } else { + rv = -1; + } + } + + return rv; +} + + +static int elf2b(char * infile, FILE * inf, + AVRMEM * mem, struct avrpart * p, + int bufsize, unsigned int fileoffset) +{ + Elf *e; + int rv = -1; + unsigned int low, high, foff; + + if (elf_mem_limits(mem, p, &low, &high, &foff) != 0) { + avrdude_message(MSG_INFO, "%s: ERROR: Cannot handle \"%s\" memory region from ELF file\n", + progname, mem->desc); + return -1; + } + + /* + * The Xmega memory regions for "boot", "application", and + * "apptable" are actually sub-regions of "flash". Refine the + * applicable limits. This allows to select only the appropriate + * sections out of an ELF file that contains section data for more + * than one sub-segment. + */ + if ((p->flags & AVRPART_HAS_PDI) != 0 && + (strcmp(mem->desc, "boot") == 0 || + strcmp(mem->desc, "application") == 0 || + strcmp(mem->desc, "apptable") == 0)) { + AVRMEM *flashmem = avr_locate_mem(p, "flash"); + if (flashmem == NULL) { + avrdude_message(MSG_INFO, "%s: ERROR: No \"flash\" memory region found, " + "cannot compute bounds of \"%s\" sub-region.\n", + progname, mem->desc); + return -1; + } + /* The config file offsets are PDI offsets, rebase to 0. */ + low = mem->offset - flashmem->offset; + high = low + mem->size - 1; + } + + if (elf_version(EV_CURRENT) == EV_NONE) { + avrdude_message(MSG_INFO, "%s: ERROR: ELF library initialization failed: %s\n", + progname, elf_errmsg(-1)); + return -1; + } + if ((e = elf_begin(fileno(inf), ELF_C_READ, NULL)) == NULL) { + avrdude_message(MSG_INFO, "%s: ERROR: Cannot open \"%s\" as an ELF file: %s\n", + progname, infile, elf_errmsg(-1)); + return -1; + } + if (elf_kind(e) != ELF_K_ELF) { + avrdude_message(MSG_INFO, "%s: ERROR: Cannot use \"%s\" as an ELF input file\n", + progname, infile); + goto done; + } + + size_t i, isize; + const char *id = elf_getident(e, &isize); + + if (id == NULL) { + avrdude_message(MSG_INFO, "%s: ERROR: Error reading ident area of \"%s\": %s\n", + progname, infile, elf_errmsg(-1)); + goto done; + } + + const char *endianname; + unsigned char endianess; + if (p->flags & AVRPART_AVR32) { + endianess = ELFDATA2MSB; + endianname = "little"; + } else { + endianess = ELFDATA2LSB; + endianname = "big"; + } + if (id[EI_CLASS] != ELFCLASS32 || + id[EI_DATA] != endianess) { + avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" is not a " + "32-bit, %s-endian file that was expected\n", + progname, infile, endianname); + goto done; + } + + Elf32_Ehdr *eh; + if ((eh = elf32_getehdr(e)) == NULL) { + avrdude_message(MSG_INFO, "%s: ERROR: Error reading ehdr of \"%s\": %s\n", + progname, infile, elf_errmsg(-1)); + goto done; + } + + if (eh->e_type != ET_EXEC) { + avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" is not an executable file\n", + progname, infile); + goto done; + } + + const char *mname; + uint16_t machine; + if (p->flags & AVRPART_AVR32) { + machine = EM_AVR32; + mname = "AVR32"; + } else { + machine = EM_AVR; + mname = "AVR"; + } + if (eh->e_machine != machine) { + avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" is not for machine %s\n", + progname, infile, mname); + goto done; + } + if (eh->e_phnum == 0xffff /* PN_XNUM */) { + avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" uses extended " + "program header numbers which are not expected\n", + progname, infile); + goto done; + } + + Elf32_Phdr *ph; + if ((ph = elf32_getphdr(e)) == NULL) { + avrdude_message(MSG_INFO, "%s: ERROR: Error reading program header table of \"%s\": %s\n", + progname, infile, elf_errmsg(-1)); + goto done; + } + + size_t sndx; + if (elf_getshdrstrndx(e, &sndx) != 0) { + avrdude_message(MSG_INFO, "%s: ERROR: Error obtaining section name string table: %s\n", + progname, elf_errmsg(-1)); + sndx = 0; + } + + /* + * Walk the program header table, pick up entries that are of type + * PT_LOAD, and have a non-zero p_filesz. + */ + for (i = 0; i < eh->e_phnum; i++) { + if (ph[i].p_type != PT_LOAD || + ph[i].p_filesz == 0) + continue; + + avrdude_message(MSG_NOTICE2, "%s: Considering PT_LOAD program header entry #%d:\n" + " p_vaddr 0x%x, p_paddr 0x%x, p_filesz %d\n", + progname, i, ph[i].p_vaddr, ph[i].p_paddr, ph[i].p_filesz); + + Elf32_Shdr *sh; + Elf_Scn *s = elf_get_scn(e, ph + i, &sh); + if (s == NULL) + continue; + + if ((sh->sh_flags & SHF_ALLOC) && sh->sh_size) { + const char *sname; + + if (sndx != 0) { + sname = elf_strptr(e, sndx, sh->sh_name); + } else { + sname = "*unknown*"; + } + + unsigned int lma; + lma = ph[i].p_paddr + sh->sh_offset - ph[i].p_offset; + + avrdude_message(MSG_NOTICE2, "%s: Found section \"%s\", LMA 0x%x, sh_size %u\n", + progname, sname, lma, sh->sh_size); + + if (lma >= low && + lma + sh->sh_size < high) { + /* OK */ + } else { + avrdude_message(MSG_NOTICE2, " => skipping, inappropriate for \"%s\" memory region\n", + mem->desc); + continue; + } + /* + * 1-byte sized memory regions are special: they are used for fuse + * bits, where multiple regions (in the config file) map to a + * single, larger region in the ELF file (e.g. "lfuse", "hfuse", + * and "efuse" all map to ".fuse"). We silently accept a larger + * ELF file region for these, and extract the actual byte to write + * from it, using the "foff" offset obtained above. + */ + if (mem->size != 1 && + sh->sh_size > mem->size) { + avrdude_message(MSG_INFO, "%s: ERROR: section \"%s\" does not fit into \"%s\" memory:\n" + " 0x%x + %u > %u\n", + progname, sname, mem->desc, + lma, sh->sh_size, mem->size); + continue; + } + + Elf_Data *d = NULL; + while ((d = elf_getdata(s, d)) != NULL) { + avrdude_message(MSG_NOTICE2, " Data block: d_buf %p, d_off 0x%x, d_size %d\n", + d->d_buf, (unsigned int)d->d_off, d->d_size); + if (mem->size == 1) { + if (d->d_off != 0) { + avrdude_message(MSG_INFO, "%s: ERROR: unexpected data block at offset != 0\n", + progname); + } else if (foff >= d->d_size) { + avrdude_message(MSG_INFO, "%s: ERROR: ELF file section does not contain byte at offset %d\n", + progname, foff); + } else { + avrdude_message(MSG_NOTICE2, " Extracting one byte from file offset %d\n", + foff); + mem->buf[0] = ((unsigned char *)d->d_buf)[foff]; + mem->tags[0] = TAG_ALLOCATED; + rv = 1; + } + } else { + unsigned int idx; + + idx = lma - low + d->d_off; + if ((int)(idx + d->d_size) > rv) + rv = idx + d->d_size; + avrdude_message(MSG_DEBUG, " Writing %d bytes to mem offset 0x%x\n", + d->d_size, idx); + memcpy(mem->buf + idx, d->d_buf, d->d_size); + memset(mem->tags + idx, TAG_ALLOCATED, d->d_size); + } + } + } + } +done: + (void)elf_end(e); + return rv; +} +#endif /* HAVE_LIBELF */ + +/* + * Simple itoa() implementation. Caller needs to allocate enough + * space in buf. Only positive integers are handled. + */ +static char *itoa_simple(int n, char *buf, int base) +{ + div_t q; + char c, *cp, *cp2; + + cp = buf; + /* + * Divide by base until the number disappeared, but ensure at least + * one digit will be emitted. + */ + do { + q = div(n, base); + n = q.quot; + if (q.rem >= 10) + c = q.rem - 10 + 'a'; + else + c = q.rem + '0'; + *cp++ = c; + } while (q.quot != 0); + + /* Terminate the string. */ + *cp-- = '\0'; + + /* Now revert the result string. */ + cp2 = buf; + while (cp > cp2) { + c = *cp; + *cp-- = *cp2; + *cp2++ = c; + } + + return buf; +} + + + +static int fileio_rbin(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, int size) +{ + int rc; + unsigned char *buf = mem->buf; + + switch (fio->op) { + case FIO_READ: + rc = fread(buf, 1, size, f); + if (rc > 0) + memset(mem->tags, TAG_ALLOCATED, rc); + break; + case FIO_WRITE: + rc = fwrite(buf, 1, size, f); + break; + default: + avrdude_message(MSG_INFO, "%s: fileio: invalid operation=%d\n", + progname, fio->op); + return -1; + } + + if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) { + avrdude_message(MSG_INFO, "%s: %s error %s %s: %s; %s %d of the expected %d bytes\n", + progname, fio->iodesc, fio->dir, filename, strerror(errno), + fio->rw, rc, size); + return -1; + } + + return rc; +} + + +static int fileio_imm(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, int size) +{ + int rc = 0; + char * e, * p; + unsigned long b; + int loc; + + switch (fio->op) { + case FIO_READ: + loc = 0; + p = strtok(filename, " ,"); + while (p != NULL && loc < size) { + b = strtoul(p, &e, 0); + /* check for binary formated (0b10101001) strings */ + b = (strncmp (p, "0b", 2))? + strtoul (p, &e, 0): + strtoul (p + 2, &e, 2); + if (*e != 0) { + avrdude_message(MSG_INFO, "%s: invalid byte value (%s) specified for immediate mode\n", + progname, p); + return -1; + } + mem->buf[loc] = b; + mem->tags[loc++] = TAG_ALLOCATED; + p = strtok(NULL, " ,"); + rc = loc; + } + break; + default: + avrdude_message(MSG_INFO, "%s: fileio: invalid operation=%d\n", + progname, fio->op); + return -1; + } + + if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) { + avrdude_message(MSG_INFO, "%s: %s error %s %s: %s; %s %d of the expected %d bytes\n", + progname, fio->iodesc, fio->dir, filename, strerror(errno), + fio->rw, rc, size); + return -1; + } + + return rc; +} + + +static int fileio_ihex(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, int size) +{ + int rc; + + switch (fio->op) { + case FIO_WRITE: + rc = b2ihex(mem->buf, size, 32, fio->fileoffset, filename, f); + if (rc < 0) { + return -1; + } + break; + + case FIO_READ: + rc = ihex2b(filename, f, mem, size, fio->fileoffset); + if (rc < 0) + return -1; + break; + + default: + avrdude_message(MSG_INFO, "%s: invalid Intex Hex file I/O operation=%d\n", + progname, fio->op); + return -1; + break; + } + + return rc; +} + + +static int fileio_srec(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, int size) +{ + int rc; + + switch (fio->op) { + case FIO_WRITE: + rc = b2srec(mem->buf, size, 32, fio->fileoffset, filename, f); + if (rc < 0) { + return -1; + } + break; + + case FIO_READ: + rc = srec2b(filename, f, mem, size, fio->fileoffset); + if (rc < 0) + return -1; + break; + + default: + avrdude_message(MSG_INFO, "%s: ERROR: invalid Motorola S-Records file I/O " + "operation=%d\n", + progname, fio->op); + return -1; + break; + } + + return rc; +} + + +#ifdef HAVE_LIBELF +static int fileio_elf(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, + struct avrpart * p, int size) +{ + int rc; + + switch (fio->op) { + case FIO_WRITE: + avrdude_message(MSG_INFO, "%s: ERROR: write operation not (yet) " + "supported for ELF\n", + progname); + return -1; + break; + + case FIO_READ: + rc = elf2b(filename, f, mem, p, size, fio->fileoffset); + return rc; + + default: + avrdude_message(MSG_INFO, "%s: ERROR: invalid ELF file I/O " + "operation=%d\n", + progname, fio->op); + return -1; + break; + } +} + +#endif + +static int fileio_num(struct fioparms * fio, + char * filename, FILE * f, AVRMEM * mem, int size, + FILEFMT fmt) +{ + const char *prefix; + char cbuf[20]; + int base, i, num; + + switch (fmt) { + case FMT_HEX: + prefix = "0x"; + base = 16; + break; + + default: + case FMT_DEC: + prefix = ""; + base = 10; + break; + + case FMT_OCT: + prefix = "0"; + base = 8; + break; + + case FMT_BIN: + prefix = "0b"; + base = 2; + break; + + } + + switch (fio->op) { + case FIO_WRITE: + break; + default: + avrdude_message(MSG_INFO, "%s: fileio: invalid operation=%d\n", + progname, fio->op); + return -1; + } + + for (i = 0; i < size; i++) { + if (i > 0) { + if (putc(',', f) == EOF) + goto writeerr; + } + num = (unsigned int)(mem->buf[i]); + /* + * For a base of 8 and a value < 8 to convert, don't write the + * prefix. The conversion will be indistinguishable from a + * decimal one then. + */ + if (prefix[0] != '\0' && !(base == 8 && num < 8)) { + if (fputs(prefix, f) == EOF) + goto writeerr; + } + itoa_simple(num, cbuf, base); + if (fputs(cbuf, f) == EOF) + goto writeerr; + } + if (putc('\n', f) == EOF) + goto writeerr; + + return 0; + + writeerr: + avrdude_message(MSG_INFO, "%s: error writing to %s: %s\n", + progname, filename, strerror(errno)); + return -1; +} + + +int fileio_setparms(int op, struct fioparms * fp, + struct avrpart * p, AVRMEM * m) +{ + fp->op = op; + + switch (op) { + case FIO_READ: + fp->mode = "r"; + fp->iodesc = "input"; + fp->dir = "from"; + fp->rw = "read"; + break; + + case FIO_WRITE: + fp->mode = "w"; + fp->iodesc = "output"; + fp->dir = "to"; + fp->rw = "wrote"; + break; + + default: + avrdude_message(MSG_INFO, "%s: invalid I/O operation %d\n", + progname, op); + return -1; + break; + } + + /* + * AVR32 devices maintain their load offset within the file itself, + * but AVRDUDE maintains all memory images 0-based. + */ + if ((p->flags & AVRPART_AVR32) != 0) + { + fp->fileoffset = m->offset; + } + else + { + fp->fileoffset = 0; + } + + return 0; +} + + + +static int fmt_autodetect(char * fname) +{ + FILE * f; + unsigned char buf[MAX_LINE_LEN]; + int i; + int len; + int found; + int first = 1; + +#if defined(WIN32NATIVE) + f = fopen(fname, "r"); +#else + f = fopen(fname, "rb"); +#endif + if (f == NULL) { + avrdude_message(MSG_INFO, "%s: error opening %s: %s\n", + progname, fname, strerror(errno)); + return -1; + } + + while (fgets((char *)buf, MAX_LINE_LEN, f)!=NULL) { + /* check for ELF file */ + if (first && + (buf[0] == 0177 && buf[1] == 'E' && + buf[2] == 'L' && buf[3] == 'F')) { + fclose(f); + return FMT_ELF; + } + + buf[MAX_LINE_LEN-1] = 0; + len = strlen((char *)buf); + if (buf[len-1] == '\n') + buf[--len] = 0; + + /* check for binary data */ + found = 0; + for (i=0; i 127) { + found = 1; + break; + } + } + if (found) { + fclose(f); + return FMT_RBIN; + } + + /* check for lines that look like intel hex */ + if ((buf[0] == ':') && (len >= 11)) { + found = 1; + for (i=1; i= 10) && isdigit(buf[1])) { + found = 1; + for (i=1; idesc); + return -1; + } + + rc = fileio_setparms(op, &fio, p, mem); + if (rc < 0) + return -1; + + if (fio.op == FIO_READ) + size = mem->size; + + if (fio.op == FIO_READ) { + /* 0xff fill unspecified memory */ + memset(mem->buf, 0xff, size); + } + memset(mem->tags, 0, size); + + using_stdio = 0; + + if (strcmp(filename, "-")==0) { + if (fio.op == FIO_READ) { + fname = ""; + f = stdin; + } + else { + fname = ""; + f = stdout; + } + using_stdio = 1; + } + else { + fname = filename; + f = NULL; + } + + if (format == FMT_AUTO) { + int format_detect; + + if (using_stdio) { + avrdude_message(MSG_INFO, "%s: can't auto detect file format when using stdin/out.\n" + "%s Please specify a file format and try again.\n", + progname, progbuf); + return -1; + } + + format_detect = fmt_autodetect(fname); + if (format_detect < 0) { + avrdude_message(MSG_INFO, "%s: can't determine file format for %s, specify explicitly\n", + progname, fname); + return -1; + } + format = format_detect; + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: %s file %s auto detected as %s\n", + progname, fio.iodesc, fname, fmtstr(format)); + } + } + +#if defined(WIN32NATIVE) + /* Open Raw Binary and ELF format in binary mode on Windows.*/ + if(format == FMT_RBIN || format == FMT_ELF) + { + if(fio.op == FIO_READ) + { + fio.mode = "rb"; + } + if(fio.op == FIO_WRITE) + { + fio.mode = "wb"; + } + } +#endif + + if (format != FMT_IMM) { + if (!using_stdio) { + f = fopen(fname, fio.mode); + if (f == NULL) { + avrdude_message(MSG_INFO, "%s: can't open %s file %s: %s\n", + progname, fio.iodesc, fname, strerror(errno)); + return -1; + } + } + } + + switch (format) { + case FMT_IHEX: + rc = fileio_ihex(&fio, fname, f, mem, size); + break; + + case FMT_SREC: + rc = fileio_srec(&fio, fname, f, mem, size); + break; + + case FMT_RBIN: + rc = fileio_rbin(&fio, fname, f, mem, size); + break; + + case FMT_ELF: +#ifdef HAVE_LIBELF + rc = fileio_elf(&fio, fname, f, mem, p, size); +#else + avrdude_message(MSG_INFO, "%s: can't handle ELF file %s, " + "ELF file support was not compiled in\n", + progname, fname); + rc = -1; +#endif + break; + + case FMT_IMM: + rc = fileio_imm(&fio, fname, f, mem, size); + break; + + case FMT_HEX: + case FMT_DEC: + case FMT_OCT: + case FMT_BIN: + rc = fileio_num(&fio, fname, f, mem, size, format); + break; + + default: + avrdude_message(MSG_INFO, "%s: invalid %s file format: %d\n", + progname, fio.iodesc, format); + return -1; + } + + if (rc > 0) { + if ((op == FIO_READ) && (strcasecmp(mem->desc, "flash") == 0 || + strcasecmp(mem->desc, "application") == 0 || + strcasecmp(mem->desc, "apptable") == 0 || + strcasecmp(mem->desc, "boot") == 0)) { + /* + * if we are reading flash, just mark the size as being the + * highest non-0xff byte + */ + rc = avr_mem_hiaddr(mem); + } + } + if (format != FMT_IMM && !using_stdio) { + fclose(f); + } + + return rc; +} + diff --git a/xs/src/avrdude/flip1.c b/xs/src/avrdude/flip1.c new file mode 100644 index 000000000..220a94266 --- /dev/null +++ b/xs/src/avrdude/flip1.c @@ -0,0 +1,949 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2014 Joerg Wunsch + * + * This implementation has been cloned from FLIPv2 implementation + * written by Kirill Levchenko. + * + * 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 "ac_cfg.h" + +#include +#include +#include +#include +#include +#include + +#if HAVE_STDINT_H +#include +#elif HAVE_INTTYPES_H +#include +#endif + + +#include "avrdude.h" +#include "libavrdude.h" + +#include "flip1.h" +#include "dfu.h" +#include "usbdevs.h" /* for USB_VENDOR_ATMEL */ + +/* There are three versions of the FLIP protocol: + * + * Version 0: C51 parts + * Version 1: megaAVR parts ("USB DFU Bootloader Datasheet" [doc7618]) + * Version 2: XMEGA parts (AVR4023 [doc8457]) + * + * This implementation handles protocol version 1. + * + * Protocol version 1 has some, erm, "interesting" features: + * + * When contacting the fresh bootloader, the only allowed actions are + * requesting the configuration/manufacturer information (which is + * used to read the signature on AVRs), and to issue a "chip erase". + * All operations on flash and EEPROM are restricted before a chip + * erase has been seen (security protection). + * + * However, after the chip erase, the configuration/manufacturer + * information can no longer be obtained ... they all respond with + * 0xff. Essentially, the device needs a power cycle then, after + * which the only actual command to access is a chip erase. + * + * Quite cumbersome to the user. + */ + +/* EXPORTED CONSTANT STRINGS */ + +const char flip1_desc[] = "FLIP USB DFU protocol version 1 (doc7618)"; + +/* PRIVATE DATA STRUCTURES */ + +struct flip1 +{ + struct dfu_dev *dfu; + unsigned char part_sig[3]; + unsigned char part_rev; + unsigned char boot_ver; + unsigned char security_mode_flag; /* indicates the user has already + * been hinted about security + * mode */ +}; + +#define FLIP1(pgm) ((struct flip1 *)(pgm->cookie)) + +/* FLIP1 data structures and constants. */ + +struct flip1_cmd +{ + unsigned char cmd; + unsigned char args[5]; +}; + +struct flip1_cmd_header /* for memory read/write */ +{ + unsigned char cmd; + unsigned char memtype; + unsigned char start_addr[2]; + unsigned char end_addr[2]; + unsigned char padding[26]; +}; + +struct flip1_prog_footer +{ + unsigned char crc[4]; /* not really used */ + unsigned char ftr_length; /* 0x10 */ + unsigned char signature[3]; /* "DFU" */ + unsigned char bcdversion[2]; /* 0x01, 0x10 */ + unsigned char vendor[2]; /* or 0xff, 0xff */ + unsigned char product[2]; /* or 0xff, 0xff */ + unsigned char device[2]; /* or 0xff, 0xff */ +}; + +#define FLIP1_CMD_PROG_START 0x01 +#define FLIP1_CMD_DISPLAY_DATA 0x03 +#define FLIP1_CMD_WRITE_COMMAND 0x04 +#define FLIP1_CMD_READ_COMMAND 0x05 +#define FLIP1_CMD_CHANGE_BASE_ADDRESS 0x06 + +/* args[1:0] for FLIP1_CMD_READ_COMMAND */ +#define FLIP1_READ_BOOTLOADER_VERSION { 0x00, 0x00 } +#define FLIP1_READ_DEVICE_BOOT_ID1 { 0x00, 0x01 } +#define FLIP1_READ_DEVICE_BOOT_ID2 { 0x00, 0x02 } +#define FLIP1_READ_MANUFACTURER_CODE { 0x01, 0x30 } +#define FLIP1_READ_FAMILY_CODE { 0x01, 0x31 } +#define FLIP1_READ_PRODUCT_NAME { 0x01, 0x60 } +#define FLIP1_READ_PRODUCT_REVISION { 0x01, 0x61 } + +enum flip1_mem_unit { + FLIP1_MEM_UNIT_FLASH = 0x00, + FLIP1_MEM_UNIT_EEPROM = 0x01, + FLIP1_MEM_UNIT_UNKNOWN = -1 +}; + +#define STATE_dfuERROR 10 /* bState; requires a DFU_CLRSTATUS */ + +#define LONG_DFU_TIMEOUT 10000 /* 10 s for program and erase */ + +/* EXPORTED PROGRAMMER FUNCTION PROTOTYPES */ + +static int flip1_open(PROGRAMMER *pgm, char *port_spec); +static int flip1_initialize(PROGRAMMER* pgm, AVRPART *part); +static void flip1_close(PROGRAMMER* pgm); +static void flip1_enable(PROGRAMMER* pgm); +static void flip1_disable(PROGRAMMER* pgm); +static void flip1_display(PROGRAMMER* pgm, const char *prefix); +static int flip1_program_enable(PROGRAMMER* pgm, AVRPART *part); +static int flip1_chip_erase(PROGRAMMER* pgm, AVRPART *part); +static int flip1_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char *value); +static int flip1_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char value); +static int flip1_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes); +static int flip1_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes); +static int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem); +static void flip1_setup(PROGRAMMER * pgm); +static void flip1_teardown(PROGRAMMER * pgm); + +/* INTERNAL PROGRAMMER FUNCTION PROTOTYPES */ +#ifdef HAVE_LIBUSB +// The internal ones are made conditional, as they're not defined further down #ifndef HAVE_LIBUSB + +static void flip1_show_info(struct flip1 *flip1); + +static int flip1_read_memory(PROGRAMMER * pgm, + enum flip1_mem_unit mem_unit, uint32_t addr, void *ptr, int size); +static int flip1_write_memory(struct dfu_dev *dfu, + enum flip1_mem_unit mem_unit, uint32_t addr, const void *ptr, int size); + +static const char * flip1_status_str(const struct dfu_status *status); +static const char * flip1_mem_unit_str(enum flip1_mem_unit mem_unit); +static int flip1_set_mem_page(struct dfu_dev *dfu, unsigned short page_addr); +static enum flip1_mem_unit flip1_mem_unit(const char *name); + +#endif /* HAVE_LIBUSB */ + +/* THE INITPGM FUNCTION DEFINITIONS */ + +void flip1_initpgm(PROGRAMMER *pgm) +{ + strcpy(pgm->type, "flip1"); + + /* Mandatory Functions */ + pgm->initialize = flip1_initialize; + pgm->enable = flip1_enable; + pgm->disable = flip1_disable; + pgm->display = flip1_display; + pgm->program_enable = flip1_program_enable; + pgm->chip_erase = flip1_chip_erase; + pgm->open = flip1_open; + pgm->close = flip1_close; + pgm->paged_load = flip1_paged_load; + pgm->paged_write = flip1_paged_write; + pgm->read_byte = flip1_read_byte; + pgm->write_byte = flip1_write_byte; + pgm->read_sig_bytes = flip1_read_sig_bytes; + pgm->setup = flip1_setup; + pgm->teardown = flip1_teardown; +} + +#ifdef HAVE_LIBUSB +/* EXPORTED PROGRAMMER FUNCTION DEFINITIONS */ + +int flip1_open(PROGRAMMER *pgm, char *port_spec) +{ + FLIP1(pgm)->dfu = dfu_open(port_spec); + return (FLIP1(pgm)->dfu != NULL) ? 0 : -1; +} + +int flip1_initialize(PROGRAMMER* pgm, AVRPART *part) +{ + unsigned short vid, pid; + int result; + struct dfu_dev *dfu = FLIP1(pgm)->dfu; + + /* A note about return values. Negative return values from this function are + * interpreted as failure by main(), from where this function is called. + * However such failures are interpreted as a device signature check failure + * and the user is adviced to use the -F option to override this check. In + * our case, this is misleading, so we defer reporting an error until another + * function is called. Thus, we always return 0 (success) from initialize(). + * I don't like this, but I don't want to mess with main(). + */ + + /* The dfu_init() function will try to find the target part either based on + * a USB address provided by the user with the -P option or by matching the + * VID and PID of the device. The VID may be specified in the programmer + * definition; if not specified, it defaults to USB_VENDOR_ATMEL (defined + * in usbdevs.h). The PID may be specified either in the programmer + * definition or the part definition; the programmer definition takes + * priority. The default PID value is 0, which causes dfu_init() to ignore + * the PID when matching a target device. + */ + + vid = (pgm->usbvid != 0) ? pgm->usbvid : USB_VENDOR_ATMEL; + LNODEID usbpid = lfirst(pgm->usbpid); + if (usbpid) { + pid = *(int *)(ldata(usbpid)); + if (lnext(usbpid)) + avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n", + progname, pid); + } else { + pid = part->usbpid; + } + if (!ovsigck && (part->flags & AVRPART_HAS_PDI)) { + avrdude_message(MSG_INFO, "%s: \"flip1\" (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices.\n" + "%s For Xmega devices, use \"flip2\".\n" + "%s (Use -F to bypass this check.)\n", + progname, progbuf, progbuf); + return -1; + } + + result = dfu_init(FLIP1(pgm)->dfu, vid, pid); + + if (result != 0) + goto flip1_initialize_fail; + + /* Check if descriptor values are what we expect. */ + + if (dfu->dev_desc.idVendor != vid) + avrdude_message(MSG_INFO, "%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n", + progname, dfu->dev_desc.idVendor, vid); + + if (pid != 0 && dfu->dev_desc.idProduct != pid) + avrdude_message(MSG_INFO, "%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n", + progname, dfu->dev_desc.idProduct, pid); + + if (dfu->dev_desc.bNumConfigurations != 1) + avrdude_message(MSG_INFO, "%s: Warning: USB bNumConfigurations = %d (expected 1)\n", + progname, (int) dfu->dev_desc.bNumConfigurations); + + if (dfu->conf_desc.bNumInterfaces != 1) + avrdude_message(MSG_INFO, "%s: Warning: USB bNumInterfaces = %d (expected 1)\n", + progname, (int) dfu->conf_desc.bNumInterfaces); + + if (dfu->dev_desc.bDeviceClass != 254) + avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceClass = %d (expected 254)\n", + progname, (int) dfu->dev_desc.bDeviceClass); + + if (dfu->dev_desc.bDeviceSubClass != 1) + avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceSubClass = %d (expected 1)\n", + progname, (int) dfu->dev_desc.bDeviceSubClass); + + if (dfu->dev_desc.bDeviceProtocol != 0) + avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceProtocol = %d (expected 0)\n", + progname, (int) dfu->dev_desc.bDeviceProtocol); + + /* + * doc7618 claims an interface class of FEh and a subclas 01h. + * However, as of today (2014-01-16), all values in the interface + * descriptor (except of bLength and bDescriptorType) are actually + * 0. So rather don't check these. + */ + if (0) { + if (dfu->intf_desc.bInterfaceClass != 254) + avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceClass = %d (expected 254)\n", + progname, (int) dfu->intf_desc.bInterfaceClass); + + if (dfu->intf_desc.bInterfaceSubClass != 1) + avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 1)\n", + progname, (int) dfu->intf_desc.bInterfaceSubClass); + + if (dfu->intf_desc.bInterfaceProtocol != 0) + avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n", + progname, (int) dfu->intf_desc.bInterfaceProtocol); + } + + if (dfu->dev_desc.bMaxPacketSize0 != 32) + avrdude_message(MSG_INFO, "%s: Warning: bMaxPacketSize0 (%d) != 32, things might go wrong\n", + progname, dfu->dev_desc.bMaxPacketSize0); + + if (verbose) + flip1_show_info(FLIP1(pgm)); + + dfu_abort(dfu); + + return 0; + +flip1_initialize_fail: + dfu_close(FLIP1(pgm)->dfu); + FLIP1(pgm)->dfu = NULL; + return 0; +} + +void flip1_close(PROGRAMMER* pgm) +{ + if (FLIP1(pgm)->dfu != NULL) { + dfu_close(FLIP1(pgm)->dfu); + FLIP1(pgm)->dfu = NULL; + } +} + +void flip1_enable(PROGRAMMER* pgm) +{ + /* Nothing to do. */ +} + +void flip1_disable(PROGRAMMER* pgm) +{ + /* Nothing to do. */ +} + +void flip1_display(PROGRAMMER* pgm, const char *prefix) +{ + /* Nothing to do. */ +} + +int flip1_program_enable(PROGRAMMER* pgm, AVRPART *part) +{ + /* I couldn't find anything that uses this function, although it is marked + * as "mandatory" in pgm.c. In case anyone does use it, we'll report an + * error if we failed to initialize. + */ + + return (FLIP1(pgm)->dfu != NULL) ? 0 : -1; +} + +int flip1_chip_erase(PROGRAMMER* pgm, AVRPART *part) +{ + struct dfu_status status; + int cmd_result = 0; + int aux_result; + unsigned int default_timeout = FLIP1(pgm)->dfu->timeout; + + avrdude_message(MSG_NOTICE2, "%s: flip_chip_erase()\n", progname); + + struct flip1_cmd cmd = { + FLIP1_CMD_WRITE_COMMAND, { 0, 0xff } + }; + + FLIP1(pgm)->dfu->timeout = LONG_DFU_TIMEOUT; + cmd_result = dfu_dnload(FLIP1(pgm)->dfu, &cmd, 3); + aux_result = dfu_getstatus(FLIP1(pgm)->dfu, &status); + FLIP1(pgm)->dfu->timeout = default_timeout; + + if (cmd_result < 0 || aux_result < 0) + return -1; + + if (status.bStatus != DFU_STATUS_OK) { + avrdude_message(MSG_INFO, "%s: failed to send chip erase command: %s\n", + progname, flip1_status_str(&status)); + if (status.bState == STATE_dfuERROR) + dfu_clrstatus(FLIP1(pgm)->dfu); + return -1; + } + + return 0; +} + +int flip1_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char *value) +{ + enum flip1_mem_unit mem_unit; + + if (FLIP1(pgm)->dfu == NULL) + return -1; + + if (strcasecmp(mem->desc, "signature") == 0) { + if (flip1_read_sig_bytes(pgm, part, mem) < 0) + return -1; + if (addr > mem->size) { + avrdude_message(MSG_INFO, "%s: flip1_read_byte(signature): address %lu out of range\n", + progname, addr); + return -1; + } + *value = mem->buf[addr]; + return 0; + } + + mem_unit = flip1_mem_unit(mem->desc); + + if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) { + avrdude_message(MSG_INFO, "%s: Error: " + "\"%s\" memory not accessible using FLIP", + progname, mem->desc); + avrdude_message(MSG_INFO, "\n"); + return -1; + } + + if (mem_unit == FLIP1_MEM_UNIT_EEPROM) + /* 0x01 is used for blank check when reading, 0x02 is EEPROM */ + mem_unit = 2; + + return flip1_read_memory(pgm, mem_unit, addr, value, 1); +} + +int flip1_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char value) +{ + enum flip1_mem_unit mem_unit; + + if (FLIP1(pgm)->dfu == NULL) + return -1; + + mem_unit = flip1_mem_unit(mem->desc); + + if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) { + avrdude_message(MSG_INFO, "%s: Error: " + "\"%s\" memory not accessible using FLIP", + progname, mem->desc); + avrdude_message(MSG_INFO, "\n"); + return -1; + } + + return flip1_write_memory(FLIP1(pgm)->dfu, mem_unit, addr, &value, 1); +} + +int flip1_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + enum flip1_mem_unit mem_unit; + + if (FLIP1(pgm)->dfu == NULL) + return -1; + + mem_unit = flip1_mem_unit(mem->desc); + + if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) { + avrdude_message(MSG_INFO, "%s: Error: " + "\"%s\" memory not accessible using FLIP", + progname, mem->desc); + avrdude_message(MSG_INFO, "\n"); + return -1; + } + + if (mem_unit == FLIP1_MEM_UNIT_EEPROM) + /* 0x01 is used for blank check when reading, 0x02 is EEPROM */ + mem_unit = 2; + + return flip1_read_memory(pgm, mem_unit, addr, mem->buf + addr, n_bytes); +} + +int flip1_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + enum flip1_mem_unit mem_unit; + int result; + + if (FLIP1(pgm)->dfu == NULL) + return -1; + + mem_unit = flip1_mem_unit(mem->desc); + + if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) { + avrdude_message(MSG_INFO, "%s: Error: " + "\"%s\" memory not accessible using FLIP", + progname, mem->desc); + avrdude_message(MSG_INFO, "\n"); + return -1; + } + + if (n_bytes > INT_MAX) { + /* This should never happen, unless the int type is only 16 bits. */ + avrdude_message(MSG_INFO, "%s: Error: Attempting to read more than %d bytes\n", + progname, INT_MAX); + exit(1); + } + + result = flip1_write_memory(FLIP1(pgm)->dfu, mem_unit, addr, + mem->buf + addr, n_bytes); + + return (result == 0) ? n_bytes : -1; +} + +int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem) +{ + avrdude_message(MSG_NOTICE2, "%s: flip1_read_sig_bytes(): ", progname); + + if (FLIP1(pgm)->dfu == NULL) + return -1; + + if (mem->size < sizeof(FLIP1(pgm)->part_sig)) { + avrdude_message(MSG_INFO, "%s: Error: Signature read must be at least %u bytes\n", + progname, (unsigned int) sizeof(FLIP1(pgm)->part_sig)); + return -1; + } + + if (FLIP1(pgm)->part_sig[0] == 0 && + FLIP1(pgm)->part_sig[1] == 0 && + FLIP1(pgm)->part_sig[2] == 0) + { + /* signature not yet cached */ + struct dfu_status status; + int cmd_result = 0; + int aux_result; + int i; + struct flip1_cmd cmd = { + FLIP1_CMD_READ_COMMAND, FLIP1_READ_FAMILY_CODE + }; + + avrdude_message(MSG_NOTICE2, "from device\n"); + + for (i = 0; i < 3; i++) + { + if (i == 1) + cmd.args[1] = 0x60; /* product name */ + else if (i == 2) + cmd.args[1] = 0x61; /* product revision */ + + cmd_result = dfu_dnload(FLIP1(pgm)->dfu, &cmd, 3); + aux_result = dfu_getstatus(FLIP1(pgm)->dfu, &status); + + if (cmd_result < 0 || aux_result < 0) + return -1; + + if (status.bStatus != DFU_STATUS_OK) + { + avrdude_message(MSG_INFO, "%s: failed to send cmd for signature byte %d: %s\n", + progname, i, flip1_status_str(&status)); + if (status.bState == STATE_dfuERROR) + dfu_clrstatus(FLIP1(pgm)->dfu); + return -1; + } + + cmd_result = dfu_upload(FLIP1(pgm)->dfu, &(FLIP1(pgm)->part_sig[i]), 1); + aux_result = dfu_getstatus(FLIP1(pgm)->dfu, &status); + + if (cmd_result < 0 || aux_result < 0) + return -1; + + if (status.bStatus != DFU_STATUS_OK) + { + avrdude_message(MSG_INFO, "%s: failed to read signature byte %d: %s\n", + progname, i, flip1_status_str(&status)); + if (status.bState == STATE_dfuERROR) + dfu_clrstatus(FLIP1(pgm)->dfu); + return -1; + } + } + } + else + { + avrdude_message(MSG_NOTICE2, "cached\n"); + } + + memcpy(mem->buf, FLIP1(pgm)->part_sig, sizeof(FLIP1(pgm)->part_sig)); + + return 0; +} + +void flip1_setup(PROGRAMMER * pgm) +{ + pgm->cookie = calloc(1, sizeof(struct flip1)); + + if (pgm->cookie == NULL) { + avrdude_message(MSG_INFO, "%s: Out of memory allocating private data structure\n", + progname); + exit(1); + } +} + +void flip1_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); + pgm->cookie = NULL; +} + +/* INTERNAL FUNCTION DEFINITIONS + */ + +void flip1_show_info(struct flip1 *flip1) +{ + dfu_show_info(flip1->dfu); + avrdude_message(MSG_INFO, " USB max packet size : %hu\n", + (unsigned short) flip1->dfu->dev_desc.bMaxPacketSize0); +} + +int flip1_read_memory(PROGRAMMER * pgm, + enum flip1_mem_unit mem_unit, uint32_t addr, void *ptr, int size) +{ + struct dfu_dev *dfu = FLIP1(pgm)->dfu; + unsigned short page_addr; + struct dfu_status status; + int cmd_result = 0; + int aux_result; + struct flip1_cmd cmd = { + FLIP1_CMD_DISPLAY_DATA, { mem_unit } + }; + unsigned int default_timeout = dfu->timeout; + + + avrdude_message(MSG_NOTICE2, "%s: flip_read_memory(%s, 0x%04x, %d)\n", + progname, flip1_mem_unit_str(mem_unit), addr, size); + + /* + * As this function is called once per page, no need to handle 64 + * KiB border crossing below. + * + * Also, on AVRs, no page size is larger than 1 KiB, so no need to + * split the request into multiple 1 KiB chunks. + */ + if (mem_unit == FLIP1_MEM_UNIT_FLASH) { + page_addr = addr >> 16; + if (flip1_set_mem_page(dfu, page_addr) < 0) + return -1; + } + + cmd.args[1] = (addr >> 8) & 0xFF; + cmd.args[2] = addr & 0xFF; + cmd.args[3] = ((addr + size - 1) >> 8) & 0xFF; + cmd.args[4] = (addr + size - 1) & 0xFF; + + dfu->timeout = LONG_DFU_TIMEOUT; + cmd_result = dfu_dnload(dfu, &cmd, 6); + dfu->timeout = default_timeout; + aux_result = dfu_getstatus(dfu, &status); + + if (cmd_result < 0 || aux_result < 0) + return -1; + + if (status.bStatus != DFU_STATUS_OK) + { + avrdude_message(MSG_INFO, "%s: failed to read %u bytes of %s memory @%u: %s\n", + progname, size, flip1_mem_unit_str(mem_unit), addr, + flip1_status_str(&status)); + if (status.bState == STATE_dfuERROR) + dfu_clrstatus(dfu); + return -1; + } + + cmd_result = dfu_upload(dfu, (char*) ptr, size); + aux_result = dfu_getstatus(dfu, &status); + + if (cmd_result < 0 && aux_result == 0 && + status.bStatus == DFU_STATUS_ERR_WRITE) { + if (FLIP1(pgm)->security_mode_flag == 0) + avrdude_message(MSG_INFO, "\n%s:\n" + "%s***********************************************************************\n" + "%sMaybe the device is in ``security mode´´, and needs a chip erase first?\n" + "%s***********************************************************************\n" + "\n", + progname, progbuf, progbuf, progbuf); + FLIP1(pgm)->security_mode_flag = 1; + } + + if (cmd_result < 0 || aux_result < 0) + return -1; + + if (status.bStatus != DFU_STATUS_OK) + { + avrdude_message(MSG_INFO, "%s: failed to read %u bytes of %s memory @%u: %s\n", + progname, size, flip1_mem_unit_str(mem_unit), addr, + flip1_status_str(&status)); + if (status.bState == STATE_dfuERROR) + dfu_clrstatus(dfu); + return -1; + } + + return 0; +} + +int flip1_write_memory(struct dfu_dev *dfu, + enum flip1_mem_unit mem_unit, uint32_t addr, const void *ptr, int size) +{ + unsigned short page_addr; + int write_size; + struct dfu_status status; + int cmd_result = 0; + int aux_result; + struct flip1_cmd_header cmd_header = { + FLIP1_CMD_PROG_START, mem_unit + }; + struct flip1_prog_footer cmd_footer = { + { 0, 0, 0, 0 }, /* CRC */ + 0x10, /* footer length */ + { 'D', 'F', 'U' }, /* signature */ + { 0x01, 0x10 }, /* BCD version */ + { 0xff, 0xff }, /* vendor */ + { 0xff, 0xff }, /* product */ + { 0xff, 0xff } /* device */ + }; + unsigned int default_timeout = dfu->timeout; + unsigned char *buf; + + avrdude_message(MSG_NOTICE2, "%s: flip_write_memory(%s, 0x%04x, %d)\n", + progname, flip1_mem_unit_str(mem_unit), addr, size); + + if (size < 32) { + /* presumably single-byte updates; must be padded to USB endpoint size */ + if ((addr + size - 1) / 32 != addr / 32) { + avrdude_message(MSG_INFO, "%s: flip_write_memory(): begin (0x%x) and end (0x%x) not within same 32-byte block\n", + progname, addr, addr + size - 1); + return -1; + } + write_size = 32; + } else { + write_size = size; + } + + if ((buf = malloc(sizeof(struct flip1_cmd_header) + + write_size + + sizeof(struct flip1_prog_footer))) == 0) { + avrdude_message(MSG_INFO, "%s: Out of memory\n", progname); + return -1; + } + + /* + * As this function is called once per page, no need to handle 64 + * KiB border crossing below. + * + * Also, on AVRs, no page size is larger than 1 KiB, so no need to + * split the request into multiple 1 KiB chunks. + */ + if (mem_unit == FLIP1_MEM_UNIT_FLASH) { + page_addr = addr >> 16; + if (flip1_set_mem_page(dfu, page_addr) < 0) { + free(buf); + return -1; + } + } + + cmd_header.start_addr[0] = (addr >> 8) & 0xFF; + cmd_header.start_addr[1] = addr & 0xFF; + cmd_header.end_addr[0] = ((addr + size - 1) >> 8) & 0xFF; + cmd_header.end_addr[1] = (addr + size - 1) & 0xFF; + + memcpy(buf, &cmd_header, sizeof(struct flip1_cmd_header)); + if (size < 32) { + memset(buf + sizeof(struct flip1_cmd_header), 0xff, 32); + memcpy(buf + sizeof(struct flip1_cmd_header) + (addr % 32), ptr, size); + } else { + memcpy(buf + sizeof(struct flip1_cmd_header), ptr, size); + } + memcpy(buf + sizeof(struct flip1_cmd_header) + write_size, + &cmd_footer, sizeof(struct flip1_prog_footer)); + + dfu->timeout = LONG_DFU_TIMEOUT; + cmd_result = dfu_dnload(dfu, buf, + sizeof(struct flip1_cmd_header) + + write_size + + sizeof(struct flip1_prog_footer)); + aux_result = dfu_getstatus(dfu, &status); + dfu->timeout = default_timeout; + + free(buf); + + if (aux_result < 0 || cmd_result < 0) + return -1; + + if (status.bStatus != DFU_STATUS_OK) + { + avrdude_message(MSG_INFO, "%s: failed to write %u bytes of %s memory @%u: %s\n", + progname, size, flip1_mem_unit_str(mem_unit), addr, + flip1_status_str(&status)); + if (status.bState == STATE_dfuERROR) + dfu_clrstatus(dfu); + return -1; + } + + return 0; +} + +int flip1_set_mem_page(struct dfu_dev *dfu, + unsigned short page_addr) +{ + struct dfu_status status; + int cmd_result = 0; + int aux_result; + + struct flip1_cmd cmd = { + FLIP1_CMD_CHANGE_BASE_ADDRESS, { 0, page_addr } + }; + + cmd_result = dfu_dnload(dfu, &cmd, 3); + + aux_result = dfu_getstatus(dfu, &status); + + if (cmd_result < 0 || aux_result < 0) + return -1; + + if (status.bStatus != DFU_STATUS_OK) + { + avrdude_message(MSG_INFO, "%s: failed to set memory page: %s\n", + progname, flip1_status_str(&status)); + if (status.bState == STATE_dfuERROR) + dfu_clrstatus(dfu); + return -1; + } + + return 0; +} + +const char * flip1_status_str(const struct dfu_status *status) +{ + static const char *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", + "Device id unable to write memory", + "Memory erase function failed", + "Memory erase check failed", + "Program memory function failed", + "Programmed memory failed verification", + "Cannot program memory due to received address that is out of range", + "Received DFU_DNLOAD with wLength = 0, but device does not think it has all the data yet.", + "Device's firmware is corrupted. It cannot return to run-time operations", + "iString indicates a vendor-specific error", + "Device detected unexpected USB reset signaling", + "Device detected unexpected power on reset", + "Something went wrong, but the device does not know what it was", + "Device stalled an unexpected request", + }; + if (status->bStatus < sizeof msg / sizeof msg[0]) + return msg[status->bStatus]; + + return "Unknown status code"; +} + +const char * flip1_mem_unit_str(enum flip1_mem_unit mem_unit) +{ + switch (mem_unit) { + case FLIP1_MEM_UNIT_FLASH: return "Flash"; + case FLIP1_MEM_UNIT_EEPROM: return "EEPROM"; + default: return "unknown"; + } +} + +enum flip1_mem_unit flip1_mem_unit(const char *name) { + if (strcasecmp(name, "flash") == 0) + return FLIP1_MEM_UNIT_FLASH; + if (strcasecmp(name, "eeprom") == 0) + return FLIP1_MEM_UNIT_EEPROM; + return FLIP1_MEM_UNIT_UNKNOWN; +} +#else /* HAVE_LIBUSB */ +// Dummy functions +int flip1_open(PROGRAMMER *pgm, char *port_spec) +{ + fprintf(stderr, "%s: Error: No USB support in this compile of avrdude\n", + progname); + return -1; +} + +int flip1_initialize(PROGRAMMER* pgm, AVRPART *part) +{ + return -1; +} + +void flip1_close(PROGRAMMER* pgm) +{ +} + +void flip1_enable(PROGRAMMER* pgm) +{ +} + +void flip1_disable(PROGRAMMER* pgm) +{ +} + +void flip1_display(PROGRAMMER* pgm, const char *prefix) +{ +} + +int flip1_program_enable(PROGRAMMER* pgm, AVRPART *part) +{ + return -1; +} + +int flip1_chip_erase(PROGRAMMER* pgm, AVRPART *part) +{ + return -1; +} + +int flip1_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char *value) +{ + return -1; +} + +int flip1_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char value) +{ + return -1; +} + +int flip1_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + return -1; +} + +int flip1_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + return -1; +} + +int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem) +{ + return -1; +} + +void flip1_setup(PROGRAMMER * pgm) +{ +} + +void flip1_teardown(PROGRAMMER * pgm) +{ +} + + +#endif /* HAVE_LIBUSB */ diff --git a/xs/src/avrdude/flip1.h b/xs/src/avrdude/flip1.h new file mode 100644 index 000000000..c5f4986b6 --- /dev/null +++ b/xs/src/avrdude/flip1.h @@ -0,0 +1,35 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 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 + * 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 flip1_h +#define flip1_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char flip1_desc[]; +extern void flip1_initpgm(PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif /* flip1_h */ diff --git a/xs/src/avrdude/flip2.c b/xs/src/avrdude/flip2.c new file mode 100644 index 000000000..ba90086a3 --- /dev/null +++ b/xs/src/avrdude/flip2.c @@ -0,0 +1,1002 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2012 Kirill Levchenko + * + * 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 "ac_cfg.h" + +#include +#include +#include +#include +#include +#include + +#if HAVE_STDINT_H +#include +#elif HAVE_INTTYPES_H +#include +#endif + +#include "avrdude.h" +#include "libavrdude.h" + +#include "flip2.h" +#include "dfu.h" +#include "usbdevs.h" /* for USB_VENDOR_ATMEL */ + +/* There are three versions of the FLIP protocol: + * + * Version 0: C51 parts + * Version 1: megaAVR parts ("USB DFU Bootloader Datasheet" [doc7618]) + * Version 2: XMEGA parts (AVR4023 [doc8457]) + * + * We currently only support Version 2, as documented in AVR4023. + * + * Additional references: + * flip_protocol.h from the Atmel Software Framework. + * udi_dfu_atmel.c from XMEGA bootloaders archive. + */ + +/* EXPORTED CONSTANT STRINGS */ + +const char flip2_desc[] = "FLIP USB DFU protocol version 2 (AVR4023)"; + +/* PRIVATE DATA STRUCTURES */ + +struct flip2 +{ + struct dfu_dev *dfu; + unsigned char part_sig[3]; + unsigned char part_rev; + unsigned char boot_ver; +}; + +#define FLIP2(pgm) ((struct flip2 *)(pgm->cookie)) + +/* The FLIP2 protocol assigns specific meaning to certain combinations of + * status and state bytes in the DFU_GETSTATUS response. These constants en- + * code these combinations as a 16-bit value: the high order byte is the + * status and the low order byte is the state of the status-state pairing. + */ + +#define FLIP2_STATUS_OK 0x0000 +#define FLIP2_STATUS_STALL 0x0F0A +#define FLIP2_STATUS_MEM_UKNOWN 0x030A +#define FLIP2_STATUS_MEM_PROTECTED 0x0300 +#define FLIP2_STATUS_OUTOFRANGE 0x080A +#define FLIP2_STATUS_BLANK_FAIL 0x0500 +#define FLIP2_STATUS_ERASE_ONGOING 0x0904 + +/* FLIP2 data structures and constants. */ + +struct flip2_cmd { + unsigned char group_id; + unsigned char cmd_id; + unsigned char args[4]; +}; + +#define FLIP2_CMD_GROUP_DOWNLOAD 0x01 +#define FLIP2_CMD_GROUP_UPLOAD 0x03 +#define FLIP2_CMD_GROUP_EXEC 0x04 +#define FLIP2_CMD_GROUP_SELECT 0x06 + +#define FLIP2_CMD_PROG_START 0x00 +#define FLIP2_CMD_READ_MEMORY 0x00 +#define FLIP2_CMD_SELECT_MEMORY 0x03 +#define FLIP2_CMD_CHIP_ERASE 0x00 +#define FLIP2_CMD_START_APP 0x03 + +#define FLIP2_SELECT_MEMORY_UNIT 0x00 +#define FLIP2_SELECT_MEMORY_PAGE 0x01 + +enum flip2_mem_unit { + FLIP2_MEM_UNIT_UNKNOWN = -1, + FLIP2_MEM_UNIT_FLASH = 0x00, + FLIP2_MEM_UNIT_EEPROM = 0x01, + FLIP2_MEM_UNIT_SECURITY = 0x02, + FLIP2_MEM_UNIT_CONFIGURATION = 0x03, + FLIP2_MEM_UNIT_BOOTLOADER = 0x04, + FLIP2_MEM_UNIT_SIGNATURE = 0x05, + FLIP2_MEM_UNIT_USER = 0x06, + FLIP2_MEM_UNIT_INT_RAM = 0x07, + FLIP2_MEM_UNIT_EXT_MEM_CS0 = 0x08, + FLIP2_MEM_UNIT_EXT_MEM_CS1 = 0x09, + FLIP2_MEM_UNIT_EXT_MEM_CS2 = 0x0A, + FLIP2_MEM_UNIT_EXT_MEM_CS3 = 0x0B, + FLIP2_MEM_UNIT_EXT_MEM_CS4 = 0x0C, + FLIP2_MEM_UNIT_EXT_MEM_CS5 = 0x0D, + FLIP2_MEM_UNIT_EXT_MEM_CS6 = 0x0E, + FLIP2_MEM_UNIT_EXT_MEM_CS7 = 0x0F, + FLIP2_MEM_UNIT_EXT_MEM_DF = 0x10 +}; + +/* EXPORTED PROGRAMMER FUNCTION PROTOTYPES */ + +static int flip2_open(PROGRAMMER *pgm, char *port_spec); +static int flip2_initialize(PROGRAMMER* pgm, AVRPART *part); +static void flip2_close(PROGRAMMER* pgm); +static void flip2_enable(PROGRAMMER* pgm); +static void flip2_disable(PROGRAMMER* pgm); +static void flip2_display(PROGRAMMER* pgm, const char *prefix); +static int flip2_program_enable(PROGRAMMER* pgm, AVRPART *part); +static int flip2_chip_erase(PROGRAMMER* pgm, AVRPART *part); +static int flip2_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char *value); +static int flip2_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char value); +static int flip2_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes); +static int flip2_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes); +static int flip2_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem); +static void flip2_setup(PROGRAMMER * pgm); +static void flip2_teardown(PROGRAMMER * pgm); + +/* INTERNAL PROGRAMMER FUNCTION PROTOTYPES */ +#ifdef HAVE_LIBUSB +// The internal ones are made conditional, as they're not defined further down #ifndef HAVE_LIBUSB + +static void flip2_show_info(struct flip2 *flip2); + +static int flip2_read_memory(struct dfu_dev *dfu, + enum flip2_mem_unit mem_unit, uint32_t addr, void *ptr, int size); +static int flip2_write_memory(struct dfu_dev *dfu, + enum flip2_mem_unit mem_unit, uint32_t addr, const void *ptr, int size); + +static int flip2_set_mem_unit(struct dfu_dev *dfu, + enum flip2_mem_unit mem_unit); +static int flip2_set_mem_page(struct dfu_dev *dfu, unsigned short page_addr); +static int flip2_read_max1k(struct dfu_dev *dfu, + unsigned short offset, void *ptr, unsigned short size); +static int flip2_write_max1k(struct dfu_dev *dfu, + unsigned short offset, const void *ptr, unsigned short size); + +static const char * flip2_status_str(const struct dfu_status *status); +static const char * flip2_mem_unit_str(enum flip2_mem_unit mem_unit); +static enum flip2_mem_unit flip2_mem_unit(const char *name); + +#endif /* HAVE_LIBUSB */ + +/* THE INITPGM FUNCTION DEFINITIONS */ + +void flip2_initpgm(PROGRAMMER *pgm) +{ + strcpy(pgm->type, "flip2"); + + /* Mandatory Functions */ + pgm->initialize = flip2_initialize; + pgm->enable = flip2_enable; + pgm->disable = flip2_disable; + pgm->display = flip2_display; + pgm->program_enable = flip2_program_enable; + pgm->chip_erase = flip2_chip_erase; + pgm->open = flip2_open; + pgm->close = flip2_close; + pgm->paged_load = flip2_paged_load; + pgm->paged_write = flip2_paged_write; + pgm->read_byte = flip2_read_byte; + pgm->write_byte = flip2_write_byte; + pgm->read_sig_bytes = flip2_read_sig_bytes; + pgm->setup = flip2_setup; + pgm->teardown = flip2_teardown; +} + +#ifdef HAVE_LIBUSB +/* EXPORTED PROGRAMMER FUNCTION DEFINITIONS */ + +int flip2_open(PROGRAMMER *pgm, char *port_spec) +{ + FLIP2(pgm)->dfu = dfu_open(port_spec); + return (FLIP2(pgm)->dfu != NULL) ? 0 : -1; +} + +int flip2_initialize(PROGRAMMER* pgm, AVRPART *part) +{ + unsigned short vid, pid; + int result; + struct dfu_dev *dfu = FLIP2(pgm)->dfu; + + /* A note about return values. Negative return values from this function are + * interpreted as failure by main(), from where this function is called. + * However such failures are interpreted as a device signature check failure + * and the user is adviced to use the -F option to override this check. In + * our case, this is misleading, so we defer reporting an error until another + * function is called. Thus, we always return 0 (success) from initialize(). + * I don't like this, but I don't want to mess with main(). + */ + + /* The dfu_init() function will try to find the target part either based on + * a USB address provided by the user with the -P option or by matching the + * VID and PID of the device. The VID may be specified in the programmer + * definition; if not specified, it defaults to USB_VENDOR_ATMEL (defined + * in usbdevs.h). The PID may be specified either in the programmer + * definition or the part definition; the programmer definition takes + * priority. The default PID value is 0, which causes dfu_init() to ignore + * the PID when matching a target device. + */ + + vid = (pgm->usbvid != 0) ? pgm->usbvid : USB_VENDOR_ATMEL; + LNODEID usbpid = lfirst(pgm->usbpid); + if (usbpid) { + pid = *(int *)(ldata(usbpid)); + if (lnext(usbpid)) + avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n", + progname, pid); + } else { + pid = part->usbpid; + } + + if (!ovsigck && !(part->flags & AVRPART_HAS_PDI)) { + avrdude_message(MSG_INFO, "%s: \"flip2\" (FLIP protocol version 2) is for Xmega devices.\n" + "%s For AT90USB* or ATmega*U* devices, use \"flip1\".\n" + "%s (Use -F to bypass this check.)\n", + progname, progbuf, progbuf); + return -1; + } + + result = dfu_init(dfu, vid, pid); + + if (result != 0) + goto flip2_initialize_fail; + + /* Check if descriptor values are what we expect. */ + + if (dfu->dev_desc.idVendor != vid) + avrdude_message(MSG_INFO, "%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n", + progname, dfu->dev_desc.idVendor, vid); + + if (pid != 0 && dfu->dev_desc.idProduct != pid) + avrdude_message(MSG_INFO, "%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n", + progname, dfu->dev_desc.idProduct, pid); + + if (dfu->dev_desc.bNumConfigurations != 1) + avrdude_message(MSG_INFO, "%s: Warning: USB bNumConfigurations = %d (expected 1)\n", + progname, (int) dfu->dev_desc.bNumConfigurations); + + if (dfu->conf_desc.bNumInterfaces != 1) + avrdude_message(MSG_INFO, "%s: Warning: USB bNumInterfaces = %d (expected 1)\n", + progname, (int) dfu->conf_desc.bNumInterfaces); + + if (dfu->dev_desc.bDeviceClass != 0) + avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceClass = %d (expected 0)\n", + progname, (int) dfu->dev_desc.bDeviceClass); + + if (dfu->dev_desc.bDeviceSubClass != 0) + avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceSubClass = %d (expected 0)\n", + progname, (int) dfu->dev_desc.bDeviceSubClass); + + if (dfu->dev_desc.bDeviceProtocol != 0) + avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceProtocol = %d (expected 0)\n", + progname, (int) dfu->dev_desc.bDeviceProtocol); + + if (dfu->intf_desc.bInterfaceClass != 0xFF) + avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceClass = %d (expected 255)\n", + progname, (int) dfu->intf_desc.bInterfaceClass); + + if (dfu->intf_desc.bInterfaceSubClass != 0) + avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n", + progname, (int) dfu->intf_desc.bInterfaceSubClass); + + if (dfu->intf_desc.bInterfaceProtocol != 0) + avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n", + progname, (int) dfu->intf_desc.bInterfaceProtocol); + + result = flip2_read_memory(FLIP2(pgm)->dfu, + FLIP2_MEM_UNIT_SIGNATURE, 0, FLIP2(pgm)->part_sig, 4); + + if (result != 0) + goto flip2_initialize_fail; + + result = flip2_read_memory(FLIP2(pgm)->dfu, + FLIP2_MEM_UNIT_BOOTLOADER, 0, &FLIP2(pgm)->boot_ver, 1); + + if (result != 0) + goto flip2_initialize_fail; + + if (verbose) + flip2_show_info(FLIP2(pgm)); + + return 0; + +flip2_initialize_fail: + dfu_close(FLIP2(pgm)->dfu); + FLIP2(pgm)->dfu = NULL; + return 0; +} + +void flip2_close(PROGRAMMER* pgm) +{ + if (FLIP2(pgm)->dfu != NULL) { + dfu_close(FLIP2(pgm)->dfu); + FLIP2(pgm)->dfu = NULL; + } +} + +void flip2_enable(PROGRAMMER* pgm) +{ + /* Nothing to do. */ +} + +void flip2_disable(PROGRAMMER* pgm) +{ + /* Nothing to do. */ +} + +void flip2_display(PROGRAMMER* pgm, const char *prefix) +{ + /* Nothing to do. */ +} + +int flip2_program_enable(PROGRAMMER* pgm, AVRPART *part) +{ + /* I couldn't find anything that uses this function, although it is marked + * as "mandatory" in pgm.c. In case anyone does use it, we'll report an + * error if we failed to initialize. + */ + + return (FLIP2(pgm)->dfu != NULL) ? 0 : -1; +} + +int flip2_chip_erase(PROGRAMMER* pgm, AVRPART *part) +{ + struct dfu_status status; + int cmd_result = 0; + int aux_result; + + avrdude_message(MSG_NOTICE2, "%s: flip_chip_erase()\n", progname); + + struct flip2_cmd cmd = { + FLIP2_CMD_GROUP_EXEC, FLIP2_CMD_CHIP_ERASE, { 0xFF, 0, 0, 0 } + }; + + for (;;) { + cmd_result = dfu_dnload(FLIP2(pgm)->dfu, &cmd, sizeof(cmd)); + aux_result = dfu_getstatus(FLIP2(pgm)->dfu, &status); + + if (aux_result != 0) + return aux_result; + + if (status.bStatus != DFU_STATUS_OK) { + if (status.bStatus == ((FLIP2_STATUS_ERASE_ONGOING >> 8) & 0xFF) && + status.bState == ((FLIP2_STATUS_ERASE_ONGOING >> 0) & 0xFF)) + { + continue; + } else + avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname, + flip2_status_str(&status)); + dfu_clrstatus(FLIP2(pgm)->dfu); + } else + break; + } + + return cmd_result; +} + +int flip2_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char *value) +{ + enum flip2_mem_unit mem_unit; + + if (FLIP2(pgm)->dfu == NULL) + return -1; + + mem_unit = flip2_mem_unit(mem->desc); + + if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) { + avrdude_message(MSG_INFO, "%s: Error: " + "\"%s\" memory not accessible using FLIP", + progname, mem->desc); + if (strcmp(mem->desc, "flash") == 0) + avrdude_message(MSG_INFO, " (did you mean \"application\"?)"); + avrdude_message(MSG_INFO, "\n"); + return -1; + } + + return flip2_read_memory(FLIP2(pgm)->dfu, mem_unit, addr, value, 1); +} + +int flip2_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char value) +{ + enum flip2_mem_unit mem_unit; + + if (FLIP2(pgm)->dfu == NULL) + return -1; + + mem_unit = flip2_mem_unit(mem->desc); + + if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) { + avrdude_message(MSG_INFO, "%s: Error: " + "\"%s\" memory not accessible using FLIP", + progname, mem->desc); + if (strcmp(mem->desc, "flash") == 0) + avrdude_message(MSG_INFO, " (did you mean \"application\"?)"); + avrdude_message(MSG_INFO, "\n"); + return -1; + } + + return flip2_write_memory(FLIP2(pgm)->dfu, mem_unit, addr, &value, 1); +} + +int flip2_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + enum flip2_mem_unit mem_unit; + int result; + + if (FLIP2(pgm)->dfu == NULL) + return -1; + + mem_unit = flip2_mem_unit(mem->desc); + + if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) { + avrdude_message(MSG_INFO, "%s: Error: " + "\"%s\" memory not accessible using FLIP", + progname, mem->desc); + if (strcmp(mem->desc, "flash") == 0) + avrdude_message(MSG_INFO, " (did you mean \"application\"?)"); + avrdude_message(MSG_INFO, "\n"); + return -1; + } + + if (n_bytes > INT_MAX) { + /* This should never happen, unless the int type is only 16 bits. */ + avrdude_message(MSG_INFO, "%s: Error: Attempting to read more than %d bytes\n", + progname, INT_MAX); + exit(1); + } + + result = flip2_read_memory(FLIP2(pgm)->dfu, mem_unit, addr, + mem->buf + addr, n_bytes); + + return (result == 0) ? n_bytes : -1; +} + +int flip2_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + enum flip2_mem_unit mem_unit; + int result; + + if (FLIP2(pgm)->dfu == NULL) + return -1; + + mem_unit = flip2_mem_unit(mem->desc); + + if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) { + avrdude_message(MSG_INFO, "%s: Error: " + "\"%s\" memory not accessible using FLIP", + progname, mem->desc); + if (strcmp(mem->desc, "flash") == 0) + avrdude_message(MSG_INFO, " (did you mean \"application\"?)"); + avrdude_message(MSG_INFO, "\n"); + return -1; + } + + if (n_bytes > INT_MAX) { + /* This should never happen, unless the int type is only 16 bits. */ + avrdude_message(MSG_INFO, "%s: Error: Attempting to read more than %d bytes\n", + progname, INT_MAX); + exit(1); + } + + result = flip2_write_memory(FLIP2(pgm)->dfu, mem_unit, addr, + mem->buf + addr, n_bytes); + + return (result == 0) ? n_bytes : -1; +} + +int flip2_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem) +{ + if (FLIP2(pgm)->dfu == NULL) + return -1; + + if (mem->size < sizeof(FLIP2(pgm)->part_sig)) { + avrdude_message(MSG_INFO, "%s: Error: Signature read must be at least %u bytes\n", + progname, (unsigned int) sizeof(FLIP2(pgm)->part_sig)); + return -1; + } + + memcpy(mem->buf, FLIP2(pgm)->part_sig, sizeof(FLIP2(pgm)->part_sig)); + return 0; +} + +void flip2_setup(PROGRAMMER * pgm) +{ + pgm->cookie = calloc(1, sizeof(struct flip2)); + + if (pgm->cookie == NULL) { + avrdude_message(MSG_INFO, "%s: Out of memory allocating private data structure\n", + progname); + exit(1); + } +} + +void flip2_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); + pgm->cookie = NULL; +} + +/* INTERNAL FUNCTION DEFINITIONS + */ + +void flip2_show_info(struct flip2 *flip2) +{ + dfu_show_info(flip2->dfu); + + avrdude_message(MSG_INFO, " Part signature : 0x%02X%02X%02X\n", + (int) flip2->part_sig[0], + (int) flip2->part_sig[1], + (int) flip2->part_sig[2]); + + if (flip2->part_rev < 26) + avrdude_message(MSG_INFO, " Part revision : %c\n", + (char) (flip2->part_rev + 'A')); + else + avrdude_message(MSG_INFO, " Part revision : %c%c\n", + (char) (flip2->part_rev / 26 - 1 + 'A'), + (char) (flip2->part_rev % 26 + 'A')); + + avrdude_message(MSG_INFO, " Bootloader version : 2.%hu.%hu\n", + ((unsigned short) flip2->boot_ver >> 4) & 0xF, + ((unsigned short) flip2->boot_ver >> 0) & 0xF); + + avrdude_message(MSG_INFO, " USB max packet size : %hu\n", + (unsigned short) flip2->dfu->dev_desc.bMaxPacketSize0); +} + +int flip2_read_memory(struct dfu_dev *dfu, + enum flip2_mem_unit mem_unit, uint32_t addr, void *ptr, int size) +{ + unsigned short prev_page_addr; + unsigned short page_addr; + const char * mem_name; + int read_size; + int result; + + avrdude_message(MSG_NOTICE2, "%s: flip_read_memory(%s, 0x%04x, %d)\n", + progname, flip2_mem_unit_str(mem_unit), addr, size); + + result = flip2_set_mem_unit(dfu, mem_unit); + + if (result != 0) { + if ((mem_name = flip2_mem_unit_str(mem_unit)) != NULL) + avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X (%s)\n", + progname, (int) mem_unit, mem_name); + else + avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X\n", + progname, (int) mem_unit); + return -1; + } + + page_addr = addr >> 16; + result = flip2_set_mem_page(dfu, page_addr); + + if (result != 0) { + avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n", + progname, page_addr); + return -1; + } + + while (size > 0) { + prev_page_addr = page_addr; + page_addr = addr >> 16; + + if (page_addr != prev_page_addr) { + result = flip2_set_mem_page(dfu, page_addr); + if (result != 0) { + avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n", + progname, page_addr); + return -1; + } + } + + read_size = (size > 0x400) ? 0x400 : size; + result = flip2_read_max1k(dfu, addr & 0xFFFF, ptr, read_size); + + if (result != 0) { + avrdude_message(MSG_INFO, "%s: Error: Failed to read 0x%04X bytes at 0x%04lX\n", + progname, read_size, (unsigned long) addr); + return -1; + } + + ptr += read_size; + addr += read_size; + size -= read_size; + } + + return 0; +} + +int flip2_write_memory(struct dfu_dev *dfu, + enum flip2_mem_unit mem_unit, uint32_t addr, const void *ptr, int size) +{ + unsigned short prev_page_addr; + unsigned short page_addr; + const char * mem_name; + int write_size; + int result; + + avrdude_message(MSG_NOTICE2, "%s: flip_write_memory(%s, 0x%04x, %d)\n", + progname, flip2_mem_unit_str(mem_unit), addr, size); + + result = flip2_set_mem_unit(dfu, mem_unit); + + if (result != 0) { + if ((mem_name = flip2_mem_unit_str(mem_unit)) != NULL) + avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X (%s)\n", + progname, (int) mem_unit, mem_name); + else + avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X\n", + progname, (int) mem_unit); + return -1; + } + + page_addr = addr >> 16; + result = flip2_set_mem_page(dfu, page_addr); + + if (result != 0) { + avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n", + progname, page_addr); + return -1; + } + + while (size > 0) { + prev_page_addr = page_addr; + page_addr = addr >> 16; + + if (page_addr != prev_page_addr) { + result = flip2_set_mem_page(dfu, page_addr); + if (result != 0) { + avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n", + progname, page_addr); + return -1; + } + } + + write_size = (size > 0x800) ? 0x800 : size; + result = flip2_write_max1k(dfu, addr & 0xFFFF, ptr, write_size); + + if (result != 0) { + avrdude_message(MSG_INFO, "%s: Error: Failed to write 0x%04X bytes at 0x%04lX\n", + progname, write_size, (unsigned long) addr); + return -1; + } + + ptr += write_size; + addr += write_size; + size -= write_size; + } + + return 0; +} + +int flip2_set_mem_unit(struct dfu_dev *dfu, enum flip2_mem_unit mem_unit) +{ + struct dfu_status status; + int cmd_result = 0; + int aux_result; + + struct flip2_cmd cmd = { + FLIP2_CMD_GROUP_SELECT, FLIP2_CMD_SELECT_MEMORY, { 0, 0, 0, 0 } + }; + + cmd.args[0] = FLIP2_SELECT_MEMORY_UNIT; + cmd.args[1] = mem_unit; + + cmd_result = dfu_dnload(dfu, &cmd, sizeof(cmd)); + + aux_result = dfu_getstatus(dfu, &status); + + if (aux_result != 0) + return aux_result; + + if (status.bStatus != DFU_STATUS_OK) { + if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) && + status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF)) + { + avrdude_message(MSG_INFO, "%s: Error: Unknown memory unit (0x%02x)\n", + progname, (unsigned int) mem_unit); + } else + avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname, + flip2_status_str(&status)); + dfu_clrstatus(dfu); + } + + return cmd_result; +} + +int flip2_set_mem_page(struct dfu_dev *dfu, + unsigned short page_addr) +{ + struct dfu_status status; + int cmd_result = 0; + int aux_result; + + struct flip2_cmd cmd = { + FLIP2_CMD_GROUP_SELECT, FLIP2_CMD_SELECT_MEMORY, { 0, 0, 0, 0 } + }; + + cmd.args[0] = FLIP2_SELECT_MEMORY_PAGE; + cmd.args[1] = (page_addr >> 8) & 0xFF; + cmd.args[2] = (page_addr >> 0) & 0xFF; + + cmd_result = dfu_dnload(dfu, &cmd, sizeof(cmd)); + + aux_result = dfu_getstatus(dfu, &status); + + if (aux_result != 0) + return aux_result; + + if (status.bStatus != DFU_STATUS_OK) { + if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) && + status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF)) + { + avrdude_message(MSG_INFO, "%s: Error: Page address out of range (0x%04hx)\n", + progname, page_addr); + } else + avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname, + flip2_status_str(&status)); + dfu_clrstatus(dfu); + } + + return cmd_result; +} + +int flip2_read_max1k(struct dfu_dev *dfu, + unsigned short offset, void *ptr, unsigned short size) +{ + struct dfu_status status; + int cmd_result = 0; + int aux_result; + + struct flip2_cmd cmd = { + FLIP2_CMD_GROUP_UPLOAD, FLIP2_CMD_READ_MEMORY, { 0, 0, 0, 0 } + }; + + cmd.args[0] = (offset >> 8) & 0xFF; + cmd.args[1] = (offset >> 0) & 0xFF; + cmd.args[2] = ((offset+size-1) >> 8) & 0xFF; + cmd.args[3] = ((offset+size-1) >> 0) & 0xFF; + + cmd_result = dfu_dnload(dfu, &cmd, sizeof(cmd)); + + if (cmd_result != 0) + goto flip2_read_max1k_status; + + cmd_result = dfu_upload(dfu, (char*) ptr, size); + +flip2_read_max1k_status: + + aux_result = dfu_getstatus(dfu, &status); + + if (aux_result != 0) + return aux_result; + + if (status.bStatus != DFU_STATUS_OK) { + if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) && + status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF)) + { + avrdude_message(MSG_INFO, "%s: Error: Address out of range [0x%04hX,0x%04hX]\n", + progname, offset, offset+size-1); + } else + avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname, + flip2_status_str(&status)); + dfu_clrstatus(dfu); + } + + return cmd_result; +} + +int flip2_write_max1k(struct dfu_dev *dfu, + unsigned short offset, const void *ptr, unsigned short size) +{ + char buffer[64+64+0x400]; + unsigned short data_offset; + struct dfu_status status; + int cmd_result = 0; + int aux_result; + + struct flip2_cmd cmd = { + FLIP2_CMD_GROUP_DOWNLOAD, FLIP2_CMD_PROG_START, { 0, 0, 0, 0 } + }; + + cmd.args[0] = (offset >> 8) & 0xFF; + cmd.args[1] = (offset >> 0) & 0xFF; + cmd.args[2] = ((offset+size-1) >> 8) & 0xFF; + cmd.args[3] = ((offset+size-1) >> 0) & 0xFF; + + if (size > 0x400) { + avrdude_message(MSG_INFO, "%s: Error: Write block too large (%hu > 1024)\n", + progname, size); + return -1; + } + + /* There are some special padding requirements for writes. The first packet + * must consist only of the FLIP2 command data, which must be padded to + * fill out the USB packet (the packet size is given by bMaxPacketSize0 in + * the device descriptor). In addition, the data must be padded so that the + * first byte of data to be written is at located at position (offset mod + * bMaxPacketSize0) within the packet. + */ + + data_offset = dfu->dev_desc.bMaxPacketSize0; + data_offset += offset % dfu->dev_desc.bMaxPacketSize0; + + memcpy(buffer, &cmd, sizeof(cmd)); + memset(buffer + sizeof(cmd), 0, data_offset - sizeof(cmd)); + memcpy(buffer + data_offset, ptr, size); + + cmd_result = dfu_dnload(dfu, buffer, data_offset + size); + + aux_result = dfu_getstatus(dfu, &status); + + if (aux_result != 0) + return aux_result; + + if (status.bStatus != DFU_STATUS_OK) { + if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) && + status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF)) + { + avrdude_message(MSG_INFO, "%s: Error: Address out of range [0x%04hX,0x%04hX]\n", + progname, offset, offset+size-1); + } else + avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname, + flip2_status_str(&status)); + dfu_clrstatus(dfu); + } + + return cmd_result; +} + +const char * flip2_status_str(const struct dfu_status *status) +{ + unsigned short selector; + + selector = (unsigned short) status->bStatus << 8; + selector |= status->bState; + + switch (selector) { + case FLIP2_STATUS_OK: return "OK"; + case FLIP2_STATUS_STALL: return "STALL"; + case FLIP2_STATUS_MEM_UKNOWN: return "MEM_UKNOWN"; + case FLIP2_STATUS_MEM_PROTECTED: return "MEM_PROTECTED"; + case FLIP2_STATUS_OUTOFRANGE: return "OUTOFRANGE"; + case FLIP2_STATUS_BLANK_FAIL: return "BLANK_FAIL"; + case FLIP2_STATUS_ERASE_ONGOING: return "ERASE_ONGOING"; + default: return dfu_status_str(status->bStatus); + } +} + +const char * flip2_mem_unit_str(enum flip2_mem_unit mem_unit) +{ + switch (mem_unit) { + case FLIP2_MEM_UNIT_FLASH: return "Flash"; + case FLIP2_MEM_UNIT_EEPROM: return "EEPROM"; + case FLIP2_MEM_UNIT_SECURITY: return "security"; + case FLIP2_MEM_UNIT_CONFIGURATION: return "configuration"; + case FLIP2_MEM_UNIT_BOOTLOADER: return "bootloader version"; + case FLIP2_MEM_UNIT_SIGNATURE: return "signature"; + case FLIP2_MEM_UNIT_USER: return "user"; + case FLIP2_MEM_UNIT_INT_RAM: return "internal RAM"; + case FLIP2_MEM_UNIT_EXT_MEM_CS0: return "EXT_MEM_CS0"; + case FLIP2_MEM_UNIT_EXT_MEM_CS1: return "EXT_MEM_CS1"; + case FLIP2_MEM_UNIT_EXT_MEM_CS2: return "EXT_MEM_CS2"; + case FLIP2_MEM_UNIT_EXT_MEM_CS3: return "EXT_MEM_CS3"; + case FLIP2_MEM_UNIT_EXT_MEM_CS4: return "EXT_MEM_CS4"; + case FLIP2_MEM_UNIT_EXT_MEM_CS5: return "EXT_MEM_CS5"; + case FLIP2_MEM_UNIT_EXT_MEM_CS6: return "EXT_MEM_CS6"; + case FLIP2_MEM_UNIT_EXT_MEM_CS7: return "EXT_MEM_CS7"; + case FLIP2_MEM_UNIT_EXT_MEM_DF: return "EXT_MEM_DF"; + default: return "unknown"; + } +} + +enum flip2_mem_unit flip2_mem_unit(const char *name) { + if (strcasecmp(name, "application") == 0) + return FLIP2_MEM_UNIT_FLASH; + if (strcasecmp(name, "eeprom") == 0) + return FLIP2_MEM_UNIT_EEPROM; + if (strcasecmp(name, "signature") == 0) + return FLIP2_MEM_UNIT_SIGNATURE; + return FLIP2_MEM_UNIT_UNKNOWN; +} + +#else /* HAVE_LIBUSB */ + +/* EXPORTED PROGRAMMER FUNCTION DEFINITIONS */ + +int flip2_open(PROGRAMMER *pgm, char *port_spec) +{ + fprintf(stderr, "%s: Error: No USB support in this compile of avrdude\n", + progname); + return -1; +} + +int flip2_initialize(PROGRAMMER* pgm, AVRPART *part) +{ + return -1; +} + +void flip2_close(PROGRAMMER* pgm) +{ +} + +void flip2_enable(PROGRAMMER* pgm) +{ +} + +void flip2_disable(PROGRAMMER* pgm) +{ +} + +void flip2_display(PROGRAMMER* pgm, const char *prefix) +{ +} + +int flip2_program_enable(PROGRAMMER* pgm, AVRPART *part) +{ + return -1; +} + +int flip2_chip_erase(PROGRAMMER* pgm, AVRPART *part) +{ + return -1; +} + +int flip2_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char *value) +{ + return -1; +} + +int flip2_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned long addr, unsigned char value) +{ + return -1; +} + +int flip2_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + return -1; +} + +int flip2_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + return -1; +} + +int flip2_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem) +{ + return -1; +} + +void flip2_setup(PROGRAMMER * pgm) +{ +} + +void flip2_teardown(PROGRAMMER * pgm) +{ +} + + +#endif /* HAVE_LIBUSB */ diff --git a/xs/src/avrdude/flip2.h b/xs/src/avrdude/flip2.h new file mode 100644 index 000000000..4b1e576d5 --- /dev/null +++ b/xs/src/avrdude/flip2.h @@ -0,0 +1,35 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2012 Kirill Levchenko + * + * 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 flip2_h +#define flip2_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char flip2_desc[]; +extern void flip2_initpgm(PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif /* flip2_h */ diff --git a/xs/src/avrdude/freebsd_ppi.h b/xs/src/avrdude/freebsd_ppi.h new file mode 100644 index 000000000..016bf1826 --- /dev/null +++ b/xs/src/avrdude/freebsd_ppi.h @@ -0,0 +1,39 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2005 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 + * 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 freebsd_ppi_h +#define freebsd_ppi_h + +#include + +#define ppi_claim(fd) {} + +#define ppi_release(fd) {} + +#define DO_PPI_READ(fd, reg, valp) \ + (void)ioctl(fd, \ + (reg) == PPIDATA? PPIGDATA: ((reg) == PPICTRL? PPIGCTRL: PPIGSTATUS), \ + valp) +#define DO_PPI_WRITE(fd, reg, valp) \ + (void)ioctl(fd, \ + (reg) == PPIDATA? PPISDATA: ((reg) == PPICTRL? PPISCTRL: PPISSTATUS), \ + valp) + +#endif /* freebsd_ppi_h */ diff --git a/xs/src/avrdude/ft245r.c b/xs/src/avrdude/ft245r.c new file mode 100644 index 000000000..cc1061df4 --- /dev/null +++ b/xs/src/avrdude/ft245r.c @@ -0,0 +1,963 @@ + +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2003-2004 Theodore A. Roth + * some code: + * Copyright (C) 2011-2012 Roger E. Wolff + * + * 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$ */ + +/* ft245r -- FT245R/FT232R Synchronous BitBangMode Programmer + default pin assign + FT232R / FT245R + miso = 1; # RxD / D1 + sck = 0; # RTS / D0 + mosi = 2; # TxD / D2 + reset = 4; # DTR / D4 +*/ + +/* + The ft232r is very similar, or even "identical" in the synchronous + bitbang mode that we use here. + + This allows boards that have an ft232r for communication and an avr + as the processor to function as their own "ICSP". Boards that fit + this description include the Arduino Duemilanove, Arduino Diecimila, + Arduino NG (http://arduino.cc/it/main/boards) and the BitWizard + ftdi_atmega board (http://www.bitwizard.nl/wiki/index.php/FTDI_ATmega) + + The Arduinos have to be patched to bring some of the control lines + to the ICSP header. The BitWizard board already has the neccessary + wiring on the PCB. + + How to add the wires to an arduino is documented here: + http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html +*/ + + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "bitbang.h" +#include "ft245r.h" +#include "usbdevs.h" + +#if defined(_WIN32) +#include +#endif + +#if defined(HAVE_LIBFTDI1) && defined(HAVE_LIBUSB_1_0) +# if defined(HAVE_LIBUSB_1_0_LIBUSB_H) +# include +# else +# include +# endif +# include +#elif defined(HAVE_LIBFTDI) && defined(HAVE_USB_H) +/* ftdi.h includes usb.h */ +#include +#else +#warning No libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again. +#define DO_NOT_BUILD_FT245R +#endif + +#ifndef HAVE_PTHREAD_H + +static int ft245r_nopthread_open (struct programmer_t *pgm, char * name) { + avrdude_message(MSG_INFO, "%s: error: no pthread support. Please compile again with pthread installed." +#if defined(_WIN32) + " See http://sourceware.org/pthreads-win32/." +#endif + "\n", + progname); + + return -1; +} + +void ft245r_initpgm(PROGRAMMER * pgm) { + strcpy(pgm->type, "ftdi_syncbb"); + pgm->open = ft245r_nopthread_open; +} + +#elif defined(DO_NOT_BUILD_FT245R) + +static int ft245r_noftdi_open (struct programmer_t *pgm, char * name) { + avrdude_message(MSG_INFO, "%s: error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n", + progname); + + return -1; +} + +void ft245r_initpgm(PROGRAMMER * pgm) { + strcpy(pgm->type, "ftdi_syncbb"); + pgm->open = ft245r_noftdi_open; +} + +#else + +#include + +#ifdef __APPLE__ +/* Mac OS X defines sem_init but actually does not implement them */ +#include + +typedef dispatch_semaphore_t sem_t; + +#define sem_init(psem,x,val) *psem = dispatch_semaphore_create(val) +#define sem_post(psem) dispatch_semaphore_signal(*psem) +#define sem_wait(psem) dispatch_semaphore_wait(*psem, DISPATCH_TIME_FOREVER) +#else +#include +#endif + +#define FT245R_CYCLES 2 +#define FT245R_FRAGMENT_SIZE 512 +#define REQ_OUTSTANDINGS 10 +//#define USE_INLINE_WRITE_PAGE + +#define FT245R_DEBUG 0 + +static struct ftdi_context *handle; + +static unsigned char ft245r_ddr; +static unsigned char ft245r_out; +static unsigned char ft245r_in; + +#define BUFSIZE 0x2000 + +// libftdi / libftd2xx compatibility functions. + +static pthread_t readerthread; +static sem_t buf_data, buf_space; +static unsigned char buffer[BUFSIZE]; +static int head, tail; + +static void add_to_buf (unsigned char c) { + int nh; + + sem_wait (&buf_space); + if (head == (BUFSIZE -1)) nh = 0; + else nh = head + 1; + + if (nh == tail) { + avrdude_message(MSG_INFO, "buffer overflow. Cannot happen!\n"); + } + buffer[head] = c; + head = nh; + sem_post (&buf_data); +} + +static void *reader (void *arg) { + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL); + struct ftdi_context *handle = (struct ftdi_context *)(arg); + unsigned char buf[0x1000]; + int br, i; + + while (1) { + pthread_testcancel(); + br = ftdi_read_data (handle, buf, sizeof(buf)); + for (i=0; iop[AVR_OP_CHIP_ERASE] == NULL) { + avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n", + p->desc); + return -1; + } + + avr_set_bits(p->op[AVR_OP_CHIP_ERASE], cmd); + pgm->cmd(pgm, cmd, res); + usleep(p->chip_erase_delay); + return pgm->initialize(pgm, p); +} + + +static int ft245r_set_bitclock(PROGRAMMER * pgm) { + int r; + int rate = 0; + + /* bitclock is second. 1us = 0.000001. Max rate for ft232r 750000 */ + if(pgm->bitclock) { + rate = (uint32_t)(1.0/pgm->bitclock) * 2; + } else if (pgm->baudrate) { + rate = pgm->baudrate * 2; + } else { + rate = 150000; /* should work for all ftdi chips and the avr default internal clock of 1MHz */ + } + + if (FT245R_DEBUG) { + avrdude_message(MSG_NOTICE2, " ft245r: spi bitclk %d -> ft baudrate %d\n", + rate / 2, rate); + } + r = ftdi_set_baudrate(handle, rate); + if (r) { + avrdude_message(MSG_INFO, "Set baudrate (%d) failed with error '%s'.\n", + rate, ftdi_get_error_string (handle)); + return -1; + } + return 0; +} + +static int set_pin(PROGRAMMER * pgm, int pinname, int val) { + unsigned char buf[1]; + + if (pgm->pin[pinname].mask[0] == 0) { + // ignore not defined pins (might be the led or vcc or buff if not needed) + return 0; + } + + ft245r_out = SET_BITS_0(ft245r_out,pgm,pinname,val); + buf[0] = ft245r_out; + + ft245r_send (pgm, buf, 1); + ft245r_recv (pgm, buf, 1); + + ft245r_in = buf[0]; + return 0; +} + +static int set_sck(PROGRAMMER * pgm, int value) { + return set_pin(pgm, PIN_AVR_SCK, value); +} + +static int set_reset(PROGRAMMER * pgm, int value) { + return set_pin(pgm, PIN_AVR_RESET, value); +} + +static int set_buff(PROGRAMMER * pgm, int value) { + return set_pin(pgm, PPI_AVR_BUFF, value); +} + +static int set_vcc(PROGRAMMER * pgm, int value) { + return set_pin(pgm, PPI_AVR_VCC, value); +} + +/* these functions are callbacks, which go into the + * PROGRAMMER data structure ("optional functions") + */ +static int set_led_pgm(struct programmer_t * pgm, int value) { + return set_pin(pgm, PIN_LED_PGM, value); +} + +static int set_led_rdy(struct programmer_t * pgm, int value) { + return set_pin(pgm, PIN_LED_RDY, value); +} + +static int set_led_err(struct programmer_t * pgm, int value) { + return set_pin(pgm, PIN_LED_ERR, value); +} + +static int set_led_vfy(struct programmer_t * pgm, int value) { + return set_pin(pgm, PIN_LED_VFY, value); +} + +/* + * apply power to the AVR processor + */ +static void ft245r_powerup(PROGRAMMER * pgm) +{ + set_vcc(pgm, ON); /* power up */ + usleep(100); +} + + +/* + * remove power from the AVR processor + */ +static void ft245r_powerdown(PROGRAMMER * pgm) +{ + set_vcc(pgm, OFF); /* power down */ +} + + +static void ft245r_disable(PROGRAMMER * pgm) { + set_buff(pgm, OFF); +} + + +static void ft245r_enable(PROGRAMMER * pgm) { + /* + * Prepare to start talking to the connected device - pull reset low + * first, delay a few milliseconds, then enable the buffer. This + * sequence allows the AVR to be reset before the buffer is enabled + * to avoid a short period of time where the AVR may be driving the + * programming lines at the same time the programmer tries to. Of + * course, if a buffer is being used, then the /RESET line from the + * programmer needs to be directly connected to the AVR /RESET line + * and not via the buffer chip. + */ + set_reset(pgm, OFF); + usleep(1); + set_buff(pgm, ON); +} + +static int ft245r_cmd(PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res); +/* + * issue the 'program enable' command to the AVR device + */ +static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) { + unsigned char cmd[4] = {0,0,0,0}; + unsigned char res[4]; + int i; + + if (p->op[AVR_OP_PGM_ENABLE] == NULL) { + avrdude_message(MSG_INFO, "%s: AVR_OP_PGM_ENABLE command not defined for %s\n", + progname, p->desc); + fflush(stderr); + return -1; + } + + avr_set_bits(p->op[AVR_OP_PGM_ENABLE], cmd); + + for(i = 0; i < 4; i++) { + ft245r_cmd(pgm, cmd, res); + + if (res[p->pollindex-1] == p->pollvalue) return 0; + + if (FT245R_DEBUG) { + avrdude_message(MSG_NOTICE, "%s: Program enable command not successful. Retrying.\n", + progname); + fflush(stderr); + } + set_pin(pgm, PIN_AVR_RESET, ON); + usleep(20); + set_pin(pgm, PIN_AVR_RESET, OFF); + + if (i == 3) { + ft245r_drain(pgm, 0); + tail = head; + } + } + + avrdude_message(MSG_INFO, "%s: Device is not responding to program enable. Check connection.\n", + progname); + fflush(stderr); + + return -1; +} + +/* + * initialize the AVR device and prepare it to accept commands + */ +static int ft245r_initialize(PROGRAMMER * pgm, AVRPART * p) { + + /* Apply power between VCC and GND while RESET and SCK are set to “0â€. 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 of at least two CPU clock cycles duration + * after SCK has been set to “0â€. + */ + set_sck(pgm, OFF); + ft245r_powerup(pgm); + + set_reset(pgm, OFF); + usleep(5000); // 5ms + set_reset(pgm, ON); + usleep(5000); // 5ms + set_reset(pgm, OFF); + + /* Wait for at least 20 ms and enable serial programming by sending the Programming + * Enable serial instruction to pin MOSI. + */ + usleep(20000); // 20ms + + return ft245r_program_enable(pgm, p); +} + +static inline int set_data(PROGRAMMER * pgm, unsigned char *buf, unsigned char data) { + int j; + int buf_pos = 0; + unsigned char bit = 0x80; + + for (j=0; j<8; j++) { + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_AVR_MOSI,data & bit); + + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_AVR_SCK,0); + buf[buf_pos] = ft245r_out; + buf_pos++; + + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_AVR_SCK,1); + buf[buf_pos] = ft245r_out; + buf_pos++; + + bit >>= 1; + } + return buf_pos; +} + +static inline unsigned char extract_data(PROGRAMMER * pgm, unsigned char *buf, int offset) { + int j; + int buf_pos = 1; + unsigned char bit = 0x80; + unsigned char r = 0; + + buf += offset * (8 * FT245R_CYCLES); + for (j=0; j<8; j++) { + if (GET_BITS_0(buf[buf_pos],pgm,PIN_AVR_MISO)) { + r |= bit; + } + buf_pos += FT245R_CYCLES; + bit >>= 1; + } + return r; +} + +/* to check data */ +static inline unsigned char extract_data_out(PROGRAMMER * pgm, unsigned char *buf, int offset) { + int j; + int buf_pos = 1; + unsigned char bit = 0x80; + unsigned char r = 0; + + buf += offset * (8 * FT245R_CYCLES); + for (j=0; j<8; j++) { + if (GET_BITS_0(buf[buf_pos],pgm,PIN_AVR_MOSI)) { + r |= bit; + } + buf_pos += FT245R_CYCLES; + bit >>= 1; + } + return r; +} + + +/* + * transmit an AVR device command and return the results; 'cmd' and + * 'res' must point to at least a 4 byte data buffer + */ +static int ft245r_cmd(PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res) { + int i,buf_pos; + unsigned char buf[128]; + + buf_pos = 0; + for (i=0; i<4; i++) { + buf_pos += set_data(pgm, buf+buf_pos, cmd[i]); + } + buf[buf_pos] = 0; + buf_pos++; + + ft245r_send (pgm, buf, buf_pos); + ft245r_recv (pgm, buf, buf_pos); + res[0] = extract_data(pgm, buf, 0); + res[1] = extract_data(pgm, buf, 1); + res[2] = extract_data(pgm, buf, 2); + res[3] = extract_data(pgm, buf, 3); + + return 0; +} + +/* lower 8 pins are accepted, they might be also inverted */ +static const struct pindef_t valid_pins = {{0xff},{0xff}} ; + +static const struct pin_checklist_t pin_checklist[] = { + { PIN_AVR_SCK, 1, &valid_pins}, + { PIN_AVR_MOSI, 1, &valid_pins}, + { PIN_AVR_MISO, 1, &valid_pins}, + { PIN_AVR_RESET,1, &valid_pins}, + { PPI_AVR_BUFF, 0, &valid_pins}, +}; + +static int ft245r_open(PROGRAMMER * pgm, char * port) { + int rv; + int devnum = -1; + + rv = pins_check(pgm,pin_checklist,sizeof(pin_checklist)/sizeof(pin_checklist[0]), true); + if(rv) { + pgm->display(pgm, progbuf); + return rv; + } + + strcpy(pgm->port, port); + + if (strcmp(port,DEFAULT_USB) != 0) { + if (strncasecmp("ft", port, 2) == 0) { + char *startptr = port + 2; + char *endptr = NULL; + devnum = strtol(startptr,&endptr,10); + if ((startptr==endptr) || (*endptr != '\0')) { + devnum = -1; + } + } + if (devnum < 0) { + avrdude_message(MSG_INFO, "%s: invalid portname '%s': use 'ft[0-9]+'\n", + progname,port); + return -1; + } + } else { + devnum = 0; + } + + handle = malloc (sizeof (struct ftdi_context)); + ftdi_init(handle); + LNODEID usbpid = lfirst(pgm->usbpid); + int pid; + if (usbpid) { + pid = *(int *)(ldata(usbpid)); + if (lnext(usbpid)) + avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n", + progname, pid); + } else { + pid = USB_DEVICE_FT245; + } + rv = ftdi_usb_open_desc_index(handle, + pgm->usbvid?pgm->usbvid:USB_VENDOR_FTDI, + pid, + pgm->usbproduct[0]?pgm->usbproduct:NULL, + pgm->usbsn[0]?pgm->usbsn:NULL, + devnum); + if (rv) { + avrdude_message(MSG_INFO, "can't open ftdi device %d. (%s)\n", devnum, ftdi_get_error_string(handle)); + goto cleanup_no_usb; + } + + ft245r_ddr = + pgm->pin[PIN_AVR_SCK].mask[0] + | pgm->pin[PIN_AVR_MOSI].mask[0] + | pgm->pin[PIN_AVR_RESET].mask[0] + | pgm->pin[PPI_AVR_BUFF].mask[0] + | pgm->pin[PPI_AVR_VCC].mask[0] + | pgm->pin[PIN_LED_ERR].mask[0] + | pgm->pin[PIN_LED_RDY].mask[0] + | pgm->pin[PIN_LED_PGM].mask[0] + | pgm->pin[PIN_LED_VFY].mask[0]; + + /* set initial values for outputs, no reset everything else is off */ + ft245r_out = 0; + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_AVR_RESET,1); + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_AVR_SCK,0); + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_AVR_MOSI,0); + ft245r_out = SET_BITS_0(ft245r_out,pgm,PPI_AVR_BUFF,0); + ft245r_out = SET_BITS_0(ft245r_out,pgm,PPI_AVR_VCC,0); + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_LED_ERR,0); + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_LED_RDY,0); + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_LED_PGM,0); + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_LED_VFY,0); + + + rv = ftdi_set_bitmode(handle, ft245r_ddr, BITMODE_SYNCBB); // set Synchronous BitBang + if (rv) { + avrdude_message(MSG_INFO, "%s: Synchronous BitBangMode is not supported (%s)\n", + progname, ftdi_get_error_string(handle)); + goto cleanup; + } + + rv = ft245r_set_bitclock(pgm); + if (rv) { + goto cleanup; + } + + /* We start a new thread to read the output from the FTDI. This is + * necessary because otherwise we'll deadlock. We cannot finish + * writing because the ftdi cannot send the results because we + * haven't provided a read buffer yet. */ + + sem_init (&buf_data, 0, 0); + sem_init (&buf_space, 0, BUFSIZE); + pthread_create (&readerthread, NULL, reader, handle); + + /* + * drain any extraneous input + */ + ft245r_drain (pgm, 0); + + ft245r_send (pgm, &ft245r_out, 1); + ft245r_recv (pgm, &ft245r_in, 1); + + return 0; + +cleanup: + ftdi_usb_close(handle); +cleanup_no_usb: + ftdi_deinit (handle); + free(handle); + handle = NULL; + return -1; +} + + +static void ft245r_close(PROGRAMMER * pgm) { + if (handle) { + // I think the switch to BB mode and back flushes the buffer. + ftdi_set_bitmode(handle, 0, BITMODE_SYNCBB); // set Synchronous BitBang, all in puts + ftdi_set_bitmode(handle, 0, BITMODE_RESET); // disable Synchronous BitBang + ftdi_usb_close(handle); + ftdi_deinit (handle); + pthread_cancel(readerthread); + pthread_join(readerthread, NULL); + free(handle); + handle = NULL; + } +} + +static void ft245r_display(PROGRAMMER * pgm, const char * p) { + avrdude_message(MSG_INFO, "%sPin assignment : 0..7 = DBUS0..7\n",p);/* , 8..11 = GPIO0..3\n",p);*/ + pgm_display_generic_mask(pgm, p, SHOW_ALL_PINS); +} + +static int ft245r_paged_write_gen(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int addr, + unsigned int n_bytes) { + unsigned long i, pa; + int rc; + + for (i=0; ibuf[addr]); + if (rc != 0) { + return -2; + } + + if (m->paged) { + // Can this piece of code ever be activated?? Do AVRs exist that + // have paged non-flash memories? -- REW + // XXX Untested code below. + /* + * check to see if it is time to flush the page with a page + * write + */ + + if (((addr % m->page_size) == m->page_size-1) || (i == n_bytes-1)) { + pa = addr - (addr % m->page_size); + + rc = avr_write_page(pgm, p, m, pa); + if (rc != 0) { + return -2; + } + } + } + } + return i; +} + +static struct ft245r_request { + int addr; + int bytes; + int n; + struct ft245r_request *next; +} *req_head,*req_tail,*req_pool; + +static void put_request(int addr, int bytes, int n) { + struct ft245r_request *p; + if (req_pool) { + p = req_pool; + req_pool = p->next; + } else { + p = malloc(sizeof(struct ft245r_request)); + if (!p) { + avrdude_message(MSG_INFO, "can't alloc memory\n"); + exit(1); + } + } + memset(p, 0, sizeof(struct ft245r_request)); + p->addr = addr; + p->bytes = bytes; + p->n = n; + if (req_tail) { + req_tail->next = p; + req_tail = p; + } else { + req_head = req_tail = p; + } +} + +static int do_request(PROGRAMMER * pgm, AVRMEM *m) { + struct ft245r_request *p; + int addr, bytes, j, n; + unsigned char buf[FT245R_FRAGMENT_SIZE+1+128]; + + if (!req_head) return 0; + p = req_head; + req_head = p->next; + if (!req_head) req_tail = req_head; + + addr = p->addr; + bytes = p->bytes; + n = p->n; + memset(p, 0, sizeof(struct ft245r_request)); + p->next = req_pool; + req_pool = p; + + ft245r_recv(pgm, buf, bytes); + for (j=0; jbuf[addr++] = extract_data(pgm, buf , (j * 4 + 3)); + } + return 1; +} + +static int ft245r_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + int page_size, int addr, int n_bytes) { + unsigned int i,j; + int addr_save,buf_pos,do_page_write,req_count; + unsigned char buf[FT245R_FRAGMENT_SIZE+1+128]; + + req_count = 0; + for (i=0; i> 9) & 0xff ); + buf_pos += set_data(pgm, buf+buf_pos, (addr >> 1) & 0xff ); + buf_pos += set_data(pgm, buf+buf_pos, m->buf[addr]); + addr ++; + i++; + if ( (m->paged) && + (((i % m->page_size) == 0) || (i == n_bytes))) { + do_page_write = 1; + break; + } + } +#if defined(USE_INLINE_WRITE_PAGE) + if (do_page_write) { + int addr_wk = addr_save - (addr_save % m->page_size); + /* If this device has a "load extended address" command, issue it. */ + if (m->op[AVR_OP_LOAD_EXT_ADDR]) { + unsigned char cmd[4]; + OPCODE *lext = m->op[AVR_OP_LOAD_EXT_ADDR]; + + memset(cmd, 0, 4); + avr_set_bits(lext, cmd); + avr_set_addr(lext, cmd, addr_wk/2); + buf_pos += set_data(pgm, buf+buf_pos, cmd[0]); + buf_pos += set_data(pgm, buf+buf_pos, cmd[1]); + buf_pos += set_data(pgm, buf+buf_pos, cmd[2]); + buf_pos += set_data(pgm, buf+buf_pos, cmd[3]); + } + buf_pos += set_data(pgm, buf+buf_pos, 0x4C); /* Issue Page Write */ + buf_pos += set_data(pgm, buf+buf_pos,(addr_wk >> 9) & 0xff); + buf_pos += set_data(pgm, buf+buf_pos,(addr_wk >> 1) & 0xff); + buf_pos += set_data(pgm, buf+buf_pos, 0); + } +#endif + if (i >= n_bytes) { + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_AVR_SCK,0); // sck down + buf[buf_pos++] = ft245r_out; + } + ft245r_send(pgm, buf, buf_pos); + put_request(addr_save, buf_pos, 0); + //ft245r_sync(pgm); +#if 0 + avrdude_message(MSG_INFO, "send addr 0x%04x bufsize %d [%02x %02x] page_write %d\n", + addr_save,buf_pos, + extract_data_out(pgm, buf , (0*4 + 3) ), + extract_data_out(pgm, buf , (1*4 + 3) ), + do_page_write); +#endif + req_count++; + if (req_count > REQ_OUTSTANDINGS) + do_request(pgm, m); + if (do_page_write) { +#if defined(USE_INLINE_WRITE_PAGE) + while (do_request(pgm, m)) + ; + usleep(m->max_write_delay); +#else + int addr_wk = addr_save - (addr_save % m->page_size); + int rc; + while (do_request(pgm, m)) + ; + rc = avr_write_page(pgm, p, m, addr_wk); + if (rc != 0) { + return -2; + } +#endif + req_count = 0; + } + } + while (do_request(pgm, m)) + ; + return i; +} + + +static int ft245r_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) { + if (strcmp(m->desc, "flash") == 0) { + return ft245r_paged_write_flash(pgm, p, m, page_size, addr, n_bytes); + } else if (strcmp(m->desc, "eeprom") == 0) { + return ft245r_paged_write_gen(pgm, p, m, page_size, addr, n_bytes); + } else { + return -2; + } +} + +static int ft245r_paged_load_gen(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int addr, + int n_bytes) { + unsigned char rbyte; + unsigned long i; + int rc; + + for (i=0; ibuf[i+addr] = rbyte; + } + return 0; +} + +static int ft245r_paged_load_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int addr, + unsigned int n_bytes) { + unsigned long i,j,n; + int addr_save,buf_pos; + int req_count = 0; + unsigned char buf[FT245R_FRAGMENT_SIZE+1]; + + for (i=0; i= n_bytes) break; + buf_pos += set_data(pgm, buf+buf_pos, (addr & 1)?0x28:0x20 ); + buf_pos += set_data(pgm, buf+buf_pos, (addr >> 9) & 0xff ); + buf_pos += set_data(pgm, buf+buf_pos, (addr >> 1) & 0xff ); + buf_pos += set_data(pgm, buf+buf_pos, 0); + addr ++; + i++; + } + if (i >= n_bytes) { + ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_AVR_SCK,0); // sck down + buf[buf_pos++] = ft245r_out; + } + n = j; + ft245r_send(pgm, buf, buf_pos); + put_request(addr_save, buf_pos, n); + req_count++; + if (req_count > REQ_OUTSTANDINGS) + do_request(pgm, m); + + } + while (do_request(pgm, m)) + ; + return 0; +} + +static int ft245r_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int addr, + unsigned int n_bytes) { + if (strcmp(m->desc, "flash") == 0) { + return ft245r_paged_load_flash(pgm, p, m, page_size, addr, n_bytes); + } else if (strcmp(m->desc, "eeprom") == 0) { + return ft245r_paged_load_gen(pgm, p, m, page_size, addr, n_bytes); + } else { + return -2; + } +} + +void ft245r_initpgm(PROGRAMMER * pgm) { + strcpy(pgm->type, "ftdi_syncbb"); + + /* + * mandatory functions + */ + pgm->initialize = ft245r_initialize; + pgm->display = ft245r_display; + pgm->enable = ft245r_enable; + pgm->disable = ft245r_disable; + pgm->program_enable = ft245r_program_enable; + pgm->chip_erase = ft245r_chip_erase; + pgm->cmd = ft245r_cmd; + pgm->open = ft245r_open; + pgm->close = ft245r_close; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; + + /* + * optional functions + */ + pgm->paged_write = ft245r_paged_write; + pgm->paged_load = ft245r_paged_load; + + pgm->rdy_led = set_led_rdy; + pgm->err_led = set_led_err; + pgm->pgm_led = set_led_pgm; + pgm->vfy_led = set_led_vfy; + pgm->powerup = ft245r_powerup; + pgm->powerdown = ft245r_powerdown; + + handle = NULL; +} + +#endif + +const char ft245r_desc[] = "FT245R/FT232R Synchronous BitBangMode Programmer"; diff --git a/xs/src/avrdude/ft245r.h b/xs/src/avrdude/ft245r.h new file mode 100644 index 000000000..40602e220 --- /dev/null +++ b/xs/src/avrdude/ft245r.h @@ -0,0 +1,8 @@ +#ifndef ft245r_h +#define ft245r_h + +extern const char ft245r_desc[]; +void ft245r_initpgm (PROGRAMMER * pgm); + + +#endif /* ft245r_h */ diff --git a/xs/src/avrdude/jtag3.c b/xs/src/avrdude/jtag3.c new file mode 100644 index 000000000..3084c3201 --- /dev/null +++ b/xs/src/avrdude/jtag3.c @@ -0,0 +1,2286 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2012 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 + * 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$ */ + +/* + * avrdude interface for Atmel JTAGICE3 programmer + */ + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "crc16.h" +#include "jtag3.h" +#include "jtag3_private.h" +#include "usbdevs.h" + +/* + * Private data for this programmer. + */ +struct pdata +{ + unsigned short command_sequence; /* Next cmd seqno to issue. */ + + /* + * See jtag3_read_byte() for an explanation of the flash and + * EEPROM page caches. + */ + unsigned char *flash_pagecache; + unsigned long flash_pageaddr; + unsigned int flash_pagesize; + + unsigned char *eeprom_pagecache; + unsigned long eeprom_pageaddr; + unsigned int eeprom_pagesize; + + int prog_enabled; /* Cached value of PROGRAMMING status. */ + + /* JTAG chain stuff */ + unsigned char jtagchain[4]; + + /* Start address of Xmega boot area */ + unsigned long boot_start; + + /* Function to set the appropriate clock parameter */ + int (*set_sck)(PROGRAMMER *, unsigned char *); +}; + +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) + +/* + * pgm->flag is marked as "for private use of the programmer". + * The following defines this programmer's use of that field. + */ +#define PGM_FL_IS_DW (0x0001) +#define PGM_FL_IS_PDI (0x0002) +#define PGM_FL_IS_JTAG (0x0004) +#define PGM_FL_IS_EDBG (0x0008) + +static int jtag3_open(PROGRAMMER * pgm, char * port); +static int jtag3_edbg_prepare(PROGRAMMER * pgm); +static int jtag3_edbg_signoff(PROGRAMMER * pgm); +static int jtag3_edbg_send(PROGRAMMER * pgm, unsigned char * data, size_t len); +static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg); + +static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p); +static int jtag3_chip_erase(PROGRAMMER * pgm, AVRPART * p); +static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value); +static int jtag3_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data); +static int jtag3_set_sck_period(PROGRAMMER * pgm, double v); +static void jtag3_print_parms1(PROGRAMMER * pgm, const char * p); +static int jtag3_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes); +static unsigned char jtag3_memtype(PROGRAMMER * pgm, AVRPART * p, unsigned long addr); +static unsigned int jtag3_memaddr(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr); + + +void jtag3_setup(PROGRAMMER * pgm) +{ + if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + avrdude_message(MSG_INFO, "%s: jtag3_setup(): Out of memory allocating private data\n", + progname); + exit(1); + } + memset(pgm->cookie, 0, sizeof(struct pdata)); +} + +void jtag3_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); +} + + +static unsigned long +b4_to_u32(unsigned char *b) +{ + unsigned long l; + l = b[0]; + l += (unsigned)b[1] << 8; + l += (unsigned)b[2] << 16; + l += (unsigned)b[3] << 24; + + return l; +} + +static void +u32_to_b4(unsigned char *b, unsigned long l) +{ + b[0] = l & 0xff; + b[1] = (l >> 8) & 0xff; + b[2] = (l >> 16) & 0xff; + b[3] = (l >> 24) & 0xff; +} + +static unsigned short +b2_to_u16(unsigned char *b) +{ + unsigned short l; + l = b[0]; + l += (unsigned)b[1] << 8; + + return l; +} + +static void +u16_to_b2(unsigned char *b, unsigned short l) +{ + b[0] = l & 0xff; + b[1] = (l >> 8) & 0xff; +} + +static void jtag3_print_data(unsigned char *b, size_t s) +{ + int i; + + if (s < 2) + return; + + for (i = 0; i < s; i++) { + avrdude_message(MSG_INFO, "0x%02x", b[i]); + if (i % 16 == 15) + putc('\n', stderr); + else + putc(' ', stderr); + } + if (i % 16 != 0) + putc('\n', stderr); +} + +static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + int i; + + if (verbose >= 4) { + avrdude_message(MSG_TRACE, "Raw message:\n"); + + for (i = 0; i < len; i++) { + avrdude_message(MSG_TRACE, "%02x ", data[i]); + if (i % 16 == 15) + putc('\n', stderr); + else + putc(' ', stderr); + } + if (i % 16 != 0) + putc('\n', stderr); + } + + switch (data[0]) { + case SCOPE_INFO: + avrdude_message(MSG_INFO, "[info] "); + break; + + case SCOPE_GENERAL: + avrdude_message(MSG_INFO, "[general] "); + break; + + case SCOPE_AVR_ISP: + avrdude_message(MSG_INFO, "[AVRISP] "); + jtag3_print_data(data + 1, len - 1); + return; + + case SCOPE_AVR: + avrdude_message(MSG_INFO, "[AVR] "); + break; + + default: + avrdude_message(MSG_INFO, "[scope 0x%02x] ", data[0]); + break; + } + + switch (data[1]) { + case RSP3_OK: + avrdude_message(MSG_INFO, "OK\n"); + break; + + case RSP3_FAILED: + avrdude_message(MSG_INFO, "FAILED"); + if (len > 3) + { + char reason[50]; + sprintf(reason, "0x%02x", data[3]); + switch (data[3]) + { + case RSP3_FAIL_NO_ANSWER: + strcpy(reason, "target does not answer"); + break; + + case RSP3_FAIL_NO_TARGET_POWER: + strcpy(reason, "no target power"); + break; + + case RSP3_FAIL_NOT_UNDERSTOOD: + strcpy(reason, "command not understood"); + break; + + case RSP3_FAIL_WRONG_MODE: + strcpy(reason, "wrong (programming) mode"); + break; + + case RSP3_FAIL_PDI: + strcpy(reason, "PDI failure"); + break; + + case RSP3_FAIL_UNSUPP_MEMORY: + strcpy(reason, "unsupported memory type"); + break; + + case RSP3_FAIL_WRONG_LENGTH: + strcpy(reason, "wrong length in memory access"); + break; + + case RSP3_FAIL_DEBUGWIRE: + strcpy(reason, "debugWIRE communication failed"); + break; + } + avrdude_message(MSG_INFO, ", reason: %s\n", reason); + } + else + { + avrdude_message(MSG_INFO, ", unspecified reason\n"); + } + break; + + case RSP3_DATA: + avrdude_message(MSG_INFO, "Data returned:\n"); + jtag3_print_data(data + 2, len - 2); + break; + + case RSP3_INFO: + avrdude_message(MSG_INFO, "Info returned:\n"); + for (i = 2; i < len; i++) { + if (isprint(data[i])) + putc(data[i], stderr); + else + avrdude_message(MSG_INFO, "\\%03o", data[i]); + } + putc('\n', stderr); + break; + + case RSP3_PC: + if (len < 7) + { + avrdude_message(MSG_INFO, "PC reply too short\n"); + } + else + { + unsigned long pc = (data[6] << 24) | (data[5] << 16) + | (data[4] << 8) | data[3]; + avrdude_message(MSG_INFO, "PC 0x%0lx\n", pc); + } + break; + + default: + avrdude_message(MSG_INFO, "unknown message 0x%02x\n", data[1]); + } +} + +static void jtag3_prevent(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + int i; + + if (verbose >= 4) { + avrdude_message(MSG_TRACE, "Raw event:\n"); + + for (i = 0; i < len; i++) { + avrdude_message(MSG_TRACE, "%02x ", data[i]); + if (i % 16 == 15) + putc('\n', stderr); + else + putc(' ', stderr); + } + if (i % 16 != 0) + putc('\n', stderr); + } + + avrdude_message(MSG_INFO, "Event serial 0x%04x, ", + (data[3] << 8) | data[2]); + + switch (data[4]) { + case SCOPE_INFO: + avrdude_message(MSG_INFO, "[info] "); + break; + + case SCOPE_GENERAL: + avrdude_message(MSG_INFO, "[general] "); + break; + + case SCOPE_AVR: + avrdude_message(MSG_INFO, "[AVR] "); + break; + + default: + avrdude_message(MSG_INFO, "[scope 0x%02x] ", data[0]); + break; + } + + switch (data[5]) { + case EVT3_BREAK: + avrdude_message(MSG_INFO, "BREAK"); + if (len >= 11) { + avrdude_message(MSG_INFO, ", PC = 0x%lx, reason ", b4_to_u32(data + 6)); + switch (data[10]) { + case 0x00: + avrdude_message(MSG_INFO, "unspecified"); + break; + case 0x01: + avrdude_message(MSG_INFO, "program break"); + break; + case 0x02: + avrdude_message(MSG_INFO, "data break PDSB"); + break; + case 0x03: + avrdude_message(MSG_INFO, "data break PDMSB"); + break; + default: + avrdude_message(MSG_INFO, "unknown: 0x%02x", data[10]); + } + /* There are two more bytes of data which always appear to be + * 0x01, 0x00. Purpose unknown. */ + } + break; + + case EVT3_SLEEP: + if (len >= 8 && data[7] == 0) + avrdude_message(MSG_INFO, "sleeping"); + else if (len >= 8 && data[7] == 1) + avrdude_message(MSG_INFO, "wakeup"); + else + avrdude_message(MSG_INFO, "unknown SLEEP event"); + break; + + case EVT3_POWER: + if (len >= 8 && data[7] == 0) + avrdude_message(MSG_INFO, "power-down"); + else if (len >= 8 && data[7] == 1) + avrdude_message(MSG_INFO, "power-up"); + else + avrdude_message(MSG_INFO, "unknown POWER event"); + break; + + default: + avrdude_message(MSG_INFO, "UNKNOWN 0x%02x", data[5]); + break; + } + putc('\n', stderr); +} + + + +int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + unsigned char *buf; + + if (pgm->flag & PGM_FL_IS_EDBG) + return jtag3_edbg_send(pgm, data, len); + + avrdude_message(MSG_DEBUG, "\n%s: jtag3_send(): sending %lu bytes\n", + progname, (unsigned long)len); + + if ((buf = malloc(len + 4)) == NULL) + { + avrdude_message(MSG_INFO, "%s: jtag3_send(): out of memory", + progname); + return -1; + } + + buf[0] = TOKEN; + buf[1] = 0; /* dummy */ + u16_to_b2(buf + 2, PDATA(pgm)->command_sequence); + memcpy(buf + 4, data, len); + + if (serial_send(&pgm->fd, buf, len + 4) != 0) { + avrdude_message(MSG_INFO, "%s: jtag3_send(): failed to send command to serial port\n", + progname); + return -1; + } + + free(buf); + + return 0; +} + +static int jtag3_edbg_send(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + unsigned char buf[USBDEV_MAX_XFER_3]; + unsigned char status[USBDEV_MAX_XFER_3]; + int rv; + + if (verbose >= 4) + { + memset(buf, 0, USBDEV_MAX_XFER_3); + memset(status, 0, USBDEV_MAX_XFER_3); + } + + avrdude_message(MSG_DEBUG, "\n%s: jtag3_edbg_send(): sending %lu bytes\n", + progname, (unsigned long)len); + + /* 4 bytes overhead for CMD, fragment #, and length info */ + int max_xfer = pgm->fd.usb.max_xfer; + int nfragments = (len + max_xfer - 1) / max_xfer; + if (nfragments > 1) + { + avrdude_message(MSG_DEBUG, "%s: jtag3_edbg_send(): fragmenting into %d packets\n", + progname, nfragments); + } + int frag; + for (frag = 0; frag < nfragments; frag++) + { + int this_len; + + /* All fragments have the (CMSIS-DAP layer) CMD, the fragment + * identifier, and the length field. */ + buf[0] = EDBG_VENDOR_AVR_CMD; + buf[1] = ((frag + 1) << 4) | nfragments; + + if (frag == 0) + { + /* Only first fragment has TOKEN and seq#, thus four bytes + * less payload than subsequent fragments. */ + this_len = len < max_xfer - 8? len: max_xfer - 8; + buf[2] = (this_len + 4) >> 8; + buf[3] = (this_len + 4) & 0xff; + buf[4] = TOKEN; + buf[5] = 0; /* dummy */ + u16_to_b2(buf + 6, PDATA(pgm)->command_sequence); + memcpy(buf + 8, data, this_len); + } + else + { + this_len = len < max_xfer - 4? len: max_xfer - 4; + buf[2] = (this_len) >> 8; + buf[3] = (this_len) & 0xff; + memcpy(buf + 4, data, this_len); + } + + if (serial_send(&pgm->fd, buf, max_xfer) != 0) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_send(): failed to send command to serial port\n", + progname); + return -1; + } + rv = serial_recv(&pgm->fd, status, max_xfer); + + if (rv < 0) { + /* timeout in receive */ + avrdude_message(MSG_NOTICE2, "%s: jtag3_edbg_send(): Timeout receiving packet\n", + progname); + return -1; + } + if (status[0] != EDBG_VENDOR_AVR_CMD || + (frag == nfragments - 1 && status[1] != 0x01)) + { + /* what to do in this case? */ + avrdude_message(MSG_INFO, "%s: jtag3_edbg_send(): Unexpected response 0x%02x, 0x%02x\n", + progname, status[0], status[1]); + } + data += this_len; + len -= this_len; + } + + return 0; +} + +/* + * Send out all the CMSIS-DAP stuff needed to prepare the ICE. + */ +static int jtag3_edbg_prepare(PROGRAMMER * pgm) +{ + unsigned char buf[USBDEV_MAX_XFER_3]; + unsigned char status[USBDEV_MAX_XFER_3]; + int rv; + + avrdude_message(MSG_DEBUG, "\n%s: jtag3_edbg_prepare()\n", + progname); + + if (verbose >= 4) + memset(buf, 0, USBDEV_MAX_XFER_3); + + buf[0] = CMSISDAP_CMD_CONNECT; + buf[1] = CMSISDAP_CONN_SWD; + if (serial_send(&pgm->fd, buf, pgm->fd.usb.max_xfer) != 0) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): failed to send command to serial port\n", + progname); + return -1; + } + rv = serial_recv(&pgm->fd, status, pgm->fd.usb.max_xfer); + if (rv != pgm->fd.usb.max_xfer) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): failed to read from serial port (%d)\n", + progname, rv); + return -1; + } + if (status[0] != CMSISDAP_CMD_CONNECT || + status[1] == 0) + avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): unexpected response 0x%02x, 0x%02x\n", + progname, status[0], status[1]); + avrdude_message(MSG_NOTICE2, "%s: jtag3_edbg_prepare(): connection status 0x%02x\n", + progname, status[1]); + + buf[0] = CMSISDAP_CMD_LED; + buf[1] = CMSISDAP_LED_CONNECT; + buf[2] = 1; + if (serial_send(&pgm->fd, buf, pgm->fd.usb.max_xfer) != 0) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): failed to send command to serial port\n", + progname); + return -1; + } + rv = serial_recv(&pgm->fd, status, pgm->fd.usb.max_xfer); + if (rv != pgm->fd.usb.max_xfer) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): failed to read from serial port (%d)\n", + progname, rv); + return -1; + } + if (status[0] != CMSISDAP_CMD_LED || + status[1] != 0) + avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): unexpected response 0x%02x, 0x%02x\n", + progname, status[0], status[1]); + + return 0; +} + + +/* + * Send out all the CMSIS-DAP stuff when signing off. + */ +static int jtag3_edbg_signoff(PROGRAMMER * pgm) +{ + unsigned char buf[USBDEV_MAX_XFER_3]; + unsigned char status[USBDEV_MAX_XFER_3]; + int rv; + + avrdude_message(MSG_DEBUG, "\n%s: jtag3_edbg_signoff()\n", + progname); + + if (verbose >= 4) + memset(buf, 0, USBDEV_MAX_XFER_3); + + buf[0] = CMSISDAP_CMD_LED; + buf[1] = CMSISDAP_LED_CONNECT; + buf[2] = 0; + if (serial_send(&pgm->fd, buf, pgm->fd.usb.max_xfer) != 0) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to send command to serial port\n", + progname); + return -1; + } + rv = serial_recv(&pgm->fd, status, pgm->fd.usb.max_xfer); + if (rv != pgm->fd.usb.max_xfer) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n", + progname, rv); + return -1; + } + if (status[0] != CMSISDAP_CMD_LED || + status[1] != 0) + avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n", + progname, status[0], status[1]); + + buf[0] = CMSISDAP_CMD_DISCONNECT; + if (serial_send(&pgm->fd, buf, pgm->fd.usb.max_xfer) != 0) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to send command to serial port\n", + progname); + return -1; + } + rv = serial_recv(&pgm->fd, status, pgm->fd.usb.max_xfer); + if (rv != pgm->fd.usb.max_xfer) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n", + progname, rv); + return -1; + } + if (status[0] != CMSISDAP_CMD_DISCONNECT || + status[1] != 0) + avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n", + progname, status[0], status[1]); + + return 0; +} + + +static int jtag3_drain(PROGRAMMER * pgm, int display) +{ + return serial_drain(&pgm->fd, display); +} + + +/* + * Receive one frame, return it in *msg. Received sequence number is + * returned in seqno. Any valid frame will be returned, regardless + * whether it matches the expected sequence number, including event + * notification frames (seqno == 0xffff). + * + * Caller must eventually free the buffer. + */ +static int jtag3_recv_frame(PROGRAMMER * pgm, unsigned char **msg) { + int rv; + unsigned char *buf = NULL; + + if (pgm->flag & PGM_FL_IS_EDBG) + return jtag3_edbg_recv_frame(pgm, msg); + + avrdude_message(MSG_TRACE, "%s: jtag3_recv():\n", progname); + + if ((buf = malloc(pgm->fd.usb.max_xfer)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtag3_recv(): out of memory\n", + progname); + return -1; + } + if (verbose >= 4) + memset(buf, 0, pgm->fd.usb.max_xfer); + + rv = serial_recv(&pgm->fd, buf, pgm->fd.usb.max_xfer); + + if (rv < 0) { + /* timeout in receive */ + avrdude_message(MSG_NOTICE2, "%s: jtag3_recv(): Timeout receiving packet\n", + progname); + free(buf); + return -1; + } + + *msg = buf; + + return rv; +} + +static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) { + int rv, len = 0; + unsigned char *buf = NULL; + unsigned char *request; + + avrdude_message(MSG_TRACE, "%s: jtag3_edbg_recv():\n", progname); + + if ((buf = malloc(USBDEV_MAX_XFER_3)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): out of memory\n", + progname); + return -1; + } + if ((request = malloc(pgm->fd.usb.max_xfer)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): out of memory\n", + progname); + free(buf); + return -1; + } + + *msg = buf; + + int nfrags = 0; + int thisfrag = 0; + + do { + request[0] = EDBG_VENDOR_AVR_RSP; + + if (serial_send(&pgm->fd, request, pgm->fd.usb.max_xfer) != 0) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): error sending CMSIS-DAP vendor command\n", + progname); + free(request); + free(*msg); + return -1; + } + + rv = serial_recv(&pgm->fd, buf, pgm->fd.usb.max_xfer); + + if (rv < 0) { + /* timeout in receive */ + avrdude_message(MSG_NOTICE2, "%s: jtag3_edbg_recv(): Timeout receiving packet\n", + progname); + free(*msg); + free(request); + return -1; + } + + if (buf[0] != EDBG_VENDOR_AVR_RSP) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): Unexpected response 0x%02x\n", + progname, buf[0]); + free(*msg); + free(request); + return -1; + } + + /* calculate fragment information */ + if (thisfrag == 0) { + /* first fragment */ + nfrags = buf[1] & 0x0F; + thisfrag = 1; + } else { + if (nfrags != (buf[1] & 0x0F)) { + avrdude_message(MSG_INFO, + "%s: jtag3_edbg_recv(): " + "Inconsistent # of fragments; had %d, now %d\n", + progname, nfrags, (buf[1] & 0x0F)); + free(*msg); + free(request); + return -1; + } + } + if (thisfrag != ((buf[1] >> 4) & 0x0F)) { + avrdude_message(MSG_INFO, + "%s: jtag3_edbg_recv(): " + "Inconsistent fragment number; expect %d, got %d\n", + progname, thisfrag, ((buf[1] >> 4) & 0x0F)); + free(*msg); + free(request); + return -1; + } + + int thislen = (buf[2] << 8) | buf[3]; + if (thislen > rv + 4) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): Unexpected length value (%d > %d)\n", + progname, thislen, rv + 4); + thislen = rv + 4; + } + if (len + thislen > USBDEV_MAX_XFER_3) { + avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): Length exceeds max size (%d > %d)\n", + progname, len + thislen, USBDEV_MAX_XFER_3); + thislen = USBDEV_MAX_XFER_3 - len; + } + memmove(buf, buf + 4, thislen); + thisfrag++; + len += thislen; + buf += thislen; + } while (thisfrag <= nfrags); + + free(request); + return len; +} + +int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) { + unsigned short r_seqno; + int rv; + + for (;;) { + if ((rv = jtag3_recv_frame(pgm, msg)) <= 0) + return rv; + + if ((rv & USB_RECV_FLAG_EVENT) != 0) { + if (verbose >= 3) + jtag3_prevent(pgm, *msg, rv & USB_RECV_LENGTH_MASK); + + free(*msg); + continue; + } + + rv &= USB_RECV_LENGTH_MASK; + r_seqno = ((*msg)[2] << 8) | (*msg)[1]; + avrdude_message(MSG_DEBUG, "%s: jtag3_recv(): " + "Got message seqno %d (command_sequence == %d)\n", + progname, r_seqno, PDATA(pgm)->command_sequence); + if (r_seqno == PDATA(pgm)->command_sequence) { + if (++(PDATA(pgm)->command_sequence) == 0xffff) + PDATA(pgm)->command_sequence = 0; + /* + * We move the payload to the beginning of the buffer, to make + * the job easier for the caller. We have to return the + * original pointer though, as the caller must free() it. + */ + rv -= 3; + memmove(*msg, *msg + 3, rv); + + return rv; + } + avrdude_message(MSG_NOTICE2, "%s: jtag3_recv(): " + "got wrong sequence number, %u != %u\n", + progname, r_seqno, PDATA(pgm)->command_sequence); + + free(*msg); + } +} + + int jtag3_command(PROGRAMMER *pgm, unsigned char *cmd, unsigned int cmdlen, + unsigned char **resp, const char *descr) +{ + int status; + unsigned char c; + + avrdude_message(MSG_NOTICE2, "%s: Sending %s command: ", + progname, descr); + jtag3_send(pgm, cmd, cmdlen); + + status = jtag3_recv(pgm, resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_NOTICE2, "%s: %s command: timeout/error communicating with programmer (status %d)\n", + progname, descr, status); + return -1; + } else if (verbose >= 3) { + putc('\n', stderr); + jtag3_prmsg(pgm, *resp, status); + } else { + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", (*resp)[1], status); + } + + c = (*resp)[1]; + if ((c & RSP3_STATUS_MASK) != RSP3_OK) { + avrdude_message(MSG_INFO, "%s: bad response to %s command: 0x%02x\n", + progname, descr, c); + free(*resp); + resp = 0; + return -1; + } + + return status; +} + + +int jtag3_getsync(PROGRAMMER * pgm, int mode) { + + unsigned char buf[3], *resp; + + avrdude_message(MSG_DEBUG, "%s: jtag3_getsync()\n", progname); + + if (pgm->flag & PGM_FL_IS_EDBG) { + if (jtag3_edbg_prepare(pgm) < 0) + return -1; + } + + /* Get the sign-on information. */ + buf[0] = SCOPE_GENERAL; + buf[1] = CMD3_SIGN_ON; + buf[2] = 0; + + if (jtag3_command(pgm, buf, 3, &resp, "sign-on") < 0) + return -1; + + free(resp); + + return 0; +} + +/* + * issue the 'chip erase' command to the AVR device + */ +static int jtag3_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char buf[8], *resp; + + buf[0] = SCOPE_AVR; + buf[1] = CMD3_ERASE_MEMORY; + buf[2] = 0; + buf[3] = XMEGA_ERASE_CHIP; + buf[4] = buf[5] = buf[6] = buf[7] = 0; /* page address */ + + if (jtag3_command(pgm, buf, 8, &resp, "chip erase") < 0) + return -1; + + free(resp); + return 0; +} + +/* + * There is no chip erase functionality in debugWire mode. + */ +static int jtag3_chip_erase_dw(PROGRAMMER * pgm, AVRPART * p) +{ + + avrdude_message(MSG_INFO, "%s: Chip erase not supported in debugWire mode\n", + progname); + + return 0; +} + +static int jtag3_program_enable_dummy(PROGRAMMER * pgm, AVRPART * p) +{ + return 0; +} + +static int jtag3_program_enable(PROGRAMMER * pgm) +{ + unsigned char buf[3], *resp; + + if (PDATA(pgm)->prog_enabled) + return 0; + + buf[0] = SCOPE_AVR; + buf[1] = CMD3_ENTER_PROGMODE; + buf[2] = 0; + + if (jtag3_command(pgm, buf, 3, &resp, "enter progmode") >= 0) { + free(resp); + PDATA(pgm)->prog_enabled = 1; + + return 0; + } + + return -1; +} + +static int jtag3_program_disable(PROGRAMMER * pgm) +{ + unsigned char buf[3], *resp; + + if (!PDATA(pgm)->prog_enabled) + return 0; + + buf[0] = SCOPE_AVR; + buf[1] = CMD3_LEAVE_PROGMODE; + buf[2] = 0; + + if (jtag3_command(pgm, buf, 3, &resp, "leave progmode") < 0) + return -1; + + free(resp); + + PDATA(pgm)->prog_enabled = 0; + + return 0; +} + +static int jtag3_set_sck_xmega_pdi(PROGRAMMER *pgm, unsigned char *clk) +{ + return jtag3_setparm(pgm, SCOPE_AVR, 1, PARM3_CLK_XMEGA_PDI, clk, 2); +} + +static int jtag3_set_sck_xmega_jtag(PROGRAMMER *pgm, unsigned char *clk) +{ + return jtag3_setparm(pgm, SCOPE_AVR, 1, PARM3_CLK_XMEGA_JTAG, clk, 2); +} + +static int jtag3_set_sck_mega_jtag(PROGRAMMER *pgm, unsigned char *clk) +{ + return jtag3_setparm(pgm, SCOPE_AVR, 1, PARM3_CLK_MEGA_PROG, clk, 2); +} + + +/* + * initialize the AVR device and prepare it to accept commands + */ +static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char conn = 0, parm[4]; + const char *ifname; + unsigned char cmd[4], *resp; + int status; + + /* + * At least, as of firmware 2.12, the JTAGICE3 doesn't handle + * splitting packets correctly. On a large transfer, the first + * split packets are correct, but remaining packets contain just + * garbage. + * + * We move the check here so in case future firmware versions fix + * this, the check below can be made dependended on the actual + * firmware level. Retrieving the firmware version can always be + * accomplished with USB 1.1 (64 byte max) packets. + * + * Allow to override the check by -F (so users could try on newer + * firmware), but warn loudly. + */ + if (jtag3_getparm(pgm, SCOPE_GENERAL, 0, PARM3_FW_MAJOR, parm, 2) < 0) + return -1; + if (pgm->fd.usb.max_xfer < USBDEV_MAX_XFER_3 && (pgm->flag & PGM_FL_IS_EDBG) == 0) { + avrdude_message(MSG_INFO, "%s: the JTAGICE3's firmware %d.%d is broken on USB 1.1 connections, sorry\n", + progname, parm[0], parm[1]); + if (ovsigck) { + avrdude_message(MSG_INFO, "%s: forced to continue by option -F; THIS PUTS THE DEVICE'S DATA INTEGRITY AT RISK!\n", + progname); + } else { + return -1; + } + } + + if (pgm->flag & PGM_FL_IS_DW) { + ifname = "debugWire"; + if (p->flags & AVRPART_HAS_DW) + conn = PARM3_CONN_DW; + } else if (pgm->flag & PGM_FL_IS_PDI) { + ifname = "PDI"; + if (p->flags & AVRPART_HAS_PDI) + conn = PARM3_CONN_PDI; + } else { + ifname = "JTAG"; + if (p->flags & AVRPART_HAS_JTAG) + conn = PARM3_CONN_JTAG; + } + + if (conn == 0) { + avrdude_message(MSG_INFO, "%s: jtag3_initialize(): part %s has no %s interface\n", + progname, p->desc, ifname); + return -1; + } + + if (p->flags & AVRPART_HAS_PDI) + parm[0] = PARM3_ARCH_XMEGA; + else if (p->flags & AVRPART_HAS_DW) + parm[0] = PARM3_ARCH_TINY; + else + parm[0] = PARM3_ARCH_MEGA; + if (jtag3_setparm(pgm, SCOPE_AVR, 0, PARM3_ARCH, parm, 1) < 0) + return -1; + + parm[0] = PARM3_SESS_PROGRAMMING; + if (jtag3_setparm(pgm, SCOPE_AVR, 0, PARM3_SESS_PURPOSE, parm, 1) < 0) + return -1; + + parm[0] = conn; + if (jtag3_setparm(pgm, SCOPE_AVR, 1, PARM3_CONNECTION, parm, 1) < 0) + return -1; + + if (conn == PARM3_CONN_PDI) + PDATA(pgm)->set_sck = jtag3_set_sck_xmega_pdi; + else if (conn == PARM3_CONN_JTAG) { + if (p->flags & AVRPART_HAS_PDI) + PDATA(pgm)->set_sck = jtag3_set_sck_xmega_jtag; + else + PDATA(pgm)->set_sck = jtag3_set_sck_mega_jtag; + } + if (pgm->bitclock != 0.0 && PDATA(pgm)->set_sck != NULL) + { + unsigned int clock = 1E-3 / pgm->bitclock; /* kHz */ + avrdude_message(MSG_NOTICE2, "%s: jtag3_initialize(): " + "trying to set JTAG clock to %u kHz\n", + progname, clock); + parm[0] = clock & 0xff; + parm[1] = (clock >> 8) & 0xff; + if (PDATA(pgm)->set_sck(pgm, parm) < 0) + return -1; + } + + if (conn == PARM3_CONN_JTAG) + { + avrdude_message(MSG_NOTICE2, "%s: jtag3_initialize(): " + "trying to set JTAG daisy-chain info to %d,%d,%d,%d\n", + progname, + PDATA(pgm)->jtagchain[0], PDATA(pgm)->jtagchain[1], + PDATA(pgm)->jtagchain[2], PDATA(pgm)->jtagchain[3]); + if (jtag3_setparm(pgm, SCOPE_AVR, 1, PARM3_JTAGCHAIN, PDATA(pgm)->jtagchain, 4) < 0) + return -1; + } + + /* set device descriptor data */ + if ((p->flags & AVRPART_HAS_PDI)) + { + struct xmega_device_desc xd; + LNODEID ln; + AVRMEM * m; + + u16_to_b2(xd.nvm_base_addr, p->nvm_base); + u16_to_b2(xd.mcu_base_addr, p->mcu_base); + + for (ln = lfirst(p->mem); ln; ln = lnext(ln)) { + m = ldata(ln); + if (strcmp(m->desc, "flash") == 0) { + if (m->readsize != 0 && m->readsize < m->page_size) + PDATA(pgm)->flash_pagesize = m->readsize; + else + PDATA(pgm)->flash_pagesize = m->page_size; + u16_to_b2(xd.flash_page_size, m->page_size); + } else if (strcmp(m->desc, "eeprom") == 0) { + PDATA(pgm)->eeprom_pagesize = m->page_size; + xd.eeprom_page_size = m->page_size; + u16_to_b2(xd.eeprom_size, m->size); + u32_to_b4(xd.nvm_eeprom_offset, m->offset); + } else if (strcmp(m->desc, "application") == 0) { + u32_to_b4(xd.app_size, m->size); + u32_to_b4(xd.nvm_app_offset, m->offset); + } else if (strcmp(m->desc, "boot") == 0) { + u16_to_b2(xd.boot_size, m->size); + u32_to_b4(xd.nvm_boot_offset, m->offset); + } else if (strcmp(m->desc, "fuse1") == 0) { + u32_to_b4(xd.nvm_fuse_offset, m->offset & ~7); + } else if (strncmp(m->desc, "lock", 4) == 0) { + u32_to_b4(xd.nvm_lock_offset, m->offset); + } else if (strcmp(m->desc, "usersig") == 0) { + u32_to_b4(xd.nvm_user_sig_offset, m->offset); + } else if (strcmp(m->desc, "prodsig") == 0) { + u32_to_b4(xd.nvm_prod_sig_offset, m->offset); + } else if (strcmp(m->desc, "data") == 0) { + u32_to_b4(xd.nvm_data_offset, m->offset); + } + } + + if (jtag3_setparm(pgm, SCOPE_AVR, 2, PARM3_DEVICEDESC, (unsigned char *)&xd, sizeof xd) < 0) + return -1; + } + else + { + struct mega_device_desc md; + LNODEID ln; + AVRMEM * m; + unsigned int flashsize = 0; + + memset(&md, 0, sizeof md); + + for (ln = lfirst(p->mem); ln; ln = lnext(ln)) { + m = ldata(ln); + if (strcmp(m->desc, "flash") == 0) { + if (m->readsize != 0 && m->readsize < m->page_size) + PDATA(pgm)->flash_pagesize = m->readsize; + else + PDATA(pgm)->flash_pagesize = m->page_size; + u16_to_b2(md.flash_page_size, m->page_size); + u32_to_b4(md.flash_size, (flashsize = m->size)); + // do we need it? just a wild guess + u32_to_b4(md.boot_address, (m->size - m->page_size * 4) / 2); + } else if (strcmp(m->desc, "eeprom") == 0) { + PDATA(pgm)->eeprom_pagesize = m->page_size; + md.eeprom_page_size = m->page_size; + u16_to_b2(md.eeprom_size, m->size); + } + } + + //md.sram_offset[2] = p->sram; // do we need it? + if (p->ocdrev == -1) { + int ocdrev; + + /* lacking a proper definition, guess the OCD revision */ + if (p->flags & AVRPART_HAS_DW) + ocdrev = 1; /* exception: ATtiny13, 2313, 4313 */ + else if (flashsize > 128 * 1024) + ocdrev = 4; + else + ocdrev = 3; /* many exceptions from that, actually */ + avrdude_message(MSG_INFO, "%s: part definition for %s lacks \"ocdrev\"; guessing %d\n", + progname, p->desc, ocdrev); + md.ocd_revision = ocdrev; + } else { + md.ocd_revision = p->ocdrev; + } + md.always_one = 1; + md.allow_full_page_bitstream = (p->flags & AVRPART_ALLOWFULLPAGEBITSTREAM) != 0; + md.idr_address = p->idr; + + if (p->eecr == 0) + p->eecr = 0x3f; /* matches most "modern" mega/tiny AVRs */ + md.eearh_address = p->eecr - 0x20 + 3; + md.eearl_address = p->eecr - 0x20 + 2; + md.eecr_address = p->eecr - 0x20; + md.eedr_address = p->eecr - 0x20 + 1; + md.spmcr_address = p->spmcr; + //md.osccal_address = p->osccal; // do we need it at all? + + if (jtag3_setparm(pgm, SCOPE_AVR, 2, PARM3_DEVICEDESC, (unsigned char *)&md, sizeof md) < 0) + return -1; + } + + int use_ext_reset; + + for (use_ext_reset = 0; use_ext_reset <= 1; use_ext_reset++) { + cmd[0] = SCOPE_AVR; + cmd[1] = CMD3_SIGN_ON; + cmd[2] = 0; + cmd[3] = use_ext_reset; /* external reset */ + + if ((status = jtag3_command(pgm, cmd, 4, &resp, "AVR sign-on")) >= 0) + break; + + avrdude_message(MSG_INFO, "%s: retrying with external reset applied\n", + progname); + } + + if (use_ext_reset > 1) { + avrdude_message(MSG_INFO, "%s: JTAGEN fuse disabled?\n", progname); + return -1; + } + + /* + * Depending on the target connection, there are two different + * possible replies of the ICE. For a JTAG connection, the reply + * format is RSP3_DATA, followed by 4 bytes of the JTAG ID read from + * the device (followed by a trailing 0). For all other connections + * (except ISP which is handled completely differently, but that + * doesn't apply here anyway), the response is just RSP_OK. + */ + if (resp[1] == RSP3_DATA && status >= 7) + /* JTAG ID has been returned */ + avrdude_message(MSG_NOTICE, "%s: JTAG ID returned: 0x%02x 0x%02x 0x%02x 0x%02x\n", + progname, resp[3], resp[4], resp[5], resp[6]); + + free(resp); + + PDATA(pgm)->boot_start = ULONG_MAX; + if ((p->flags & AVRPART_HAS_PDI)) { + /* + * Find out where the border between application and boot area + * is. + */ + AVRMEM *bootmem = avr_locate_mem(p, "boot"); + AVRMEM *flashmem = avr_locate_mem(p, "flash"); + if (bootmem == NULL || flashmem == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmk3_initialize(): Cannot locate \"flash\" and \"boot\" memories in description\n", + progname); + } else { + PDATA(pgm)->boot_start = bootmem->offset - flashmem->offset; + } + } + + free(PDATA(pgm)->flash_pagecache); + free(PDATA(pgm)->eeprom_pagecache); + if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtag3_initialize(): Out of memory\n", + progname); + return -1; + } + if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtag3_initialize(): Out of memory\n", + progname); + free(PDATA(pgm)->flash_pagecache); + return -1; + } + PDATA(pgm)->flash_pageaddr = PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + + return 0; +} + +static void jtag3_disable(PROGRAMMER * pgm) +{ + + free(PDATA(pgm)->flash_pagecache); + PDATA(pgm)->flash_pagecache = NULL; + free(PDATA(pgm)->eeprom_pagecache); + PDATA(pgm)->eeprom_pagecache = NULL; + + /* + * jtag3_program_disable() doesn't do anything if the + * device is currently not in programming mode, so just + * call it unconditionally here. + */ + (void)jtag3_program_disable(pgm); +} + +static void jtag3_enable(PROGRAMMER * pgm) +{ + return; +} + +static int jtag3_parseextparms(PROGRAMMER * pgm, LISTID extparms) +{ + LNODEID ln; + const char *extended_param; + int rv = 0; + + for (ln = lfirst(extparms); ln; ln = lnext(ln)) { + extended_param = ldata(ln); + + if (strncmp(extended_param, "jtagchain=", strlen("jtagchain=")) == 0) { + unsigned int ub, ua, bb, ba; + if (sscanf(extended_param, "jtagchain=%u,%u,%u,%u", &ub, &ua, &bb, &ba) + != 4) { + avrdude_message(MSG_INFO, "%s: jtag3_parseextparms(): invalid JTAG chain '%s'\n", + progname, extended_param); + rv = -1; + continue; + } + avrdude_message(MSG_NOTICE2, "%s: jtag3_parseextparms(): JTAG chain parsed as:\n" + "%s %u units before, %u units after, %u bits before, %u bits after\n", + progname, + progbuf, ub, ua, bb, ba); + PDATA(pgm)->jtagchain[0] = ub; + PDATA(pgm)->jtagchain[1] = ua; + PDATA(pgm)->jtagchain[2] = bb; + PDATA(pgm)->jtagchain[3] = ba; + + continue; + } + + avrdude_message(MSG_INFO, "%s: jtag3_parseextparms(): invalid extended parameter '%s'\n", + progname, extended_param); + rv = -1; + } + + return rv; +} + +int jtag3_open_common(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + LNODEID usbpid; + int rv = -1; + +#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBHIDAPI) + avrdude_message(MSG_INFO, "avrdude was compiled without USB or HIDAPI support.\n"); + return -1; +#endif + + if (strncmp(port, "usb", 3) != 0) { + avrdude_message(MSG_INFO, "%s: jtag3_open_common(): JTAGICE3/EDBG port names must start with \"usb\"\n", + progname); + return -1; + } + + if (pgm->usbvid) + pinfo.usbinfo.vid = pgm->usbvid; + else + pinfo.usbinfo.vid = USB_VENDOR_ATMEL; + + /* If the config entry did not specify a USB PID, insert the default one. */ + if (lfirst(pgm->usbpid) == NULL) + ladd(pgm->usbpid, (void *)USB_DEVICE_JTAGICE3); + +#if defined(HAVE_LIBHIDAPI) + /* + * Try HIDAPI first. LibUSB is more generic, but might then cause + * troubles for HID-class devices in some OSes (like Windows). + */ + serdev = &usbhid_serdev; + for (usbpid = lfirst(pgm->usbpid); rv < 0 && usbpid != NULL; usbpid = lnext(usbpid)) { + pinfo.usbinfo.flags = PINFO_FL_SILENT; + pinfo.usbinfo.pid = *(int *)(ldata(usbpid)); + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3; + pgm->fd.usb.eep = 0; + + strcpy(pgm->port, port); + rv = serial_open(port, pinfo, &pgm->fd); + } + if (rv < 0) { +#endif /* HAVE_LIBHIDAPI */ +#if defined(HAVE_LIBUSB) + serdev = &usb_serdev_frame; + for (usbpid = lfirst(pgm->usbpid); rv < 0 && usbpid != NULL; usbpid = lnext(usbpid)) { + pinfo.usbinfo.flags = PINFO_FL_SILENT; + pinfo.usbinfo.pid = *(int *)(ldata(usbpid)); + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3; + pgm->fd.usb.eep = USBDEV_EVT_EP_READ_3; + + strcpy(pgm->port, port); + rv = serial_open(port, pinfo, &pgm->fd); + } +#endif /* HAVE_LIBUSB */ +#if defined(HAVE_LIBHIDAPI) + } +#endif + if (rv < 0) { + avrdude_message(MSG_INFO, "%s: jtag3_open_common(): Did not find any device matching VID 0x%04x and PID list: ", + progname, (unsigned)pinfo.usbinfo.vid); + int notfirst = 0; + for (usbpid = lfirst(pgm->usbpid); usbpid != NULL; usbpid = lnext(usbpid)) { + if (notfirst) + avrdude_message(MSG_INFO, ", "); + avrdude_message(MSG_INFO, "0x%04x", (unsigned int)(*(int *)(ldata(usbpid)))); + notfirst = 1; + } + fputc('\n', stderr); + + return -1; + } + + if (pgm->fd.usb.eep == 0) + { + /* The event EP has been deleted by usb_open(), so we are + running on a CMSIS-DAP device, using EDBG protocol */ + pgm->flag |= PGM_FL_IS_EDBG; + avrdude_message(MSG_NOTICE, "%s: Found CMSIS-DAP compliant device, using EDBG protocol\n", + progname); + } + + /* + * drain any extraneous input + */ + jtag3_drain(pgm, 0); + + return 0; +} + + + +static int jtag3_open(PROGRAMMER * pgm, char * port) +{ + avrdude_message(MSG_NOTICE2, "%s: jtag3_open()\n", progname); + + if (jtag3_open_common(pgm, port) < 0) + return -1; + + if (jtag3_getsync(pgm, PARM3_CONN_JTAG) < 0) + return -1; + + return 0; +} + +static int jtag3_open_dw(PROGRAMMER * pgm, char * port) +{ + avrdude_message(MSG_NOTICE2, "%s: jtag3_open_dw()\n", progname); + + if (jtag3_open_common(pgm, port) < 0) + return -1; + + if (jtag3_getsync(pgm, PARM3_CONN_DW) < 0) + return -1; + + return 0; +} + +static int jtag3_open_pdi(PROGRAMMER * pgm, char * port) +{ + avrdude_message(MSG_NOTICE2, "%s: jtag3_open_pdi()\n", progname); + + if (jtag3_open_common(pgm, port) < 0) + return -1; + + if (jtag3_getsync(pgm, PARM3_CONN_PDI) < 0) + return -1; + + return 0; +} + + +void jtag3_close(PROGRAMMER * pgm) +{ + unsigned char buf[4], *resp; + + avrdude_message(MSG_NOTICE2, "%s: jtag3_close()\n", progname); + + buf[0] = SCOPE_AVR; + buf[1] = CMD3_SIGN_OFF; + buf[2] = buf[3] = 0; + + if (jtag3_command(pgm, buf, 3, &resp, "AVR sign-off") >= 0) + free(resp); + + buf[0] = SCOPE_GENERAL; + buf[1] = CMD3_SIGN_OFF; + + if (jtag3_command(pgm, buf, 4, &resp, "sign-off") >= 0) + free(resp); + + if (pgm->flag & PGM_FL_IS_EDBG) + jtag3_edbg_signoff(pgm); + + serial_close(&pgm->fd); + pgm->fd.ifd = -1; +} + +static int jtag3_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int addr) +{ + unsigned char cmd[8], *resp; + + avrdude_message(MSG_NOTICE2, "%s: jtag3_page_erase(.., %s, 0x%x)\n", + progname, m->desc, addr); + + if (!(p->flags & AVRPART_HAS_PDI)) { + avrdude_message(MSG_INFO, "%s: jtag3_page_erase: not an Xmega device\n", + progname); + return -1; + } + + if (jtag3_program_enable(pgm) < 0) + return -1; + + cmd[0] = SCOPE_AVR; + cmd[1] = CMD3_ERASE_MEMORY; + cmd[2] = 0; + + if (strcmp(m->desc, "flash") == 0) { + if (jtag3_memtype(pgm, p, addr) == MTYPE_FLASH) + cmd[3] = XMEGA_ERASE_APP_PAGE; + else + cmd[3] = XMEGA_ERASE_BOOT_PAGE; + } else if (strcmp(m->desc, "eeprom") == 0) { + cmd[3] = XMEGA_ERASE_EEPROM_PAGE; + } else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { + cmd[3] = XMEGA_ERASE_USERSIG; + } else if ( ( strcmp(m->desc, "boot") == 0 ) ) { + cmd[3] = XMEGA_ERASE_BOOT_PAGE; + } else { + cmd[3] = XMEGA_ERASE_APP_PAGE; + } + + u32_to_b4(cmd + 4, addr + m->offset); + + if (jtag3_command(pgm, cmd, 8, &resp, "page erase") < 0) + return -1; + + free(resp); + return 0; +} + +static int jtag3_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int block_size; + unsigned int maxaddr = addr + n_bytes; + unsigned char *cmd; + unsigned char *resp; + int status, dynamic_memtype = 0; + long otimeout = serial_recv_timeout; + + avrdude_message(MSG_NOTICE2, "%s: jtag3_paged_write(.., %s, %d, %d)\n", + progname, m->desc, page_size, n_bytes); + + if (!(pgm->flag & PGM_FL_IS_DW) && jtag3_program_enable(pgm) < 0) + return -1; + + if (page_size == 0) page_size = 256; + + if ((cmd = malloc(page_size + 13)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtag3_paged_write(): Out of memory\n", + progname); + return -1; + } + + cmd[0] = SCOPE_AVR; + cmd[1] = CMD3_WRITE_MEMORY; + cmd[2] = 0; + if (strcmp(m->desc, "flash") == 0) { + PDATA(pgm)->flash_pageaddr = (unsigned long)-1L; + cmd[3] = jtag3_memtype(pgm, p, addr); + if (p->flags & AVRPART_HAS_PDI) + /* dynamically decide between flash/boot memtype */ + dynamic_memtype = 1; + } else if (strcmp(m->desc, "eeprom") == 0) { + if (pgm->flag & PGM_FL_IS_DW) { + /* + * jtag3_paged_write() to EEPROM attempted while in + * DW mode. Use jtag3_write_byte() instead. + */ + for (; addr < maxaddr; addr++) { + status = jtag3_write_byte(pgm, p, m, addr, m->buf[addr]); + if (status < 0) { + free(cmd); + return -1; + } + } + free(cmd); + return n_bytes; + } + cmd[3] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM_XMEGA : MTYPE_EEPROM_PAGE; + PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + } else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { + cmd[3] = MTYPE_USERSIG; + } else if ( ( strcmp(m->desc, "boot") == 0 ) ) { + cmd[3] = MTYPE_BOOT_FLASH; + } else if ( p->flags & AVRPART_HAS_PDI ) { + cmd[3] = MTYPE_FLASH; + } else { + cmd[3] = MTYPE_SPM; + } + serial_recv_timeout = 100; + for (; addr < maxaddr; addr += page_size) { + if ((maxaddr - addr) < page_size) + block_size = maxaddr - addr; + else + block_size = page_size; + avrdude_message(MSG_DEBUG, "%s: jtag3_paged_write(): " + "block_size at addr %d is %d\n", + progname, addr, block_size); + + if (dynamic_memtype) + cmd[3] = jtag3_memtype(pgm, p, addr); + + u32_to_b4(cmd + 8, page_size); + u32_to_b4(cmd + 4, jtag3_memaddr(pgm, p, m, addr)); + cmd[12] = 0; + + /* + * The JTAG ICE will refuse to write anything but a full page, at + * least for the flash ROM. If a partial page has been requested, + * set the remainder to 0xff. (Maybe we should rather read back + * the existing contents instead before? Doesn't matter much, as + * bits cannot be written to 1 anyway.) + */ + memset(cmd + 13, 0xff, page_size); + memcpy(cmd + 13, m->buf + addr, block_size); + + if ((status = jtag3_command(pgm, cmd, page_size + 13, + &resp, "write memory")) < 0) { + free(cmd); + serial_recv_timeout = otimeout; + return -1; + } + + free(resp); + } + + free(cmd); + serial_recv_timeout = otimeout; + + return n_bytes; +} + +static int jtag3_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int block_size; + unsigned int maxaddr = addr + n_bytes; + unsigned char cmd[12]; + unsigned char *resp; + int status, dynamic_memtype = 0; + long otimeout = serial_recv_timeout; + + avrdude_message(MSG_NOTICE2, "%s: jtag3_paged_load(.., %s, %d, %d)\n", + progname, m->desc, page_size, n_bytes); + + if (!(pgm->flag & PGM_FL_IS_DW) && jtag3_program_enable(pgm) < 0) + return -1; + + page_size = m->readsize; + + cmd[0] = SCOPE_AVR; + cmd[1] = CMD3_READ_MEMORY; + cmd[2] = 0; + + if (strcmp(m->desc, "flash") == 0) { + cmd[3] = jtag3_memtype(pgm, p, addr); + if (p->flags & AVRPART_HAS_PDI) + /* dynamically decide between flash/boot memtype */ + dynamic_memtype = 1; + } else if (strcmp(m->desc, "eeprom") == 0) { + cmd[3] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE; + if (pgm->flag & PGM_FL_IS_DW) + return -1; + } else if ( ( strcmp(m->desc, "prodsig") == 0 ) ) { + cmd[3] = MTYPE_PRODSIG; + } else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { + cmd[3] = MTYPE_USERSIG; + } else if ( ( strcmp(m->desc, "boot") == 0 ) ) { + cmd[3] = MTYPE_BOOT_FLASH; + } else if ( p->flags & AVRPART_HAS_PDI ) { + cmd[3] = MTYPE_FLASH; + } else { + cmd[3] = MTYPE_SPM; + } + serial_recv_timeout = 100; + for (; addr < maxaddr; addr += page_size) { + if ((maxaddr - addr) < page_size) + block_size = maxaddr - addr; + else + block_size = page_size; + avrdude_message(MSG_DEBUG, "%s: jtag3_paged_load(): " + "block_size at addr %d is %d\n", + progname, addr, block_size); + + if (dynamic_memtype) + cmd[3] = jtag3_memtype(pgm, p, addr); + + u32_to_b4(cmd + 8, block_size); + u32_to_b4(cmd + 4, jtag3_memaddr(pgm, p, m, addr)); + + if ((status = jtag3_command(pgm, cmd, 12, &resp, "read memory")) < 0) + return -1; + + if (resp[1] != RSP3_DATA || + status < block_size + 4) { + avrdude_message(MSG_INFO, "%s: wrong/short reply to read memory command\n", + progname); + serial_recv_timeout = otimeout; + free(resp); + return -1; + } + memcpy(m->buf + addr, resp + 3, status - 4); + free(resp); + } + serial_recv_timeout = otimeout; + + return n_bytes; +} + +static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value) +{ + unsigned char cmd[12]; + unsigned char *resp, *cache_ptr = NULL; + int status, unsupp = 0; + unsigned long paddr = 0UL, *paddr_ptr = NULL; + unsigned int pagesize = 0; + + avrdude_message(MSG_NOTICE2, "%s: jtag3_read_byte(.., %s, 0x%lx, ...)\n", + progname, mem->desc, addr); + + if (!(pgm->flag & PGM_FL_IS_DW) && jtag3_program_enable(pgm) < 0) + return -1; + + cmd[0] = SCOPE_AVR; + cmd[1] = CMD3_READ_MEMORY; + cmd[2] = 0; + + cmd[3] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_FLASH : MTYPE_FLASH_PAGE; + if (strcmp(mem->desc, "flash") == 0 || + strcmp(mem->desc, "application") == 0 || + strcmp(mem->desc, "apptable") == 0 || + strcmp(mem->desc, "boot") == 0) { + addr += mem->offset & (512 * 1024 - 1); /* max 512 KiB flash */ + pagesize = PDATA(pgm)->flash_pagesize; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->flash_pageaddr; + cache_ptr = PDATA(pgm)->flash_pagecache; + } else if (strcmp(mem->desc, "eeprom") == 0) { + if ( (pgm->flag & PGM_FL_IS_DW) || ( p->flags & AVRPART_HAS_PDI ) ) { + cmd[3] = MTYPE_EEPROM; + } else { + cmd[3] = MTYPE_EEPROM_PAGE; + } + pagesize = mem->page_size; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->eeprom_pageaddr; + cache_ptr = PDATA(pgm)->eeprom_pagecache; + } else if (strcmp(mem->desc, "lfuse") == 0) { + cmd[3] = MTYPE_FUSE_BITS; + addr = 0; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "hfuse") == 0) { + cmd[3] = MTYPE_FUSE_BITS; + addr = 1; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "efuse") == 0) { + cmd[3] = MTYPE_FUSE_BITS; + addr = 2; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strncmp(mem->desc, "lock", 4) == 0) { + cmd[3] = MTYPE_LOCK_BITS; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) { + cmd[3] = MTYPE_FUSE_BITS; + addr = mem->offset & 7; + } else if (strcmp(mem->desc, "usersig") == 0) { + cmd[3] = MTYPE_USERSIG; + } else if (strcmp(mem->desc, "prodsig") == 0) { + cmd[3] = MTYPE_PRODSIG; + } else if (strcmp(mem->desc, "calibration") == 0) { + cmd[3] = MTYPE_OSCCAL_BYTE; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "signature") == 0) { + static unsigned char signature_cache[2]; + + cmd[3] = MTYPE_SIGN_JTAG; + + /* + * dW can read out the signature on JTAGICE3, but only allows + * for a full three-byte read. We cache them in a local + * variable to avoid multiple reads. This optimization does not + * harm for other connection types either. + */ + u32_to_b4(cmd + 8, 3); + u32_to_b4(cmd + 4, 0); + + if (addr == 0) { + if ((status = jtag3_command(pgm, cmd, 12, &resp, "read memory")) < 0) + return -1; + + signature_cache[0] = resp[4]; + signature_cache[1] = resp[5]; + *value = resp[3]; + free(resp); + return 0; + } else if (addr <= 2) { + *value = signature_cache[addr - 1]; + return 0; + } else { + /* should not happen */ + avrdude_message(MSG_INFO, "address out of range for signature memory: %lu\n", addr); + return -1; + } + } + + /* + * If the respective memory area is not supported under debugWire, + * leave here. + */ + if (unsupp) { + *value = 42; + return -1; + } + + /* + * To improve the read speed, we used paged reads for flash and + * EEPROM, and cache the results in a page cache. + * + * Page cache validation is based on "{flash,eeprom}_pageaddr" + * (holding the base address of the most recent cache fill + * operation). This variable is set to (unsigned long)-1L when the + * cache needs to be invalidated. + */ + if (pagesize && paddr == *paddr_ptr) { + *value = cache_ptr[addr & (pagesize - 1)]; + return 0; + } + + if (pagesize) { + u32_to_b4(cmd + 8, pagesize); + u32_to_b4(cmd + 4, paddr); + } else { + u32_to_b4(cmd + 8, 1); + u32_to_b4(cmd + 4, addr); + } + + if ((status = jtag3_command(pgm, cmd, 12, &resp, "read memory")) < 0) + return -1; + + if (resp[1] != RSP3_DATA || + status < (pagesize? pagesize: 1) + 4) { + avrdude_message(MSG_INFO, "%s: wrong/short reply to read memory command\n", + progname); + free(resp); + return -1; + } + + if (pagesize) { + *paddr_ptr = paddr; + memcpy(cache_ptr, resp + 3, pagesize); + *value = cache_ptr[addr & (pagesize - 1)]; + } else + *value = resp[3]; + + free(resp); + return 0; +} + +static int jtag3_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + unsigned char cmd[14]; + unsigned char *resp; + unsigned char *cache_ptr = 0; + int status, unsupp = 0; + unsigned int pagesize = 0; + + avrdude_message(MSG_NOTICE2, "%s: jtag3_write_byte(.., %s, 0x%lx, ...)\n", + progname, mem->desc, addr); + + cmd[0] = SCOPE_AVR; + cmd[1] = CMD3_WRITE_MEMORY; + cmd[2] = 0; + cmd[3] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_FLASH : MTYPE_SPM; + if (strcmp(mem->desc, "flash") == 0) { + cache_ptr = PDATA(pgm)->flash_pagecache; + pagesize = PDATA(pgm)->flash_pagesize; + PDATA(pgm)->flash_pageaddr = (unsigned long)-1L; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "eeprom") == 0) { + if (pgm->flag & PGM_FL_IS_DW) { + cmd[3] = MTYPE_EEPROM; + } else { + cache_ptr = PDATA(pgm)->eeprom_pagecache; + pagesize = PDATA(pgm)->eeprom_pagesize; + } + PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + } else if (strcmp(mem->desc, "lfuse") == 0) { + cmd[3] = MTYPE_FUSE_BITS; + addr = 0; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "hfuse") == 0) { + cmd[3] = MTYPE_FUSE_BITS; + addr = 1; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "efuse") == 0) { + cmd[3] = MTYPE_FUSE_BITS; + addr = 2; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) { + cmd[3] = MTYPE_FUSE_BITS; + addr = mem->offset & 7; + } else if (strcmp(mem->desc, "usersig") == 0) { + cmd[3] = MTYPE_USERSIG; + } else if (strcmp(mem->desc, "prodsig") == 0) { + cmd[3] = MTYPE_PRODSIG; + } else if (strncmp(mem->desc, "lock", 4) == 0) { + cmd[3] = MTYPE_LOCK_BITS; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "calibration") == 0) { + cmd[3] = MTYPE_OSCCAL_BYTE; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "signature") == 0) { + cmd[3] = MTYPE_SIGN_JTAG; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } + + if (unsupp) + return -1; + + if (pagesize != 0) { + /* flash or EEPROM write: use paged algorithm */ + unsigned char dummy; + int i; + + /* step #1: ensure the page cache is up to date */ + if (jtag3_read_byte(pgm, p, mem, addr, &dummy) < 0) + return -1; + /* step #2: update our value in page cache, and copy + * cache to mem->buf */ + cache_ptr[addr & (pagesize - 1)] = data; + addr &= ~(pagesize - 1); /* page base address */ + memcpy(mem->buf + addr, cache_ptr, pagesize); + /* step #3: write back */ + i = jtag3_paged_write(pgm, p, mem, pagesize, addr, pagesize); + if (i < 0) + return -1; + else + return 0; + } + + /* non-paged writes go here */ + if (!(pgm->flag & PGM_FL_IS_DW) && jtag3_program_enable(pgm) < 0) + return -1; + + u32_to_b4(cmd + 8, 1); + u32_to_b4(cmd + 4, addr); + cmd[12] = 0; + cmd[13] = data; + + if ((status = jtag3_command(pgm, cmd, 14, &resp, "write memory")) < 0) + return -1; + + free(resp); + + return 0; +} + + +/* + * Set the JTAG clock. The actual frequency is quite a bit of + * guesswork, based on the values claimed by AVR Studio. Inside the + * JTAG ICE, the value is the delay count of a delay loop between the + * JTAG clock edges. A count of 0 bypasses the delay loop. + * + * As the STK500 expresses it as a period length (and we actualy do + * program a period length as well), we rather call it by that name. + */ +static int jtag3_set_sck_period(PROGRAMMER * pgm, double v) +{ + unsigned char parm[2]; + unsigned int clock = 1E-3 / v; /* kHz */ + + parm[0] = clock & 0xff; + parm[1] = (clock >> 8) & 0xff; + + if (PDATA(pgm)->set_sck == NULL) { + avrdude_message(MSG_INFO, "%s: No backend to set the SCK period for\n", + progname); + return -1; + } + + return (PDATA(pgm)->set_sck(pgm, parm) < 0)? -1: 0; +} + + +/* + * Read (an) emulator parameter(s). + */ +int jtag3_getparm(PROGRAMMER * pgm, unsigned char scope, + unsigned char section, unsigned char parm, + unsigned char *value, unsigned char length) +{ + int status; + unsigned char buf[6], *resp, c; + char descr[60]; + + avrdude_message(MSG_NOTICE2, "%s: jtag3_getparm()\n", progname); + + buf[0] = scope; + buf[1] = CMD3_GET_PARAMETER; + buf[2] = 0; + buf[3] = section; + buf[4] = parm; + buf[5] = length; + + sprintf(descr, "get parameter (scope 0x%02x, section %d, parm %d)", + scope, section, parm); + + if ((status = jtag3_command(pgm, buf, 6, &resp, descr)) < 0) + return -1; + + c = resp[1]; + if (c != RSP3_DATA || status < 3) { + avrdude_message(MSG_INFO, "%s: jtag3_getparm(): " + "bad response to %s\n", + progname, descr); + free(resp); + return -1; + } + + status -= 3; + memcpy(value, resp + 3, (length < status? length: status)); + free(resp); + + return 0; +} + +/* + * Write an emulator parameter. + */ +int jtag3_setparm(PROGRAMMER * pgm, unsigned char scope, + unsigned char section, unsigned char parm, + unsigned char *value, unsigned char length) +{ + int status; + unsigned char *buf, *resp; + char descr[60]; + + avrdude_message(MSG_NOTICE2, "%s: jtag3_setparm()\n", progname); + + sprintf(descr, "set parameter (scope 0x%02x, section %d, parm %d)", + scope, section, parm); + + if ((buf = malloc(6 + length)) == NULL) + { + avrdude_message(MSG_INFO, "%s: jtag3_setparm(): Out of memory\n", + progname); + return -1; + } + + buf[0] = scope; + buf[1] = CMD3_SET_PARAMETER; + buf[2] = 0; + buf[3] = section; + buf[4] = parm; + buf[5] = length; + memcpy(buf + 6, value, length); + + status = jtag3_command(pgm, buf, length + 6, &resp, descr); + + free(buf); + if (status > 0) + free(resp); + + return status; +} + + +static void jtag3_display(PROGRAMMER * pgm, const char * p) +{ + unsigned char parms[5]; + unsigned char cmd[4], *resp, c; + int status; + + /* + * Ask for: + * PARM3_HW_VER (1 byte) + * PARM3_FW_MAJOR (1 byte) + * PARM3_FW_MINOR (1 byte) + * PARM3_FW_RELEASE (2 bytes) + */ + if (jtag3_getparm(pgm, SCOPE_GENERAL, 0, PARM3_HW_VER, parms, 5) < 0) + return; + + cmd[0] = SCOPE_INFO; + cmd[1] = CMD3_GET_INFO; + cmd[2] = 0; + cmd[3] = CMD3_INFO_SERIAL; + + if ((status = jtag3_command(pgm, cmd, 4, &resp, "get info (serial number)")) < 0) + return; + + c = resp[1]; + if (c != RSP3_INFO) { + avrdude_message(MSG_INFO, "%s: jtag3_display(): response is not RSP3_INFO\n", + progname); + free(resp); + return; + } + memmove(resp, resp + 3, status - 3); + resp[status - 3] = 0; + + avrdude_message(MSG_INFO, "%sICE hardware version: %d\n", p, parms[0]); + avrdude_message(MSG_INFO, "%sICE firmware version: %d.%02d (rel. %d)\n", p, + parms[1], parms[2], + (parms[3] | (parms[4] << 8))); + avrdude_message(MSG_INFO, "%sSerial number : %s\n", p, resp); + free(resp); + + jtag3_print_parms1(pgm, p); +} + + +static void jtag3_print_parms1(PROGRAMMER * pgm, const char * p) +{ + unsigned char buf[2]; + + if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VTARGET, buf, 2) < 0) + return; + + avrdude_message(MSG_INFO, "%sVtarget : %.2f V\n", p, + b2_to_u16(buf) / 1000.0); + + if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_MEGA_PROG, buf, 2) < 0) + return; + avrdude_message(MSG_INFO, "%sJTAG clock megaAVR/program: %u kHz\n", p, + b2_to_u16(buf)); + + if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_MEGA_DEBUG, buf, 2) < 0) + return; + avrdude_message(MSG_INFO, "%sJTAG clock megaAVR/debug: %u kHz\n", p, + b2_to_u16(buf)); + + if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_XMEGA_JTAG, buf, 2) < 0) + return; + avrdude_message(MSG_INFO, "%sJTAG clock Xmega: %u kHz\n", p, + b2_to_u16(buf)); + + if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_XMEGA_PDI, buf, 2) < 0) + return; + avrdude_message(MSG_INFO, "%sPDI clock Xmega : %u kHz\n", p, + b2_to_u16(buf)); +} + +static void jtag3_print_parms(PROGRAMMER * pgm) +{ + jtag3_print_parms1(pgm, ""); +} + +static unsigned char jtag3_memtype(PROGRAMMER * pgm, AVRPART * p, unsigned long addr) +{ + if ( p->flags & AVRPART_HAS_PDI ) { + if (addr >= PDATA(pgm)->boot_start) + return MTYPE_BOOT_FLASH; + else + return MTYPE_FLASH; + } else { + return MTYPE_FLASH_PAGE; + } +} + +static unsigned int jtag3_memaddr(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr) +{ + if ((p->flags & AVRPART_HAS_PDI) != 0) { + if (addr >= PDATA(pgm)->boot_start) + /* + * all memories but "flash" are smaller than boot_start anyway, so + * no need for an extra check we are operating on "flash" + */ + return addr - PDATA(pgm)->boot_start; + else + /* normal flash, or anything else */ + return addr; + } + /* + * Non-Xmega device. + */ + return addr; +} + + +const char jtag3_desc[] = "Atmel JTAGICE3"; + +void jtag3_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "JTAGICE3"); + + /* + * mandatory functions + */ + pgm->initialize = jtag3_initialize; + pgm->display = jtag3_display; + pgm->enable = jtag3_enable; + pgm->disable = jtag3_disable; + pgm->program_enable = jtag3_program_enable_dummy; + pgm->chip_erase = jtag3_chip_erase; + pgm->open = jtag3_open; + pgm->close = jtag3_close; + pgm->read_byte = jtag3_read_byte; + pgm->write_byte = jtag3_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtag3_paged_write; + pgm->paged_load = jtag3_paged_load; + pgm->page_erase = jtag3_page_erase; + pgm->print_parms = jtag3_print_parms; + pgm->set_sck_period = jtag3_set_sck_period; + pgm->parseextparams = jtag3_parseextparms; + pgm->setup = jtag3_setup; + pgm->teardown = jtag3_teardown; + pgm->page_size = 256; + pgm->flag = PGM_FL_IS_JTAG; +} + +const char jtag3_dw_desc[] = "Atmel JTAGICE3 in debugWire mode"; + +void jtag3_dw_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "JTAGICE3_DW"); + + /* + * mandatory functions + */ + pgm->initialize = jtag3_initialize; + pgm->display = jtag3_display; + pgm->enable = jtag3_enable; + pgm->disable = jtag3_disable; + pgm->program_enable = jtag3_program_enable_dummy; + pgm->chip_erase = jtag3_chip_erase_dw; + pgm->open = jtag3_open_dw; + pgm->close = jtag3_close; + pgm->read_byte = jtag3_read_byte; + pgm->write_byte = jtag3_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtag3_paged_write; + pgm->paged_load = jtag3_paged_load; + pgm->print_parms = jtag3_print_parms; + pgm->setup = jtag3_setup; + pgm->teardown = jtag3_teardown; + pgm->page_size = 256; + pgm->flag = PGM_FL_IS_DW; +} + +const char jtag3_pdi_desc[] = "Atmel JTAGICE3 in PDI mode"; + +void jtag3_pdi_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "JTAGICE3_PDI"); + + /* + * mandatory functions + */ + pgm->initialize = jtag3_initialize; + pgm->display = jtag3_display; + pgm->enable = jtag3_enable; + pgm->disable = jtag3_disable; + pgm->program_enable = jtag3_program_enable_dummy; + pgm->chip_erase = jtag3_chip_erase; + pgm->open = jtag3_open_pdi; + pgm->close = jtag3_close; + pgm->read_byte = jtag3_read_byte; + pgm->write_byte = jtag3_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtag3_paged_write; + pgm->paged_load = jtag3_paged_load; + pgm->page_erase = jtag3_page_erase; + pgm->print_parms = jtag3_print_parms; + pgm->set_sck_period = jtag3_set_sck_period; + pgm->setup = jtag3_setup; + pgm->teardown = jtag3_teardown; + pgm->page_size = 256; + pgm->flag = PGM_FL_IS_PDI; +} + diff --git a/xs/src/avrdude/jtag3.h b/xs/src/avrdude/jtag3.h new file mode 100644 index 000000000..fef3be011 --- /dev/null +++ b/xs/src/avrdude/jtag3.h @@ -0,0 +1,60 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2012 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 + * 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 jtag3_h +#define jtag3_h + +#ifdef __cplusplus +extern "C" { +#endif + +int jtag3_open_common(PROGRAMMER * pgm, char * port); +int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len); +int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg); +void jtag3_close(PROGRAMMER * pgm); +int jtag3_getsync(PROGRAMMER * pgm, int mode); +int jtag3_getparm(PROGRAMMER * pgm, unsigned char scope, + unsigned char section, unsigned char parm, + unsigned char *value, unsigned char length); +int jtag3_setparm(PROGRAMMER * pgm, unsigned char scope, + unsigned char section, unsigned char parm, + unsigned char *value, unsigned char length); +int jtag3_command(PROGRAMMER *pgm, unsigned char *cmd, unsigned int cmdlen, + unsigned char **resp, const char *descr); +extern const char jtag3_desc[]; +extern const char jtag3_dw_desc[]; +extern const char jtag3_pdi_desc[]; +void jtag3_initpgm (PROGRAMMER * pgm); +void jtag3_dw_initpgm (PROGRAMMER * pgm); +void jtag3_pdi_initpgm (PROGRAMMER * pgm); + +/* + * These functions are referenced from stk500v2.c for JTAGICE3 in + * one of the STK500v2 modi. + */ +void jtag3_setup(PROGRAMMER * pgm); +void jtag3_teardown(PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/xs/src/avrdude/jtag3_private.h b/xs/src/avrdude/jtag3_private.h new file mode 100644 index 000000000..8ee37505d --- /dev/null +++ b/xs/src/avrdude/jtag3_private.h @@ -0,0 +1,319 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2012 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 + * 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$ */ + + +/* + * JTAGICE3 definitions + * Reverse-engineered from various USB traces. + */ + +#if !defined(JTAG3_PRIVATE_EXPORTED) +/* + * Communication with the JTAGICE3 uses three data endpoints: + * + * Endpoint 0x01 (OUT) and 0x82 (IN) are the usual conversation + * endpoints, with a maximal packet size of 512 octets. The + * JTAGICE3 does *not* work on older USB 1.1 hubs that would only + * allow for 64-octet max packet size. + * + * Endpoint 0x83 (IN) is also a bulk endpoint, with a max packetsize + * of 64 octets. This endpoint is used by the ICE to deliver events + * from the ICE. + * + * The request (host -> ICE, EP 0x01) format is: + * + * +--------------------------------------------- + * | 0 | 1 | 2 . 3 | 4 | 5 | 6 | ... + * | | | | | | | + * | token |dummy|serial# |scope| cmd |dummy| optional data + * | 0x0e | 0 | NNNN | SS | CC | 0 | ... + * +--------------------------------------------- + * + * Both dummy bytes are always 0. The "scope" identifier appears + * to distinguish commands (responses, events, parameters) roughly: + * + * 0x01 - general scope ("hello", "goodbye", firmware info, target + * voltage readout) + * 0x11 - scope for AVR in ISP mode (basically a wrapper around + * the AVRISPmkII commands, as usual) + * 0x12 - scope for AVR (JTAG, PDI, debugWIRE) + * + * The serial number is counted up. + * + * + * The response (ICE -> host, EP 0x82) format is: + * + * +--------------------------------------------------+ + * | 0 | 1 . 2 | 3 | 4 | ... | N | + * | | | | | | | + * | token |serial# |scope| rsp | optional data |dummy| + * | 0x0e | NNNN | SS | RR | ... | 0 | + * +--------------------------------------------------+ + * + * The response's serial number is mirrored from the request, but the + * dummy byte before the serial number is left out. However, another + * zero dummy byte is always attached to the end of the response data. + * Response codes are similar to the JTAGICEmkII, 0x80 is a generic + * "OK" response, other responses above 0x80 indicate various data + * responses (parameter read, memory read, PC value), and 0xa0 is a + * generic "failure" response. It appears the failure response gets + * another byte appended (probably indicating the reason) after the + * 0 dummy byte, but there's not enough analysis material so far. + * + * + * The event format (EP 0x83) is: + * + * +---------------------------------------- + * | 0 | 1 | 2 . 3 | 4 | 5 | ... + * | | | | | | + * | token |dummy|serial# |scope| evt | data + * | 0x0e | 0 | NNNN | SS | EV | ... + * +---------------------------------------- + */ +#define TOKEN 0x0e + +#endif /* JTAG3_PRIVATE_EXPORTED */ + +#define SCOPE_INFO 0x00 +#define SCOPE_GENERAL 0x01 +#define SCOPE_AVR_ISP 0x11 +#define SCOPE_AVR 0x12 + +/* Info scope */ +#define CMD3_GET_INFO 0x00 + +/* byte after GET_INFO is always 0, next is: */ +# define CMD3_INFO_NAME 0x80 /* JTAGICE3 */ +# define CMD3_INFO_SERIAL 0x81 /* J3xxxxxxxxxx */ + +/* Generic scope */ +#define CMD3_SET_PARAMETER 0x01 +#define CMD3_GET_PARAMETER 0x02 +#define CMD3_SIGN_ON 0x10 +#define CMD3_SIGN_OFF 0x11 /* takes one parameter? */ +#define CMD3_START_DW_DEBUG 0x13 +#define CMD3_MONCON_DISABLE 0x17 + +/* AVR ISP scope: no commands of its own */ + +/* AVR scope */ +//#define CMD3_SET_PARAMETER 0x01 +//#define CMD3_GET_PARAMETER 0x02 +//#define CMD3_SIGN_ON 0x10 /* an additional signon/-off pair */ +//#define CMD3_SIGN_OFF 0x11 +#define CMD3_ENTER_PROGMODE 0x15 +#define CMD3_LEAVE_PROGMODE 0x16 +#define CMD3_ERASE_MEMORY 0x20 +#define CMD3_READ_MEMORY 0x21 +#define CMD3_WRITE_MEMORY 0x23 +#define CMD3_READ_PC 0x35 + +/* ICE responses */ +#define RSP3_OK 0x80 +#define RSP3_INFO 0x81 +#define RSP3_PC 0x83 +#define RSP3_DATA 0x84 +#define RSP3_FAILED 0xA0 + +#define RSP3_STATUS_MASK 0xE0 + +/* possible failure codes that could be appended to RSP3_FAILED: */ +# define RSP3_FAIL_DEBUGWIRE 0x10 +# define RSP3_FAIL_PDI 0x1B +# define RSP3_FAIL_NO_ANSWER 0x20 +# define RSP3_FAIL_NO_TARGET_POWER 0x22 +# define RSP3_FAIL_WRONG_MODE 0x32 /* progmode vs. non-prog */ +# define RSP3_FAIL_UNSUPP_MEMORY 0x34 /* unsupported memory type */ +# define RSP3_FAIL_WRONG_LENGTH 0x35 /* wrong lenth for mem access */ +# define RSP3_FAIL_NOT_UNDERSTOOD 0x91 + +/* ICE events */ +#define EVT3_BREAK 0x40 /* AVR scope */ +#define EVT3_SLEEP 0x11 /* General scope, also wakeup */ +#define EVT3_POWER 0x10 /* General scope */ + +/* memory types */ +#define MTYPE_SRAM 0x20 /* target's SRAM or [ext.] IO registers */ +#define MTYPE_EEPROM 0x22 /* EEPROM, what way? */ +#define MTYPE_SPM 0xA0 /* flash through LPM/SPM */ +#define MTYPE_FLASH_PAGE 0xB0 /* flash in programming mode */ +#define MTYPE_EEPROM_PAGE 0xB1 /* EEPROM in programming mode */ +#define MTYPE_FUSE_BITS 0xB2 /* fuse bits in programming mode */ +#define MTYPE_LOCK_BITS 0xB3 /* lock bits in programming mode */ +#define MTYPE_SIGN_JTAG 0xB4 /* signature in programming mode */ +#define MTYPE_OSCCAL_BYTE 0xB5 /* osccal cells in programming mode */ +#define MTYPE_FLASH 0xc0 /* xmega (app.) flash - undocumented in AVR067 */ +#define MTYPE_BOOT_FLASH 0xc1 /* xmega boot flash - undocumented in AVR067 */ +#define MTYPE_EEPROM_XMEGA 0xc4 /* xmega EEPROM in debug mode - undocumented in AVR067 */ +#define MTYPE_USERSIG 0xc5 /* xmega user signature - undocumented in AVR067 */ +#define MTYPE_PRODSIG 0xc6 /* xmega production signature - undocumented in AVR067 */ + +/* + * Parameters are divided into sections, where the section number + * precedes each parameter address. There are distinct parameter + * sets for generic and AVR scope. + */ +#define PARM3_HW_VER 0x00 /* section 0, generic scope, 1 byte */ +#define PARM3_FW_MAJOR 0x01 /* section 0, generic scope, 1 byte */ +#define PARM3_FW_MINOR 0x02 /* section 0, generic scope, 1 byte */ +#define PARM3_FW_RELEASE 0x03 /* section 0, generic scope, 1 byte; + * always asked for by Atmel Studio, + * but never displayed there */ +#define PARM3_VTARGET 0x00 /* section 1, generic scope, 2 bytes, + * in millivolts */ +#define PARM3_DEVICEDESC 0x00 /* section 2, memory etc. configuration, + * 31 bytes for tiny/mega AVR, 47 bytes + * for Xmega; is also used in command + * 0x36 in JTAGICEmkII, starting with + * firmware 7.x */ + +#define PARM3_ARCH 0x00 /* section 0, AVR scope, 1 byte */ +# define PARM3_ARCH_TINY 1 /* also small megaAVR with ISP/DW only */ +# define PARM3_ARCH_MEGA 2 +# define PARM3_ARCH_XMEGA 3 + +#define PARM3_SESS_PURPOSE 0x01 /* section 0, AVR scope, 1 byte */ +# define PARM3_SESS_PROGRAMMING 1 +# define PARM3_SESS_DEBUGGING 2 + +#define PARM3_CONNECTION 0x00 /* section 1, AVR scope, 1 byte */ +# define PARM3_CONN_ISP 1 +# define PARM3_CONN_JTAG 4 +# define PARM3_CONN_DW 5 +# define PARM3_CONN_PDI 6 + + +#define PARM3_JTAGCHAIN 0x01 /* JTAG chain info, AVR scope (units + * before/after, bits before/after), 4 + * bytes */ + +#define PARM3_CLK_MEGA_PROG 0x20 /* section 1, AVR scope, 2 bytes (kHz) */ +#define PARM3_CLK_MEGA_DEBUG 0x21 /* section 1, AVR scope, 2 bytes (kHz) */ +#define PARM3_CLK_XMEGA_JTAG 0x30 /* section 1, AVR scope, 2 bytes (kHz) */ +#define PARM3_CLK_XMEGA_PDI 0x31 /* section 1, AVR scope, 2 bytes (kHz) */ + + + +/* Xmega erase memory types, for CMND_XMEGA_ERASE */ +#define XMEGA_ERASE_CHIP 0x00 +#define XMEGA_ERASE_APP 0x01 +#define XMEGA_ERASE_BOOT 0x02 +#define XMEGA_ERASE_EEPROM 0x03 +#define XMEGA_ERASE_APP_PAGE 0x04 +#define XMEGA_ERASE_BOOT_PAGE 0x05 +#define XMEGA_ERASE_EEPROM_PAGE 0x06 +#define XMEGA_ERASE_USERSIG 0x07 + +/* EDBG vendor commands */ +#define EDBG_VENDOR_AVR_CMD 0x80 +#define EDBG_VENDOR_AVR_RSP 0x81 +#define EDBG_VENDOR_AVR_EVT 0x82 + +/* CMSIS-DAP commands */ +#define CMSISDAP_CMD_INFO 0x00 /* get info, followed by INFO byte */ +# define CMSISDAP_INFO_VID 0x01 /* vendor ID (string) */ +# define CMSISDAP_INFO_PID 0x02 /* product ID (string) */ +# define CMSISDAP_INFO_SERIAL 0x03 /* serial number (string) */ +# define CMSISDAP_INFO_FIRMWARE 0x04 /* firmware version (string) */ +# define CMSISDAP_INFO_TARGET_VENDOR 0x05 /* target device vendor (string) */ +# define CMSISDAP_INFO_TARGET_NAME 0x06 /* target device name (string) */ +# define CMSISDAP_INFO_CAPABILITIES 0xF0 /* debug unit capabilities (byte) */ +# define CMSISDAP_INFO_PACKET_COUNT 0xFE /* packet count (byte) (which packets, anyway?) */ +# define CMSISDAP_INFO_PACKET_SIZE 0xFF /* packet size (short) */ + +#define CMSISDAP_CMD_LED 0x01 /* LED control, followed by LED number and on/off byte */ +# define CMSISDAP_LED_CONNECT 0x00 /* connect LED */ +# define CMSISDAP_LED_RUNNING 0x01 /* running LED */ + +#define CMSISDAP_CMD_CONNECT 0x02 /* connect to target, followed by DAP mode */ +# define CMSISDAP_CONN_DEFAULT 0x00 +# define CMSISDAP_CONN_SWD 0x01 /* serial wire debug */ +# define CMSISDAP_CONN_JTAG 0x02 /* JTAG mode */ + +#define CMSISDAP_CMD_DISCONNECT 0x03 /* disconnect from target */ + +#define CMSISDAP_XFR_CONFIGURE 0x04 /* configure transfers; idle cycles (byte); + wait retry (short); match retry (short) */ + +#define CMSISDAP_CMD_WRITEAPBORT 0x08 /* write to CoreSight ABORT register of target */ + +#define CMSISDAP_CMD_DELAY 0x09 /* delay for number of microseconds (short) */ + +#define CMSISDAP_CMD_RESET 0x0A /* reset target */ + +#define CMSISDAP_CMD_SWJ_CLOCK 0x11 /* SWD/JTAG clock, (word) */ + +#define CMSISDAP_CMD_SWD_CONFIGURE 0x13 /* configure SWD protocol; (byte) */ + +#if !defined(JTAG3_PRIVATE_EXPORTED) + +struct mega_device_desc { + unsigned char flash_page_size[2]; // in bytes + unsigned char flash_size[4]; // in bytes + unsigned char dummy1[4]; // always 0 + unsigned char boot_address[4]; // maximal (BOOTSZ = 3) bootloader + // address, in 16-bit words (!) + unsigned char sram_offset[2]; // pointing behind IO registers + unsigned char eeprom_size[2]; + unsigned char eeprom_page_size; + unsigned char ocd_revision; // see XML; basically: + // t13*, t2313*, t4313: 0 + // all other DW devices: 1 + // ATmega128(A): 1 (!) + // ATmega16*,162,169*,32*,64*: 2 + // ATmega2560/2561: 4 + // all other megaAVR devices: 3 + unsigned char always_one; // always = 1 + unsigned char allow_full_page_bitstream; // old AVRs, see XML + unsigned char dummy2[2]; // always 0 + // all IO addresses below are given + // in IO number space (without + // offset 0x20), even though e.g. + // OSCCAL always resides outside + unsigned char idr_address; // IDR, aka. OCDR + unsigned char eearh_address; // EEPROM access + unsigned char eearl_address; + unsigned char eecr_address; + unsigned char eedr_address; + unsigned char spmcr_address; + unsigned char osccal_address; +}; + + +/* Xmega device descriptor */ +struct xmega_device_desc { + unsigned char nvm_app_offset[4]; // NVM offset for application flash + unsigned char nvm_boot_offset[4]; // NVM offset for boot flash + unsigned char nvm_eeprom_offset[4]; // NVM offset for EEPROM + unsigned char nvm_fuse_offset[4]; // NVM offset for fuses + unsigned char nvm_lock_offset[4]; // NVM offset for lock bits + unsigned char nvm_user_sig_offset[4]; // NVM offset for user signature row + unsigned char nvm_prod_sig_offset[4]; // NVM offset for production sign. row + unsigned char nvm_data_offset[4]; // NVM offset for data memory (SRAM + IO) + unsigned char app_size[4]; // size of application flash + unsigned char boot_size[2]; // size of boot flash + unsigned char flash_page_size[2]; // flash page size + unsigned char eeprom_size[2]; // size of EEPROM + unsigned char eeprom_page_size; // EEPROM page size + unsigned char nvm_base_addr[2]; // IO space base address of NVM controller + unsigned char mcu_base_addr[2]; // IO space base address of MCU control +}; +#endif /* JTAG3_PRIVATE_EXPORTED */ diff --git a/xs/src/avrdude/jtagmkI.c b/xs/src/avrdude/jtagmkI.c new file mode 100644 index 000000000..2a5f27e4a --- /dev/null +++ b/xs/src/avrdude/jtagmkI.c @@ -0,0 +1,1365 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2005, 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 + * 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$ */ + +/* + * avrdude interface for Atmel JTAG ICE (mkI) programmer + */ + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "crc16.h" +#include "jtagmkI.h" +#include "jtagmkI_private.h" + +/* + * Private data for this programmer. + */ +struct pdata +{ + int initial_baudrate; + + /* + * See jtagmkI_read_byte() for an explanation of the flash and + * EEPROM page caches. + */ + unsigned char *flash_pagecache; + unsigned long flash_pageaddr; + unsigned int flash_pagesize; + + unsigned char *eeprom_pagecache; + unsigned long eeprom_pageaddr; + unsigned int eeprom_pagesize; + + int prog_enabled; /* Cached value of PROGRAMMING status. */ +}; + +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) + +/* + * The OCDEN fuse is bit 7 of the high fuse (hfuse). In order to + * perform memory operations on MTYPE_SPM and MTYPE_EEPROM, OCDEN + * needs to be programmed. + * + * OCDEN should probably rather be defined via the configuration, but + * if this ever changes to a different fuse byte for one MCU, quite + * some code here needs to be generalized anyway. + */ +#define OCDEN (1 << 7) + +/* + * Table of baud rates supported by the mkI ICE, accompanied by their + * internal parameter value. + * + * 19200 is the initial value of the ICE after powerup, and virtually + * all connections then switch to 115200. As the table is also used + * to try connecting at startup, we keep these two entries on top to + * speedup the program start. + */ +const static struct { + long baud; + unsigned char val; +} baudtab[] = { + { 19200L, 0xfa }, + { 115200L, 0xff }, + { 9600L, 0xf4 }, + { 38400L, 0xfd }, + { 57600L, 0xfe }, +/* { 14400L, 0xf8 }, */ /* not supported by serial driver */ +}; + +static int jtagmkI_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value); +static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data); +static int jtagmkI_set_sck_period(PROGRAMMER * pgm, double v); +static int jtagmkI_getparm(PROGRAMMER * pgm, unsigned char parm, + unsigned char * value); +static int jtagmkI_setparm(PROGRAMMER * pgm, unsigned char parm, + unsigned char value); +static void jtagmkI_print_parms1(PROGRAMMER * pgm, const char * p); + +static int jtagmkI_resync(PROGRAMMER *pgm, int maxtries, int signon); + +static void jtagmkI_setup(PROGRAMMER * pgm) +{ + if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + avrdude_message(MSG_INFO, "%s: jtagmkI_setup(): Out of memory allocating private data\n", + progname); + exit(1); + } + memset(pgm->cookie, 0, sizeof(struct pdata)); +} + +static void jtagmkI_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); +} + + +static void +u32_to_b3(unsigned char *b, unsigned long l) +{ + b[2] = l & 0xff; + b[1] = (l >> 8) & 0xff; + b[0] = (l >> 16) & 0xff; +} + +static void +u16_to_b2(unsigned char *b, unsigned short l) +{ + b[0] = l & 0xff; + b[1] = (l >> 8) & 0xff; +} + +static void jtagmkI_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + int i; + + if (verbose >= 4) { + avrdude_message(MSG_TRACE, "Raw message:\n"); + + for (i = 0; i < len; i++) { + avrdude_message(MSG_TRACE, "0x%02x ", data[i]); + if (i % 16 == 15) + putc('\n', stderr); + else + putc(' ', stderr); + } + if (i % 16 != 0) + putc('\n', stderr); + } + + switch (data[0]) { + case RESP_OK: + avrdude_message(MSG_INFO, "OK\n"); + break; + + case RESP_FAILED: + avrdude_message(MSG_INFO, "FAILED\n"); + break; + + case RESP_BREAK: + avrdude_message(MSG_INFO, "breakpoint hit\n"); + break; + + case RESP_INFO: + avrdude_message(MSG_INFO, "IDR dirty\n"); + break; + + case RESP_SYNC_ERROR: + avrdude_message(MSG_INFO, "Synchronization lost\n"); + break; + + case RESP_SLEEP: + avrdude_message(MSG_INFO, "sleep instruction hit\n"); + break; + + case RESP_POWER: + avrdude_message(MSG_INFO, "target power lost\n"); + + default: + avrdude_message(MSG_INFO, "unknown message 0x%02x\n", data[0]); + } + + putc('\n', stderr); +} + + +static int jtagmkI_send(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + unsigned char *buf; + + avrdude_message(MSG_DEBUG, "\n%s: jtagmkI_send(): sending %u bytes\n", + progname, (unsigned int)len); + + if ((buf = malloc(len + 2)) == NULL) + { + avrdude_message(MSG_INFO, "%s: jtagmkI_send(): out of memory", + progname); + exit(1); + } + + memcpy(buf, data, len); + buf[len] = ' '; /* "CRC" */ + buf[len + 1] = ' '; /* EOP */ + + if (serial_send(&pgm->fd, buf, len + 2) != 0) { + avrdude_message(MSG_INFO, "%s: jtagmkI_send(): failed to send command to serial port\n", + progname); + return -1; + } + + free(buf); + + return 0; +} + +static int jtagmkI_recv(PROGRAMMER * pgm, unsigned char * buf, size_t len) +{ + if (serial_recv(&pgm->fd, buf, len) != 0) { + avrdude_message(MSG_INFO, "\n%s: jtagmkI_recv(): failed to send command to serial port\n", + progname); + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkI_prmsg(pgm, buf, len); + } + return 0; +} + + +static int jtagmkI_drain(PROGRAMMER * pgm, int display) +{ + return serial_drain(&pgm->fd, display); +} + + +static int jtagmkI_resync(PROGRAMMER * pgm, int maxtries, int signon) +{ + int tries; + unsigned char buf[4], resp[9]; + long otimeout = serial_recv_timeout; + + serial_recv_timeout = 200; + + avrdude_message(MSG_TRACE, "%s: jtagmkI_resync()\n", progname); + + jtagmkI_drain(pgm, 0); + + for (tries = 0; tries < maxtries; tries++) { + + /* Get the sign-on information. */ + buf[0] = CMD_GET_SYNC; + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_resync(): Sending sync command: ", + progname); + + if (serial_send(&pgm->fd, buf, 1) != 0) { + avrdude_message(MSG_INFO, "\n%s: jtagmkI_resync(): failed to send command to serial port\n", + progname); + serial_recv_timeout = otimeout; + return -1; + } + if (serial_recv(&pgm->fd, resp, 1) == 0 && resp[0] == RESP_OK) { + avrdude_message(MSG_NOTICE2, "got RESP_OK\n"); + break; + } + + if (signon) { + /* + * The following is black magic, the idea has been taken from + * AVaRICE. + * + * Apparently, the ICE behaves differently right after a + * power-up vs. when reconnecting to an ICE that has already + * been worked with. The undocumented 'E' command (or + * subcommand) occasionally helps in getting the connection into + * sync. + */ + buf[0] = CMD_GET_SIGNON; + buf[1] = 'E'; + buf[2] = ' '; + buf[3] = ' '; + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_resync(): Sending sign-on command: ", + progname); + + if (serial_send(&pgm->fd, buf, 4) != 0) { + avrdude_message(MSG_INFO, "\n%s: jtagmkI_resync(): failed to send command to serial port\n", + progname); + serial_recv_timeout = otimeout; + return -1; + } + if (serial_recv(&pgm->fd, resp, 9) == 0 && resp[0] == RESP_OK) { + avrdude_message(MSG_NOTICE2, "got RESP_OK\n"); + break; + } + } + } + if (tries >= maxtries) { + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_resync(): " + "timeout/error communicating with programmer\n", + progname); + serial_recv_timeout = otimeout; + return -1; + } + + serial_recv_timeout = otimeout; + return 0; +} + +static int jtagmkI_getsync(PROGRAMMER * pgm) +{ + unsigned char buf[1], resp[9]; + + if (jtagmkI_resync(pgm, 5, 1) < 0) { + jtagmkI_drain(pgm, 0); + return -1; + } + + jtagmkI_drain(pgm, 0); + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_getsync(): Sending sign-on command: ", + progname); + + buf[0] = CMD_GET_SIGNON; + jtagmkI_send(pgm, buf, 1); + if (jtagmkI_recv(pgm, resp, 9) < 0) + return -1; + if (verbose >= 2) { + resp[8] = '\0'; + avrdude_message(MSG_NOTICE2, "got %s\n", resp + 1); + } + + return 0; +} + +/* + * issue the 'chip erase' command to the AVR device + */ +static int jtagmkI_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char buf[1], resp[2]; + + buf[0] = CMD_CHIP_ERASE; + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_chip_erase(): Sending chip erase command: ", + progname); + jtagmkI_send(pgm, buf, 1); + if (jtagmkI_recv(pgm, resp, 2) < 0) + return -1; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_chip_erase(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + + pgm->initialize(pgm, p); + + return 0; +} + +static void jtagmkI_set_devdescr(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char resp[2]; + LNODEID ln; + AVRMEM * m; + struct { + unsigned char cmd; + struct device_descriptor dd; + } sendbuf; + + memset(&sendbuf, 0, sizeof sendbuf); + sendbuf.cmd = CMD_SET_DEVICE_DESCRIPTOR; + sendbuf.dd.ucSPMCRAddress = p->spmcr; + sendbuf.dd.ucRAMPZAddress = p->rampz; + sendbuf.dd.ucIDRAddress = p->idr; + for (ln = lfirst(p->mem); ln; ln = lnext(ln)) { + m = ldata(ln); + if (strcmp(m->desc, "flash") == 0) { + PDATA(pgm)->flash_pagesize = m->page_size; + u16_to_b2(sendbuf.dd.uiFlashPageSize, PDATA(pgm)->flash_pagesize); + } else if (strcmp(m->desc, "eeprom") == 0) { + sendbuf.dd.ucEepromPageSize = PDATA(pgm)->eeprom_pagesize = m->page_size; + } + } + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_set_devdescr(): " + "Sending set device descriptor command: ", + progname); + jtagmkI_send(pgm, (unsigned char *)&sendbuf, sizeof(sendbuf)); + + if (jtagmkI_recv(pgm, resp, 2) < 0) + return; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_set_devdescr(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } +} + +/* + * Reset the target. + */ +static int jtagmkI_reset(PROGRAMMER * pgm) +{ + unsigned char buf[1], resp[2]; + + buf[0] = CMD_RESET; + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_reset(): Sending reset command: ", + progname); + jtagmkI_send(pgm, buf, 1); + + if (jtagmkI_recv(pgm, resp, 2) < 0) + return -1; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_reset(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + + return 0; +} + +static int jtagmkI_program_enable_dummy(PROGRAMMER * pgm, AVRPART * p) +{ + + return 0; +} + +static int jtagmkI_program_enable(PROGRAMMER * pgm) +{ + unsigned char buf[1], resp[2]; + + if (PDATA(pgm)->prog_enabled) + return 0; + + buf[0] = CMD_ENTER_PROGMODE; + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_program_enable(): " + "Sending enter progmode command: ", + progname); + jtagmkI_send(pgm, buf, 1); + + if (jtagmkI_recv(pgm, resp, 2) < 0) + return -1; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_program_enable(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + + PDATA(pgm)->prog_enabled = 1; + + return 0; +} + +static int jtagmkI_program_disable(PROGRAMMER * pgm) +{ + unsigned char buf[1], resp[2]; + + if (!PDATA(pgm)->prog_enabled) + return 0; + + if (pgm->fd.ifd != -1) { + buf[0] = CMD_LEAVE_PROGMODE; + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_program_disable(): " + "Sending leave progmode command: ", + progname); + jtagmkI_send(pgm, buf, 1); + + if (jtagmkI_recv(pgm, resp, 2) < 0) + return -1; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_program_disable(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + } + PDATA(pgm)->prog_enabled = 0; + + return 0; +} + +static unsigned char jtagmkI_get_baud(long baud) +{ + int i; + + for (i = 0; i < sizeof baudtab / sizeof baudtab[0]; i++) + if (baud == baudtab[i].baud) + return baudtab[i].val; + + return 0; +} + +/* + * initialize the AVR device and prepare it to accept commands + */ +static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + AVRMEM hfuse; + unsigned char cmd[1], resp[5]; + unsigned char b; + + if (!(p->flags & AVRPART_HAS_JTAG)) { + avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): part %s has no JTAG interface\n", + progname, p->desc); + return -1; + } + + jtagmkI_drain(pgm, 0); + + if ((serdev->flags & SERDEV_FL_CANSETSPEED) && PDATA(pgm)->initial_baudrate != pgm->baudrate) { + if ((b = jtagmkI_get_baud(pgm->baudrate)) == 0) { + avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): unsupported baudrate %d\n", + progname, pgm->baudrate); + } else { + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_initialize(): " + "trying to set baudrate to %d\n", + progname, pgm->baudrate); + if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) { + PDATA(pgm)->initial_baudrate = pgm->baudrate; /* don't adjust again later */ + serial_setspeed(&pgm->fd, pgm->baudrate); + } + } + } + + if (pgm->bitclock != 0.0) { + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_initialize(): " + "trying to set JTAG clock period to %.1f us\n", + progname, pgm->bitclock); + if (jtagmkI_set_sck_period(pgm, pgm->bitclock) != 0) + return -1; + } + + cmd[0] = CMD_STOP; + jtagmkI_send(pgm, cmd, 1); + if (jtagmkI_recv(pgm, resp, 5) < 0) + return -1; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + + /* + * Must set the device descriptor before entering programming mode. + */ + jtagmkI_set_devdescr(pgm, p); + + jtagmkI_setparm(pgm, PARM_FLASH_PAGESIZE_LOW, PDATA(pgm)->flash_pagesize & 0xff); + jtagmkI_setparm(pgm, PARM_FLASH_PAGESIZE_HIGH, PDATA(pgm)->flash_pagesize >> 8); + jtagmkI_setparm(pgm, PARM_EEPROM_PAGESIZE, PDATA(pgm)->eeprom_pagesize & 0xff); + + free(PDATA(pgm)->flash_pagecache); + free(PDATA(pgm)->eeprom_pagecache); + if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): Out of memory\n", + progname); + return -1; + } + if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): Out of memory\n", + progname); + free(PDATA(pgm)->flash_pagecache); + return -1; + } + PDATA(pgm)->flash_pageaddr = PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + + if (jtagmkI_reset(pgm) < 0) + return -1; + + strcpy(hfuse.desc, "hfuse"); + if (jtagmkI_read_byte(pgm, p, &hfuse, 1, &b) < 0) + return -1; + if ((b & OCDEN) != 0) + avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): warning: OCDEN fuse not programmed, " + "single-byte EEPROM updates not possible\n", + progname); + + return 0; +} + + +static void jtagmkI_disable(PROGRAMMER * pgm) +{ + + free(PDATA(pgm)->flash_pagecache); + PDATA(pgm)->flash_pagecache = NULL; + free(PDATA(pgm)->eeprom_pagecache); + PDATA(pgm)->eeprom_pagecache = NULL; + + (void)jtagmkI_program_disable(pgm); +} + +static void jtagmkI_enable(PROGRAMMER * pgm) +{ + return; +} + + +static int jtagmkI_open(PROGRAMMER * pgm, char * port) +{ + size_t i; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_open()\n", progname); + + strcpy(pgm->port, port); + PDATA(pgm)->initial_baudrate = -1L; + + for (i = 0; i < sizeof(baudtab) / sizeof(baudtab[0]); i++) { + union pinfo pinfo; + pinfo.baud = baudtab[i].baud; + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_open(): trying to sync at baud rate %ld:\n", + progname, pinfo.baud); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + jtagmkI_drain(pgm, 0); + + if (jtagmkI_getsync(pgm) == 0) { + PDATA(pgm)->initial_baudrate = baudtab[i].baud; + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_open(): succeeded\n", progname); + return 0; + } + + serial_close(&pgm->fd); + } + + avrdude_message(MSG_INFO, "%s: jtagmkI_open(): failed to synchronize to ICE\n", + progname); + pgm->fd.ifd = -1; + + return -1; +} + + +static void jtagmkI_close(PROGRAMMER * pgm) +{ + unsigned char b; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_close()\n", progname); + + /* + * Revert baud rate to what it used to be when we started. This + * appears to make AVR Studio happier when it is about to access the + * ICE later on. + */ + if ((serdev->flags & SERDEV_FL_CANSETSPEED) && PDATA(pgm)->initial_baudrate != pgm->baudrate) { + if ((b = jtagmkI_get_baud(PDATA(pgm)->initial_baudrate)) == 0) { + avrdude_message(MSG_INFO, "%s: jtagmkI_close(): unsupported baudrate %d\n", + progname, PDATA(pgm)->initial_baudrate); + } else { + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_close(): " + "trying to set baudrate to %d\n", + progname, PDATA(pgm)->initial_baudrate); + if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) { + serial_setspeed(&pgm->fd, pgm->baudrate); + } + } + } + + if (pgm->fd.ifd != -1) { + serial_close(&pgm->fd); + } + + pgm->fd.ifd = -1; +} + + +static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + int block_size, send_size, tries; + unsigned int maxaddr = addr + n_bytes; + unsigned char cmd[6], *datacmd; + unsigned char resp[2]; + int is_flash = 0; + long otimeout = serial_recv_timeout; +#define MAXTRIES 3 + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_write(.., %s, %d, %d)\n", + progname, m->desc, page_size, n_bytes); + + if (jtagmkI_program_enable(pgm) < 0) + return -1; + + if (page_size == 0) page_size = 256; + + if (page_size > 256) { + avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): page size %d too large\n", + progname, page_size); + return -1; + } + + if ((datacmd = malloc(page_size + 1)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): Out of memory\n", + progname); + return -1; + } + + cmd[0] = CMD_WRITE_MEM; + if (strcmp(m->desc, "flash") == 0) { + cmd[1] = MTYPE_FLASH_PAGE; + PDATA(pgm)->flash_pageaddr = (unsigned long)-1L; + page_size = PDATA(pgm)->flash_pagesize; + is_flash = 1; + } else if (strcmp(m->desc, "eeprom") == 0) { + cmd[1] = MTYPE_EEPROM_PAGE; + PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + page_size = PDATA(pgm)->eeprom_pagesize; + } + datacmd[0] = CMD_DATA; + + serial_recv_timeout = 1000; + for (; addr < maxaddr; addr += page_size) { + tries = 0; + again: + + if (tries != 0 && jtagmkI_resync(pgm, 2000, 0) < 0) { + avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): sync loss, retries exhausted\n", + progname); + return -1; + } + + if (n_bytes < page_size) + block_size = n_bytes; + else + block_size = page_size; + avrdude_message(MSG_DEBUG, "%s: jtagmkI_paged_write(): " + "block_size at addr %d is %d\n", + progname, addr, block_size); + + /* We always write full pages. */ + send_size = page_size; + if (is_flash) { + cmd[2] = send_size / 2 - 1; + u32_to_b3(cmd + 3, addr / 2); + } else { + cmd[2] = send_size - 1; + u32_to_b3(cmd + 3, addr); + } + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_write(): " + "Sending write memory command: ", + progname); + + /* First part, send the write command. */ + jtagmkI_send(pgm, cmd, 6); + if (jtagmkI_recv(pgm, resp, 1) < 0) + return -1; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + if (tries++ < MAXTRIES) + goto again; + serial_recv_timeout = otimeout; + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + + /* + * The JTAG ICE will refuse to write anything but a full page, at + * least for the flash ROM. If a partial page has been requested, + * set the remainder to 0xff. (Maybe we should rather read back + * the existing contents instead before? Doesn't matter much, as + * bits cannot be written to 1 anyway.) + */ + memset(datacmd + 1, 0xff, page_size); + memcpy(datacmd + 1, m->buf + addr, block_size); + + /* Second, send the data command. */ + jtagmkI_send(pgm, datacmd, send_size + 1); + if (jtagmkI_recv(pgm, resp, 2) < 0) + return -1; + if (resp[1] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + if (tries++ < MAXTRIES) + goto again; + serial_recv_timeout = otimeout; + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + } + + free(datacmd); + serial_recv_timeout = otimeout; + +#undef MAXTRIES + return n_bytes; +} + +static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + int block_size, read_size, is_flash = 0, tries; + unsigned int maxaddr = addr + n_bytes; + unsigned char cmd[6], resp[256 * 2 + 3]; + long otimeout = serial_recv_timeout; +#define MAXTRIES 3 + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_load(.., %s, %d, %d)\n", + progname, m->desc, page_size, n_bytes); + + if (jtagmkI_program_enable(pgm) < 0) + return -1; + + page_size = m->readsize; + + cmd[0] = CMD_READ_MEM; + if (strcmp(m->desc, "flash") == 0) { + cmd[1] = MTYPE_FLASH_PAGE; + is_flash = 1; + } else if (strcmp(m->desc, "eeprom") == 0) { + cmd[1] = MTYPE_EEPROM_PAGE; + } + + if (page_size > (is_flash? 512: 256)) { + avrdude_message(MSG_INFO, "%s: jtagmkI_paged_load(): page size %d too large\n", + progname, page_size); + return -1; + } + + serial_recv_timeout = 1000; + for (; addr < maxaddr; addr += page_size) { + tries = 0; + again: + if (tries != 0 && jtagmkI_resync(pgm, 2000, 0) < 0) { + avrdude_message(MSG_INFO, "%s: jtagmkI_paged_load(): sync loss, retries exhausted\n", + progname); + return -1; + } + + if (n_bytes < page_size) + block_size = n_bytes; + else + block_size = page_size; + avrdude_message(MSG_DEBUG, "%s: jtagmkI_paged_load(): " + "block_size at addr %d is %d\n", + progname, addr, block_size); + + if (is_flash) { + read_size = 2 * ((block_size + 1) / 2); /* round up */ + cmd[2] = read_size / 2 - 1; + u32_to_b3(cmd + 3, addr / 2); + } else { + read_size = page_size; + cmd[2] = page_size - 1; + u32_to_b3(cmd + 3, addr); + } + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_load(): Sending read memory command: ", + progname); + + jtagmkI_send(pgm, cmd, 6); + if (jtagmkI_recv(pgm, resp, read_size + 3) < 0) + return -1; + + if (resp[read_size + 3 - 1] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_paged_load(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[read_size + 3 - 1]); + if (tries++ < MAXTRIES) + goto again; + + serial_recv_timeout = otimeout; + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + + memcpy(m->buf + addr, resp + 1, block_size); + } + serial_recv_timeout = otimeout; + +#undef MAXTRIES + return n_bytes; +} + +static int jtagmkI_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value) +{ + unsigned char cmd[6]; + unsigned char resp[256 * 2 + 3], *cache_ptr = NULL; + unsigned long paddr = 0UL, *paddr_ptr = NULL; + unsigned int pagesize = 0; + int respsize = 3 + 1; + int is_flash = 0; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_read_byte(.., %s, 0x%lx, ...)\n", + progname, mem->desc, addr); + + if (jtagmkI_program_enable(pgm) < 0) + return -1; + + cmd[0] = CMD_READ_MEM; + + if (strcmp(mem->desc, "flash") == 0) { + cmd[1] = MTYPE_FLASH_PAGE; + pagesize = mem->page_size; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->flash_pageaddr; + cache_ptr = PDATA(pgm)->flash_pagecache; + is_flash = 1; + } else if (strcmp(mem->desc, "eeprom") == 0) { + cmd[1] = MTYPE_EEPROM_PAGE; + pagesize = mem->page_size; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->eeprom_pageaddr; + cache_ptr = PDATA(pgm)->eeprom_pagecache; + } else if (strcmp(mem->desc, "lfuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 0; + } else if (strcmp(mem->desc, "hfuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 1; + } else if (strcmp(mem->desc, "efuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 2; + } else if (strcmp(mem->desc, "lock") == 0) { + cmd[1] = MTYPE_LOCK_BITS; + } else if (strcmp(mem->desc, "calibration") == 0) { + cmd[1] = MTYPE_OSCCAL_BYTE; + } else if (strcmp(mem->desc, "signature") == 0) { + cmd[1] = MTYPE_SIGN_JTAG; + } + + /* + * To improve the read speed, we used paged reads for flash and + * EEPROM, and cache the results in a page cache. + * + * Page cache validation is based on "{flash,eeprom}_pageaddr" + * (holding the base address of the most recent cache fill + * operation). This variable is set to (unsigned long)-1L when the + * cache needs to be invalidated. + */ + if (pagesize && paddr == *paddr_ptr) { + *value = cache_ptr[addr & (pagesize - 1)]; + return 0; + } + + if (pagesize) { + if (is_flash) { + cmd[2] = pagesize / 2 - 1; + u32_to_b3(cmd + 3, paddr / 2); + } else { + cmd[2] = pagesize - 1; + u32_to_b3(cmd + 3, paddr); + } + respsize = 3 + pagesize; + } else { + if (cmd[1] == MTYPE_FUSE_BITS) { + /* + * The mkI ICE has a bug where it doesn't read efuse correctly + * when reading it as a single byte @offset 2, while reading all + * fuses at once does work. + */ + cmd[2] = 3 - 1; + u32_to_b3(cmd + 3, 0); + respsize = 3 + 3; + } else { + cmd[2] = 1 - 1; + u32_to_b3(cmd + 3, addr); + } + } + + jtagmkI_send(pgm, cmd, 6); + if (jtagmkI_recv(pgm, resp, respsize) < 0) + return -1; + + if (resp[respsize - 1] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_read_byte(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[respsize - 1]); + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + + if (pagesize) { + *paddr_ptr = paddr; + memcpy(cache_ptr, resp + 1, pagesize); + *value = cache_ptr[addr & (pagesize - 1)]; + } else if (cmd[1] == MTYPE_FUSE_BITS) { + /* extract the desired fuse */ + *value = resp[1 + addr]; + } else + *value = resp[1]; + + return 0; +} + +static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + unsigned char cmd[6], datacmd[1 * 2 + 1]; + unsigned char resp[1], writedata; + int len, need_progmode = 1; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_write_byte(.., %s, 0x%lx, ...)\n", + progname, mem->desc, addr); + + writedata = data; + cmd[0] = CMD_WRITE_MEM; + if (strcmp(mem->desc, "flash") == 0) { + cmd[1] = MTYPE_SPM; + need_progmode = 0; + PDATA(pgm)->flash_pageaddr = (unsigned long)-1L; + } else if (strcmp(mem->desc, "eeprom") == 0) { + cmd[1] = MTYPE_EEPROM; + need_progmode = 0; + PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + } else if (strcmp(mem->desc, "lfuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 0; + } else if (strcmp(mem->desc, "hfuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 1; + } else if (strcmp(mem->desc, "efuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 2; + } else if (strcmp(mem->desc, "lock") == 0) { + cmd[1] = MTYPE_LOCK_BITS; + } else if (strcmp(mem->desc, "calibration") == 0) { + cmd[1] = MTYPE_OSCCAL_BYTE; + } else if (strcmp(mem->desc, "signature") == 0) { + cmd[1] = MTYPE_SIGN_JTAG; + } + + if (need_progmode) { + if (jtagmkI_program_enable(pgm) < 0) + return -1; + } else { + if (jtagmkI_program_disable(pgm) < 0) + return -1; + } + + cmd[2] = 1 - 1; + if (cmd[1] == MTYPE_SPM) { + /* + * Flash is word-addressed, but we cannot handle flash anyway + * here, as it needs to be written one page at a time... + */ + u32_to_b3(cmd + 3, addr / 2); + } else { + u32_to_b3(cmd + 3, addr); + } + /* First part, send the write command. */ + jtagmkI_send(pgm, cmd, 6); + if (jtagmkI_recv(pgm, resp, 1) < 0) + return -1; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_write_byte(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + + /* Now, send the data buffer. */ + datacmd[0] = CMD_DATA; + if (cmd[1] == MTYPE_SPM) { + len = 3; + if ((addr & 1) != 0) { + datacmd[1] = 0; + datacmd[2] = writedata; + } else { + datacmd[1] = writedata; + datacmd[2] = 0; + } + } else { + len = 2; + datacmd[1] = writedata; + } + jtagmkI_send(pgm, datacmd, len); + if (jtagmkI_recv(pgm, resp, 1) < 0) + return -1; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_write_byte(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + + return 0; +} + + +/* + * Set the JTAG clock. The actual frequency is quite a bit of + * guesswork, based on the values claimed by AVR Studio. Inside the + * JTAG ICE, the value is the delay count of a delay loop between the + * JTAG clock edges. A count of 0 bypasses the delay loop. + * + * As the STK500 expresses it as a period length (and we actualy do + * program a period length as well), we rather call it by that name. + */ +static int jtagmkI_set_sck_period(PROGRAMMER * pgm, double v) +{ + unsigned char dur; + + v = 1 / v; /* convert to frequency */ + if (v >= 1e6) + dur = JTAG_BITRATE_1_MHz; + else if (v >= 499e3) + dur = JTAG_BITRATE_500_kHz; + else if (v >= 249e3) + dur = JTAG_BITRATE_250_kHz; + else + dur = JTAG_BITRATE_125_kHz; + + return jtagmkI_setparm(pgm, PARM_CLOCK, dur); +} + + +/* + * Read an emulator parameter. The result is exactly one byte, + * multi-byte parameters get two different parameter names for + * their components. + */ +static int jtagmkI_getparm(PROGRAMMER * pgm, unsigned char parm, + unsigned char * value) +{ + unsigned char buf[2], resp[3]; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_getparm()\n", progname); + + buf[0] = CMD_GET_PARAM; + buf[1] = parm; + if (verbose >= 2) + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_getparm(): " + "Sending get parameter command (parm 0x%02x): ", + progname, parm); + jtagmkI_send(pgm, buf, 2); + + if (jtagmkI_recv(pgm, resp, 3) < 0) + return -1; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_getparm(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + return -1; + } else if (resp[2] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_getparm(): " + "unknown parameter 0x%02x\n", + progname, parm); + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK, value 0x%02x\n", resp[1]); + } + + *value = resp[1]; + + return 0; +} + +/* + * Write an emulator parameter. + */ +static int jtagmkI_setparm(PROGRAMMER * pgm, unsigned char parm, + unsigned char value) +{ + unsigned char buf[3], resp[2]; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_setparm()\n", progname); + + buf[0] = CMD_SET_PARAM; + buf[1] = parm; + buf[2] = value; + avrdude_message(MSG_NOTICE2, "%s: jtagmkI_setparm(): " + "Sending set parameter command (parm 0x%02x): ", + progname, parm); + jtagmkI_send(pgm, buf, 3); + if (jtagmkI_recv(pgm, resp, 2) < 0) + return -1; + if (resp[0] != RESP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkI_setparm(): " + "timeout/error communicating with programmer (resp %c)\n", + progname, resp[0]); + return -1; + } else { + if (verbose == 2) + avrdude_message(MSG_NOTICE2, "OK\n"); + } + + return 0; +} + + +static void jtagmkI_display(PROGRAMMER * pgm, const char * p) +{ + + unsigned char hw, fw; + + if (jtagmkI_getparm(pgm, PARM_HW_VERSION, &hw) < 0 || + jtagmkI_getparm(pgm, PARM_SW_VERSION, &fw) < 0) + return; + + avrdude_message(MSG_INFO, "%sICE hardware version: 0x%02x\n", p, hw); + avrdude_message(MSG_INFO, "%sICE firmware version: 0x%02x\n", p, fw); + + jtagmkI_print_parms1(pgm, p); + + return; +} + + +static void jtagmkI_print_parms1(PROGRAMMER * pgm, const char * p) +{ + unsigned char vtarget, jtag_clock; + const char *clkstr; + double clk; + + if (jtagmkI_getparm(pgm, PARM_OCD_VTARGET, &vtarget) < 0 || + jtagmkI_getparm(pgm, PARM_CLOCK, &jtag_clock) < 0) + return; + + switch ((unsigned)jtag_clock) { + case JTAG_BITRATE_1_MHz: + clkstr = "1 MHz"; + clk = 1e6; + break; + + case JTAG_BITRATE_500_kHz: + clkstr = "500 kHz"; + clk = 500e3; + break; + + case JTAG_BITRATE_250_kHz: + clkstr = "250 kHz"; + clk = 250e3; + break; + + case JTAG_BITRATE_125_kHz: + clkstr = "125 kHz"; + clk = 125e3; + break; + + default: + clkstr = "???"; + clk = 1e6; + } + + avrdude_message(MSG_INFO, "%sVtarget : %.1f V\n", p, + 6.25 * (unsigned)vtarget / 255.0); + avrdude_message(MSG_INFO, "%sJTAG clock : %s (%.1f us)\n", p, clkstr, + 1.0e6 / clk); + + return; +} + + +static void jtagmkI_print_parms(PROGRAMMER * pgm) +{ + jtagmkI_print_parms1(pgm, ""); +} + +const char jtagmkI_desc[] = "Atmel JTAG ICE mkI"; + +void jtagmkI_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "JTAGMKI"); + + /* + * mandatory functions + */ + pgm->initialize = jtagmkI_initialize; + pgm->display = jtagmkI_display; + pgm->enable = jtagmkI_enable; + pgm->disable = jtagmkI_disable; + pgm->program_enable = jtagmkI_program_enable_dummy; + pgm->chip_erase = jtagmkI_chip_erase; + pgm->open = jtagmkI_open; + pgm->close = jtagmkI_close; + pgm->read_byte = jtagmkI_read_byte; + pgm->write_byte = jtagmkI_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtagmkI_paged_write; + pgm->paged_load = jtagmkI_paged_load; + pgm->print_parms = jtagmkI_print_parms; + pgm->set_sck_period = jtagmkI_set_sck_period; + pgm->setup = jtagmkI_setup; + pgm->teardown = jtagmkI_teardown; + pgm->page_size = 256; +} diff --git a/xs/src/avrdude/jtagmkI.h b/xs/src/avrdude/jtagmkI.h new file mode 100644 index 000000000..fbc0d161d --- /dev/null +++ b/xs/src/avrdude/jtagmkI.h @@ -0,0 +1,36 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 jtagmkI_h +#define jtagmkI_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char jtagmkI_desc[]; +void jtagmkI_initpgm (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/xs/src/avrdude/jtagmkII.c b/xs/src/avrdude/jtagmkII.c new file mode 100644 index 000000000..78c412ce6 --- /dev/null +++ b/xs/src/avrdude/jtagmkII.c @@ -0,0 +1,4023 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2005-2007 Joerg Wunsch + * + * Derived from stk500 code which is: + * Copyright (C) 2002-2004 Brian S. Dean + * Copyright (C) 2005 Erik Walthinsen + * + * + * 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$ */ + +/* + * avrdude interface for Atmel JTAG ICE mkII programmer + * + * The AVR Dragon also uses the same protocol, so it is handled here + * as well. + */ + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "crc16.h" +#include "jtagmkII.h" +#include "jtagmkII_private.h" +#include "usbdevs.h" + +/* + * Private data for this programmer. + */ +struct pdata +{ + unsigned short command_sequence; /* Next cmd seqno to issue. */ + + /* + * See jtagmkII_read_byte() for an explanation of the flash and + * EEPROM page caches. + */ + unsigned char *flash_pagecache; + unsigned long flash_pageaddr; + unsigned int flash_pagesize; + + unsigned char *eeprom_pagecache; + unsigned long eeprom_pageaddr; + unsigned int eeprom_pagesize; + + int prog_enabled; /* Cached value of PROGRAMMING status. */ + unsigned char serno[6]; /* JTAG ICE serial number. */ + + /* JTAG chain stuff */ + unsigned char jtagchain[4]; + + /* The length of the device descriptor is firmware-dependent. */ + size_t device_descriptor_length; + + /* Start address of Xmega boot area */ + unsigned long boot_start; + + /* Major firmware version (needed for Xmega programming) */ + unsigned int fwver; +}; + +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) + +/* + * The OCDEN fuse is bit 7 of the high fuse (hfuse). In order to + * perform memory operations on MTYPE_SPM and MTYPE_EEPROM, OCDEN + * needs to be programmed. + * + * OCDEN should probably rather be defined via the configuration, but + * if this ever changes to a different fuse byte for one MCU, quite + * some code here needs to be generalized anyway. + */ +#define OCDEN (1 << 7) + +#define RC(x) { x, #x }, +static struct { + unsigned int code; + const char *descr; +} jtagresults[] = { + RC(RSP_DEBUGWIRE_SYNC_FAILED) + RC(RSP_FAILED) + RC(RSP_ILLEGAL_BREAKPOINT) + RC(RSP_ILLEGAL_COMMAND) + RC(RSP_ILLEGAL_EMULATOR_MODE) + RC(RSP_ILLEGAL_JTAG_ID) + RC(RSP_ILLEGAL_MCU_STATE) + RC(RSP_ILLEGAL_MEMORY_TYPE) + RC(RSP_ILLEGAL_MEMORY_RANGE) + RC(RSP_ILLEGAL_PARAMETER) + RC(RSP_ILLEGAL_POWER_STATE) + RC(RSP_ILLEGAL_VALUE) + RC(RSP_NO_TARGET_POWER) + RC(RSP_SET_N_PARAMETERS) +}; + +/* + * pgm->flag is marked as "for private use of the programmer". + * The following defines this programmer's use of that field. + */ +#define PGM_FL_IS_DW (0x0001) +#define PGM_FL_IS_PDI (0x0002) +#define PGM_FL_IS_JTAG (0x0004) + +static int jtagmkII_open(PROGRAMMER * pgm, char * port); + +static int jtagmkII_initialize(PROGRAMMER * pgm, AVRPART * p); +static int jtagmkII_chip_erase(PROGRAMMER * pgm, AVRPART * p); +static int jtagmkII_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value); +static int jtagmkII_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data); +static int jtagmkII_reset(PROGRAMMER * pgm, unsigned char flags); +static int jtagmkII_set_sck_period(PROGRAMMER * pgm, double v); +static int jtagmkII_setparm(PROGRAMMER * pgm, unsigned char parm, + unsigned char * value); +static void jtagmkII_print_parms1(PROGRAMMER * pgm, const char * p); +static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes); +static unsigned char jtagmkII_memtype(PROGRAMMER * pgm, AVRPART * p, unsigned long addr); +static unsigned int jtagmkII_memaddr(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr); + +// AVR32 +#define ERROR_SAB 0xFFFFFFFF + +static int jtagmkII_open32(PROGRAMMER * pgm, char * port); +static void jtagmkII_close32(PROGRAMMER * pgm); +static int jtagmkII_reset32(PROGRAMMER * pgm, unsigned short flags); +static int jtagmkII_initialize32(PROGRAMMER * pgm, AVRPART * p); +static int jtagmkII_chip_erase32(PROGRAMMER * pgm, AVRPART * p); +static unsigned long jtagmkII_read_SABaddr(PROGRAMMER * pgm, unsigned long addr, + unsigned int prefix); // ERROR_SAB illegal +static int jtagmkII_write_SABaddr(PROGRAMMER * pgm, unsigned long addr, + unsigned int prefix, unsigned long val); +static int jtagmkII_avr32_reset(PROGRAMMER * pgm, unsigned char val, + unsigned char ret1, unsigned char ret2); +static int jtagmkII_smc_init32(PROGRAMMER * pgm); +static int jtagmkII_paged_write32(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes); +static int jtagmkII_flash_lock32(PROGRAMMER * pgm, unsigned char lock, + unsigned int page); +static int jtagmkII_flash_erase32(PROGRAMMER * pgm, unsigned int page); +static int jtagmkII_flash_write_page32(PROGRAMMER * pgm, unsigned int page); +static int jtagmkII_flash_clear_pagebuffer32(PROGRAMMER * pgm); +static int jtagmkII_paged_load32(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes); + +void jtagmkII_setup(PROGRAMMER * pgm) +{ + if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + avrdude_message(MSG_INFO, "%s: jtagmkII_setup(): Out of memory allocating private data\n", + progname); + exit(1); + } + memset(pgm->cookie, 0, sizeof(struct pdata)); +} + +void jtagmkII_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); +} + + +static unsigned long +b4_to_u32(unsigned char *b) +{ + unsigned long l; + l = b[0]; + l += (unsigned)b[1] << 8; + l += (unsigned)b[2] << 16; + l += (unsigned)b[3] << 24; + + return l; +} +static unsigned long +b4_to_u32r(unsigned char *b) +{ + unsigned long l; + l = b[3]; + l += (unsigned)b[2] << 8; + l += (unsigned)b[1] << 16; + l += (unsigned)b[0] << 24; + + return l; +} + +static void +u32_to_b4(unsigned char *b, unsigned long l) +{ + b[0] = l & 0xff; + b[1] = (l >> 8) & 0xff; + b[2] = (l >> 16) & 0xff; + b[3] = (l >> 24) & 0xff; +} +static void +u32_to_b4r(unsigned char *b, unsigned long l) +{ + b[3] = l & 0xff; + b[2] = (l >> 8) & 0xff; + b[1] = (l >> 16) & 0xff; + b[0] = (l >> 24) & 0xff; +} + +static unsigned short +b2_to_u16(unsigned char *b) +{ + unsigned short l; + l = b[0]; + l += (unsigned)b[1] << 8; + + return l; +} + +static void +u16_to_b2(unsigned char *b, unsigned short l) +{ + b[0] = l & 0xff; + b[1] = (l >> 8) & 0xff; +} + +static const char * +jtagmkII_get_rc(unsigned int rc) +{ + int i; + static char msg[50]; + + for (i = 0; i < sizeof jtagresults / sizeof jtagresults[0]; i++) + if (jtagresults[i].code == rc) + return jtagresults[i].descr; + + sprintf(msg, "Unknown JTAG ICE mkII result code 0x%02x", rc); + return msg; +} + + +static void jtagmkII_print_memory(unsigned char *b, size_t s) +{ + int i; + + if (s < 2) + return; + + for (i = 0; i < s - 1; i++) { + avrdude_message(MSG_INFO, "0x%02x ", b[i + 1]); + if (i % 16 == 15) + putc('\n', stderr); + else + putc(' ', stderr); + } + if (i % 16 != 0) + putc('\n', stderr); +} + +static void jtagmkII_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + int i; + + if (verbose >= 4) { + avrdude_message(MSG_TRACE, "Raw message:\n"); + + for (i = 0; i < len; i++) { + avrdude_message(MSG_TRACE, "0x%02x", data[i]); + if (i % 16 == 15) + putc('\n', stderr); + else + putc(' ', stderr); + } + if (i % 16 != 0) + putc('\n', stderr); + } + + switch (data[0]) { + case RSP_OK: + avrdude_message(MSG_INFO, "OK\n"); + break; + + case RSP_FAILED: + avrdude_message(MSG_INFO, "FAILED\n"); + break; + + case RSP_ILLEGAL_BREAKPOINT: + avrdude_message(MSG_INFO, "Illegal breakpoint\n"); + break; + + case RSP_ILLEGAL_COMMAND: + avrdude_message(MSG_INFO, "Illegal command\n"); + break; + + case RSP_ILLEGAL_EMULATOR_MODE: + avrdude_message(MSG_INFO, "Illegal emulator mode"); + if (len > 1) + switch (data[1]) { + case EMULATOR_MODE_DEBUGWIRE: avrdude_message(MSG_INFO, ": DebugWire"); break; + case EMULATOR_MODE_JTAG: avrdude_message(MSG_INFO, ": JTAG"); break; + case EMULATOR_MODE_HV: avrdude_message(MSG_INFO, ": HVSP/PP"); break; + case EMULATOR_MODE_SPI: avrdude_message(MSG_INFO, ": SPI"); break; + case EMULATOR_MODE_JTAG_XMEGA: avrdude_message(MSG_INFO, ": JTAG/Xmega"); break; + } + putc('\n', stderr); + break; + + case RSP_ILLEGAL_JTAG_ID: + avrdude_message(MSG_INFO, "Illegal JTAG ID\n"); + break; + + case RSP_ILLEGAL_MCU_STATE: + avrdude_message(MSG_INFO, "Illegal MCU state"); + if (len > 1) + switch (data[1]) { + case STOPPED: avrdude_message(MSG_INFO, ": Stopped"); break; + case RUNNING: avrdude_message(MSG_INFO, ": Running"); break; + case PROGRAMMING: avrdude_message(MSG_INFO, ": Programming"); break; + } + putc('\n', stderr); + break; + + case RSP_ILLEGAL_MEMORY_TYPE: + avrdude_message(MSG_INFO, "Illegal memory type\n"); + break; + + case RSP_ILLEGAL_MEMORY_RANGE: + avrdude_message(MSG_INFO, "Illegal memory range\n"); + break; + + case RSP_ILLEGAL_PARAMETER: + avrdude_message(MSG_INFO, "Illegal parameter\n"); + break; + + case RSP_ILLEGAL_POWER_STATE: + avrdude_message(MSG_INFO, "Illegal power state\n"); + break; + + case RSP_ILLEGAL_VALUE: + avrdude_message(MSG_INFO, "Illegal value\n"); + break; + + case RSP_NO_TARGET_POWER: + avrdude_message(MSG_INFO, "No target power\n"); + break; + + case RSP_SIGN_ON: + avrdude_message(MSG_INFO, "Sign-on succeeded\n"); + /* Sign-on data will be printed below anyway. */ + break; + + case RSP_MEMORY: + avrdude_message(MSG_INFO, "memory contents:\n"); + jtagmkII_print_memory(data, len); + break; + + case RSP_PARAMETER: + avrdude_message(MSG_INFO, "parameter values:\n"); + jtagmkII_print_memory(data, len); + break; + + case RSP_SPI_DATA: + avrdude_message(MSG_INFO, "SPI data returned:\n"); + for (i = 1; i < len; i++) + avrdude_message(MSG_INFO, "0x%02x ", data[i]); + putc('\n', stderr); + break; + + case EVT_BREAK: + avrdude_message(MSG_INFO, "BREAK event"); + if (len >= 6) { + avrdude_message(MSG_INFO, ", PC = 0x%lx, reason ", b4_to_u32(data + 1)); + switch (data[5]) { + case 0x00: + avrdude_message(MSG_INFO, "unspecified"); + break; + case 0x01: + avrdude_message(MSG_INFO, "program break"); + break; + case 0x02: + avrdude_message(MSG_INFO, "data break PDSB"); + break; + case 0x03: + avrdude_message(MSG_INFO, "data break PDMSB"); + break; + default: + avrdude_message(MSG_INFO, "unknown: 0x%02x", data[5]); + } + } + putc('\n', stderr); + break; + + default: + avrdude_message(MSG_INFO, "unknown message 0x%02x\n", data[0]); + } + + putc('\n', stderr); +} + + +int jtagmkII_send(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + unsigned char *buf; + + avrdude_message(MSG_DEBUG, "\n%s: jtagmkII_send(): sending %lu bytes\n", + progname, (unsigned long)len); + + if ((buf = malloc(len + 10)) == NULL) + { + avrdude_message(MSG_INFO, "%s: jtagmkII_send(): out of memory", + progname); + return -1; + } + + buf[0] = MESSAGE_START; + u16_to_b2(buf + 1, PDATA(pgm)->command_sequence); + u32_to_b4(buf + 3, len); + buf[7] = TOKEN; + memcpy(buf + 8, data, len); + + crcappend(buf, len + 8); + + if (serial_send(&pgm->fd, buf, len + 10) != 0) { + avrdude_message(MSG_INFO, "%s: jtagmkII_send(): failed to send command to serial port\n", + progname); + free(buf); + return -1; + } + + free(buf); + + return 0; +} + + +static int jtagmkII_drain(PROGRAMMER * pgm, int display) +{ + return serial_drain(&pgm->fd, display); +} + + +/* + * Receive one frame, return it in *msg. Received sequence number is + * returned in seqno. Any valid frame will be returned, regardless + * whether it matches the expected sequence number, including event + * notification frames (seqno == 0xffff). + * + * Caller must eventually free the buffer. + */ +static int jtagmkII_recv_frame(PROGRAMMER * pgm, unsigned char **msg, + unsigned short * seqno) { + enum states { sSTART, + /* NB: do NOT change the sequence of the following: */ + sSEQNUM1, sSEQNUM2, + sSIZE1, sSIZE2, sSIZE3, sSIZE4, + sTOKEN, + sDATA, + sCSUM1, sCSUM2, + /* end NB */ + sDONE + } state = sSTART; + unsigned long msglen = 0, l = 0; + int headeridx = 0; + int timeout = 0; + int ignorpkt = 0; + int rv; + unsigned char c, *buf = NULL, header[8]; + unsigned short r_seqno = 0; + unsigned short checksum = 0; + + struct timeval tv; + double timeoutval = 100; /* seconds */ + double tstart, tnow; + + avrdude_message(MSG_TRACE, "%s: jtagmkII_recv():\n", progname); + + gettimeofday(&tv, NULL); + tstart = tv.tv_sec; + + while ( (state != sDONE ) && (!timeout) ) { + if (state == sDATA) { + rv = 0; + if (ignorpkt) { + /* skip packet's contents */ + for(l = 0; l < msglen; l++) + rv += serial_recv(&pgm->fd, &c, 1); + } else { + rv += serial_recv(&pgm->fd, buf + 8, msglen); + } + if (rv != 0) { + timedout: + /* timeout in receive */ + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_recv(): Timeout receiving packet\n", + progname); + free(buf); + return -1; + } + } else { + if (serial_recv(&pgm->fd, &c, 1) != 0) + goto timedout; + } + checksum ^= c; + + if (state < sDATA) + header[headeridx++] = c; + + switch (state) { + case sSTART: + if (c == MESSAGE_START) { + state = sSEQNUM1; + } else { + headeridx = 0; + } + break; + case sSEQNUM1: + case sSEQNUM2: + r_seqno >>= 8; + r_seqno |= ((unsigned)c << 8); + state++; + break; + case sSIZE1: + case sSIZE2: + case sSIZE3: + case sSIZE4: + msglen >>= 8; + msglen |= ((unsigned)c << 24); + state++; + break; + case sTOKEN: + if (c == TOKEN) { + state = sDATA; + if (msglen > MAX_MESSAGE) { + avrdude_message(MSG_INFO, "%s: jtagmkII_recv(): msglen %lu exceeds max message " + "size %u, ignoring message\n", + progname, msglen, MAX_MESSAGE); + state = sSTART; + headeridx = 0; + } else if ((buf = malloc(msglen + 10)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkII_recv(): out of memory\n", + progname); + ignorpkt++; + } else { + memcpy(buf, header, 8); + } + } else { + state = sSTART; + headeridx = 0; + } + break; + case sDATA: + /* The entire payload has been read above. */ + l = msglen + 8; + state = sCSUM1; + break; + case sCSUM1: + case sCSUM2: + buf[l++] = c; + if (state == sCSUM2) { + if (crcverify(buf, msglen + 10)) { + if (verbose >= 9) + avrdude_message(MSG_TRACE2, "%s: jtagmkII_recv(): CRC OK", + progname); + state = sDONE; + } else { + avrdude_message(MSG_INFO, "%s: jtagmkII_recv(): checksum error\n", + progname); + free(buf); + return -4; + } + } else + state++; + break; + default: + avrdude_message(MSG_INFO, "%s: jtagmkII_recv(): unknown state\n", + progname); + free(buf); + return -5; + } + + gettimeofday(&tv, NULL); + tnow = tv.tv_sec; + if (tnow - tstart > timeoutval) { + avrdude_message(MSG_INFO, "%s: jtagmkII_recv_frame(): timeout\n", + progname); + return -1; + } + + } + avrdude_message(MSG_DEBUG, "\n"); + + *seqno = r_seqno; + *msg = buf; + + return msglen; +} + +int jtagmkII_recv(PROGRAMMER * pgm, unsigned char **msg) { + unsigned short r_seqno; + int rv; + + for (;;) { + if ((rv = jtagmkII_recv_frame(pgm, msg, &r_seqno)) <= 0) + return rv; + avrdude_message(MSG_DEBUG, "%s: jtagmkII_recv(): " + "Got message seqno %d (command_sequence == %d)\n", + progname, r_seqno, PDATA(pgm)->command_sequence); + if (r_seqno == PDATA(pgm)->command_sequence) { + if (++(PDATA(pgm)->command_sequence) == 0xffff) + PDATA(pgm)->command_sequence = 0; + /* + * We move the payload to the beginning of the buffer, to make + * the job easier for the caller. We have to return the + * original pointer though, as the caller must free() it. + */ + memmove(*msg, *msg + 8, rv); + + if (verbose == 4) + { + int i = rv; + unsigned char *p = *msg; + avrdude_message(MSG_TRACE, "%s: Recv: ", progname); + + while (i) { + unsigned char c = *p; + if (isprint(c)) { + avrdude_message(MSG_TRACE, "%c ", c); + } + else { + avrdude_message(MSG_TRACE, ". "); + } + avrdude_message(MSG_TRACE, "[%02x] ", c); + + p++; + i--; + } + avrdude_message(MSG_TRACE, "\n"); + } + return rv; + } + if (r_seqno == 0xffff) { + avrdude_message(MSG_DEBUG, "%s: jtagmkII_recv(): got asynchronous event\n", + progname); + } else { + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_recv(): " + "got wrong sequence number, %u != %u\n", + progname, r_seqno, PDATA(pgm)->command_sequence); + } + free(*msg); + } +} + + +int jtagmkII_getsync(PROGRAMMER * pgm, int mode) { + int tries; +#define MAXTRIES 33 + unsigned char buf[3], *resp, c = 0xff; + int status; + unsigned int fwver, hwver; + int is_dragon; + + avrdude_message(MSG_DEBUG, "%s: jtagmkII_getsync()\n", progname); + + if (strncmp(pgm->type, "JTAG", strlen("JTAG")) == 0) { + is_dragon = 0; + } else if (strncmp(pgm->type, "DRAGON", strlen("DRAGON")) == 0) { + is_dragon = 1; + } else { + avrdude_message(MSG_INFO, "%s: Programmer is neither JTAG ICE mkII nor AVR Dragon\n", + progname); + return -1; + } + for (tries = 0; tries < MAXTRIES; tries++) { + + /* Get the sign-on information. */ + buf[0] = CMND_GET_SIGN_ON; + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_getsync(): Sending sign-on command: ", + progname); + jtagmkII_send(pgm, buf, 1); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): sign-on command: " + "status %d\n", + progname, status); + } else if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + + if (status > 0) { + if ((c = resp[0]) == RSP_SIGN_ON) { + fwver = ((unsigned)resp[8] << 8) | (unsigned)resp[7]; + PDATA(pgm)->fwver = fwver; + hwver = (unsigned)resp[9]; + memcpy(PDATA(pgm)->serno, resp + 10, 6); + if (status > 17) { + avrdude_message(MSG_NOTICE, "JTAG ICE mkII sign-on message:\n"); + avrdude_message(MSG_NOTICE, "Communications protocol version: %u\n", + (unsigned)resp[1]); + avrdude_message(MSG_NOTICE, "M_MCU:\n"); + avrdude_message(MSG_NOTICE, " boot-loader FW version: %u\n", + (unsigned)resp[2]); + avrdude_message(MSG_NOTICE, " firmware version: %u.%02u\n", + (unsigned)resp[4], (unsigned)resp[3]); + avrdude_message(MSG_NOTICE, " hardware version: %u\n", + (unsigned)resp[5]); + avrdude_message(MSG_NOTICE, "S_MCU:\n"); + avrdude_message(MSG_NOTICE, " boot-loader FW version: %u\n", + (unsigned)resp[6]); + avrdude_message(MSG_NOTICE, " firmware version: %u.%02u\n", + (unsigned)resp[8], (unsigned)resp[7]); + avrdude_message(MSG_NOTICE, " hardware version: %u\n", + (unsigned)resp[9]); + avrdude_message(MSG_NOTICE, "Serial number: " + "%02x:%02x:%02x:%02x:%02x:%02x\n", + PDATA(pgm)->serno[0], PDATA(pgm)->serno[1], PDATA(pgm)->serno[2], PDATA(pgm)->serno[3], PDATA(pgm)->serno[4], PDATA(pgm)->serno[5]); + resp[status - 1] = '\0'; + avrdude_message(MSG_NOTICE, "Device ID: %s\n", + resp + 16); + } + break; + } + free(resp); + } + } + if (tries >= MAXTRIES) { + if (status <= 0) + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + else + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): " + "bad response to sign-on command: %s\n", + progname, jtagmkII_get_rc(c)); + return -1; + } + + PDATA(pgm)->device_descriptor_length = sizeof(struct device_descriptor); + /* + * There's no official documentation from Atmel about what firmware + * revision matches what device descriptor length. The algorithm + * below has been found empirically. + */ +#define FWVER(maj, min) ((maj << 8) | (min)) + if (!is_dragon && fwver < FWVER(3, 16)) { + PDATA(pgm)->device_descriptor_length -= 2; + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): " + "S_MCU firmware version might be too old to work correctly\n", + progname); + } else if (!is_dragon && fwver < FWVER(4, 0)) { + PDATA(pgm)->device_descriptor_length -= 2; + } + if (mode != EMULATOR_MODE_SPI) + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_getsync(): Using a %u-byte device descriptor\n", + progname, (unsigned)PDATA(pgm)->device_descriptor_length); + if (mode == EMULATOR_MODE_SPI) { + PDATA(pgm)->device_descriptor_length = 0; + if (!is_dragon && fwver < FWVER(4, 14)) { + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): ISP functionality requires firmware " + "version >= 4.14\n", + progname); + return -1; + } + } + if (mode == EMULATOR_MODE_PDI || mode == EMULATOR_MODE_JTAG_XMEGA) { + if (!is_dragon && mode == EMULATOR_MODE_PDI && hwver < 1) { + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): Xmega PDI support requires hardware " + "revision >= 1\n", + progname); + return -1; + } + if (!is_dragon && fwver < FWVER(5, 37)) { + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): Xmega support requires firmware " + "version >= 5.37\n", + progname); + return -1; + } + if (is_dragon && fwver < FWVER(6, 11)) { + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): Xmega support requires firmware " + "version >= 6.11\n", + progname); + return -1; + } + } +#undef FWVER + + if(mode < 0) return 0; // for AVR32 + + tries = 0; +retry: + /* Turn the ICE into JTAG or ISP mode as requested. */ + buf[0] = mode; + if (jtagmkII_setparm(pgm, PAR_EMULATOR_MODE, buf) < 0) { + if (mode == EMULATOR_MODE_SPI) { + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): " + "ISP activation failed, trying debugWire\n", + progname); + buf[0] = EMULATOR_MODE_DEBUGWIRE; + if (jtagmkII_setparm(pgm, PAR_EMULATOR_MODE, buf) < 0) + return -1; + else { + /* + * We are supposed to send a CMND_RESET with the + * MONCOM_DISABLE flag set right now, and then + * restart from scratch. + * + * As this will make the ICE sign off from USB, so + * we risk losing our USB connection, it's easier + * to instruct the user to restart AVRDUDE rather + * than trying to cope with all this inside the + * program. + */ + (void)jtagmkII_reset(pgm, 0x04); + if (tries++ > 3) { + avrdude_message(MSG_INFO, "%s: Failed to return from debugWIRE to ISP.\n", + progname); + return -1; + } + avrdude_message(MSG_INFO, "%s: Target prepared for ISP, signed off.\n" + "%s: Now retrying without power-cycling the target.\n", + progname, progname); + goto retry; + } + } else { + return -1; + } + } + + /* GET SYNC forces the target into STOPPED mode */ + buf[0] = CMND_GET_SYNC; + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_getsync(): Sending get sync command: ", + progname); + jtagmkII_send(pgm, buf, 1); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): " + "bad response to set parameter command: %s\n", + progname, jtagmkII_get_rc(c)); + return -1; + } + + return 0; +} + +/* + * issue the 'chip erase' command to the AVR device + */ +static int jtagmkII_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + int status, len; + unsigned char buf[6], *resp, c; + + if (p->flags & AVRPART_HAS_PDI) { + buf[0] = CMND_XMEGA_ERASE; + buf[1] = XMEGA_ERASE_CHIP; + memset(buf + 2, 0, 4); /* address of area to be erased */ + len = 6; + } else { + buf[0] = CMND_CHIP_ERASE; + len = 1; + } + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_chip_erase(): Sending %schip erase command: ", + progname, + (p->flags & AVRPART_HAS_PDI)? "Xmega ": ""); + jtagmkII_send(pgm, buf, len); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_chip_erase(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_chip_erase(): " + "bad response to chip erase command: %s\n", + progname, jtagmkII_get_rc(c)); + return -1; + } + + if (!(p->flags & AVRPART_HAS_PDI)) + pgm->initialize(pgm, p); + + return 0; +} + +/* + * There is no chip erase functionality in debugWire mode. + */ +static int jtagmkII_chip_erase_dw(PROGRAMMER * pgm, AVRPART * p) +{ + + avrdude_message(MSG_INFO, "%s: Chip erase not supported in debugWire mode\n", + progname); + + return 0; +} + +static void jtagmkII_set_devdescr(PROGRAMMER * pgm, AVRPART * p) +{ + int status; + unsigned char *resp, c; + LNODEID ln; + AVRMEM * m; + struct { + unsigned char cmd; + struct device_descriptor dd; + } sendbuf; + + memset(&sendbuf, 0, sizeof sendbuf); + sendbuf.cmd = CMND_SET_DEVICE_DESCRIPTOR; + sendbuf.dd.ucSPMCRAddress = p->spmcr; + sendbuf.dd.ucRAMPZAddress = p->rampz; + sendbuf.dd.ucIDRAddress = p->idr; + u16_to_b2(sendbuf.dd.EECRAddress, p->eecr); + sendbuf.dd.ucAllowFullPageBitstream = + (p->flags & AVRPART_ALLOWFULLPAGEBITSTREAM) != 0; + sendbuf.dd.EnablePageProgramming = + (p->flags & AVRPART_ENABLEPAGEPROGRAMMING) != 0; + for (ln = lfirst(p->mem); ln; ln = lnext(ln)) { + m = ldata(ln); + if (strcmp(m->desc, "flash") == 0) { + if (m->page_size > 256) + PDATA(pgm)->flash_pagesize = 256; + else + PDATA(pgm)->flash_pagesize = m->page_size; + u32_to_b4(sendbuf.dd.ulFlashSize, m->size); + u16_to_b2(sendbuf.dd.uiFlashPageSize, m->page_size); + u16_to_b2(sendbuf.dd.uiFlashpages, m->size / m->page_size); + if (p->flags & AVRPART_HAS_DW) { + memcpy(sendbuf.dd.ucFlashInst, p->flash_instr, FLASH_INSTR_SIZE); + memcpy(sendbuf.dd.ucEepromInst, p->eeprom_instr, EEPROM_INSTR_SIZE); + } + } else if (strcmp(m->desc, "eeprom") == 0) { + sendbuf.dd.ucEepromPageSize = PDATA(pgm)->eeprom_pagesize = m->page_size; + } + } + sendbuf.dd.ucCacheType = + (p->flags & AVRPART_HAS_PDI)? 0x02 /* ATxmega */: 0x00; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_set_devdescr(): " + "Sending set device descriptor command: ", + progname); + jtagmkII_send(pgm, (unsigned char *)&sendbuf, + PDATA(pgm)->device_descriptor_length + sizeof(unsigned char)); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_set_devdescr(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_set_devdescr(): " + "bad response to set device descriptor command: %s\n", + progname, jtagmkII_get_rc(c)); + } +} + +static void jtagmkII_set_xmega_params(PROGRAMMER * pgm, AVRPART * p) +{ + int status; + unsigned char *resp, c; + LNODEID ln; + AVRMEM * m; + struct { + unsigned char cmd; + struct xmega_device_desc dd; + } sendbuf; + + memset(&sendbuf, 0, sizeof sendbuf); + sendbuf.cmd = CMND_SET_XMEGA_PARAMS; + u16_to_b2(sendbuf.dd.whatever, 0x0002); + sendbuf.dd.datalen = 47; + u16_to_b2(sendbuf.dd.nvm_base_addr, p->nvm_base); + u16_to_b2(sendbuf.dd.mcu_base_addr, p->mcu_base); + + for (ln = lfirst(p->mem); ln; ln = lnext(ln)) { + m = ldata(ln); + if (strcmp(m->desc, "flash") == 0) { + if (m->page_size > 256) + PDATA(pgm)->flash_pagesize = 256; + else + PDATA(pgm)->flash_pagesize = m->page_size; + u16_to_b2(sendbuf.dd.flash_page_size, m->page_size); + } else if (strcmp(m->desc, "eeprom") == 0) { + sendbuf.dd.eeprom_page_size = m->page_size; + u16_to_b2(sendbuf.dd.eeprom_size, m->size); + u32_to_b4(sendbuf.dd.nvm_eeprom_offset, m->offset); + } else if (strcmp(m->desc, "application") == 0) { + u32_to_b4(sendbuf.dd.app_size, m->size); + u32_to_b4(sendbuf.dd.nvm_app_offset, m->offset); + } else if (strcmp(m->desc, "boot") == 0) { + u16_to_b2(sendbuf.dd.boot_size, m->size); + u32_to_b4(sendbuf.dd.nvm_boot_offset, m->offset); + } else if (strcmp(m->desc, "fuse1") == 0) { + u32_to_b4(sendbuf.dd.nvm_fuse_offset, m->offset & ~7); + } else if (strncmp(m->desc, "lock", 4) == 0) { + u32_to_b4(sendbuf.dd.nvm_lock_offset, m->offset); + } else if (strcmp(m->desc, "usersig") == 0) { + u32_to_b4(sendbuf.dd.nvm_user_sig_offset, m->offset); + } else if (strcmp(m->desc, "prodsig") == 0) { + u32_to_b4(sendbuf.dd.nvm_prod_sig_offset, m->offset); + } else if (strcmp(m->desc, "data") == 0) { + u32_to_b4(sendbuf.dd.nvm_data_offset, m->offset); + } + } + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_set_xmega_params(): " + "Sending set Xmega params command: ", + progname); + jtagmkII_send(pgm, (unsigned char *)&sendbuf, sizeof sendbuf); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_set_xmega_params(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_set_xmega_params(): " + "bad response to set device descriptor command: %s\n", + progname, jtagmkII_get_rc(c)); + } +} + +/* + * Reset the target. + */ +static int jtagmkII_reset(PROGRAMMER * pgm, unsigned char flags) +{ + int status; + unsigned char buf[2], *resp, c; + + /* + * In debugWire mode, don't reset. Do a forced stop, and tell the + * ICE to stop any timers, too. + */ + if (pgm->flag & PGM_FL_IS_DW) { + unsigned char parm[] = { 0 }; + + (void)jtagmkII_setparm(pgm, PAR_TIMERS_RUNNING, parm); + } + + buf[0] = (pgm->flag & PGM_FL_IS_DW)? CMND_FORCED_STOP: CMND_RESET; + buf[1] = (pgm->flag & PGM_FL_IS_DW)? 1: flags; + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_reset(): Sending %s command: ", + progname, (pgm->flag & PGM_FL_IS_DW)? "stop": "reset"); + jtagmkII_send(pgm, buf, 2); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_reset(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_reset(): " + "bad response to reset command: %s\n", + progname, jtagmkII_get_rc(c)); + return -1; + } + + return 0; +} + +static int jtagmkII_program_enable_INFO(PROGRAMMER * pgm, AVRPART * p) +{ + return 0; +} + +static int jtagmkII_program_enable(PROGRAMMER * pgm) +{ + int status; + unsigned char buf[1], *resp, c; + int use_ext_reset; + + if (PDATA(pgm)->prog_enabled) + return 0; + + for (use_ext_reset = 0; use_ext_reset <= 1; use_ext_reset++) { + buf[0] = CMND_ENTER_PROGMODE; + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_program_enable(): " + "Sending enter progmode command: ", + progname); + jtagmkII_send(pgm, buf, 1); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_program_enable(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_program_enable(): " + "bad response to enter progmode command: %s\n", + progname, jtagmkII_get_rc(c)); + if (c == RSP_ILLEGAL_JTAG_ID) { + if (use_ext_reset == 0) { + unsigned char parm[] = { 1}; + avrdude_message(MSG_INFO, "%s: retrying with external reset applied\n", + progname); + + (void)jtagmkII_setparm(pgm, PAR_EXTERNAL_RESET, parm); + continue; + } + + avrdude_message(MSG_INFO, "%s: JTAGEN fuse disabled?\n", progname); + return -1; + } + } + } + + PDATA(pgm)->prog_enabled = 1; + return 0; +} + +static int jtagmkII_program_disable(PROGRAMMER * pgm) +{ + int status; + unsigned char buf[1], *resp, c; + + if (!PDATA(pgm)->prog_enabled) + return 0; + + buf[0] = CMND_LEAVE_PROGMODE; + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_program_disable(): " + "Sending leave progmode command: ", + progname); + jtagmkII_send(pgm, buf, 1); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_program_disable(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_program_disable(): " + "bad response to leave progmode command: %s\n", + progname, jtagmkII_get_rc(c)); + return -1; + } + + PDATA(pgm)->prog_enabled = 0; + (void)jtagmkII_reset(pgm, 0x01); + + return 0; +} + +static unsigned char jtagmkII_get_baud(long baud) +{ + static struct { + long baud; + unsigned char val; + } baudtab[] = { + { 2400L, PAR_BAUD_2400 }, + { 4800L, PAR_BAUD_4800 }, + { 9600L, PAR_BAUD_9600 }, + { 19200L, PAR_BAUD_19200 }, + { 38400L, PAR_BAUD_38400 }, + { 57600L, PAR_BAUD_57600 }, + { 115200L, PAR_BAUD_115200 }, + { 14400L, PAR_BAUD_14400 }, + }; + int i; + + for (i = 0; i < sizeof baudtab / sizeof baudtab[0]; i++) + if (baud == baudtab[i].baud) + return baudtab[i].val; + + return 0; +} + +/* + * initialize the AVR device and prepare it to accept commands + */ +static int jtagmkII_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + AVRMEM hfuse; + unsigned char b; + int ok; + const char *ifname; + + ok = 0; + if (pgm->flag & PGM_FL_IS_DW) { + ifname = "debugWire"; + if (p->flags & AVRPART_HAS_DW) + ok = 1; + } else if (pgm->flag & PGM_FL_IS_PDI) { + ifname = "PDI"; + if (p->flags & AVRPART_HAS_PDI) + ok = 1; + } else { + ifname = "JTAG"; + if (p->flags & AVRPART_HAS_JTAG) + ok = 1; + } + + if (!ok) { + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize(): part %s has no %s interface\n", + progname, p->desc, ifname); + return -1; + } + + if ((serdev->flags & SERDEV_FL_CANSETSPEED) && pgm->baudrate && pgm->baudrate != 19200) { + if ((b = jtagmkII_get_baud(pgm->baudrate)) == 0) { + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize(): unsupported baudrate %d\n", + progname, pgm->baudrate); + } else { + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_initialize(): " + "trying to set baudrate to %d\n", + progname, pgm->baudrate); + if (jtagmkII_setparm(pgm, PAR_BAUD_RATE, &b) == 0) + serial_setspeed(&pgm->fd, pgm->baudrate); + } + } + if ((pgm->flag & PGM_FL_IS_JTAG) && pgm->bitclock != 0.0) { + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_initialize(): " + "trying to set JTAG clock period to %.1f us\n", + progname, pgm->bitclock); + if (jtagmkII_set_sck_period(pgm, pgm->bitclock) != 0) + return -1; + } + + if ((pgm->flag & PGM_FL_IS_JTAG) && + jtagmkII_setparm(pgm, PAR_DAISY_CHAIN_INFO, PDATA(pgm)->jtagchain) < 0) { + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize(): Failed to setup JTAG chain\n", + progname); + return -1; + } + + /* + * If this is an ATxmega device in JTAG mode, change the emulator + * mode from JTAG to JTAG_XMEGA. + */ + if ((pgm->flag & PGM_FL_IS_JTAG) && + (p->flags & AVRPART_HAS_PDI)) { + if (jtagmkII_getsync(pgm, EMULATOR_MODE_JTAG_XMEGA) < 0) + return -1; + } + /* + * Must set the device descriptor before entering programming mode. + */ + if (PDATA(pgm)->fwver >= 0x700 && (p->flags & AVRPART_HAS_PDI) != 0) + jtagmkII_set_xmega_params(pgm, p); + else + jtagmkII_set_devdescr(pgm, p); + + PDATA(pgm)->boot_start = ULONG_MAX; + /* + * If this is an ATxmega device in JTAG mode, change the emulator + * mode from JTAG to JTAG_XMEGA. + */ + if ((pgm->flag & PGM_FL_IS_JTAG) && + (p->flags & AVRPART_HAS_PDI)) { + /* + * Find out where the border between application and boot area + * is. + */ + AVRMEM *bootmem = avr_locate_mem(p, "boot"); + AVRMEM *flashmem = avr_locate_mem(p, "flash"); + if (bootmem == NULL || flashmem == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize(): Cannot locate \"flash\" and \"boot\" memories in description\n", + progname); + } else { + if (PDATA(pgm)->fwver < 0x700) { + /* V7+ firmware does not need this anymore */ + unsigned char par[4]; + + u32_to_b4(par, flashmem->offset); + (void) jtagmkII_setparm(pgm, PAR_PDI_OFFSET_START, par); + u32_to_b4(par, bootmem->offset); + (void) jtagmkII_setparm(pgm, PAR_PDI_OFFSET_END, par); + } + + PDATA(pgm)->boot_start = bootmem->offset - flashmem->offset; + } + } + + free(PDATA(pgm)->flash_pagecache); + free(PDATA(pgm)->eeprom_pagecache); + if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize(): Out of memory\n", + progname); + return -1; + } + if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize(): Out of memory\n", + progname); + free(PDATA(pgm)->flash_pagecache); + return -1; + } + PDATA(pgm)->flash_pageaddr = PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + + if (PDATA(pgm)->fwver >= 0x700 && (p->flags & AVRPART_HAS_PDI)) { + /* + * Work around for + * https://savannah.nongnu.org/bugs/index.php?37942 + * + * Firmware version 7.24 (at least) on the Dragon behaves very + * strange when it gets a RESET request here. All subsequent + * responses are completely off, so the emulator becomes unusable. + * This appears to be a firmware bug (earlier versions, at least + * 7.14, didn't experience this), but by omitting the RESET for + * Xmega devices, we can work around it. + */ + } else { + if (jtagmkII_reset(pgm, 0x01) < 0) + return -1; + } + + if ((pgm->flag & PGM_FL_IS_JTAG) && !(p->flags & AVRPART_HAS_PDI)) { + strcpy(hfuse.desc, "hfuse"); + if (jtagmkII_read_byte(pgm, p, &hfuse, 1, &b) < 0) + return -1; + if ((b & OCDEN) != 0) + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize(): warning: OCDEN fuse not programmed, " + "single-byte EEPROM updates not possible\n", + progname); + } + + return 0; +} + +static void jtagmkII_disable(PROGRAMMER * pgm) +{ + + free(PDATA(pgm)->flash_pagecache); + PDATA(pgm)->flash_pagecache = NULL; + free(PDATA(pgm)->eeprom_pagecache); + PDATA(pgm)->eeprom_pagecache = NULL; + + /* + * jtagmkII_program_disable() doesn't do anything if the + * device is currently not in programming mode, so just + * call it unconditionally here. + */ + (void)jtagmkII_program_disable(pgm); +} + +static void jtagmkII_enable(PROGRAMMER * pgm) +{ + return; +} + +static int jtagmkII_parseextparms(PROGRAMMER * pgm, LISTID extparms) +{ + LNODEID ln; + const char *extended_param; + int rv = 0; + + for (ln = lfirst(extparms); ln; ln = lnext(ln)) { + extended_param = ldata(ln); + + if (strncmp(extended_param, "jtagchain=", strlen("jtagchain=")) == 0) { + unsigned int ub, ua, bb, ba; + if (sscanf(extended_param, "jtagchain=%u,%u,%u,%u", &ub, &ua, &bb, &ba) + != 4) { + avrdude_message(MSG_INFO, "%s: jtagmkII_parseextparms(): invalid JTAG chain '%s'\n", + progname, extended_param); + rv = -1; + continue; + } + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_parseextparms(): JTAG chain parsed as:\n" + "%s %u units before, %u units after, %u bits before, %u bits after\n", + progname, + progbuf, ub, ua, bb, ba); + PDATA(pgm)->jtagchain[0] = ub; + PDATA(pgm)->jtagchain[1] = ua; + PDATA(pgm)->jtagchain[2] = bb; + PDATA(pgm)->jtagchain[3] = ba; + + continue; + } + + avrdude_message(MSG_INFO, "%s: jtagmkII_parseextparms(): invalid extended parameter '%s'\n", + progname, extended_param); + rv = -1; + } + + return rv; +} + + +static int jtagmkII_open(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_open()\n", progname); + + /* + * The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon + * attaching. If the config file or command-line parameters specify + * a higher baud rate, we switch to it later on, after establishing + * the connection with the ICE. + */ + pinfo.baud = 19200; + + /* + * If the port name starts with "usb", divert the serial routines + * to the USB ones. The serial_open() function for USB overrides + * the meaning of the "baud" parameter to be the USB device ID to + * search for. + */ + if (strncmp(port, "usb", 3) == 0) { +#if defined(HAVE_LIBUSB) + serdev = &usb_serdev; + pinfo.usbinfo.vid = USB_VENDOR_ATMEL; + pinfo.usbinfo.flags = 0; + pinfo.usbinfo.pid = USB_DEVICE_JTAGICEMKII; + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; + pgm->fd.usb.eep = 0; /* no seperate EP for events */ +#else + avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); + return -1; +#endif + } + + strcpy(pgm->port, port); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + jtagmkII_drain(pgm, 0); + + if (jtagmkII_getsync(pgm, EMULATOR_MODE_JTAG) < 0) + return -1; + + return 0; +} + +static int jtagmkII_open_dw(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_open_dw()\n", progname); + + /* + * The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon + * attaching. If the config file or command-line parameters specify + * a higher baud rate, we switch to it later on, after establishing + * the connection with the ICE. + */ + pinfo.baud = 19200; + + /* + * If the port name starts with "usb", divert the serial routines + * to the USB ones. The serial_open() function for USB overrides + * the meaning of the "baud" parameter to be the USB device ID to + * search for. + */ + if (strncmp(port, "usb", 3) == 0) { +#if defined(HAVE_LIBUSB) + serdev = &usb_serdev; + pinfo.usbinfo.vid = USB_VENDOR_ATMEL; + pinfo.usbinfo.flags = 0; + pinfo.usbinfo.pid = USB_DEVICE_JTAGICEMKII; + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; + pgm->fd.usb.eep = 0; /* no seperate EP for events */ +#else + avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); + return -1; +#endif + } + + strcpy(pgm->port, port); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + jtagmkII_drain(pgm, 0); + + if (jtagmkII_getsync(pgm, EMULATOR_MODE_DEBUGWIRE) < 0) + return -1; + + return 0; +} + +static int jtagmkII_open_pdi(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_open_pdi()\n", progname); + + /* + * The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon + * attaching. If the config file or command-line parameters specify + * a higher baud rate, we switch to it later on, after establishing + * the connection with the ICE. + */ + pinfo.baud = 19200; + + /* + * If the port name starts with "usb", divert the serial routines + * to the USB ones. The serial_open() function for USB overrides + * the meaning of the "baud" parameter to be the USB device ID to + * search for. + */ + if (strncmp(port, "usb", 3) == 0) { +#if defined(HAVE_LIBUSB) + serdev = &usb_serdev; + pinfo.usbinfo.vid = USB_VENDOR_ATMEL; + pinfo.usbinfo.flags = 0; + pinfo.usbinfo.pid = USB_DEVICE_JTAGICEMKII; + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; + pgm->fd.usb.eep = 0; /* no seperate EP for events */ +#else + avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); + return -1; +#endif + } + + strcpy(pgm->port, port); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + jtagmkII_drain(pgm, 0); + + if (jtagmkII_getsync(pgm, EMULATOR_MODE_PDI) < 0) + return -1; + + return 0; +} + + +static int jtagmkII_dragon_open(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_dragon_open()\n", progname); + + /* + * The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon + * attaching. If the config file or command-line parameters specify + * a higher baud rate, we switch to it later on, after establishing + * the connection with the ICE. + */ + pinfo.baud = 19200; + + /* + * If the port name starts with "usb", divert the serial routines + * to the USB ones. The serial_open() function for USB overrides + * the meaning of the "baud" parameter to be the USB device ID to + * search for. + */ + if (strncmp(port, "usb", 3) == 0) { +#if defined(HAVE_LIBUSB) + serdev = &usb_serdev; + pinfo.usbinfo.vid = USB_VENDOR_ATMEL; + pinfo.usbinfo.flags = 0; + pinfo.usbinfo.pid = USB_DEVICE_AVRDRAGON; + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; + pgm->fd.usb.eep = 0; /* no seperate EP for events */ +#else + avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); + return -1; +#endif + } + + strcpy(pgm->port, port); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + jtagmkII_drain(pgm, 0); + + if (jtagmkII_getsync(pgm, EMULATOR_MODE_JTAG) < 0) + return -1; + + return 0; +} + + +static int jtagmkII_dragon_open_dw(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_dragon_open_dw()\n", progname); + + /* + * The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon + * attaching. If the config file or command-line parameters specify + * a higher baud rate, we switch to it later on, after establishing + * the connection with the ICE. + */ + pinfo.baud = 19200; + + /* + * If the port name starts with "usb", divert the serial routines + * to the USB ones. The serial_open() function for USB overrides + * the meaning of the "baud" parameter to be the USB device ID to + * search for. + */ + if (strncmp(port, "usb", 3) == 0) { +#if defined(HAVE_LIBUSB) + serdev = &usb_serdev; + pinfo.usbinfo.vid = USB_VENDOR_ATMEL; + pinfo.usbinfo.flags = 0; + pinfo.usbinfo.pid = USB_DEVICE_AVRDRAGON; + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; + pgm->fd.usb.eep = 0; /* no seperate EP for events */ +#else + avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); + return -1; +#endif + } + + strcpy(pgm->port, port); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + jtagmkII_drain(pgm, 0); + + if (jtagmkII_getsync(pgm, EMULATOR_MODE_DEBUGWIRE) < 0) + return -1; + + return 0; +} + + +static int jtagmkII_dragon_open_pdi(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_dragon_open_pdi()\n", progname); + + /* + * The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon + * attaching. If the config file or command-line parameters specify + * a higher baud rate, we switch to it later on, after establishing + * the connection with the ICE. + */ + pinfo.baud = 19200; + + /* + * If the port name starts with "usb", divert the serial routines + * to the USB ones. The serial_open() function for USB overrides + * the meaning of the "baud" parameter to be the USB device ID to + * search for. + */ + if (strncmp(port, "usb", 3) == 0) { +#if defined(HAVE_LIBUSB) + serdev = &usb_serdev; + pinfo.usbinfo.vid = USB_VENDOR_ATMEL; + pinfo.usbinfo.flags = 0; + pinfo.usbinfo.pid = USB_DEVICE_AVRDRAGON; + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; + pgm->fd.usb.eep = 0; /* no seperate EP for events */ +#else + avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); + return -1; +#endif + } + + strcpy(pgm->port, port); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + jtagmkII_drain(pgm, 0); + + if (jtagmkII_getsync(pgm, EMULATOR_MODE_PDI) < 0) + return -1; + + return 0; +} + + +void jtagmkII_close(PROGRAMMER * pgm) +{ + int status; + unsigned char buf[1], *resp, c; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_close()\n", progname); + + if (pgm->flag & PGM_FL_IS_PDI) { + /* When in PDI mode, restart target. */ + buf[0] = CMND_GO; + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_close(): Sending GO command: ", + progname); + jtagmkII_send(pgm, buf, 1); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_close(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + } else { + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_close(): " + "bad response to GO command: %s\n", + progname, jtagmkII_get_rc(c)); + } + } + } + + buf[0] = CMND_SIGN_OFF; + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_close(): Sending sign-off command: ", + progname); + jtagmkII_send(pgm, buf, 1); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_close(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_close(): " + "bad response to sign-off command: %s\n", + progname, jtagmkII_get_rc(c)); + } + + serial_close(&pgm->fd); + pgm->fd.ifd = -1; +} + +static int jtagmkII_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int addr) +{ + unsigned char cmd[6]; + unsigned char *resp; + int status, tries; + long otimeout = serial_recv_timeout; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_page_erase(.., %s, 0x%x)\n", + progname, m->desc, addr); + + if (!(p->flags & AVRPART_HAS_PDI)) { + avrdude_message(MSG_INFO, "%s: jtagmkII_page_erase: not an Xmega device\n", + progname); + return -1; + } + if ((pgm->flag & PGM_FL_IS_DW)) { + avrdude_message(MSG_INFO, "%s: jtagmkII_page_erase: not applicable to debugWIRE\n", + progname); + return -1; + } + + if (jtagmkII_program_enable(pgm) < 0) + return -1; + + cmd[0] = CMND_XMEGA_ERASE; + if (strcmp(m->desc, "flash") == 0) { + if (jtagmkII_memtype(pgm, p, addr) == MTYPE_FLASH) + cmd[1] = XMEGA_ERASE_APP_PAGE; + else + cmd[1] = XMEGA_ERASE_BOOT_PAGE; + } else if (strcmp(m->desc, "eeprom") == 0) { + cmd[1] = XMEGA_ERASE_EEPROM_PAGE; + } else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { + cmd[1] = XMEGA_ERASE_USERSIG; + } else if ( ( strcmp(m->desc, "boot") == 0 ) ) { + cmd[1] = XMEGA_ERASE_BOOT_PAGE; + } else { + cmd[1] = XMEGA_ERASE_APP_PAGE; + } + serial_recv_timeout = 100; + + /* + * Don't use jtagmkII_memaddr() here. While with all other + * commands, firmware 7+ doesn't require the NVM offsets being + * applied, the erase page commands make an exception, and do + * require the NVM offsets as part of the (page) address. + */ + u32_to_b4(cmd + 2, addr + m->offset); + + tries = 0; + + retry: + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_page_erase(): " + "Sending xmega erase command: ", + progname); + jtagmkII_send(pgm, cmd, sizeof cmd); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_page_erase(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + if (tries++ < 4) { + serial_recv_timeout *= 2; + goto retry; + } + avrdude_message(MSG_INFO, "%s: jtagmkII_page_erase(): fatal timeout/" + "error communicating with programmer (status %d)\n", + progname, status); + serial_recv_timeout = otimeout; + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + if (resp[0] != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_page_erase(): " + "bad response to xmega erase command: %s\n", + progname, jtagmkII_get_rc(resp[0])); + free(resp); + serial_recv_timeout = otimeout; + return -1; + } + free(resp); + + serial_recv_timeout = otimeout; + + return 0; +} + +static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int block_size; + unsigned int maxaddr = addr + n_bytes; + unsigned char *cmd; + unsigned char *resp; + int status, tries, dynamic_memtype = 0; + long otimeout = serial_recv_timeout; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_paged_write(.., %s, %d, %d)\n", + progname, m->desc, page_size, n_bytes); + + if (!(pgm->flag & PGM_FL_IS_DW) && jtagmkII_program_enable(pgm) < 0) + return -1; + + if (page_size == 0) page_size = 256; + else if (page_size > 256) page_size = 256; + + if ((cmd = malloc(page_size + 10)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_write(): Out of memory\n", + progname); + return -1; + } + + cmd[0] = CMND_WRITE_MEMORY; + if (strcmp(m->desc, "flash") == 0) { + PDATA(pgm)->flash_pageaddr = (unsigned long)-1L; + cmd[1] = jtagmkII_memtype(pgm, p, addr); + if (p->flags & AVRPART_HAS_PDI) + /* dynamically decide between flash/boot memtype */ + dynamic_memtype = 1; + } else if (strcmp(m->desc, "eeprom") == 0) { + if (pgm->flag & PGM_FL_IS_DW) { + /* + * jtagmkII_paged_write() to EEPROM attempted while in + * DW mode. Use jtagmkII_write_byte() instead. + */ + for (; addr < maxaddr; addr++) { + status = jtagmkII_write_byte(pgm, p, m, addr, m->buf[addr]); + if (status < 0) { + free(cmd); + return -1; + } + } + free(cmd); + return n_bytes; + } + cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE; + PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + } else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { + cmd[1] = MTYPE_USERSIG; + } else if ( ( strcmp(m->desc, "boot") == 0 ) ) { + cmd[1] = MTYPE_BOOT_FLASH; + } else if ( p->flags & AVRPART_HAS_PDI ) { + cmd[1] = MTYPE_FLASH; + } else { + cmd[1] = MTYPE_SPM; + } + serial_recv_timeout = 100; + for (; addr < maxaddr; addr += page_size) { + if ((maxaddr - addr) < page_size) + block_size = maxaddr - addr; + else + block_size = page_size; + avrdude_message(MSG_DEBUG, "%s: jtagmkII_paged_write(): " + "block_size at addr %d is %d\n", + progname, addr, block_size); + + if (dynamic_memtype) + cmd[1] = jtagmkII_memtype(pgm, p, addr); + + u32_to_b4(cmd + 2, page_size); + u32_to_b4(cmd + 6, jtagmkII_memaddr(pgm, p, m, addr)); + + /* + * The JTAG ICE will refuse to write anything but a full page, at + * least for the flash ROM. If a partial page has been requested, + * set the remainder to 0xff. (Maybe we should rather read back + * the existing contents instead before? Doesn't matter much, as + * bits cannot be written to 1 anyway.) + */ + memset(cmd + 10, 0xff, page_size); + memcpy(cmd + 10, m->buf + addr, block_size); + + tries = 0; + + retry: + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_paged_write(): " + "Sending write memory command: ", + progname); + jtagmkII_send(pgm, cmd, page_size + 10); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_write(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + if (tries++ < 4) { + serial_recv_timeout *= 2; + goto retry; + } + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_write(): fatal timeout/" + "error communicating with programmer (status %d)\n", + progname, status); + free(cmd); + serial_recv_timeout = otimeout; + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + if (resp[0] != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_write(): " + "bad response to write memory command: %s\n", + progname, jtagmkII_get_rc(resp[0])); + free(resp); + free(cmd); + serial_recv_timeout = otimeout; + return -1; + } + free(resp); + } + + free(cmd); + serial_recv_timeout = otimeout; + + return n_bytes; +} + +static int jtagmkII_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int block_size; + unsigned int maxaddr = addr + n_bytes; + unsigned char cmd[10]; + unsigned char *resp; + int status, tries, dynamic_memtype = 0; + long otimeout = serial_recv_timeout; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_paged_load(.., %s, %d, %d)\n", + progname, m->desc, page_size, n_bytes); + + if (!(pgm->flag & PGM_FL_IS_DW) && jtagmkII_program_enable(pgm) < 0) + return -1; + + page_size = m->readsize; + + cmd[0] = CMND_READ_MEMORY; + if (strcmp(m->desc, "flash") == 0) { + cmd[1] = jtagmkII_memtype(pgm, p, addr); + if (p->flags & AVRPART_HAS_PDI) + /* dynamically decide between flash/boot memtype */ + dynamic_memtype = 1; + } else if (strcmp(m->desc, "eeprom") == 0) { + cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE; + if (pgm->flag & PGM_FL_IS_DW) + return -1; + } else if ( ( strcmp(m->desc, "prodsig") == 0 ) ) { + cmd[1] = MTYPE_PRODSIG; + } else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { + cmd[1] = MTYPE_USERSIG; + } else if ( ( strcmp(m->desc, "boot") == 0 ) ) { + cmd[1] = MTYPE_BOOT_FLASH; + } else if ( p->flags & AVRPART_HAS_PDI ) { + cmd[1] = MTYPE_FLASH; + } else { + cmd[1] = MTYPE_SPM; + } + serial_recv_timeout = 100; + for (; addr < maxaddr; addr += page_size) { + if ((maxaddr - addr) < page_size) + block_size = maxaddr - addr; + else + block_size = page_size; + avrdude_message(MSG_DEBUG, "%s: jtagmkII_paged_load(): " + "block_size at addr %d is %d\n", + progname, addr, block_size); + + if (dynamic_memtype) + cmd[1] = jtagmkII_memtype(pgm, p, addr); + + u32_to_b4(cmd + 2, block_size); + u32_to_b4(cmd + 6, jtagmkII_memaddr(pgm, p, m, addr)); + + tries = 0; + + retry: + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_paged_load(): Sending read memory command: ", + progname); + jtagmkII_send(pgm, cmd, 10); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_load(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + if (tries++ < 4) { + serial_recv_timeout *= 2; + goto retry; + } + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_load(): fatal timeout/" + "error communicating with programmer (status %d)\n", + progname, status); + serial_recv_timeout = otimeout; + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + if (resp[0] != RSP_MEMORY) { + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_load(): " + "bad response to read memory command: %s\n", + progname, jtagmkII_get_rc(resp[0])); + free(resp); + serial_recv_timeout = otimeout; + return -1; + } + memcpy(m->buf + addr, resp + 1, status-1); + free(resp); + } + serial_recv_timeout = otimeout; + + return n_bytes; +} + +static int jtagmkII_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value) +{ + unsigned char cmd[10]; + unsigned char *resp = NULL, *cache_ptr = NULL; + int status, tries, unsupp; + unsigned long paddr = 0UL, *paddr_ptr = NULL; + unsigned int pagesize = 0; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_read_byte(.., %s, 0x%lx, ...)\n", + progname, mem->desc, addr); + + if (!(pgm->flag & PGM_FL_IS_DW) && jtagmkII_program_enable(pgm) < 0) + return -1; + + cmd[0] = CMND_READ_MEMORY; + unsupp = 0; + + addr += mem->offset; + cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_FLASH : MTYPE_FLASH_PAGE; + if (strcmp(mem->desc, "flash") == 0 || + strcmp(mem->desc, "application") == 0 || + strcmp(mem->desc, "apptable") == 0 || + strcmp(mem->desc, "boot") == 0) { + pagesize = PDATA(pgm)->flash_pagesize; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->flash_pageaddr; + cache_ptr = PDATA(pgm)->flash_pagecache; + } else if (strcmp(mem->desc, "eeprom") == 0) { + if ( (pgm->flag & PGM_FL_IS_DW) || ( p->flags & AVRPART_HAS_PDI ) ) { + /* debugWire cannot use page access for EEPROM */ + cmd[1] = MTYPE_EEPROM; + } else { + cmd[1] = MTYPE_EEPROM_PAGE; + pagesize = mem->page_size; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->eeprom_pageaddr; + cache_ptr = PDATA(pgm)->eeprom_pagecache; + } + } else if (strcmp(mem->desc, "lfuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 0; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "hfuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 1; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "efuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 2; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strncmp(mem->desc, "lock", 4) == 0) { + cmd[1] = MTYPE_LOCK_BITS; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) { + cmd[1] = MTYPE_FUSE_BITS; + } else if (strcmp(mem->desc, "usersig") == 0) { + cmd[1] = MTYPE_USERSIG; + } else if (strcmp(mem->desc, "prodsig") == 0) { + cmd[1] = MTYPE_PRODSIG; + } else if (strcmp(mem->desc, "calibration") == 0) { + cmd[1] = MTYPE_OSCCAL_BYTE; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "signature") == 0) { + cmd[1] = MTYPE_SIGN_JTAG; + + if (pgm->flag & PGM_FL_IS_DW) { + /* + * In debugWire mode, there is no accessible memory area to read + * the signature from, but the essential two bytes can be read + * as a parameter from the ICE. + */ + unsigned char parm[4]; + + switch (addr) { + case 0: + *value = 0x1E; /* Atmel vendor ID */ + break; + + case 1: + case 2: + if (jtagmkII_getparm(pgm, PAR_TARGET_SIGNATURE, parm) < 0) + return -1; + *value = parm[2 - addr]; + break; + + default: + avrdude_message(MSG_INFO, "%s: illegal address %lu for signature memory\n", + progname, addr); + return -1; + } + return 0; + } + + } + + /* + * If the respective memory area is not supported under debugWire, + * leave here. + */ + if (unsupp) { + *value = 42; + return -1; + } + + /* + * To improve the read speed, we used paged reads for flash and + * EEPROM, and cache the results in a page cache. + * + * Page cache validation is based on "{flash,eeprom}_pageaddr" + * (holding the base address of the most recent cache fill + * operation). This variable is set to (unsigned long)-1L when the + * cache needs to be invalidated. + */ + if (pagesize && paddr == *paddr_ptr) { + *value = cache_ptr[addr & (pagesize - 1)]; + return 0; + } + + if (pagesize) { + u32_to_b4(cmd + 2, pagesize); + u32_to_b4(cmd + 6, paddr); + } else { + u32_to_b4(cmd + 2, 1); + u32_to_b4(cmd + 6, addr); + } + + tries = 0; + retry: + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_read_byte(): Sending read memory command: ", + progname); + jtagmkII_send(pgm, cmd, 10); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_read_byte(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + if (tries++ < 3) + goto retry; + avrdude_message(MSG_INFO, "%s: jtagmkII_read_byte(): " + "fatal timeout/error communicating with programmer (status %d)\n", + progname, status); + if (status < 0) + resp = 0; + goto fail; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + if (resp[0] != RSP_MEMORY) { + avrdude_message(MSG_INFO, "%s: jtagmkII_read_byte(): " + "bad response to read memory command: %s\n", + progname, jtagmkII_get_rc(resp[0])); + goto fail; + } + + if (pagesize) { + *paddr_ptr = paddr; + memcpy(cache_ptr, resp + 1, pagesize); + *value = cache_ptr[addr & (pagesize - 1)]; + } else + *value = resp[1]; + + free(resp); + return 0; + +fail: + free(resp); + return -1; +} + +static int jtagmkII_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + unsigned char cmd[12]; + unsigned char *resp = NULL, writedata, writedata2 = 0xFF; + int status, tries, need_progmode = 1, unsupp = 0, writesize = 1; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_write_byte(.., %s, 0x%lx, ...)\n", + progname, mem->desc, addr); + + addr += mem->offset; + + writedata = data; + cmd[0] = CMND_WRITE_MEMORY; + cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_FLASH : MTYPE_SPM; + if (strcmp(mem->desc, "flash") == 0) { + if ((addr & 1) == 1) { + /* odd address = high byte */ + writedata = 0xFF; /* don't modify the low byte */ + writedata2 = data; + addr &= ~1L; + } + writesize = 2; + need_progmode = 0; + PDATA(pgm)->flash_pageaddr = (unsigned long)-1L; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "eeprom") == 0) { + cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM_XMEGA: MTYPE_EEPROM; + need_progmode = 0; + PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + } else if (strcmp(mem->desc, "lfuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 0; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "hfuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 1; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "efuse") == 0) { + cmd[1] = MTYPE_FUSE_BITS; + addr = 2; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) { + cmd[1] = MTYPE_FUSE_BITS; + } else if (strcmp(mem->desc, "usersig") == 0) { + cmd[1] = MTYPE_USERSIG; + } else if (strcmp(mem->desc, "prodsig") == 0) { + cmd[1] = MTYPE_PRODSIG; + } else if (strncmp(mem->desc, "lock", 4) == 0) { + cmd[1] = MTYPE_LOCK_BITS; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "calibration") == 0) { + cmd[1] = MTYPE_OSCCAL_BYTE; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } else if (strcmp(mem->desc, "signature") == 0) { + cmd[1] = MTYPE_SIGN_JTAG; + if (pgm->flag & PGM_FL_IS_DW) + unsupp = 1; + } + + if (unsupp) + return -1; + + if (need_progmode) { + if (jtagmkII_program_enable(pgm) < 0) + return -1; + } else { + if (jtagmkII_program_disable(pgm) < 0) + return -1; + } + + u32_to_b4(cmd + 2, writesize); + u32_to_b4(cmd + 6, addr); + cmd[10] = writedata; + cmd[11] = writedata2; + + tries = 0; + retry: + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_write_byte(): Sending write memory command: ", + progname); + jtagmkII_send(pgm, cmd, 10 + writesize); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_write_byte(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + if (tries++ < 3) + goto retry; + avrdude_message(MSG_INFO, "%s: jtagmkII_write_byte(): " + "fatal timeout/error communicating with programmer (status %d)\n", + progname, status); + goto fail; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + if (resp[0] != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_write_byte(): " + "bad response to write memory command: %s\n", + progname, jtagmkII_get_rc(resp[0])); + goto fail; + } + + free(resp); + return 0; + +fail: + free(resp); + return -1; +} + + +/* + * Set the JTAG clock. The actual frequency is quite a bit of + * guesswork, based on the values claimed by AVR Studio. Inside the + * JTAG ICE, the value is the delay count of a delay loop between the + * JTAG clock edges. A count of 0 bypasses the delay loop. + * + * As the STK500 expresses it as a period length (and we actualy do + * program a period length as well), we rather call it by that name. + */ +static int jtagmkII_set_sck_period(PROGRAMMER * pgm, double v) +{ + unsigned char dur; + + v = 1 / v; /* convert to frequency */ + if (v >= 6.4e6) + dur = 0; + else if (v >= 2.8e6) + dur = 1; + else if (v >= 20.9e3) + dur = (unsigned char)(5.35e6 / v); + else + dur = 255; + + return jtagmkII_setparm(pgm, PAR_OCD_JTAG_CLK, &dur); +} + + +/* + * Read an emulator parameter. As the maximal parameter length is 4 + * bytes by now, we always copy out 4 bytes to *value, so the caller + * must have allocated sufficient space. + */ +int jtagmkII_getparm(PROGRAMMER * pgm, unsigned char parm, + unsigned char * value) +{ + int status; + unsigned char buf[2], *resp, c; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_getparm()\n", progname); + + buf[0] = CMND_GET_PARAMETER; + buf[1] = parm; + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_getparm(): " + "Sending get parameter command (parm 0x%02x): ", + progname, parm); + jtagmkII_send(pgm, buf, 2); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_getparm(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + if (c != RSP_PARAMETER) { + avrdude_message(MSG_INFO, "%s: jtagmkII_getparm(): " + "bad response to get parameter command: %s\n", + progname, jtagmkII_get_rc(c)); + free(resp); + return -1; + } + + memcpy(value, resp + 1, 4); + free(resp); + + return 0; +} + +/* + * Write an emulator parameter. + */ +static int jtagmkII_setparm(PROGRAMMER * pgm, unsigned char parm, + unsigned char * value) +{ + int status; + /* + * As the maximal parameter length is 4 bytes, we use a fixed-length + * buffer, as opposed to malloc()ing it. + */ + unsigned char buf[2 + 4], *resp, c; + size_t size; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_setparm()\n", progname); + + switch (parm) { + case PAR_HW_VERSION: size = 2; break; + case PAR_FW_VERSION: size = 4; break; + case PAR_EMULATOR_MODE: size = 1; break; + case PAR_BAUD_RATE: size = 1; break; + case PAR_OCD_VTARGET: size = 2; break; + case PAR_OCD_JTAG_CLK: size = 1; break; + case PAR_TIMERS_RUNNING: size = 1; break; + case PAR_EXTERNAL_RESET: size = 1; break; + case PAR_DAISY_CHAIN_INFO: size = 4; break; + case PAR_PDI_OFFSET_START: + case PAR_PDI_OFFSET_END: size = 4; break; + default: + avrdude_message(MSG_INFO, "%s: jtagmkII_setparm(): unknown parameter 0x%02x\n", + progname, parm); + return -1; + } + + buf[0] = CMND_SET_PARAMETER; + buf[1] = parm; + memcpy(buf + 2, value, size); + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_setparm(): " + "Sending set parameter command (parm 0x%02x, %u bytes): ", + progname, parm, (unsigned)size); + jtagmkII_send(pgm, buf, size + 2); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_setparm(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return -1; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_setparm(): " + "bad response to set parameter command: %s\n", + progname, jtagmkII_get_rc(c)); + return -1; + } + + return 0; +} + + +static void jtagmkII_display(PROGRAMMER * pgm, const char * p) +{ + unsigned char hw[4], fw[4]; + + if (jtagmkII_getparm(pgm, PAR_HW_VERSION, hw) < 0 || + jtagmkII_getparm(pgm, PAR_FW_VERSION, fw) < 0) + return; + + avrdude_message(MSG_INFO, "%sM_MCU hardware version: %d\n", p, hw[0]); + avrdude_message(MSG_INFO, "%sM_MCU firmware version: %d.%02d\n", p, fw[1], fw[0]); + avrdude_message(MSG_INFO, "%sS_MCU hardware version: %d\n", p, hw[1]); + avrdude_message(MSG_INFO, "%sS_MCU firmware version: %d.%02d\n", p, fw[3], fw[2]); + avrdude_message(MSG_INFO, "%sSerial number: %02x:%02x:%02x:%02x:%02x:%02x\n", + p, PDATA(pgm)->serno[0], PDATA(pgm)->serno[1], PDATA(pgm)->serno[2], PDATA(pgm)->serno[3], PDATA(pgm)->serno[4], PDATA(pgm)->serno[5]); + + jtagmkII_print_parms1(pgm, p); + + return; +} + + +static void jtagmkII_print_parms1(PROGRAMMER * pgm, const char * p) +{ + unsigned char vtarget[4], jtag_clock[4]; + char clkbuf[20]; + double clk; + + if (jtagmkII_getparm(pgm, PAR_OCD_VTARGET, vtarget) < 0) + return; + + avrdude_message(MSG_INFO, "%sVtarget : %.1f V\n", p, + b2_to_u16(vtarget) / 1000.0); + + if ((pgm->flag & PGM_FL_IS_JTAG)) { + if (jtagmkII_getparm(pgm, PAR_OCD_JTAG_CLK, jtag_clock) < 0) + return; + + if (jtag_clock[0] == 0) { + strcpy(clkbuf, "6.4 MHz"); + clk = 6.4e6; + } else if (jtag_clock[0] == 1) { + strcpy(clkbuf, "2.8 MHz"); + clk = 2.8e6; + } else if (jtag_clock[0] <= 5) { + sprintf(clkbuf, "%.1f MHz", 5.35 / (double)jtag_clock[0]); + clk = 5.35e6 / (double)jtag_clock[0]; + } else { + sprintf(clkbuf, "%.1f kHz", 5.35e3 / (double)jtag_clock[0]); + clk = 5.35e6 / (double)jtag_clock[0]; + + avrdude_message(MSG_INFO, "%sJTAG clock : %s (%.1f us)\n", p, clkbuf, + 1.0e6 / clk); + } + } + + return; +} + +static void jtagmkII_print_parms(PROGRAMMER * pgm) +{ + jtagmkII_print_parms1(pgm, ""); +} + +static unsigned char jtagmkII_memtype(PROGRAMMER * pgm, AVRPART * p, unsigned long addr) +{ + if ( p->flags & AVRPART_HAS_PDI ) { + if (addr >= PDATA(pgm)->boot_start) + return MTYPE_BOOT_FLASH; + else + return MTYPE_FLASH; + } else { + return MTYPE_FLASH_PAGE; + } +} + +static unsigned int jtagmkII_memaddr(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr) +{ + /* + * Xmega devices handled by V7+ firmware don't want to be told their + * m->offset within the write memory command. + */ + if (PDATA(pgm)->fwver >= 0x700 && (p->flags & AVRPART_HAS_PDI) != 0) { + if (addr >= PDATA(pgm)->boot_start) + /* + * all memories but "flash" are smaller than boot_start anyway, so + * no need for an extra check we are operating on "flash" + */ + return addr - PDATA(pgm)->boot_start; + else + /* normal flash, or anything else */ + return addr; + } + /* + * Old firmware, or non-Xmega device. Non-Xmega (and non-AVR32) + * devices always have an m->offset of 0, so we don't have to + * distinguish them here. + */ + return addr + m->offset; +} + + +#ifdef __OBJC__ +#pragma mark - +#endif + +static int jtagmkII_avr32_reset(PROGRAMMER * pgm, unsigned char val, + unsigned char ret1, unsigned char ret2) +{ + int status; + unsigned char buf[3], *resp; + + avrdude_message(MSG_NOTICE, "%s: jtagmkII_avr32_reset(%2.2x)\n", + progname, val); + + buf[0] = CMND_GET_IR; + buf[1] = 0x0C; + status = jtagmkII_send(pgm, buf, 2); + if(status < 0) return -1; + + status = jtagmkII_recv(pgm, &resp); + if (status != 2 || resp[0] != 0x87 || resp[1] != ret1) { + avrdude_message(MSG_NOTICE, "%s: jtagmkII_avr32_reset(): " + "Get_IR, expecting %2.2x but got %2.2x\n", + progname, ret1, resp[1]); + + //return -1; + } + + buf[0] = CMND_GET_xxx; + buf[1] = 5; + buf[2] = val; + status = jtagmkII_send(pgm, buf, 3); + if(status < 0) return -1; + + status = jtagmkII_recv(pgm, &resp); + if (status != 2 || resp[0] != 0x87 || resp[1] != ret2) { + avrdude_message(MSG_NOTICE, "%s: jtagmkII_avr32_reset(): " + "Get_XXX, expecting %2.2x but got %2.2x\n", + progname, ret2, resp[1]); + //return -1; + } + + return 0; +} + +// At init: AVR32_RESET_READ_IR | AVR32_RESET_READ_READ_CHIPINFO +static int jtagmkII_reset32(PROGRAMMER * pgm, unsigned short flags) +{ + int status, j, lineno; + unsigned char *resp, buf[3]; + unsigned long val=0; + + avrdude_message(MSG_NOTICE, "%s: jtagmkII_reset32(%2.2x)\n", + progname, flags); + + status = -1; + + // Happens at the start of a programming operation + if(flags & AVR32_RESET_READ) { + buf[0] = CMND_GET_IR; + buf[1] = 0x11; + status = jtagmkII_send(pgm, buf, 2); + if(status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_recv(pgm, &resp); + if (status != 2 || resp[0] != 0x87 || resp[1] != 01) + {lineno = __LINE__; goto eRR;}; + } + + if(flags & (AVR32_RESET_WRITE | AVR32_SET4RUNNING)) { + // AVR_RESET(0x1F) + status = jtagmkII_avr32_reset(pgm, 0x1F, 0x01, 0x00); + if(status < 0) {lineno = __LINE__; goto eRR;} + // AVR_RESET(0x07) + status = jtagmkII_avr32_reset(pgm, 0x07, 0x11, 0x1F); + if(status < 0) {lineno = __LINE__; goto eRR;} + } + + //if(flags & AVR32_RESET_COMMON) + { + val = jtagmkII_read_SABaddr(pgm, AVR32_DS, 0x01); + if(val != 0) {lineno = __LINE__; goto eRR;} + val = jtagmkII_read_SABaddr(pgm, AVR32_DC, 0x01); + if(val != 0) {lineno = __LINE__; goto eRR;} + } + + if(flags & (AVR32_RESET_READ | AVR32_RESET_CHIP_ERASE)) { + status = jtagmkII_write_SABaddr(pgm, AVR32_DC, 0x01, + AVR32_DC_DBE | AVR32_DC_DBR); + if(status < 0) return -1; + } + + if(flags & (AVR32_RESET_WRITE | AVR32_SET4RUNNING)) { + status = jtagmkII_write_SABaddr(pgm, AVR32_DC, 0x01, + AVR32_DC_ABORT | AVR32_DC_RESET | AVR32_DC_DBE | AVR32_DC_DBR); + if(status < 0) return -1; + for(j=0; j<21; ++j) { + val = jtagmkII_read_SABaddr(pgm, AVR32_DS, 0x01); + } + if(val != 0x04000000) {lineno = __LINE__; goto eRR;} + + // AVR_RESET(0x00) + status = jtagmkII_avr32_reset(pgm, 0x00, 0x01, 0x07); + if(status < 0) {lineno = __LINE__; goto eRR;} + } +// if(flags & (AVR32_RESET_READ | AVR32_RESET_WRITE)) + { + for(j=0; j<2; ++j) { + val = jtagmkII_read_SABaddr(pgm, AVR32_DS, 0x01); + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + if((val&0x05000020) != 0x05000020) {lineno = __LINE__; goto eRR;} + } + } + + //if(flags & (AVR32_RESET_READ | AVR32_RESET_WRITE | AVR32_RESET_CHIP_ERASE)) + { + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe7b00044); // mtdr 272, R0 + if(status < 0) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCSR, 0x01); + if(val != 0x00000001) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCCPU, 0x01); + if(val != 0x00000000) {lineno = __LINE__; goto eRR;} + } + + // Read chip configuration - common for all + if(flags & (AVR32_RESET_READ | AVR32_RESET_WRITE | AVR32_RESET_CHIP_ERASE)) { + for(j=0; j<2; ++j) { + val = jtagmkII_read_SABaddr(pgm, AVR32_DS, 0x01); + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + if((val&0x05000020) != 0x05000020) {lineno = __LINE__; goto eRR;} + } + + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe7b00044); // mtdr 272, R0 + if(status < 0) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCSR, 0x01); + if(val != 0x00000001) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCCPU, 0x01); + if(val != 0x00000000) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe1b00040); // mfsr R0, 256 + if(status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe7b00044); // mtdr 272, R0 + if(status < 0) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCSR, 0x01); + if(val != 0x00000001) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCCPU, 0x01); + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DCEMU, 0x01, 0x00000000); + if(status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe5b00045); // mtdr R0, 276 + if(status < 0) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DS, 0x01); + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + if((val&0x05000020) != 0x05000020) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe7b00044); // mtdr 272, R0 + if(status < 0) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCSR, 0x01); + if(val != 0x00000001) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCCPU, 0x01); + if(val != 0x00000000) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe1b00041); // mfsr R0, 260 + if(status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe7b00044); // mtdr 272, R0 + if(status < 0) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCSR, 0x01); + if(val != 0x00000001) {lineno = __LINE__; goto eRR;} + val = jtagmkII_read_SABaddr(pgm, AVR32_DCCPU, 0x01); + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DCEMU, 0x01, 0x00000000); + if(status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe5b00045); // mtdr R0, 276 + if(status < 0) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, 0x00000010, 0x06); // need to recheck who does this... + if(val != 0x00000000) {lineno = __LINE__; goto eRR;} + } + + if(flags & AVR32_RESET_CHIP_ERASE) { + status = jtagmkII_avr32_reset(pgm, 0x1f, 0x01, 0x00); + if(status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_avr32_reset(pgm, 0x01, 0x11, 0x1f); + if(status < 0) {lineno = __LINE__; goto eRR;} + } + + if(flags & AVR32_SET4RUNNING) { + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe1b00014); // mfsr R0, 80 + if(status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe7b00044); // mtdr 272, R0 + if(status < 0) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCSR, 0x01); + if(val != 0x00000001) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DCCPU, 0x01); + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DCEMU, 0x01, 0x00000000); + if(status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xe5b00045); // mfdr R0, 276 + if(status < 0) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, AVR32_DS, 0x01); + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + if((val&0x05000020) != 0x05000020) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, AVR32_DINST, 0x01, 0xd623d703); // retd + if(status < 0) {lineno = __LINE__; goto eRR;} + } + + return 0; + + eRR: + avrdude_message(MSG_INFO, "%s: jtagmkII_reset32(): " + "failed at line %d (status=%x val=%lx)\n", + progname, lineno, status, val); + return -1; +} + +static int jtagmkII_smc_init32(PROGRAMMER * pgm) +{ + int status, lineno; + unsigned long val; + + // HMATRIX 0xFFFF1000 + status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x04000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x04000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x04000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x04000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x04000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x08000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x08000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x08000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x08000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x08000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x10000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x10000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x10000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x10000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x10000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x00020000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x00020000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x00020000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x00020000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x00020000); + if (status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x02000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x02000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x02000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x02000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x02000000); + if (status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_write_SABaddr(pgm, 0xfffe1c00, 0x05, 0x00010001); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xfffe1c04, 0x05, 0x05070a0b); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xfffe1c08, 0x05, 0x000b000c); + if (status < 0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_write_SABaddr(pgm, 0xfffe1c0c, 0x05, 0x00031103); + if (status < 0) {lineno = __LINE__; goto eRR;} + + // switchToClockSource + val = jtagmkII_read_SABaddr(pgm, 0xffff0c28, 0x05); + if (val != 0x00000000) {lineno = __LINE__; goto eRR;} // OSC 0 + status = jtagmkII_write_SABaddr(pgm, 0xffff0c28, 0x05, 0x0000607); + if (status < 0) {lineno = __LINE__; goto eRR;} + val = jtagmkII_read_SABaddr(pgm, 0xffff0c00, 0x05); + if (val != 0x00000000) {lineno = __LINE__; goto eRR;} // PLL 0 + status = jtagmkII_write_SABaddr(pgm, 0xffff0c00, 0x05, 0x0000004); + if (status < 0) {lineno = __LINE__; goto eRR;} // Power Manager + status = jtagmkII_write_SABaddr(pgm, 0xffff0c00, 0x05, 0x0000005); + if (status < 0) {lineno = __LINE__; goto eRR;} + + usleep(1000000); + + val = jtagmkII_read_SABaddr(pgm, 0xfffe1408, 0x05); + if (val != 0x0000a001) {lineno = __LINE__; goto eRR;} // PLL 0 + + // need a small delay to let clock stabliize + usleep(50*1000); + + return 0; + + eRR: + avrdude_message(MSG_INFO, "%s: jtagmkII_smc_init32(): " + "failed at line %d\n", + progname, lineno); + return -1; +} + + +/* + * initialize the AVR device and prepare it to accept commands + */ +static int jtagmkII_initialize32(PROGRAMMER * pgm, AVRPART * p) +{ + int status, j; + unsigned char buf[6], *resp; + + if (jtagmkII_setparm(pgm, PAR_DAISY_CHAIN_INFO, PDATA(pgm)->jtagchain) < 0) { + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize(): Failed to setup JTAG chain\n", + progname); + return -1; + } + + free(PDATA(pgm)->flash_pagecache); + free(PDATA(pgm)->eeprom_pagecache); + if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize(): Out of memory\n", + progname); + return -1; + } + if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize32(): Out of memory\n", + progname); + free(PDATA(pgm)->flash_pagecache); + return -1; + } + PDATA(pgm)->flash_pageaddr = PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + + for(j=0; j<2; ++j) { + buf[0] = CMND_GET_IR; + buf[1] = 0x1; + if(jtagmkII_send(pgm, buf, 2) < 0) + return -1; + status = jtagmkII_recv(pgm, &resp); + if(status <= 0 || resp[0] != 0x87) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize32(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return -1; + } + free(resp); + + memset(buf, 0, sizeof(buf)); + buf[0] = CMND_GET_xxx; + buf[1] = 0x20; + if(jtagmkII_send(pgm, buf, 6) < 0) + return -1; + status = jtagmkII_recv(pgm, &resp); + if(status <= 0 || resp[0] != 0x87) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_initialize32(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return -1; + } + + if (status != 5 || + resp[2] != p->signature[0] || + resp[3] != p->signature[1] || + resp[4] != p->signature[2]) { + avrdude_message(MSG_INFO, "%s: Expected signature for %s is %02X %02X %02X\n", + progname, p->desc, + p->signature[0], p->signature[1], p->signature[2]); + if (!ovsigck) { + avrdude_message(MSG_INFO, "%sDouble check chip, " + "or use -F to override this check.\n", + progbuf); + return -1; + } + } + free(resp); + } + + return 0; +} + +static int jtagmkII_chip_erase32(PROGRAMMER * pgm, AVRPART * p) +{ + int status=0, loops; + unsigned char *resp, buf[3], x, ret[4], *retP; + unsigned long val=0; + unsigned int lineno; + + avrdude_message(MSG_NOTICE, "%s: jtagmkII_chip_erase32()\n", + progname); + + status = jtagmkII_reset32(pgm, AVR32_RESET_CHIP_ERASE); + if(status != 0) {lineno = __LINE__; goto eRR;} + + // sequence of IR transitions + ret[0] = 0x01; + ret[1] = 0x05; + ret[2] = 0x01; + ret[3] = 0x00; + + retP = ret; + for(loops=0; loops<1000; ++loops) { + buf[0] = CMND_GET_IR; + buf[1] = 0x0F; + status = jtagmkII_send(pgm, buf, 2); + if(status < 0) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_recv(pgm, &resp); + if (status != 2 || resp[0] != 0x87) { + {lineno = __LINE__; goto eRR;} + } + x = resp[1]; + free(resp); + if(x == *retP) ++retP; + if(*retP == 0x00) break; + } + if(loops == 1000) {lineno = __LINE__; goto eRR;} + + status = jtagmkII_avr32_reset(pgm, 0x00, 0x01, 0x01); + if(status < 0) {lineno = __LINE__; goto eRR;} + + val = jtagmkII_read_SABaddr(pgm, 0x00000010, 0x06); + if(val != 0x00000000) {lineno = __LINE__; goto eRR;} + + // AVR32 "special" + buf[0] = CMND_SET_PARAMETER; + buf[1] = 0x03; + buf[2] = 0x02; + jtagmkII_send(pgm, buf, 3); + status = jtagmkII_recv(pgm, &resp); + if(status < 0 || resp[0] != RSP_OK) {lineno = __LINE__; goto eRR;} + free(resp); + + return 0; + + eRR: + avrdude_message(MSG_INFO, "%s: jtagmkII_reset32(): " + "failed at line %d (status=%x val=%lx)\n", + progname, lineno, status, val); + return -1; +} + +static unsigned long jtagmkII_read_SABaddr(PROGRAMMER * pgm, unsigned long addr, + unsigned int prefix) +{ + unsigned char buf[6], *resp; + int status; + unsigned long val; + unsigned long otimeout = serial_recv_timeout; + + serial_recv_timeout = 256; + + buf[0] = CMND_READ_SAB; + buf[1] = prefix; + u32_to_b4r(&buf[2], addr); + + if(jtagmkII_send(pgm, buf, 6) < 0) + return ERROR_SAB; + + status = jtagmkII_recv(pgm, &resp); + if(status <= 0 || resp[0] != 0x87) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_read_SABaddr(): " + "timeout/error communicating with programmer (status %d) resp=%x\n", + progname, status, resp[0]); + serial_recv_timeout = otimeout; + + if(status > 0) { + int i; + avrdude_message(MSG_INFO, "Cmd: "); + for(i=0; i<6; ++i) avrdude_message(MSG_INFO, "%2.2x ", buf[i]); + avrdude_message(MSG_INFO, "\n"); + avrdude_message(MSG_INFO, "Data: "); + for(i=0; i= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_read_SABaddr(): " + "wrong number of bytes (status %d)\n", + progname, status); + serial_recv_timeout = otimeout; + return ERROR_SAB; + } + + val = b4_to_u32r(&resp[1]); + free(resp); + + if (verbose) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_read_SABaddr(): " + "OCD Register %lx -> %4.4lx\n", + progname, addr, val); + } + serial_recv_timeout = otimeout; + return val; +} + +static int jtagmkII_write_SABaddr(PROGRAMMER * pgm, unsigned long addr, + unsigned int prefix, unsigned long val) +{ + unsigned char buf[10], *resp; + int status; + + buf[0] = CMND_WRITE_SAB; + buf[1] = prefix; + u32_to_b4r(&buf[2], addr); + u32_to_b4r(&buf[6], val); + + if(jtagmkII_send(pgm, buf, 10) < 0) + return -1; + + status = jtagmkII_recv(pgm, &resp); + if(status <= 0 || resp[0] != RSP_OK) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_write_SABaddr(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return -1; + } + + + if (verbose) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_write_SABaddr(): " + "OCD Register %lx -> %4.4lx\n", + progname, addr, val); + } + return 0; +} + +static int jtagmkII_open32(PROGRAMMER * pgm, char * port) +{ + int status; + unsigned char buf[6], *resp; + union pinfo pinfo; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_open32()\n", progname); + + /* + * The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon + * attaching. If the config file or command-line parameters specify + * a higher baud rate, we switch to it later on, after establishing + * the connection with the ICE. + */ + pinfo.baud = 19200; + + /* + * If the port name starts with "usb", divert the serial routines + * to the USB ones. The serial_open() function for USB overrides + * the meaning of the "baud" parameter to be the USB device ID to + * search for. + */ + if (strncmp(port, "usb", 3) == 0) { +#if defined(HAVE_LIBUSB) + serdev = &usb_serdev; + pinfo.usbinfo.vid = USB_VENDOR_ATMEL; + pinfo.usbinfo.flags = 0; + pinfo.usbinfo.pid = USB_DEVICE_JTAGICEMKII; + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; + pgm->fd.usb.eep = 0; /* no seperate EP for events */ +#else + avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); + return -1; +#endif + } + + strcpy(pgm->port, port); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + jtagmkII_drain(pgm, 0); + + status = jtagmkII_getsync(pgm, -1); + if(status < 0) return -1; + + // AVR32 "special" + buf[0] = CMND_SET_PARAMETER; + buf[1] = 0x2D; + buf[2] = 0x03; + jtagmkII_send(pgm, buf, 3); + status = jtagmkII_recv(pgm, &resp); + if(status < 0 || resp[0] != RSP_OK) + return -1; + free(resp); + + buf[1] = 0x03; + buf[2] = 0x02; + jtagmkII_send(pgm, buf, 3); + status = jtagmkII_recv(pgm, &resp); + if(status < 0 || resp[0] != RSP_OK) + return -1; + free(resp); + + buf[1] = 0x03; + buf[2] = 0x04; + jtagmkII_send(pgm, buf, 3); + status = jtagmkII_recv(pgm, &resp); + if(status < 0 || resp[0] != RSP_OK) + return -1; + free(resp); + + return 0; +} + +static void jtagmkII_close32(PROGRAMMER * pgm) +{ + int status, lineno; + unsigned char *resp, buf[3], c; + unsigned long val=0; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_close32()\n", progname); + + // AVR32 "special" + buf[0] = CMND_SET_PARAMETER; + buf[1] = 0x03; + buf[2] = 0x02; + jtagmkII_send(pgm, buf, 3); + status = jtagmkII_recv(pgm, &resp); + if(status < 0 || resp[0] != RSP_OK) {lineno = __LINE__; goto eRR;} + free(resp); + + buf[0] = CMND_SIGN_OFF; + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_close(): Sending sign-off command: ", + progname); + jtagmkII_send(pgm, buf, 1); + + status = jtagmkII_recv(pgm, &resp); + if (status <= 0) { + if (verbose >= 2) + putc('\n', stderr); + avrdude_message(MSG_INFO, "%s: jtagmkII_close(): " + "timeout/error communicating with programmer (status %d)\n", + progname, status); + return; + } + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + c = resp[0]; + free(resp); + if (c != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_close(): " + "bad response to sign-off command: %s\n", + progname, jtagmkII_get_rc(c)); + } + + ret: + serial_close(&pgm->fd); + pgm->fd.ifd = -1; + return; + + eRR: + avrdude_message(MSG_INFO, "%s: jtagmkII_reset32(): " + "failed at line %d (status=%x val=%lx)\n", + progname, lineno, status, val); + goto ret; +} + +static int jtagmkII_paged_load32(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int block_size; + unsigned int maxaddr = addr + n_bytes; + unsigned char cmd[7]; + unsigned char *resp; + int lineno, status; + unsigned long val=0; + long otimeout = serial_recv_timeout; + + avrdude_message(MSG_NOTICE2, "%s: jtagmkII_paged_load32(.., %s, %d, %d)\n", + progname, m->desc, page_size, n_bytes); + + serial_recv_timeout = 256; + + if(!(p->flags & AVRPART_WRITE)) { + status = jtagmkII_reset32(pgm, AVR32_RESET_READ); + if(status != 0) {lineno = __LINE__; goto eRR;} + } + + // Init SMC and set clocks + if(!(p->flags & AVRPART_INIT_SMC)) { + status = jtagmkII_smc_init32(pgm); + if(status != 0) {lineno = __LINE__; goto eRR;} // PLL 0 + p->flags |= AVRPART_INIT_SMC; + } + + // Init SMC and set clocks + if(!(p->flags & AVRPART_INIT_SMC)) { + status = jtagmkII_smc_init32(pgm); + if(status != 0) {lineno = __LINE__; goto eRR;} // PLL 0 + p->flags |= AVRPART_INIT_SMC; + } + + //avrdude_message(MSG_INFO, "\n pageSize=%d bytes=%d pages=%d m->offset=0x%x pgm->page_size %d\n", + // page_size, n_bytes, pages, m->offset, pgm->page_size); + + cmd[0] = CMND_READ_MEMORY32; + cmd[1] = 0x40; + cmd[2] = 0x05; + + for (; addr < maxaddr; addr += block_size) { + block_size = ((maxaddr-addr) < pgm->page_size) ? (maxaddr - addr) : pgm->page_size; + avrdude_message(MSG_DEBUG, "%s: jtagmkII_paged_load32(): " + "block_size at addr %d is %d\n", + progname, addr, block_size); + + u32_to_b4r(cmd + 3, m->offset + addr); + + status = jtagmkII_send(pgm, cmd, 7); + if(status<0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_recv(pgm, &resp); + if(status<0) {lineno = __LINE__; goto eRR;} + + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + if (resp[0] != 0x87) { + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_load32(): " + "bad response to write memory command: %s\n", + progname, jtagmkII_get_rc(resp[0])); + free(resp); + return -1; + } + memcpy(m->buf + addr, resp + 1, block_size); + free(resp); + + } + + serial_recv_timeout = otimeout; + + status = jtagmkII_reset32(pgm, AVR32_SET4RUNNING); + if(status < 0) {lineno = __LINE__; goto eRR;} + + return addr; + + eRR: + serial_recv_timeout = otimeout; + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_load32(): " + "failed at line %d (status=%x val=%lx)\n", + progname, lineno, status, val); + return -1; +} + +static int jtagmkII_paged_write32(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int block_size; + unsigned char *cmd=NULL; + unsigned char *resp; + int lineno, status, pages, sPageNum, pageNum, blocks; + unsigned long val=0; + unsigned long otimeout = serial_recv_timeout; + unsigned int maxaddr = addr + n_bytes; + + serial_recv_timeout = 256; + + if(n_bytes == 0) return -1; + + status = jtagmkII_reset32(pgm, AVR32_RESET_WRITE); + if(status != 0) {lineno = __LINE__; goto eRR;} + p->flags |= AVRPART_WRITE; + + pages = (n_bytes - addr - 1)/page_size + 1; + sPageNum = addr/page_size; + //avrdude_message(MSG_INFO, "\n pageSize=%d bytes=%d pages=%d m->offset=0x%x pgm->page_size %d\n", + // page_size, n_bytes, pages, m->offset, pgm->page_size); + + // Before any errors can happen + if ((cmd = malloc(pgm->page_size + 10)) == NULL) { + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_write32(): Out of memory\n", progname); + return -1; + } + + // Init SMC and set clocks + if(!(p->flags & AVRPART_INIT_SMC)) { + status = jtagmkII_smc_init32(pgm); + if(status != 0) {lineno = __LINE__; goto eRR;} // PLL 0 + p->flags |= AVRPART_INIT_SMC; + } + + // First unlock the pages + for(pageNum=sPageNum; pageNum < pages; ++pageNum) { + status =jtagmkII_flash_lock32(pgm, 0, pageNum); + if(status < 0) {lineno = __LINE__; goto eRR;} + } + + // Then erase them (guess could do this in the same loop above?) + for(pageNum=sPageNum; pageNum < pages; ++pageNum) { + status =jtagmkII_flash_erase32(pgm, pageNum); + if(status < 0) {lineno = __LINE__; goto eRR;} + } + + cmd[0] = CMND_WRITE_MEMORY32; + u32_to_b4r(&cmd[1], 0x40000000); // who knows + cmd[5] = 0x5; + + for(pageNum=sPageNum; pageNum < pages; ++pageNum) { + + status = jtagmkII_flash_clear_pagebuffer32(pgm); + if(status != 0) {lineno = __LINE__; goto eRR;} + + for(blocks=0; blocks<2; ++blocks) { + block_size = ((maxaddr-addr) < pgm->page_size) ? (maxaddr - addr) : pgm->page_size; + avrdude_message(MSG_DEBUG, "%s: jtagmkII_paged_write32(): " + "block_size at addr %d is %d\n", + progname, addr, block_size); + + u32_to_b4r(cmd + 6, m->offset + addr); + memset(cmd + 10, 0xff, pgm->page_size); + memcpy(cmd + 10, m->buf + addr, block_size); + + status = jtagmkII_send(pgm, cmd, pgm->page_size + 10); + if(status<0) {lineno = __LINE__; goto eRR;} + status = jtagmkII_recv(pgm, &resp); + if (status<0) {lineno = __LINE__; goto eRR;} + + if (verbose >= 3) { + putc('\n', stderr); + jtagmkII_prmsg(pgm, resp, status); + } else if (verbose == 2) + avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", resp[0], status); + if (resp[0] != RSP_OK) { + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_write32(): " + "bad response to write memory command: %s\n", + progname, jtagmkII_get_rc(resp[0])); + free(resp); + free(cmd); + return -1; + } + free(resp); + + addr += block_size; + + + } + status = jtagmkII_flash_write_page32(pgm, pageNum); + if(status < 0) {lineno = __LINE__; goto eRR;} + } + free(cmd); + serial_recv_timeout = otimeout; + + status = jtagmkII_reset32(pgm, AVR32_SET4RUNNING); // AVR32_SET4RUNNING | AVR32_RELEASE_JTAG + if(status < 0) {lineno = __LINE__; goto eRR;} + + return addr; + + eRR: + serial_recv_timeout = otimeout; + free(cmd); + avrdude_message(MSG_INFO, "%s: jtagmkII_paged_write32(): " + "failed at line %d (status=%x val=%lx)\n", + progname, lineno, status, val); + return -1; +} + + +static int jtagmkII_flash_lock32(PROGRAMMER * pgm, unsigned char lock, unsigned int page) +{ + int status, lineno, i; + unsigned long val, cmd=0; + + for(i=0; i<256; ++i) { + val = jtagmkII_read_SABaddr(pgm, AVR32_FLASHC_FSR, 0x05); + if(val == ERROR_SAB) continue; + if(val & AVR32_FLASHC_FSR_RDY) break; + } + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + if(!(val&AVR32_FLASHC_FSR_RDY)) {lineno = __LINE__; goto eRR;} // Flash better be ready + + page <<= 8; + cmd = AVR32_FLASHC_FCMD_KEY | page | (lock ? AVR32_FLASHC_FCMD_LOCK : AVR32_FLASHC_FCMD_UNLOCK); + status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd); + if (status < 0) {lineno = __LINE__; goto eRR;} + + return 0; + + eRR: + avrdude_message(MSG_INFO, "%s: jtagmkII_flash_lock32(): " + "failed at line %d page %d cmd %8.8lx\n", + progname, lineno, page, cmd); + return -1; +} + +static int jtagmkII_flash_erase32(PROGRAMMER * pgm, unsigned int page) +{ + int status, lineno, i; + unsigned long val=0, cmd=0, err=0; + + for(i=0; i<256; ++i) { + val = jtagmkII_read_SABaddr(pgm, AVR32_FLASHC_FSR, 0x05); + if(val == ERROR_SAB) continue; + if(val & AVR32_FLASHC_FSR_RDY) break; + } + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + if(!(val&AVR32_FLASHC_FSR_RDY)) {lineno = __LINE__; goto eRR;} // Flash better be ready + + page <<= 8; + cmd = AVR32_FLASHC_FCMD_KEY | page | AVR32_FLASHC_FCMD_ERASE_PAGE; + status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd); + if (status < 0) {lineno = __LINE__; goto eRR;} + +//avrdude_message(MSG_INFO, "ERASE %x -> %x\n", cmd, AVR32_FLASHC_FCMD); + + err = 0; + for(i=0; i<256; ++i) { + val = jtagmkII_read_SABaddr(pgm, AVR32_FLASHC_FSR, 0x05); + if(val == ERROR_SAB) continue; + err |= val; + if(val & AVR32_FLASHC_FSR_RDY) break; + } + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + if(!(val & AVR32_FLASHC_FSR_RDY)) {lineno = __LINE__; goto eRR;} + if(err & AVR32_FLASHC_FSR_ERR) {lineno = __LINE__; goto eRR;} + + return 0; + + eRR: + avrdude_message(MSG_INFO, "%s: jtagmkII_flash_erase32(): " + "failed at line %d page %d cmd %8.8lx val %lx\n", + progname, lineno, page, cmd, val); + return -1; +} + +static int jtagmkII_flash_write_page32(PROGRAMMER * pgm, unsigned int page) +{ + int status, lineno, i; + unsigned long val=0, cmd, err; + + page <<= 8; + cmd = AVR32_FLASHC_FCMD_KEY | page | AVR32_FLASHC_FCMD_WRITE_PAGE; + status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd); + if (status < 0) {lineno = __LINE__; goto eRR;} + + err = 0; + for(i=0; i<256; ++i) { + val = jtagmkII_read_SABaddr(pgm, AVR32_FLASHC_FSR, 0x05); + if(val == ERROR_SAB) continue; + err |= val; + if(val & AVR32_FLASHC_FSR_RDY) break; + } + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + if(!(val & AVR32_FLASHC_FSR_RDY)) {lineno = __LINE__; goto eRR;} + if(err & AVR32_FLASHC_FSR_ERR) {lineno = __LINE__; goto eRR;} + + return 0; + + eRR: + avrdude_message(MSG_INFO, "%s: jtagmkII_flash_write_page32(): " + "failed at line %d page %d cmd %8.8lx val %lx\n", + progname, lineno, page, cmd, val); + return -1; +} + +static int jtagmkII_flash_clear_pagebuffer32(PROGRAMMER * pgm) +{ + int status, lineno, i; + unsigned long val=0, cmd, err; + + cmd = AVR32_FLASHC_FCMD_KEY | AVR32_FLASHC_FCMD_CLEAR_PAGE_BUFFER; + status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd); + if (status < 0) {lineno = __LINE__; goto eRR;} + + err = 0; + for(i=0; i<256; ++i) { + val = jtagmkII_read_SABaddr(pgm, AVR32_FLASHC_FSR, 0x05); + if(val == ERROR_SAB) continue; + err |= val; + if(val & AVR32_FLASHC_FSR_RDY) break; + } + if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;} + if(!(val & AVR32_FLASHC_FSR_RDY)) {lineno = __LINE__; goto eRR;} + if(err & AVR32_FLASHC_FSR_ERR) {lineno = __LINE__; goto eRR;} + + return 0; + + eRR: + avrdude_message(MSG_INFO, "%s: jtagmkII_flash_clear_pagebuffer32(): " + "failed at line %d cmd %8.8lx val %lx\n", + progname, lineno, cmd, val); + return -1; +} + +#ifdef __OBJC__ +#pragma mark - +#endif + +const char jtagmkII_desc[] = "Atmel JTAG ICE mkII"; + +void jtagmkII_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "JTAGMKII"); + + /* + * mandatory functions + */ + pgm->initialize = jtagmkII_initialize; + pgm->display = jtagmkII_display; + pgm->enable = jtagmkII_enable; + pgm->disable = jtagmkII_disable; + pgm->program_enable = jtagmkII_program_enable_INFO; + pgm->chip_erase = jtagmkII_chip_erase; + pgm->open = jtagmkII_open; + pgm->close = jtagmkII_close; + pgm->read_byte = jtagmkII_read_byte; + pgm->write_byte = jtagmkII_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtagmkII_paged_write; + pgm->paged_load = jtagmkII_paged_load; + pgm->page_erase = jtagmkII_page_erase; + pgm->print_parms = jtagmkII_print_parms; + pgm->set_sck_period = jtagmkII_set_sck_period; + pgm->parseextparams = jtagmkII_parseextparms; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; + pgm->page_size = 256; + pgm->flag = PGM_FL_IS_JTAG; +} + +const char jtagmkII_dw_desc[] = "Atmel JTAG ICE mkII in debugWire mode"; + +void jtagmkII_dw_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "JTAGMKII_DW"); + + /* + * mandatory functions + */ + pgm->initialize = jtagmkII_initialize; + pgm->display = jtagmkII_display; + pgm->enable = jtagmkII_enable; + pgm->disable = jtagmkII_disable; + pgm->program_enable = jtagmkII_program_enable_INFO; + pgm->chip_erase = jtagmkII_chip_erase_dw; + pgm->open = jtagmkII_open_dw; + pgm->close = jtagmkII_close; + pgm->read_byte = jtagmkII_read_byte; + pgm->write_byte = jtagmkII_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtagmkII_paged_write; + pgm->paged_load = jtagmkII_paged_load; + pgm->print_parms = jtagmkII_print_parms; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; + pgm->page_size = 256; + pgm->flag = PGM_FL_IS_DW; +} + +const char jtagmkII_pdi_desc[] = "Atmel JTAG ICE mkII in PDI mode"; + +void jtagmkII_pdi_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "JTAGMKII_PDI"); + + /* + * mandatory functions + */ + pgm->initialize = jtagmkII_initialize; + pgm->display = jtagmkII_display; + pgm->enable = jtagmkII_enable; + pgm->disable = jtagmkII_disable; + pgm->program_enable = jtagmkII_program_enable_INFO; + pgm->chip_erase = jtagmkII_chip_erase; + pgm->open = jtagmkII_open_pdi; + pgm->close = jtagmkII_close; + pgm->read_byte = jtagmkII_read_byte; + pgm->write_byte = jtagmkII_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtagmkII_paged_write; + pgm->paged_load = jtagmkII_paged_load; + pgm->page_erase = jtagmkII_page_erase; + pgm->print_parms = jtagmkII_print_parms; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; + pgm->page_size = 256; + pgm->flag = PGM_FL_IS_PDI; +} + +const char jtagmkII_dragon_desc[] = "Atmel AVR Dragon in JTAG mode"; + +void jtagmkII_dragon_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "DRAGON_JTAG"); + + /* + * mandatory functions + */ + pgm->initialize = jtagmkII_initialize; + pgm->display = jtagmkII_display; + pgm->enable = jtagmkII_enable; + pgm->disable = jtagmkII_disable; + pgm->program_enable = jtagmkII_program_enable_INFO; + pgm->chip_erase = jtagmkII_chip_erase; + pgm->open = jtagmkII_dragon_open; + pgm->close = jtagmkII_close; + pgm->read_byte = jtagmkII_read_byte; + pgm->write_byte = jtagmkII_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtagmkII_paged_write; + pgm->paged_load = jtagmkII_paged_load; + pgm->page_erase = jtagmkII_page_erase; + pgm->print_parms = jtagmkII_print_parms; + pgm->set_sck_period = jtagmkII_set_sck_period; + pgm->parseextparams = jtagmkII_parseextparms; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; + pgm->page_size = 256; + pgm->flag = PGM_FL_IS_JTAG; +} + +const char jtagmkII_dragon_dw_desc[] = "Atmel AVR Dragon in debugWire mode"; + +void jtagmkII_dragon_dw_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "DRAGON_DW"); + + /* + * mandatory functions + */ + pgm->initialize = jtagmkII_initialize; + pgm->display = jtagmkII_display; + pgm->enable = jtagmkII_enable; + pgm->disable = jtagmkII_disable; + pgm->program_enable = jtagmkII_program_enable_INFO; + pgm->chip_erase = jtagmkII_chip_erase_dw; + pgm->open = jtagmkII_dragon_open_dw; + pgm->close = jtagmkII_close; + pgm->read_byte = jtagmkII_read_byte; + pgm->write_byte = jtagmkII_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtagmkII_paged_write; + pgm->paged_load = jtagmkII_paged_load; + pgm->print_parms = jtagmkII_print_parms; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; + pgm->page_size = 256; + pgm->flag = PGM_FL_IS_DW; +} + +const char jtagmkII_avr32_desc[] = "Atmel JTAG ICE mkII in AVR32 mode"; + +void jtagmkII_avr32_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "JTAGMKII_AVR32"); + + /* + * mandatory functions + */ + pgm->initialize = jtagmkII_initialize32; + pgm->display = jtagmkII_display; + pgm->enable = jtagmkII_enable; + pgm->disable = jtagmkII_disable; + pgm->program_enable = jtagmkII_program_enable_INFO; + pgm->chip_erase = jtagmkII_chip_erase32; + pgm->open = jtagmkII_open32; + pgm->close = jtagmkII_close32; + pgm->read_byte = jtagmkII_read_byte; + pgm->write_byte = jtagmkII_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtagmkII_paged_write32; + pgm->paged_load = jtagmkII_paged_load32; + pgm->print_parms = jtagmkII_print_parms; + //pgm->set_sck_period = jtagmkII_set_sck_period; + //pgm->parseextparams = jtagmkII_parseextparms; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; + pgm->page_size = 256; + pgm->flag = PGM_FL_IS_JTAG; +} + +const char jtagmkII_dragon_pdi_desc[] = "Atmel AVR Dragon in PDI mode"; + +void jtagmkII_dragon_pdi_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "DRAGON_PDI"); + + /* + * mandatory functions + */ + pgm->initialize = jtagmkII_initialize; + pgm->display = jtagmkII_display; + pgm->enable = jtagmkII_enable; + pgm->disable = jtagmkII_disable; + pgm->program_enable = jtagmkII_program_enable_INFO; + pgm->chip_erase = jtagmkII_chip_erase; + pgm->open = jtagmkII_dragon_open_pdi; + pgm->close = jtagmkII_close; + pgm->read_byte = jtagmkII_read_byte; + pgm->write_byte = jtagmkII_write_byte; + + /* + * optional functions + */ + pgm->paged_write = jtagmkII_paged_write; + pgm->paged_load = jtagmkII_paged_load; + pgm->page_erase = jtagmkII_page_erase; + pgm->print_parms = jtagmkII_print_parms; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; + pgm->page_size = 256; + pgm->flag = PGM_FL_IS_PDI; +} + diff --git a/xs/src/avrdude/jtagmkII.h b/xs/src/avrdude/jtagmkII.h new file mode 100644 index 000000000..aa79c18d2 --- /dev/null +++ b/xs/src/avrdude/jtagmkII.h @@ -0,0 +1,63 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 jtagmkII_h +#define jtagmkII_h + +#ifdef __cplusplus +extern "C" { +#endif + +int jtagmkII_send(PROGRAMMER * pgm, unsigned char * data, size_t len); +int jtagmkII_recv(PROGRAMMER * pgm, unsigned char **msg); +void jtagmkII_close(PROGRAMMER * pgm); +int jtagmkII_getsync(PROGRAMMER * pgm, int mode); +int jtagmkII_getparm(PROGRAMMER * pgm, unsigned char parm, + unsigned char * value); + +extern const char jtagmkII_desc[]; +extern const char jtagmkII_avr32_desc[]; +extern const char jtagmkII_dw_desc[]; +extern const char jtagmkII_pdi_desc[]; +extern const char jtagmkII_dragon_desc[]; +extern const char jtagmkII_dragon_dw_desc[]; +extern const char jtagmkII_dragon_pdi_desc[]; +void jtagmkII_initpgm (PROGRAMMER * pgm); +void jtagmkII_avr32_initpgm (PROGRAMMER * pgm); +void jtagmkII_dw_initpgm (PROGRAMMER * pgm); +void jtagmkII_pdi_initpgm (PROGRAMMER * pgm); +void jtagmkII_dragon_initpgm (PROGRAMMER * pgm); +void jtagmkII_dragon_dw_initpgm (PROGRAMMER * pgm); +void jtagmkII_dragon_pdi_initpgm (PROGRAMMER * pgm); + +/* + * These functions are referenced from stk500v2.c for JTAG ICE mkII + * and AVR Dragon programmers running in one of the STK500v2 + * modi. + */ +void jtagmkII_setup(PROGRAMMER * pgm); +void jtagmkII_teardown(PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/xs/src/avrdude/jtagmkII_private.h b/xs/src/avrdude/jtagmkII_private.h new file mode 100644 index 000000000..6df8f6f23 --- /dev/null +++ b/xs/src/avrdude/jtagmkII_private.h @@ -0,0 +1,385 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2005, 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 + * 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$ */ + + +/* + * JTAG ICE mkII definitions + * Taken from Appnote AVR067 + */ + +#if !defined(JTAGMKII_PRIVATE_EXPORTED) +/* + * Communication with the JTAG ICE works in frames. The protocol + * somewhat resembles the STK500v2 protocol, yet it is sufficiently + * different to prevent a direct code reuse. :-( + * + * Frame format: + * + * +---------------------------------------------------------------+ + * | 0 | 1 . 2 | 3 . 4 . 5 . 6 | 7 | ... | N-1 . N | + * | | | | | | | + * | start | LSB MSB | LSB ....... MSB | token | msg | LSB MSB | + * | 0x1B | sequence# | message size | 0x0E | | CRC16 | + * +---------------------------------------------------------------+ + * + * Each request message will be returned by a response with a matching + * sequence #. Sequence # 0xffff is reserved for asynchronous event + * notifications that will be sent by the ICE without a request + * message (e.g. when the target hit a breakpoint). + * + * The message size excludes the framing overhead (10 bytes). + * + * The first byte of the message is always the request or response + * code, which is roughly classified as: + * + * . Messages (commands) use 0x00 through 0x3f. (The documentation + * claims that messages start at 0x01, but actually CMND_SIGN_OFF is + * 0x00.) + * . Internal commands use 0x40 through 0x7f (not documented). + * . Success responses use 0x80 through 0x9f. + * . Failure responses use 0xa0 through 0xbf. + * . Events use 0xe0 through 0xff. + */ +#define MESSAGE_START 0x1b +#define TOKEN 0x0e + +/* + * Max message size we are willing to accept. Prevents us from trying + * to allocate too much VM in case we received a nonsensical packet + * length. We have to allocate the buffer as soon as we've got the + * length information (and thus have to trust that information by that + * time at first), as the final CRC check can only be done once the + * entire packet came it. + */ +#define MAX_MESSAGE 100000 + +#endif /* JTAGMKII_PRIVATE_EXPORTED */ + +/* ICE command codes */ +#define CMND_SIGN_OFF 0x00 +#define CMND_GET_SIGN_ON 0x01 +#define CMND_SET_PARAMETER 0x02 +#define CMND_GET_PARAMETER 0x03 +#define CMND_WRITE_MEMORY 0x04 +#define CMND_READ_MEMORY 0x05 +#define CMND_WRITE_PC 0x06 +#define CMND_READ_PC 0x07 +#define CMND_GO 0x08 +#define CMND_SINGLE_STEP 0x09 +#define CMND_FORCED_STOP 0x0A +#define CMND_RESET 0x0B +#define CMND_SET_DEVICE_DESCRIPTOR 0x0C +#define CMND_ERASEPAGE_SPM 0x0D +#define CMND_GET_SYNC 0x0f +#define CMND_SELFTEST 0x10 +#define CMND_SET_BREAK 0x11 +#define CMND_GET_BREAK 0x12 +#define CMND_CHIP_ERASE 0x13 +#define CMND_ENTER_PROGMODE 0x14 +#define CMND_LEAVE_PROGMODE 0x15 +#define CMND_SET_N_PARAMETERS 0x16 +#define CMND_CLR_BREAK 0x1A +#define CMND_RUN_TO_ADDR 0x1C +#define CMND_SPI_CMD 0x1D +#define CMND_CLEAR_EVENTS 0x22 +#define CMND_RESTORE_TARGET 0x23 +#define CMND_GET_IR 0x24 +#define CMND_GET_xxx 0x25 +#define CMND_WRITE_SAB 0x28 +#define CMND_READ_SAB 0x29 +#define CMND_RESET_AVR 0x2B +#define CMND_READ_MEMORY32 0x2C +#define CMND_WRITE_MEMORY32 0x2D +#define CMND_ISP_PACKET 0x2F +#define CMND_XMEGA_ERASE 0x34 +#define CMND_SET_XMEGA_PARAMS 0x36 // undocumented in AVR067 + + +/* ICE responses */ +#define RSP_OK 0x80 +#define RSP_PARAMETER 0x81 +#define RSP_MEMORY 0x82 +#define RSP_GET_BREAK 0x83 +#define RSP_PC 0x84 +#define RSP_SELFTEST 0x85 +#define RSP_SIGN_ON 0x86 +#define RSP_SPI_DATA 0x88 +#define RSP_FAILED 0xA0 +#define RSP_ILLEGAL_PARAMETER 0xA1 +#define RSP_ILLEGAL_MEMORY_TYPE 0xA2 +#define RSP_ILLEGAL_MEMORY_RANGE 0xA3 +#define RSP_ILLEGAL_EMULATOR_MODE 0xA4 +#define RSP_ILLEGAL_MCU_STATE 0xA5 +#define RSP_ILLEGAL_VALUE 0xA6 +#define RSP_SET_N_PARAMETERS 0xA7 +#define RSP_ILLEGAL_BREAKPOINT 0xA8 +#define RSP_ILLEGAL_JTAG_ID 0xA9 +#define RSP_ILLEGAL_COMMAND 0xAA +#define RSP_NO_TARGET_POWER 0xAB +#define RSP_DEBUGWIRE_SYNC_FAILED 0xAC +#define RSP_ILLEGAL_POWER_STATE 0xAD + +/* ICE events */ +#define EVT_BREAK 0xE0 +#define EVT_RUN 0xE1 +#define EVT_ERROR_PHY_FORCE_BREAK_TIMEOUT 0xE2 +#define EVT_ERROR_PHY_RELEASE_BREAK_TIMEOUT 0xE3 +#define EVT_TARGET_POWER_ON 0xE4 +#define EVT_TARGET_POWER_OFF 0xE5 +#define EVT_DEBUG 0xE6 +#define EVT_EXT_RESET 0xE7 +#define EVT_TARGET_SLEEP 0xE8 +#define EVT_TARGET_WAKEUP 0xE9 +#define EVT_ICE_POWER_ERROR_STATE 0xEA +#define EVT_ICE_POWER_OK 0xEB +#define EVT_IDR_DIRTY 0xEC +#define EVT_ERROR_PHY_MAX_BIT_LENGTH_DIFF 0xED +#define EVT_NONE 0xEF +#define EVT_ERROR_PHY_SYNC_TIMEOUT 0xF0 +#define EVT_PROGRAM_BREAK 0xF1 +#define EVT_PDSB_BREAK 0xF2 +#define EVT_PDSMB_BREAK 0xF3 +#define EVT_ERROR_PHY_SYNC_TIMEOUT_BAUD 0xF4 +#define EVT_ERROR_PHY_SYNC_OUT_OF_RANGE 0xF5 +#define EVT_ERROR_PHY_SYNC_WAIT_TIMEOUT 0xF6 +#define EVT_ERROR_PHY_RECEIVE_TIMEOUT 0xF7 +#define EVT_ERROR_PHY_RECEIVED_BREAK 0xF8 +#define EVT_ERROR_PHY_OPT_RECEIVE_TIMEOUT 0xF9 +#define EVT_ERROR_PHY_OPT_RECEIVED_BREAK 0xFA +#define EVT_RESULT_PHY_NO_ACTIVITY 0xFB + +/* memory types for CMND_{READ,WRITE}_MEMORY */ +#define MTYPE_IO_SHADOW 0x30 /* cached IO registers? */ +#define MTYPE_SRAM 0x20 /* target's SRAM or [ext.] IO registers */ +#define MTYPE_EEPROM 0x22 /* EEPROM, what way? */ +#define MTYPE_EVENT 0x60 /* ICE event memory */ +#define MTYPE_SPM 0xA0 /* flash through LPM/SPM */ +#define MTYPE_FLASH_PAGE 0xB0 /* flash in programming mode */ +#define MTYPE_EEPROM_PAGE 0xB1 /* EEPROM in programming mode */ +#define MTYPE_FUSE_BITS 0xB2 /* fuse bits in programming mode */ +#define MTYPE_LOCK_BITS 0xB3 /* lock bits in programming mode */ +#define MTYPE_SIGN_JTAG 0xB4 /* signature in programming mode */ +#define MTYPE_OSCCAL_BYTE 0xB5 /* osccal cells in programming mode */ +#define MTYPE_CAN 0xB6 /* CAN mailbox */ +#define MTYPE_FLASH 0xc0 /* xmega (app.) flash - undocumented in AVR067 */ +#define MTYPE_BOOT_FLASH 0xc1 /* xmega boot flash - undocumented in AVR067 */ +#define MTYPE_EEPROM_XMEGA 0xc4 /* xmega EEPROM in debug mode - undocumented in AVR067 */ +#define MTYPE_USERSIG 0xc5 /* xmega user signature - undocumented in AVR067 */ +#define MTYPE_PRODSIG 0xc6 /* xmega production signature - undocumented in AVR067 */ + +/* (some) ICE parameters, for CMND_{GET,SET}_PARAMETER */ +#define PAR_HW_VERSION 0x01 +#define PAR_FW_VERSION 0x02 +#define PAR_EMULATOR_MODE 0x03 +# define EMULATOR_MODE_DEBUGWIRE 0x00 +# define EMULATOR_MODE_JTAG 0x01 +# define EMULATOR_MODE_HV 0x02 /* HVSP or PP mode of AVR Dragon */ +# define EMULATOR_MODE_SPI 0x03 +# define EMULATOR_MODE_JTAG_AVR32 0x04 +# define EMULATOR_MODE_JTAG_XMEGA 0x05 +# define EMULATOR_MODE_PDI 0x06 +#define PAR_IREG 0x04 +#define PAR_BAUD_RATE 0x05 +# define PAR_BAUD_2400 0x01 +# define PAR_BAUD_4800 0x02 +# define PAR_BAUD_9600 0x03 +# define PAR_BAUD_19200 0x04 /* default */ +# define PAR_BAUD_38400 0x05 +# define PAR_BAUD_57600 0x06 +# define PAR_BAUD_115200 0x07 +# define PAR_BAUD_14400 0x08 +#define PAR_OCD_VTARGET 0x06 +#define PAR_OCD_JTAG_CLK 0x07 +#define PAR_OCD_BREAK_CAUSE 0x08 +#define PAR_TIMERS_RUNNING 0x09 +#define PAR_BREAK_ON_CHANGE_FLOW 0x0A +#define PAR_BREAK_ADDR1 0x0B +#define PAR_BREAK_ADDR2 0x0C +#define PAR_COMBBREAKCTRL 0x0D +#define PAR_JTAGID 0x0E +#define PAR_UNITS_BEFORE 0x0F +#define PAR_UNITS_AFTER 0x10 +#define PAR_BIT_BEFORE 0x11 +#define PAR_BIT_ATER 0x12 +#define PAR_EXTERNAL_RESET 0x13 +#define PAR_FLASH_PAGE_SIZE 0x14 +#define PAR_EEPROM_PAGE_SIZE 0x15 +#define PAR_UNUSED1 0x16 +#define PAR_PSB0 0x17 +#define PAR_PSB1 0x18 +#define PAR_PROTOCOL_DEBUG_EVENT 0x19 +#define PAR_MCU_STATE 0x1A +# define STOPPED 0x00 +# define RUNNING 0x01 +# define PROGRAMMING 0x02 +#define PAR_DAISY_CHAIN_INFO 0x1B +#define PAR_BOOT_ADDRESS 0x1C +#define PAR_TARGET_SIGNATURE 0x1D +#define PAR_DEBUGWIRE_BAUDRATE 0x1E +#define PAR_PROGRAM_ENTRY_POINT 0x1F +#define PAR_PDI_OFFSET_START 0x32 +#define PAR_PDI_OFFSET_END 0x33 +#define PAR_PACKET_PARSING_ERRORS 0x40 +#define PAR_VALID_PACKETS_RECEIVED 0x41 +#define PAR_INTERCOMMUNICATION_TX_FAILURES 0x42 +#define PAR_INTERCOMMUNICATION_RX_FAILURES 0x43 +#define PAR_CRC_ERRORS 0x44 +#define PAR_POWER_SOURCE 0x45 +# define POWER_EXTERNAL 0x00 +# define POWER_USB 0x01 +#define PAR_CAN_FLAG 0x22 +# define DONT_READ_CAN_MAILBOX 0x00 +# define READ_CAN_MAILBOX 0x01 +#define PAR_ENABLE_IDR_IN_RUN_MODE 0x23 +# define ACCESS_OSCCAL 0x00 +# define ACCESS_IDR 0x01 +#define PAR_ALLOW_PAGEPROGRAMMING_IN_SCANCHAIN 0x24 +# define PAGEPROG_NOT_ALLOWED 0x00 +# define PAGEPROG_ALLOWED 0x01 + +/* Xmega erase memory types, for CMND_XMEGA_ERASE */ +#define XMEGA_ERASE_CHIP 0x00 +#define XMEGA_ERASE_APP 0x01 +#define XMEGA_ERASE_BOOT 0x02 +#define XMEGA_ERASE_EEPROM 0x03 +#define XMEGA_ERASE_APP_PAGE 0x04 +#define XMEGA_ERASE_BOOT_PAGE 0x05 +#define XMEGA_ERASE_EEPROM_PAGE 0x06 +#define XMEGA_ERASE_USERSIG 0x07 + +/* AVR32 related definitions */ +#define AVR32_FLASHC_FCR 0xFFFE1400 +#define AVR32_FLASHC_FCMD 0xFFFE1404 +#define AVR32_FLASHC_FCMD_KEY 0xA5000000 +#define AVR32_FLASHC_FCMD_WRITE_PAGE 1 +#define AVR32_FLASHC_FCMD_ERASE_PAGE 2 +#define AVR32_FLASHC_FCMD_CLEAR_PAGE_BUFFER 3 +#define AVR32_FLASHC_FCMD_LOCK 4 +#define AVR32_FLASHC_FCMD_UNLOCK 5 +#define AVR32_FLASHC_FSR 0xFFFE1408 +#define AVR32_FLASHC_FSR_RDY 0x00000001 +#define AVR32_FLASHC_FSR_ERR 0x00000008 +#define AVR32_FLASHC_FGPFRHI 0xFFFE140C +#define AVR32_FLASHC_FGPFRLO 0xFFFE1410 + +#define AVR32_DC 0x00000008 +#define AVR32_DS 0x00000010 +#define AVR32_DINST 0x00000104 +#define AVR32_DCCPU 0x00000110 +#define AVR32_DCEMU 0x00000114 +#define AVR32_DCSR 0x00000118 + +#define AVR32_DC_ABORT 0x80000000 +#define AVR32_DC_RESET 0x40000000 +#define AVR32_DC_DBE 0x00002000 +#define AVR32_DC_DBR 0x00001000 + +#define AVR32_RESET_READ 0x0001 +#define AVR32_RESET_WRITE 0x0002 +#define AVR32_RESET_CHIP_ERASE 0x0004 +#define AVR32_SET4RUNNING 0x0008 +//#define AVR32_RESET_COMMON (AVR32_RESET_READ | AVR32_RESET_WRITE | AVR32_RESET_CHIP_ERASE ) + + +#if !defined(JTAGMKII_PRIVATE_EXPORTED) +/* + * 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 + * conversion macros. + */ +struct device_descriptor +{ + unsigned char ucReadIO[8]; /*LSB = IOloc 0, MSB = IOloc63 */ + unsigned char ucReadIOShadow[8]; /*LSB = IOloc 0, MSB = IOloc63 */ + unsigned char ucWriteIO[8]; /*LSB = IOloc 0, MSB = IOloc63 */ + unsigned char ucWriteIOShadow[8]; /*LSB = IOloc 0, MSB = IOloc63 */ + unsigned char ucReadExtIO[52]; /*LSB = IOloc 96, MSB = IOloc511 */ + unsigned char ucReadIOExtShadow[52]; /*LSB = IOloc 96, MSB = IOloc511 */ + unsigned char ucWriteExtIO[52]; /*LSB = IOloc 96, MSB = IOloc511 */ + unsigned char ucWriteIOExtShadow[52];/*LSB = IOloc 96, MSB = IOloc511 */ + unsigned char ucIDRAddress; /*IDR address */ + unsigned char ucSPMCRAddress; /*SPMCR Register address and dW BasePC */ + unsigned char ucRAMPZAddress; /*RAMPZ Register address in SRAM I/O */ + /*space */ + unsigned char uiFlashPageSize[2]; /*Device Flash Page Size, Size = */ + /*2 exp ucFlashPageSize */ + unsigned char ucEepromPageSize; /*Device Eeprom Page Size in bytes */ + unsigned char ulBootAddress[4]; /*Device Boot Loader Start Address */ + unsigned char uiUpperExtIOLoc[2]; /*Topmost (last) extended I/O */ + /*location, 0 if no external I/O */ + unsigned char ulFlashSize[4]; /*Device Flash Size */ + unsigned char ucEepromInst[20]; /*Instructions for W/R EEPROM */ + unsigned char ucFlashInst[3]; /*Instructions for W/R FLASH */ + unsigned char ucSPHaddr; /* stack pointer high */ + unsigned char ucSPLaddr; /* stack pointer low */ + /* new as of 16-02-2004 */ + unsigned char uiFlashpages[2]; /* number of pages in flash */ + unsigned char ucDWDRAddress; /* DWDR register address */ + unsigned char ucDWBasePC; /* base/mask value of the PC */ + /* new as of 30-04-2004 */ + unsigned char ucAllowFullPageBitstream; /* FALSE on ALL new */ + /*parts */ + unsigned char uiStartSmallestBootLoaderSection[2]; /* */ + /* new as of 18-10-2004 */ + unsigned char EnablePageProgramming; /* For JTAG parts only, */ + /* default TRUE */ + unsigned char ucCacheType; /* CacheType_Normal 0x00, */ + /* CacheType_CAN 0x01, */ + /* CacheType_HEIMDALL 0x02 */ + /* new as of 27-10-2004 */ + unsigned char uiSramStartAddr[2]; /* Start of SRAM */ + unsigned char ucResetType; /* Selects reset type. ResetNormal = 0x00 */ + /* ResetAT76CXXX = 0x01 */ + unsigned char ucPCMaskExtended; /* For parts with extended PC */ + unsigned char ucPCMaskHigh; /* PC high mask */ + unsigned char ucEindAddress; /* Selects reset type. [EIND address...] */ + /* new as of early 2005, firmware 4.x */ + unsigned char EECRAddress[2]; /* EECR memory-mapped IO address */ +}; + +/* New Xmega device descriptor, for firmware version 7 and above */ +struct xmega_device_desc { + unsigned char whatever[2]; // cannot guess; must be 0x0002 + unsigned char datalen; // length of the following data, = 47 + unsigned char nvm_app_offset[4]; // NVM offset for application flash + unsigned char nvm_boot_offset[4]; // NVM offset for boot flash + unsigned char nvm_eeprom_offset[4]; // NVM offset for EEPROM + unsigned char nvm_fuse_offset[4]; // NVM offset for fuses + unsigned char nvm_lock_offset[4]; // NVM offset for lock bits + unsigned char nvm_user_sig_offset[4]; // NVM offset for user signature row + unsigned char nvm_prod_sig_offset[4]; // NVM offset for production sign. row + unsigned char nvm_data_offset[4]; // NVM offset for data memory (SRAM + IO) + unsigned char app_size[4]; // size of application flash + unsigned char boot_size[2]; // size of boot flash + unsigned char flash_page_size[2]; // flash page size + unsigned char eeprom_size[2]; // size of EEPROM + unsigned char eeprom_page_size; // EEPROM page size + unsigned char nvm_base_addr[2]; // IO space base address of NVM controller + unsigned char mcu_base_addr[2]; // IO space base address of MCU control +}; +#endif /* JTAGMKII_PRIVATE_EXPORTED */ + +/* return code from jtagmkII_getsync() to indicate a "graceful" + * failure, i.e. an attempt to enable ISP failed and should be + * eventually retried */ +#define JTAGII_GETSYNC_FAIL_GRACEFUL (-2) diff --git a/xs/src/avrdude/jtagmkI_private.h b/xs/src/avrdude/jtagmkI_private.h new file mode 100644 index 000000000..7d5e247a9 --- /dev/null +++ b/xs/src/avrdude/jtagmkI_private.h @@ -0,0 +1,168 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2005 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 + * 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$ */ + + +/* + * JTAG ICE mkI definitions + */ + +/* ICE command codes */ +/* 0x20 Get Synch [Resp_OK] */ +#define CMD_GET_SYNC ' ' + +/* 0x31 Single Step [Sync_CRC/EOP] [Resp_OK] */ +/* 0x32 Read PC [Sync_CRC/EOP] [Resp_OK] [program counter] + * [Resp_OK] */ +/* 0x33 Write PC [program counter] [Sync_CRC/EOP] [Resp_OK] + * [Resp_OK] */ +/* 0xA2 Firmware Upgrade [upgrade string] [Sync_CRC/EOP] [Resp_OK] + * [Resp_OK] */ +/* 0xA0 Set Device Descriptor [device info] [Sync_CRC/EOP] [Resp_OK] + * [Resp_OK] */ +#define CMD_SET_DEVICE_DESCRIPTOR 0xA0 + +/* 0x42 Set Parameter [parameter] [setting] [Sync_CRC/EOP] [Resp_OK] + * [Resp_OK] */ +#define CMD_SET_PARAM 'B' + +/* 0x46 Forced Stop [Sync_CRC/EOP] [Resp_OK] [checksum][program + * counter] [Resp_OK] */ +#define CMD_STOP 'F' + +/* 0x47 Go [Sync_CRC/EOP] [Resp_OK] */ +#define CMD_GO 'G' + +/* 0x52 Read Memory [memory type] [word count] [start address] + * [Sync_CRC/EOP] [Resp_OK] [word 0] ... [word n] [checksum] + * [Resp_OK] */ +#define CMD_READ_MEM 'R' + +/* 0x53 Get Sign On [Sync_CRC/EOP] [Resp_OK] ["AVRNOCD"] [Resp_OK] */ +#define CMD_GET_SIGNON 'S' + +/* 0XA1 Erase Page spm [address] [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */ + +/* 0x57 Write Memory [memory type] [word count] [start address] + * [Sync_CRC/EOP] [Resp_OK] [Cmd_DATA] [word 0] ... [word n] */ +#define CMD_WRITE_MEM 'W' + +/* Second half of write memory: the data command. Undocumented. */ +#define CMD_DATA 'h' + +/* 0x64 Get Debug Info [Sync_CRC/EOP] [Resp_OK] [0x00] [Resp_OK] */ +/* 0x71 Get Parameter [parameter] [Sync_CRC/EOP] [Resp_OK] [setting] + * [Resp_OK] */ +#define CMD_GET_PARAM 'q' + +/* 0x78 Reset [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */ +#define CMD_RESET 'x' + +/* 0xA3 Enter Progmode [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */ +#define CMD_ENTER_PROGMODE 0xa3 + +/* 0xA4 Leave Progmode [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */ +#define CMD_LEAVE_PROGMODE 0xa4 + +/* 0xA5 Chip Erase [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */ +#define CMD_CHIP_ERASE 0xa5 + + +/* ICE responses */ +#define RESP_OK 'A' +#define RESP_BREAK 'B' +#define RESP_INFO 'G' +#define RESP_FAILED 'F' +#define RESP_SYNC_ERROR 'E' +#define RESP_SLEEP 'H' +#define RESP_POWER 'I' + +#define PARM_BITRATE 'b' +#define PARM_SW_VERSION 0x7b +#define PARM_HW_VERSION 0x7a +#define PARM_IREG_HIGH 0x81 +#define PARM_IREG_LOW 0x82 +#define PARM_OCD_VTARGET 0x84 +#define PARM_OCD_BREAK_CAUSE 0x85 +#define PARM_CLOCK 0x86 +#define PARM_EXTERNAL_RESET 0x8b +#define PARM_FLASH_PAGESIZE_LOW 0x88 +#define PARM_FLASH_PAGESIZE_HIGH 0x89 +#define PARM_EEPROM_PAGESIZE 0x8a +#define PARM_TIMERS_RUNNING 0xa0 +#define PARM_BP_FLOW 0xa1 +#define PARM_BP_X_HIGH 0xa2 +#define PARM_BP_X_LOW 0xa3 +#define PARM_BP_Y_HIGH 0xa4 +#define PARM_BP_Y_LOW 0xa5 +#define PARM_BP_MODE 0xa6 +#define PARM_JTAGID_BYTE0 0xa7 +#define PARM_JTAGID_BYTE1 0xa8 +#define PARM_JTAGID_BYTE2 0xa9 +#define PARM_JTAGID_BYTE3 0xaa +#define PARM_UNITS_BEFORE 0xab +#define PARM_UNITS_AFTER 0xac +#define PARM_BIT_BEFORE 0xad +#define PARM_BIT_AFTER 0xae +#define PARM_PSB0_LOW 0xaf +#define PARM_PSBO_HIGH 0xb0 +#define PARM_PSB1_LOW 0xb1 +#define PARM_PSB1_HIGH 0xb2 +#define PARM_MCU_MODE 0xb3 + +#define JTAG_BITRATE_1_MHz 0xff +#define JTAG_BITRATE_500_kHz 0xfe +#define JTAG_BITRATE_250_kHz 0xfd +#define JTAG_BITRATE_125_kHz 0xfb + +/* memory types for CMND_{READ,WRITE}_MEMORY */ +#define MTYPE_IO_SHADOW 0x30 /* cached IO registers? */ +#define MTYPE_SRAM 0x20 /* target's SRAM or [ext.] IO registers */ +#define MTYPE_EEPROM 0x22 /* EEPROM, what way? */ +#define MTYPE_EVENT 0x60 /* ICE event memory */ +#define MTYPE_SPM 0xA0 /* flash through LPM/SPM */ +#define MTYPE_FLASH_PAGE 0xB0 /* flash in programming mode */ +#define MTYPE_EEPROM_PAGE 0xB1 /* EEPROM in programming mode */ +#define MTYPE_FUSE_BITS 0xB2 /* fuse bits in programming mode */ +#define MTYPE_LOCK_BITS 0xB3 /* lock bits in programming mode */ +#define MTYPE_SIGN_JTAG 0xB4 /* signature in programming mode */ +#define MTYPE_OSCCAL_BYTE 0xB5 /* osccal cells in programming mode */ + +struct device_descriptor +{ + unsigned char ucReadIO[8]; /*LSB = IOloc 0, MSB = IOloc63 */ + unsigned char ucWriteIO[8]; /*LSB = IOloc 0, MSB = IOloc63 */ + unsigned char ucReadIOShadow[8]; /*LSB = IOloc 0, MSB = IOloc63 */ + unsigned char ucWriteIOShadow[8]; /*LSB = IOloc 0, MSB = IOloc63 */ + unsigned char ucReadExtIO[20]; /*LSB = IOloc 96, MSB = IOloc255 */ + unsigned char ucWriteExtIO[20]; /*LSB = IOloc 96, MSB = IOloc255 */ + unsigned char ucReadIOExtShadow[20]; /*LSB = IOloc 96, MSB = IOloc255 */ + unsigned char ucWriteIOExtShadow[20];/*LSB = IOloc 96, MSB = IOloc255 */ + unsigned char ucIDRAddress; /*IDR address */ + unsigned char ucSPMCRAddress; /*SPMCR Register address and dW BasePC */ + unsigned char ucRAMPZAddress; /*RAMPZ Register address in SRAM I/O */ + /*space */ + unsigned char uiFlashPageSize[2]; /*Device Flash Page Size, Size = */ + /*2 exp ucFlashPageSize */ + unsigned char ucEepromPageSize; /*Device Eeprom Page Size in bytes */ + unsigned char ulBootAddress[4]; /*Device Boot Loader Start Address */ + unsigned char uiUpperExtIOLoc; /*Topmost (last) extended I/O */ + /*location, 0 if no external I/O */ +}; diff --git a/xs/src/avrdude/lexer.c b/xs/src/avrdude/lexer.c new file mode 100644 index 000000000..93249a9ab --- /dev/null +++ b/xs/src/avrdude/lexer.c @@ -0,0 +1,3066 @@ + +#line 2 "lexer.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern int yyleng; + +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = NULL; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); + +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); + +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +typedef flex_uint8_t YY_CHAR; + +FILE *yyin = NULL, *yyout = NULL; + +typedef int yy_state_type; + +extern int yylineno; +int yylineno = 1; + +extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; +#define YY_NUM_RULES 156 +#define YY_END_OF_BUFFER 157 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[877] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 157, 155, + 153, 152, 7, 9, 150, 151, 146, 155, 155, 4, + 4, 148, 147, 155, 155, 155, 155, 155, 155, 155, + 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, + 155, 155, 155, 149, 20, 21, 13, 156, 156, 10, + 11, 153, 0, 3, 1, 6, 12, 5, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 154, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 62, 64, + 0, 0, 0, 0, 0, 0, 0, 0, 78, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 20, 19, 17, + 18, 14, 16, 15, 3, 2, 5, 8, 0, 0, + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 120, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 132, 139, 0, 0, 145, + + 2, 0, 0, 0, 0, 0, 29, 0, 0, 0, + 0, 0, 0, 0, 45, 0, 47, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 75, 76, 77, 0, 0, 0, 0, 0, + 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 109, 0, 0, 0, 0, + 123, 0, 0, 0, 0, 0, 0, 131, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, + 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 85, 86, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 107, 0, 0, 0, 0, 115, 0, + 0, 0, 124, 0, 0, 0, 0, 0, 0, 0, + 0, 136, 0, 0, 0, 141, 0, 0, 0, 25, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 48, 0, 51, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, + 0, 0, 0, 0, 82, 83, 0, 0, 88, 0, + + 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 105, 0, 108, 0, 0, 0, 0, 0, 0, 121, + 0, 0, 0, 0, 0, 0, 0, 133, 134, 0, + 0, 138, 140, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 56, 57, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 110, 111, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, + 0, 0, 0, 0, 66, 0, 0, 0, 0, 72, + 0, 0, 0, 81, 0, 87, 0, 0, 0, 0, + 0, 0, 0, 98, 0, 0, 0, 0, 0, 0, + 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 142, 143, 0, 0, 0, 24, 27, 30, 0, + 0, 0, 0, 38, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 79, 80, 84, 0, 92, 0, 94, 95, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 122, 125, 0, 0, 0, 130, 0, 137, 144, 0, + 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 90, 93, 0, + 0, 0, 0, 0, 104, 0, 0, 116, 0, 0, + 0, 128, 135, 0, 0, 0, 0, 0, 0, 36, + 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, + 0, 0, 0, 0, 0, 67, 0, 69, 70, 0, + 0, 0, 0, 0, 0, 0, 0, 112, 113, 0, + + 0, 119, 0, 127, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, + 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 117, 118, 0, 0, 0, 0, 0, + 0, 35, 0, 0, 0, 0, 0, 0, 0, 54, + 0, 0, 0, 0, 68, 0, 0, 96, 0, 99, + 0, 0, 0, 0, 0, 0, 0, 23, 0, 0, + 0, 0, 0, 0, 0, 0, 43, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 126, 0, 0, 0, 0, 37, 0, 0, 0, 0, + + 0, 0, 0, 0, 61, 71, 74, 97, 0, 0, + 0, 0, 0, 0, 32, 0, 0, 39, 40, 0, + 42, 0, 58, 59, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, + 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, + 106, 0, 0, 34, 0, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 0, 0, 0, 50, 0, 101, + 0, 103, 22, 100, 102, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 5, 1, 1, 1, 1, 6, + 7, 8, 9, 10, 9, 11, 12, 13, 14, 15, + 16, 17, 18, 17, 17, 17, 19, 20, 21, 1, + 22, 1, 1, 1, 23, 23, 23, 23, 23, 23, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 24, 1, 1, 25, 1, 26, 27, 28, 29, + + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 1, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 1, 1, 1, 51, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static const YY_CHAR yy_meta[52] = + { 0, + 1, 1, 2, 2, 1, 1, 1, 1, 3, 1, + 4, 1, 5, 5, 5, 5, 5, 5, 5, 1, + 1, 1, 6, 2, 1, 6, 6, 6, 6, 6, + 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 7, 1, 1, + 1 + } ; + +static const flex_int16_t yy_base[885] = + { 0, + 0, 0, 49, 51, 0, 0, 976, 975, 977, 980, + 974, 980, 980, 47, 980, 980, 980, 46, 967, 46, + 55, 980, 980, 30, 42, 50, 944, 39, 936, 46, + 53, 58, 71, 62, 43, 74, 83, 90, 46, 929, + 91, 929, 940, 980, 0, 980, 980, 96, 980, 980, + 980, 967, 117, 128, 121, 135, 980, 142, 0, 0, + 931, 925, 65, 926, 950, 933, 919, 980, 928, 932, + 921, 133, 137, 933, 916, 931, 913, 137, 913, 980, + 929, 909, 926, 903, 905, 911, 86, 134, 980, 910, + 909, 917, 914, 139, 906, 145, 918, 143, 912, 899, + + 902, 890, 142, 902, 895, 134, 898, 161, 896, 896, + 901, 891, 904, 902, 880, 894, 884, 0, 980, 980, + 980, 980, 980, 980, 185, 192, 199, 0, 886, 906, + 888, 894, 894, 980, 890, 890, 878, 888, 878, 882, + 889, 888, 885, 878, 869, 868, 882, 871, 864, 881, + 866, 874, 862, 980, 876, 873, 871, 874, 873, 857, + 871, 855, 864, 859, 867, 866, 848, 846, 858, 193, + 52, 850, 842, 855, 856, 854, 850, 836, 840, 838, + 841, 848, 846, 833, 980, 840, 834, 842, 843, 843, + 851, 840, 837, 834, 835, 192, 980, 827, 819, 980, + + 211, 815, 847, 164, 818, 823, 980, 829, 165, 809, + 826, 827, 809, 804, 980, 824, 980, 811, 813, 819, + 815, 205, 803, 820, 108, 147, 812, 195, 797, 816, + 800, 794, 980, 980, 980, 204, 813, 809, 808, 214, + 800, 797, 980, 805, 804, 210, 804, 790, 791, 800, + 212, 800, 797, 777, 796, 228, 781, 775, 797, 796, + 980, 779, 791, 806, 785, 777, 779, 980, 785, 218, + 775, 227, 783, 782, 780, 797, 766, 779, 781, 763, + 775, 774, 761, 772, 773, 774, 762, 980, 768, 759, + 766, 766, 769, 763, 748, 762, 749, 759, 742, 759, + + 748, 766, 742, 755, 752, 755, 738, 753, 729, 735, + 750, 749, 748, 727, 728, 728, 980, 980, 733, 725, + 729, 738, 727, 735, 738, 733, 722, 722, 723, 719, + 732, 717, 725, 980, 726, 225, 728, 719, 723, 726, + 713, 705, 980, 718, 734, 204, 701, 715, 698, 714, + 702, 980, 702, 711, 710, 222, 693, 712, 702, 980, + 691, 700, 696, 690, 705, 701, 685, 684, 683, 698, + 700, 683, 980, 689, 695, 695, 686, 685, 676, 687, + 676, 686, 701, 697, 663, 663, 678, 675, 665, 980, + 673, 667, 673, 661, 980, 980, 669, 672, 980, 675, + + 980, 671, 655, 661, 660, 665, 651, 668, 664, 654, + 980, 666, 980, 656, 649, 660, 637, 656, 644, 980, + 639, 646, 657, 632, 640, 635, 632, 980, 980, 648, + 647, 980, 980, 231, 649, 637, 644, 622, 641, 620, + 643, 642, 624, 636, 631, 634, 638, 622, 627, 634, + 620, 613, 625, 980, 980, 613, 612, 615, 623, 609, + 636, 622, 605, 618, 603, 616, 601, 608, 613, 612, + 591, 603, 612, 608, 604, 591, 609, 603, 591, 583, + 601, 228, 604, 980, 980, 593, 598, 590, 581, 583, + 598, 594, 594, 581, 980, 576, 574, 578, 583, 576, + + 583, 577, 583, 582, 980, 581, 561, 566, 578, 570, + 566, 576, 240, 575, 564, 570, 558, 568, 980, 555, + 554, 553, 548, 581, 980, 557, 568, 567, 561, 980, + 560, 546, 545, 980, 557, 980, 549, 537, 544, 553, + 533, 552, 540, 980, 550, 533, 537, 546, 544, 549, + 980, 547, 535, 541, 521, 539, 531, 526, 534, 537, + 522, 980, 980, 533, 521, 515, 980, 980, 980, 530, + 128, 533, 519, 980, 523, 243, 244, 526, 512, 524, + 509, 505, 525, 524, 507, 518, 532, 516, 519, 239, + 519, 518, 980, 980, 980, 512, 980, 512, 980, 980, + + 510, 502, 508, 494, 508, 493, 490, 492, 483, 488, + 980, 980, 484, 499, 485, 980, 483, 980, 980, 500, + 497, 499, 233, 489, 473, 496, 476, 477, 478, 486, + 474, 980, 471, 473, 471, 478, 484, 483, 469, 479, + 494, 463, 476, 470, 463, 473, 472, 980, 980, 463, + 456, 461, 467, 460, 980, 465, 265, 237, 464, 465, + 449, 980, 980, 459, 450, 460, 451, 450, 448, 980, + 441, 456, 457, 436, 435, 103, 133, 154, 980, 180, + 213, 248, 247, 256, 274, 980, 259, 980, 980, 259, + 260, 265, 248, 267, 253, 254, 254, 980, 980, 254, + + 255, 980, 259, 980, 270, 272, 272, 266, 261, 275, + 257, 270, 271, 267, 272, 285, 980, 272, 283, 284, + 285, 273, 280, 980, 276, 282, 283, 272, 296, 274, + 284, 285, 301, 980, 980, 298, 301, 301, 295, 289, + 304, 980, 294, 296, 300, 312, 299, 303, 309, 980, + 305, 306, 300, 319, 980, 320, 321, 980, 320, 980, + 312, 313, 314, 315, 306, 324, 321, 980, 330, 323, + 311, 329, 332, 331, 324, 334, 980, 322, 339, 340, + 341, 319, 320, 321, 335, 335, 330, 337, 332, 334, + 980, 333, 329, 341, 346, 980, 345, 345, 345, 354, + + 359, 337, 338, 360, 980, 980, 980, 980, 345, 360, + 347, 362, 359, 351, 980, 365, 367, 980, 980, 367, + 980, 360, 980, 980, 363, 366, 354, 368, 356, 360, + 361, 366, 363, 366, 371, 980, 372, 377, 374, 379, + 384, 373, 371, 384, 980, 384, 389, 391, 391, 393, + 980, 393, 380, 980, 386, 386, 383, 388, 385, 404, + 980, 399, 387, 400, 389, 402, 398, 980, 393, 980, + 394, 980, 980, 980, 980, 980, 438, 445, 452, 457, + 459, 466, 473, 476 + } ; + +static const flex_int16_t yy_def[885] = + { 0, + 876, 1, 877, 877, 878, 878, 879, 879, 876, 876, + 876, 876, 876, 880, 876, 876, 876, 876, 876, 881, + 881, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 882, 876, 876, 883, 876, 876, + 876, 876, 880, 876, 880, 876, 876, 876, 21, 884, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 882, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 884, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 0, 876, 876, 876, 876, + 876, 876, 876, 876 + } ; + +static const flex_int16_t yy_nxt[1032] = + { 0, + 10, 11, 12, 13, 14, 15, 16, 10, 10, 17, + 18, 19, 20, 21, 21, 21, 21, 21, 21, 10, + 22, 23, 10, 10, 10, 24, 25, 26, 27, 28, + 29, 10, 30, 31, 10, 10, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 10, 43, 10, + 44, 46, 47, 46, 47, 53, 58, 54, 56, 56, + 56, 56, 56, 56, 56, 58, 61, 63, 73, 68, + 92, 77, 48, 93, 48, 62, 244, 74, 64, 110, + 75, 79, 69, 82, 65, 111, 66, 70, 245, 71, + 67, 78, 80, 60, 112, 81, 84, 83, 85, 94, + + 86, 89, 876, 131, 87, 95, 90, 91, 101, 132, + 88, 102, 103, 96, 97, 98, 99, 104, 114, 105, + 100, 115, 120, 106, 161, 53, 121, 54, 162, 876, + 107, 126, 300, 108, 122, 301, 716, 123, 109, 124, + 125, 125, 125, 125, 125, 125, 125, 56, 56, 56, + 56, 56, 56, 56, 127, 127, 127, 127, 127, 127, + 127, 140, 163, 141, 145, 187, 151, 182, 623, 142, + 169, 624, 176, 152, 717, 143, 164, 146, 144, 153, + 170, 172, 177, 188, 183, 184, 190, 173, 277, 282, + 302, 174, 303, 278, 283, 718, 191, 125, 125, 125, + + 125, 125, 125, 125, 201, 201, 201, 201, 201, 201, + 201, 127, 127, 127, 127, 127, 127, 127, 241, 305, + 269, 719, 242, 201, 201, 201, 201, 201, 201, 201, + 311, 424, 270, 294, 271, 306, 243, 272, 316, 295, + 425, 720, 317, 323, 312, 296, 434, 324, 297, 330, + 318, 350, 336, 331, 337, 325, 353, 414, 546, 351, + 354, 415, 435, 499, 547, 548, 575, 500, 628, 630, + 338, 644, 667, 631, 700, 645, 721, 668, 698, 699, + 576, 701, 577, 722, 629, 723, 724, 725, 726, 727, + 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, + + 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, + 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, + 758, 759, 760, 761, 763, 765, 766, 767, 762, 764, + 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, + 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, + 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, + 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, + 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, + 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, + 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, + + 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, + 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, + 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, + 868, 869, 870, 871, 872, 873, 874, 875, 45, 45, + 45, 45, 45, 45, 45, 49, 49, 49, 49, 49, + 49, 49, 50, 50, 50, 50, 50, 50, 50, 55, + 55, 55, 59, 59, 715, 59, 118, 714, 118, 118, + 118, 118, 118, 119, 119, 119, 119, 119, 119, 119, + 128, 128, 713, 712, 711, 710, 709, 708, 707, 706, + 705, 704, 703, 702, 697, 696, 695, 694, 693, 692, + + 691, 690, 689, 688, 687, 686, 685, 684, 683, 682, + 681, 680, 679, 678, 677, 676, 675, 674, 673, 672, + 671, 670, 669, 666, 665, 664, 663, 662, 661, 660, + 659, 658, 657, 656, 655, 654, 653, 652, 651, 650, + 649, 648, 647, 646, 643, 642, 641, 640, 639, 638, + 637, 636, 635, 634, 633, 632, 627, 626, 625, 622, + 621, 620, 619, 618, 617, 616, 615, 614, 613, 612, + 611, 610, 609, 608, 607, 606, 605, 604, 603, 602, + 601, 600, 599, 598, 597, 596, 595, 594, 593, 592, + 591, 590, 589, 588, 587, 586, 585, 584, 583, 582, + + 581, 580, 579, 578, 574, 573, 572, 571, 570, 569, + 568, 567, 566, 565, 564, 563, 562, 561, 560, 559, + 558, 557, 556, 555, 554, 553, 552, 551, 550, 549, + 545, 544, 543, 542, 541, 540, 539, 538, 537, 536, + 535, 534, 533, 532, 531, 530, 529, 528, 527, 526, + 525, 524, 523, 522, 521, 520, 519, 518, 517, 516, + 515, 514, 513, 512, 511, 510, 509, 508, 507, 506, + 505, 504, 503, 502, 501, 498, 497, 496, 495, 494, + 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, + 483, 482, 481, 480, 479, 478, 477, 476, 475, 474, + + 473, 472, 471, 470, 469, 468, 467, 466, 465, 464, + 463, 462, 461, 460, 459, 458, 457, 456, 455, 454, + 453, 452, 451, 450, 449, 448, 447, 446, 445, 444, + 443, 442, 441, 440, 439, 438, 437, 436, 433, 432, + 431, 430, 429, 428, 427, 426, 423, 422, 421, 420, + 419, 418, 417, 416, 413, 412, 411, 410, 409, 408, + 407, 406, 405, 404, 403, 402, 401, 400, 399, 398, + 397, 396, 395, 394, 393, 392, 391, 390, 389, 388, + 387, 386, 385, 384, 383, 382, 381, 380, 379, 378, + 377, 376, 375, 374, 373, 372, 371, 370, 369, 368, + + 367, 366, 365, 364, 363, 362, 361, 360, 359, 358, + 357, 356, 355, 352, 349, 348, 347, 346, 345, 344, + 343, 342, 341, 340, 339, 335, 334, 333, 332, 329, + 328, 327, 326, 322, 321, 320, 319, 315, 314, 313, + 310, 309, 308, 307, 304, 299, 298, 293, 292, 291, + 290, 289, 288, 287, 286, 285, 284, 281, 280, 279, + 276, 275, 274, 273, 268, 267, 266, 265, 264, 263, + 262, 261, 260, 259, 258, 257, 256, 255, 254, 253, + 252, 251, 250, 249, 248, 247, 246, 240, 239, 238, + 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, + + 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, + 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, + 207, 206, 205, 204, 203, 202, 200, 199, 198, 197, + 196, 195, 194, 193, 192, 189, 186, 185, 181, 180, + 179, 178, 175, 171, 168, 167, 166, 165, 160, 159, + 158, 157, 156, 155, 154, 150, 149, 148, 147, 139, + 138, 137, 136, 135, 134, 133, 130, 129, 52, 117, + 116, 113, 76, 72, 57, 52, 876, 51, 51, 9, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876 + } ; + +static const flex_int16_t yy_chk[1032] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 3, 4, 4, 14, 20, 14, 18, 18, + 18, 18, 18, 18, 18, 21, 24, 25, 28, 26, + 35, 30, 3, 35, 4, 24, 171, 28, 25, 39, + 28, 31, 26, 32, 25, 39, 25, 26, 171, 26, + 25, 30, 31, 20, 39, 31, 33, 32, 33, 36, + + 33, 34, 21, 63, 33, 36, 34, 34, 37, 63, + 33, 37, 37, 36, 36, 36, 36, 38, 41, 38, + 36, 41, 48, 38, 87, 53, 48, 53, 87, 55, + 38, 55, 225, 38, 48, 225, 676, 48, 38, 48, + 54, 54, 54, 54, 54, 54, 54, 56, 56, 56, + 56, 56, 56, 56, 58, 58, 58, 58, 58, 58, + 58, 72, 88, 72, 73, 106, 78, 103, 571, 72, + 94, 571, 98, 78, 677, 72, 88, 73, 72, 78, + 94, 96, 98, 106, 103, 103, 108, 96, 204, 209, + 226, 96, 226, 204, 209, 678, 108, 125, 125, 125, + + 125, 125, 125, 125, 126, 126, 126, 126, 126, 126, + 126, 127, 127, 127, 127, 127, 127, 127, 170, 228, + 196, 680, 170, 201, 201, 201, 201, 201, 201, 201, + 236, 346, 196, 222, 196, 228, 170, 196, 240, 222, + 346, 681, 240, 246, 236, 222, 356, 246, 222, 251, + 240, 270, 256, 251, 256, 246, 272, 336, 482, 270, + 272, 336, 356, 434, 482, 482, 513, 434, 576, 577, + 256, 590, 623, 577, 658, 590, 682, 623, 657, 657, + 513, 658, 513, 683, 576, 684, 685, 687, 690, 691, + 692, 693, 694, 695, 696, 697, 700, 701, 703, 705, + + 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, + 716, 718, 719, 720, 721, 722, 723, 725, 726, 727, + 728, 729, 730, 731, 732, 733, 736, 737, 731, 732, + 738, 739, 740, 741, 743, 744, 745, 746, 747, 748, + 749, 751, 752, 753, 754, 756, 757, 759, 761, 762, + 763, 764, 765, 766, 767, 769, 770, 771, 772, 773, + 774, 775, 776, 778, 779, 780, 781, 782, 783, 784, + 785, 786, 787, 788, 789, 790, 792, 793, 794, 795, + 797, 798, 799, 800, 801, 802, 803, 804, 809, 810, + 811, 812, 813, 814, 816, 817, 820, 822, 825, 826, + + 827, 828, 829, 830, 831, 832, 833, 834, 835, 837, + 838, 839, 840, 841, 842, 843, 844, 846, 847, 848, + 849, 850, 852, 853, 855, 856, 857, 858, 859, 860, + 862, 863, 864, 865, 866, 867, 869, 871, 877, 877, + 877, 877, 877, 877, 877, 878, 878, 878, 878, 878, + 878, 878, 879, 879, 879, 879, 879, 879, 879, 880, + 880, 880, 881, 881, 675, 881, 882, 674, 882, 882, + 882, 882, 882, 883, 883, 883, 883, 883, 883, 883, + 884, 884, 673, 672, 671, 669, 668, 667, 666, 665, + 664, 661, 660, 659, 656, 654, 653, 652, 651, 650, + + 647, 646, 645, 644, 643, 642, 641, 640, 639, 638, + 637, 636, 635, 634, 633, 631, 630, 629, 628, 627, + 626, 625, 624, 622, 621, 620, 617, 615, 614, 613, + 610, 609, 608, 607, 606, 605, 604, 603, 602, 601, + 598, 596, 592, 591, 589, 588, 587, 586, 585, 584, + 583, 582, 581, 580, 579, 578, 575, 573, 572, 570, + 566, 565, 564, 561, 560, 559, 558, 557, 556, 555, + 554, 553, 552, 550, 549, 548, 547, 546, 545, 543, + 542, 541, 540, 539, 538, 537, 535, 533, 532, 531, + 529, 528, 527, 526, 524, 523, 522, 521, 520, 518, + + 517, 516, 515, 514, 512, 511, 510, 509, 508, 507, + 506, 504, 503, 502, 501, 500, 499, 498, 497, 496, + 494, 493, 492, 491, 490, 489, 488, 487, 486, 483, + 481, 480, 479, 478, 477, 476, 475, 474, 473, 472, + 471, 470, 469, 468, 467, 466, 465, 464, 463, 462, + 461, 460, 459, 458, 457, 456, 453, 452, 451, 450, + 449, 448, 447, 446, 445, 444, 443, 442, 441, 440, + 439, 438, 437, 436, 435, 431, 430, 427, 426, 425, + 424, 423, 422, 421, 419, 418, 417, 416, 415, 414, + 412, 410, 409, 408, 407, 406, 405, 404, 403, 402, + + 400, 398, 397, 394, 393, 392, 391, 389, 388, 387, + 386, 385, 384, 383, 382, 381, 380, 379, 378, 377, + 376, 375, 374, 372, 371, 370, 369, 368, 367, 366, + 365, 364, 363, 362, 361, 359, 358, 357, 355, 354, + 353, 351, 350, 349, 348, 347, 345, 344, 342, 341, + 340, 339, 338, 337, 335, 333, 332, 331, 330, 329, + 328, 327, 326, 325, 324, 323, 322, 321, 320, 319, + 316, 315, 314, 313, 312, 311, 310, 309, 308, 307, + 306, 305, 304, 303, 302, 301, 300, 299, 298, 297, + 296, 295, 294, 293, 292, 291, 290, 289, 287, 286, + + 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, + 275, 274, 273, 271, 269, 267, 266, 265, 264, 263, + 262, 260, 259, 258, 257, 255, 254, 253, 252, 250, + 249, 248, 247, 245, 244, 242, 241, 239, 238, 237, + 232, 231, 230, 229, 227, 224, 223, 221, 220, 219, + 218, 216, 214, 213, 212, 211, 210, 208, 206, 205, + 203, 202, 199, 198, 195, 194, 193, 192, 191, 190, + 189, 188, 187, 186, 184, 183, 182, 181, 180, 179, + 178, 177, 176, 175, 174, 173, 172, 169, 168, 167, + 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, + + 156, 155, 153, 152, 151, 150, 149, 148, 147, 146, + 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, + 135, 133, 132, 131, 130, 129, 117, 116, 115, 114, + 113, 112, 111, 110, 109, 107, 105, 104, 102, 101, + 100, 99, 97, 95, 93, 92, 91, 90, 86, 85, + 84, 83, 82, 81, 79, 77, 76, 75, 74, 71, + 70, 69, 67, 66, 65, 64, 62, 61, 52, 43, + 42, 40, 29, 27, 19, 11, 9, 8, 7, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, + 876 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int yy_flex_debug; +int yy_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "lexer.l" +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2000-2004 Brian S. Dean + * 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 + * 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$ */ +#line 23 "lexer.l" +/* need this for the call to atof() below */ +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" +#include "config.h" + +#include "config_gram.h" + +#ifndef YYERRCODE +#define YYERRCODE 256 +#endif + +#line 996 "lexer.c" + +/* Bump resources for classic lex. */ +#line 999 "lexer.c" + +#define INITIAL 0 +#define strng 1 +#define incl 2 +#define comment 3 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals ( void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( void ); + +int yyget_debug ( void ); + +void yyset_debug ( int debug_flag ); + +YY_EXTRA_TYPE yyget_extra ( void ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined ); + +FILE *yyget_in ( void ); + +void yyset_in ( FILE * _in_str ); + +FILE *yyget_out ( void ); + +void yyset_out ( FILE * _out_str ); + + int yyget_leng ( void ); + +char *yyget_text ( void ); + +int yyget_lineno ( void ); + +void yyset_lineno ( int _line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( void ); +#else +extern int yywrap ( void ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * ); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( void ); +#else +static int input ( void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + { +#line 57 "lexer.l" + + +#line 1220 "lexer.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 877 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 980 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 59 "lexer.l" +{ yylval = number(yytext); return TKN_NUMBER; } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 60 "lexer.l" +{ yylval = number_real(yytext); return TKN_NUMBER_REAL; } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 61 "lexer.l" +{ yylval = number_real(yytext); return TKN_NUMBER_REAL; } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 62 "lexer.l" +{ yylval = number(yytext); return TKN_NUMBER; } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 63 "lexer.l" +{ yylval = number_real(yytext); return TKN_NUMBER_REAL; } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 64 "lexer.l" +{ yylval = number_real(yytext); return TKN_NUMBER_REAL; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 66 "lexer.l" +{ string_buf_ptr = string_buf; BEGIN(strng); } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 68 "lexer.l" +{ yylval = hexnumber(yytext); return TKN_NUMBER; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 72 "lexer.l" +{ /* The following eats '#' style comments to end of line */ + BEGIN(comment); } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 74 "lexer.l" +{ /* eat comments */ } + YY_BREAK +case 11: +/* rule 11 can match eol */ +YY_RULE_SETUP +#line 75 "lexer.l" +{ lineno++; BEGIN(INITIAL); } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 78 "lexer.l" +{ /* The following eats multiline C style comments */ + int c; + int comment_start; + + comment_start = lineno; + while (1) { + while (((c = input()) != '*') && (c != EOF)) { + /* eat up text of comment, but keep counting lines */ + if (c == '\n') + lineno++; + } + + if (c == '*') { + while ((c = input()) == '*') + ; + if (c == '/') + break; /* found the end */ + } + + if (c == EOF) { + yyerror("EOF in comment (started on line %d)", comment_start); + return YYERRCODE; + } + } + } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 105 "lexer.l" +{ *string_buf_ptr = 0; string_buf_ptr = string_buf; + yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 107 "lexer.l" +*string_buf_ptr++ = '\n'; + YY_BREAK +case 15: +YY_RULE_SETUP +#line 108 "lexer.l" +*string_buf_ptr++ = '\t'; + YY_BREAK +case 16: +YY_RULE_SETUP +#line 109 "lexer.l" +*string_buf_ptr++ = '\r'; + YY_BREAK +case 17: +YY_RULE_SETUP +#line 110 "lexer.l" +*string_buf_ptr++ = '\b'; + YY_BREAK +case 18: +YY_RULE_SETUP +#line 111 "lexer.l" +*string_buf_ptr++ = '\f'; + YY_BREAK +case 19: +/* rule 19 can match eol */ +YY_RULE_SETUP +#line 112 "lexer.l" +*(string_buf_ptr++) = yytext[1]; + YY_BREAK +case 20: +YY_RULE_SETUP +#line 113 "lexer.l" +{ char *yptr = yytext; while (*yptr) + *(string_buf_ptr++) = *(yptr++); } + YY_BREAK +case 21: +/* rule 21 can match eol */ +YY_RULE_SETUP +#line 116 "lexer.l" +{ yyerror("unterminated character constant"); + return YYERRCODE; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 119 "lexer.l" +{ yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 120 "lexer.l" +{ yylval=NULL; return K_AVR910_DEVCODE; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 121 "lexer.l" +{ yylval=NULL; return K_PAGE_SIZE; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 122 "lexer.l" +{ yylval=NULL; return K_PAGED; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 123 "lexer.l" +{ yylval=NULL; return K_BAUDRATE; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 124 "lexer.l" +{ yylval=NULL; return K_BLOCKSIZE; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 125 "lexer.l" +{ yylval=NULL; return K_BS2; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 126 "lexer.l" +{ yylval=NULL; return K_BUFF; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 127 "lexer.l" +{ yylval=NULL; return K_BYTEDELAY; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 128 "lexer.l" +{ yylval=new_token(K_CHIP_ERASE); return K_CHIP_ERASE; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 129 "lexer.l" +{ yylval=NULL; return K_CHIP_ERASE_DELAY; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 130 "lexer.l" +{ yylval=NULL; return K_CHIPERASEPOLLTIMEOUT; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 131 "lexer.l" +{ yylval=NULL; return K_CHIPERASEPULSEWIDTH; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 132 "lexer.l" +{ yylval=NULL; return K_CHIPERASETIME; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 133 "lexer.l" +{ yylval=NULL; return K_CMDEXEDELAY; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 134 "lexer.l" +{ yylval=NULL; return K_CONNTYPE; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 135 "lexer.l" +{ yylval=new_token(K_DEDICATED); return K_DEDICATED; } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 136 "lexer.l" +{ yylval=NULL; return K_DEFAULT_BITCLOCK; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 137 "lexer.l" +{ yylval=NULL; return K_DEFAULT_PARALLEL; } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 138 "lexer.l" +{ yylval=NULL; return K_DEFAULT_PROGRAMMER; } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 139 "lexer.l" +{ yylval=NULL; return K_DEFAULT_SAFEMODE; } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 140 "lexer.l" +{ yylval=NULL; return K_DEFAULT_SERIAL; } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 141 "lexer.l" +{ yylval=NULL; return K_DELAY; } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 142 "lexer.l" +{ yylval=NULL; return K_DESC; } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 143 "lexer.l" +{ yylval=NULL; return K_DEVICECODE; } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 144 "lexer.l" +{ yylval=NULL; return K_EECR; } + YY_BREAK +case 48: +YY_RULE_SETUP +#line 145 "lexer.l" +{ yylval=NULL; return K_EEPROM; } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 146 "lexer.l" +{ yylval=NULL; return K_EEPROM_INSTR; } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 147 "lexer.l" +{ yylval=NULL; return K_ENABLEPAGEPROGRAMMING; } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 148 "lexer.l" +{ yylval=NULL; return K_ERRLED; } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 149 "lexer.l" +{ yylval=NULL; return K_FLASH; } + YY_BREAK +case 53: +YY_RULE_SETUP +#line 150 "lexer.l" +{ yylval=NULL; return K_FLASH_INSTR; } + YY_BREAK +case 54: +YY_RULE_SETUP +#line 151 "lexer.l" +{ yylval=NULL; return K_HAS_DW; } + YY_BREAK +case 55: +YY_RULE_SETUP +#line 152 "lexer.l" +{ yylval=NULL; return K_HAS_JTAG; } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 153 "lexer.l" +{ yylval=NULL; return K_HAS_PDI; } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 154 "lexer.l" +{ yylval=NULL; return K_HAS_TPI; } + YY_BREAK +case 58: +YY_RULE_SETUP +#line 155 "lexer.l" +{ yylval=NULL; return K_HVENTERSTABDELAY; } + YY_BREAK +case 59: +YY_RULE_SETUP +#line 156 "lexer.l" +{ yylval=NULL; return K_HVLEAVESTABDELAY; } + YY_BREAK +case 60: +YY_RULE_SETUP +#line 157 "lexer.l" +{ yylval=NULL; return K_HVSP_CONTROLSTACK; } + YY_BREAK +case 61: +YY_RULE_SETUP +#line 158 "lexer.l" +{ yylval=NULL; return K_HVSPCMDEXEDELAY; } + YY_BREAK +case 62: +YY_RULE_SETUP +#line 159 "lexer.l" +{ yylval=NULL; return K_ID; } + YY_BREAK +case 63: +YY_RULE_SETUP +#line 160 "lexer.l" +{ yylval=NULL; return K_IDR; } + YY_BREAK +case 64: +YY_RULE_SETUP +#line 161 "lexer.l" +{ yylval=new_token(K_IO); return K_IO; } + YY_BREAK +case 65: +YY_RULE_SETUP +#line 162 "lexer.l" +{ yylval=NULL; return K_IS_AT90S1200; } + YY_BREAK +case 66: +YY_RULE_SETUP +#line 163 "lexer.l" +{ yylval=NULL; return K_IS_AVR32; } + YY_BREAK +case 67: +YY_RULE_SETUP +#line 164 "lexer.l" +{ yylval=NULL; return K_LATCHCYCLES; } + YY_BREAK +case 68: +YY_RULE_SETUP +#line 165 "lexer.l" +{ yylval=new_token(K_LOAD_EXT_ADDR); return K_LOAD_EXT_ADDR; } + YY_BREAK +case 69: +YY_RULE_SETUP +#line 166 "lexer.l" +{ yylval=new_token(K_LOADPAGE_HI); return K_LOADPAGE_HI; } + YY_BREAK +case 70: +YY_RULE_SETUP +#line 167 "lexer.l" +{ yylval=new_token(K_LOADPAGE_LO); return K_LOADPAGE_LO; } + YY_BREAK +case 71: +YY_RULE_SETUP +#line 168 "lexer.l" +{ yylval=NULL; return K_MAX_WRITE_DELAY; } + YY_BREAK +case 72: +YY_RULE_SETUP +#line 169 "lexer.l" +{ yylval=NULL; return K_MCU_BASE; } + YY_BREAK +case 73: +YY_RULE_SETUP +#line 170 "lexer.l" +{ yylval=NULL; return K_MEMORY; } + YY_BREAK +case 74: +YY_RULE_SETUP +#line 171 "lexer.l" +{ yylval=NULL; return K_MIN_WRITE_DELAY; } + YY_BREAK +case 75: +YY_RULE_SETUP +#line 172 "lexer.l" +{ yylval=NULL; return K_MISO; } + YY_BREAK +case 76: +YY_RULE_SETUP +#line 173 "lexer.l" +{ yylval=NULL; return K_MODE; } + YY_BREAK +case 77: +YY_RULE_SETUP +#line 174 "lexer.l" +{ yylval=NULL; return K_MOSI; } + YY_BREAK +case 78: +YY_RULE_SETUP +#line 175 "lexer.l" +{ yylval=new_token(K_NO); return K_NO; } + YY_BREAK +case 79: +YY_RULE_SETUP +#line 176 "lexer.l" +{ yylval=NULL; return K_NUM_PAGES; } + YY_BREAK +case 80: +YY_RULE_SETUP +#line 177 "lexer.l" +{ yylval=NULL; return K_NUM_PAGES; } + YY_BREAK +case 81: +YY_RULE_SETUP +#line 178 "lexer.l" +{ yylval=NULL; return K_NVM_BASE; } + YY_BREAK +case 82: +YY_RULE_SETUP +#line 179 "lexer.l" +{ yylval=NULL; return K_OCDREV; } + YY_BREAK +case 83: +YY_RULE_SETUP +#line 180 "lexer.l" +{ yylval=NULL; return K_OFFSET; } + YY_BREAK +case 84: +YY_RULE_SETUP +#line 181 "lexer.l" +{ yylval=NULL; return K_PAGE_SIZE; } + YY_BREAK +case 85: +YY_RULE_SETUP +#line 182 "lexer.l" +{ yylval=NULL; return K_PAGED; } + YY_BREAK +case 86: +YY_RULE_SETUP +#line 183 "lexer.l" +{ yylval=NULL; return K_PAGEL; } + YY_BREAK +case 87: +YY_RULE_SETUP +#line 184 "lexer.l" +{ yylval=NULL; return K_PARALLEL; } + YY_BREAK +case 88: +YY_RULE_SETUP +#line 185 "lexer.l" +{ yylval=NULL; return K_PARENT; } + YY_BREAK +case 89: +YY_RULE_SETUP +#line 186 "lexer.l" +{ yylval=NULL; return K_PART; } + YY_BREAK +case 90: +YY_RULE_SETUP +#line 187 "lexer.l" +{ yylval=new_token(K_PGM_ENABLE); return K_PGM_ENABLE; } + YY_BREAK +case 91: +YY_RULE_SETUP +#line 188 "lexer.l" +{ yylval=NULL; return K_PGMLED; } + YY_BREAK +case 92: +YY_RULE_SETUP +#line 189 "lexer.l" +{ yylval=NULL; return K_POLLINDEX; } + YY_BREAK +case 93: +YY_RULE_SETUP +#line 190 "lexer.l" +{ yylval=NULL; return K_POLLMETHOD; } + YY_BREAK +case 94: +YY_RULE_SETUP +#line 191 "lexer.l" +{ yylval=NULL; return K_POLLVALUE; } + YY_BREAK +case 95: +YY_RULE_SETUP +#line 192 "lexer.l" +{ yylval=NULL; return K_POSTDELAY; } + YY_BREAK +case 96: +YY_RULE_SETUP +#line 193 "lexer.l" +{ yylval=NULL; return K_POWEROFFDELAY; } + YY_BREAK +case 97: +YY_RULE_SETUP +#line 194 "lexer.l" +{ yylval=NULL; return K_PP_CONTROLSTACK; } + YY_BREAK +case 98: +YY_RULE_SETUP +#line 195 "lexer.l" +{ yylval=NULL; return K_PREDELAY; } + YY_BREAK +case 99: +YY_RULE_SETUP +#line 196 "lexer.l" +{ yylval=NULL; return K_PROGMODEDELAY; } + YY_BREAK +case 100: +YY_RULE_SETUP +#line 197 "lexer.l" +{ yylval=NULL; return K_PROGRAMFUSEPOLLTIMEOUT; } + YY_BREAK +case 101: +YY_RULE_SETUP +#line 198 "lexer.l" +{ yylval=NULL; return K_PROGRAMFUSEPULSEWIDTH; } + YY_BREAK +case 102: +YY_RULE_SETUP +#line 199 "lexer.l" +{ yylval=NULL; return K_PROGRAMLOCKPOLLTIMEOUT; } + YY_BREAK +case 103: +YY_RULE_SETUP +#line 200 "lexer.l" +{ yylval=NULL; return K_PROGRAMLOCKPULSEWIDTH; } + YY_BREAK +case 104: +YY_RULE_SETUP +#line 201 "lexer.l" +{ yylval=NULL; return K_PROGRAMMER; } + YY_BREAK +case 105: +YY_RULE_SETUP +#line 202 "lexer.l" +{ yylval=new_token(K_PSEUDO); return K_PSEUDO; } + YY_BREAK +case 106: +YY_RULE_SETUP +#line 203 "lexer.l" +{ yylval=NULL; return K_PWROFF_AFTER_WRITE; } + YY_BREAK +case 107: +YY_RULE_SETUP +#line 204 "lexer.l" +{ yylval=NULL; return K_RAMPZ; } + YY_BREAK +case 108: +YY_RULE_SETUP +#line 205 "lexer.l" +{ yylval=NULL; return K_RDYLED; } + YY_BREAK +case 109: +YY_RULE_SETUP +#line 206 "lexer.l" +{ yylval=new_token(K_READ); return K_READ; } + YY_BREAK +case 110: +YY_RULE_SETUP +#line 207 "lexer.l" +{ yylval=new_token(K_READ_HI); return K_READ_HI; } + YY_BREAK +case 111: +YY_RULE_SETUP +#line 208 "lexer.l" +{ yylval=new_token(K_READ_LO); return K_READ_LO; } + YY_BREAK +case 112: +YY_RULE_SETUP +#line 209 "lexer.l" +{ yylval=NULL; return K_READBACK_P1; } + YY_BREAK +case 113: +YY_RULE_SETUP +#line 210 "lexer.l" +{ yylval=NULL; return K_READBACK_P2; } + YY_BREAK +case 114: +YY_RULE_SETUP +#line 211 "lexer.l" +{ yylval=NULL; return K_READSIZE; } + YY_BREAK +case 115: +YY_RULE_SETUP +#line 212 "lexer.l" +{ yylval=new_token(K_RESET); return K_RESET; } + YY_BREAK +case 116: +YY_RULE_SETUP +#line 213 "lexer.l" +{ yylval=NULL; return K_RESETDELAY; } + YY_BREAK +case 117: +YY_RULE_SETUP +#line 214 "lexer.l" +{ yylval=NULL; return K_RESETDELAYMS; } + YY_BREAK +case 118: +YY_RULE_SETUP +#line 215 "lexer.l" +{ yylval=NULL; return K_RESETDELAYUS; } + YY_BREAK +case 119: +YY_RULE_SETUP +#line 216 "lexer.l" +{ yylval=NULL; return K_RETRY_PULSE; } + YY_BREAK +case 120: +YY_RULE_SETUP +#line 217 "lexer.l" +{ yylval=new_token(K_SCK); return K_SCK; } + YY_BREAK +case 121: +YY_RULE_SETUP +#line 218 "lexer.l" +{ yylval=NULL; return K_SERIAL; } + YY_BREAK +case 122: +YY_RULE_SETUP +#line 219 "lexer.l" +{ yylval=NULL; return K_SIGNATURE; } + YY_BREAK +case 123: +YY_RULE_SETUP +#line 220 "lexer.l" +{ yylval=NULL; return K_SIZE; } + YY_BREAK +case 124: +YY_RULE_SETUP +#line 221 "lexer.l" +{ yylval=NULL; return K_SPMCR; } + YY_BREAK +case 125: +YY_RULE_SETUP +#line 222 "lexer.l" +{ yylval=NULL; return K_STABDELAY; } + YY_BREAK +case 126: +YY_RULE_SETUP +#line 223 "lexer.l" +{ yylval=NULL; return K_STK500_DEVCODE; } + YY_BREAK +case 127: +YY_RULE_SETUP +#line 224 "lexer.l" +{ yylval=NULL; return K_SYNCHCYCLES; } + YY_BREAK +case 128: +YY_RULE_SETUP +#line 225 "lexer.l" +{ yylval=NULL; return K_SYNCHLOOPS; } + YY_BREAK +case 129: +YY_RULE_SETUP +#line 226 "lexer.l" +{ yylval=NULL; return K_TIMEOUT; } + YY_BREAK +case 130: +YY_RULE_SETUP +#line 227 "lexer.l" +{ yylval=NULL; return K_TOGGLEVTG; } + YY_BREAK +case 131: +YY_RULE_SETUP +#line 228 "lexer.l" +{ yylval=NULL; return K_TYPE; } + YY_BREAK +case 132: +YY_RULE_SETUP +#line 229 "lexer.l" +{ yylval=NULL; return K_USB; } + YY_BREAK +case 133: +YY_RULE_SETUP +#line 230 "lexer.l" +{ yylval=NULL; return K_USBDEV; } + YY_BREAK +case 134: +YY_RULE_SETUP +#line 231 "lexer.l" +{ yylval=NULL; return K_USBPID; } + YY_BREAK +case 135: +YY_RULE_SETUP +#line 232 "lexer.l" +{ yylval=NULL; return K_USBPRODUCT; } + YY_BREAK +case 136: +YY_RULE_SETUP +#line 233 "lexer.l" +{ yylval=NULL; return K_USBSN; } + YY_BREAK +case 137: +YY_RULE_SETUP +#line 234 "lexer.l" +{ yylval=NULL; return K_USBVENDOR; } + YY_BREAK +case 138: +YY_RULE_SETUP +#line 235 "lexer.l" +{ yylval=NULL; return K_USBVID; } + YY_BREAK +case 139: +YY_RULE_SETUP +#line 236 "lexer.l" +{ yylval=NULL; return K_VCC; } + YY_BREAK +case 140: +YY_RULE_SETUP +#line 237 "lexer.l" +{ yylval=NULL; return K_VFYLED; } + YY_BREAK +case 141: +YY_RULE_SETUP +#line 238 "lexer.l" +{ yylval=new_token(K_WRITE); return K_WRITE; } + YY_BREAK +case 142: +YY_RULE_SETUP +#line 239 "lexer.l" +{ yylval=new_token(K_WRITE_HI); return K_WRITE_HI; } + YY_BREAK +case 143: +YY_RULE_SETUP +#line 240 "lexer.l" +{ yylval=new_token(K_WRITE_LO); return K_WRITE_LO; } + YY_BREAK +case 144: +YY_RULE_SETUP +#line 241 "lexer.l" +{ yylval=new_token(K_WRITEPAGE); return K_WRITEPAGE; } + YY_BREAK +case 145: +YY_RULE_SETUP +#line 242 "lexer.l" +{ yylval=new_token(K_YES); return K_YES; } + YY_BREAK +case 146: +YY_RULE_SETUP +#line 244 "lexer.l" +{ yylval = NULL; pyytext(); return TKN_COMMA; } + YY_BREAK +case 147: +YY_RULE_SETUP +#line 245 "lexer.l" +{ yylval = NULL; pyytext(); return TKN_EQUAL; } + YY_BREAK +case 148: +YY_RULE_SETUP +#line 246 "lexer.l" +{ yylval = NULL; pyytext(); return TKN_SEMI; } + YY_BREAK +case 149: +YY_RULE_SETUP +#line 247 "lexer.l" +{ yylval = NULL; pyytext(); return TKN_TILDE; } + YY_BREAK +case 150: +YY_RULE_SETUP +#line 248 "lexer.l" +{ yylval = NULL; pyytext(); return TKN_LEFT_PAREN; } + YY_BREAK +case 151: +YY_RULE_SETUP +#line 249 "lexer.l" +{ yylval = NULL; pyytext(); return TKN_RIGHT_PAREN; } + YY_BREAK +case 152: +/* rule 152 can match eol */ +YY_RULE_SETUP +#line 251 "lexer.l" +{ lineno++; } + YY_BREAK +case 153: +YY_RULE_SETUP +#line 252 "lexer.l" +{ /* ignore whitespace */ } + YY_BREAK +case 154: +YY_RULE_SETUP +#line 254 "lexer.l" +{ yyerror("possible old-style config file entry\n" + " Update your config file (see " CONFIG_DIR + "/avrdude.conf.sample for a sample)"); + return YYERRCODE; } + YY_BREAK +case 155: +YY_RULE_SETUP +#line 259 "lexer.l" +{ return YYERRCODE; } + YY_BREAK +case 156: +YY_RULE_SETUP +#line 261 "lexer.l" +ECHO; + YY_BREAK +#line 2092 "lexer.c" +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(strng): +case YY_STATE_EOF(incl): +case YY_STATE_EOF(comment): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + yy_state_type yy_current_state; + char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 877 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 877 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 876); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf ); + + yyfree( (void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr ) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg ) +{ + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} + +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} + +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} + +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} + +/** Get the current token. + * + */ + +char *yyget_text (void) +{ + return yytext; +} + +/** Set the current line number. + * @param _line_number line number + * + */ +void yyset_lineno (int _line_number ) +{ + + yylineno = _line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str ) +{ + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str ) +{ + yyout = _out_str ; +} + +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int _bdebug ) +{ + yy_flex_debug = _bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = NULL; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = NULL; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n ) +{ + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s ) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 261 "lexer.l" + + + diff --git a/xs/src/avrdude/lexer.l b/xs/src/avrdude/lexer.l new file mode 100644 index 000000000..34af33d64 --- /dev/null +++ b/xs/src/avrdude/lexer.l @@ -0,0 +1,262 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2000-2004 Brian S. Dean + * 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 + * 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$ */ + +%{ +/* need this for the call to atof() below */ +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" +#include "config.h" + +#include "config_gram.h" + +#ifndef YYERRCODE +#define YYERRCODE 256 +#endif + +%} + +DIGIT [0-9] +HEXDIGIT [0-9a-fA-F] +SIGN [+-] + +%x strng +%x incl +%x comment +%option nounput + +/* Bump resources for classic lex. */ +%e2000 +%p10000 +%n1000 + +%% + +#{SIGN}*{DIGIT}+ { yylval = number(yytext); return TKN_NUMBER; } +#{SIGN}*{DIGIT}+"."{DIGIT}* { yylval = number_real(yytext); return TKN_NUMBER_REAL; } +#{SIGN}*"."{DIGIT}* { yylval = number_real(yytext); return TKN_NUMBER_REAL; } +{DIGIT}+ { yylval = number(yytext); return TKN_NUMBER; } +{DIGIT}+"."{DIGIT}* { yylval = number_real(yytext); return TKN_NUMBER_REAL; } +"."{DIGIT}+ { yylval = number_real(yytext); return TKN_NUMBER_REAL; } + +"\"" { string_buf_ptr = string_buf; BEGIN(strng); } + +0x{HEXDIGIT}+ { yylval = hexnumber(yytext); return TKN_NUMBER; } + + + +# { /* The following eats '#' style comments to end of line */ + BEGIN(comment); } +[^\n] { /* eat comments */ } +\n { lineno++; BEGIN(INITIAL); } + + +"/*" { /* The following eats multiline C style comments */ + int c; + int comment_start; + + comment_start = lineno; + while (1) { + while (((c = input()) != '*') && (c != EOF)) { + /* eat up text of comment, but keep counting lines */ + if (c == '\n') + lineno++; + } + + if (c == '*') { + while ((c = input()) == '*') + ; + if (c == '/') + break; /* found the end */ + } + + if (c == EOF) { + yyerror("EOF in comment (started on line %d)", comment_start); + return YYERRCODE; + } + } + } + + +\" { *string_buf_ptr = 0; string_buf_ptr = string_buf; + yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; } +\\n *string_buf_ptr++ = '\n'; +\\t *string_buf_ptr++ = '\t'; +\\r *string_buf_ptr++ = '\r'; +\\b *string_buf_ptr++ = '\b'; +\\f *string_buf_ptr++ = '\f'; +\\(.|\n) *(string_buf_ptr++) = yytext[1]; +[^\\\n\"]+ { char *yptr = yytext; while (*yptr) + *(string_buf_ptr++) = *(yptr++); } + +\n { yyerror("unterminated character constant"); + return YYERRCODE; } + +allowfullpagebitstream { yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; } +avr910_devcode { yylval=NULL; return K_AVR910_DEVCODE; } +bank_size { yylval=NULL; return K_PAGE_SIZE; } +banked { yylval=NULL; return K_PAGED; } +baudrate { yylval=NULL; return K_BAUDRATE; } +blocksize { yylval=NULL; return K_BLOCKSIZE; } +bs2 { yylval=NULL; return K_BS2; } +buff { yylval=NULL; return K_BUFF; } +bytedelay { yylval=NULL; return K_BYTEDELAY; } +chip_erase { yylval=new_token(K_CHIP_ERASE); return K_CHIP_ERASE; } +chip_erase_delay { yylval=NULL; return K_CHIP_ERASE_DELAY; } +chiperasepolltimeout { yylval=NULL; return K_CHIPERASEPOLLTIMEOUT; } +chiperasepulsewidth { yylval=NULL; return K_CHIPERASEPULSEWIDTH; } +chiperasetime { yylval=NULL; return K_CHIPERASETIME; } +cmdexedelay { yylval=NULL; return K_CMDEXEDELAY; } +connection_type { yylval=NULL; return K_CONNTYPE; } +dedicated { yylval=new_token(K_DEDICATED); return K_DEDICATED; } +default_bitclock { yylval=NULL; return K_DEFAULT_BITCLOCK; } +default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; } +default_programmer { yylval=NULL; return K_DEFAULT_PROGRAMMER; } +default_safemode { yylval=NULL; return K_DEFAULT_SAFEMODE; } +default_serial { yylval=NULL; return K_DEFAULT_SERIAL; } +delay { yylval=NULL; return K_DELAY; } +desc { yylval=NULL; return K_DESC; } +devicecode { yylval=NULL; return K_DEVICECODE; } +eecr { yylval=NULL; return K_EECR; } +eeprom { yylval=NULL; return K_EEPROM; } +eeprom_instr { yylval=NULL; return K_EEPROM_INSTR; } +enablepageprogramming { yylval=NULL; return K_ENABLEPAGEPROGRAMMING; } +errled { yylval=NULL; return K_ERRLED; } +flash { yylval=NULL; return K_FLASH; } +flash_instr { yylval=NULL; return K_FLASH_INSTR; } +has_debugwire { yylval=NULL; return K_HAS_DW; } +has_jtag { yylval=NULL; return K_HAS_JTAG; } +has_pdi { yylval=NULL; return K_HAS_PDI; } +has_tpi { yylval=NULL; return K_HAS_TPI; } +hventerstabdelay { yylval=NULL; return K_HVENTERSTABDELAY; } +hvleavestabdelay { yylval=NULL; return K_HVLEAVESTABDELAY; } +hvsp_controlstack { yylval=NULL; return K_HVSP_CONTROLSTACK; } +hvspcmdexedelay { yylval=NULL; return K_HVSPCMDEXEDELAY; } +id { yylval=NULL; return K_ID; } +idr { yylval=NULL; return K_IDR; } +io { yylval=new_token(K_IO); return K_IO; } +is_at90s1200 { yylval=NULL; return K_IS_AT90S1200; } +is_avr32 { yylval=NULL; return K_IS_AVR32; } +latchcycles { yylval=NULL; return K_LATCHCYCLES; } +load_ext_addr { yylval=new_token(K_LOAD_EXT_ADDR); return K_LOAD_EXT_ADDR; } +loadpage_hi { yylval=new_token(K_LOADPAGE_HI); return K_LOADPAGE_HI; } +loadpage_lo { yylval=new_token(K_LOADPAGE_LO); return K_LOADPAGE_LO; } +max_write_delay { yylval=NULL; return K_MAX_WRITE_DELAY; } +mcu_base { yylval=NULL; return K_MCU_BASE; } +memory { yylval=NULL; return K_MEMORY; } +min_write_delay { yylval=NULL; return K_MIN_WRITE_DELAY; } +miso { yylval=NULL; return K_MISO; } +mode { yylval=NULL; return K_MODE; } +mosi { yylval=NULL; return K_MOSI; } +no { yylval=new_token(K_NO); return K_NO; } +num_banks { yylval=NULL; return K_NUM_PAGES; } +num_pages { yylval=NULL; return K_NUM_PAGES; } +nvm_base { yylval=NULL; return K_NVM_BASE; } +ocdrev { yylval=NULL; return K_OCDREV; } +offset { yylval=NULL; return K_OFFSET; } +page_size { yylval=NULL; return K_PAGE_SIZE; } +paged { yylval=NULL; return K_PAGED; } +pagel { yylval=NULL; return K_PAGEL; } +parallel { yylval=NULL; return K_PARALLEL; } +parent { yylval=NULL; return K_PARENT; } +part { yylval=NULL; return K_PART; } +pgm_enable { yylval=new_token(K_PGM_ENABLE); return K_PGM_ENABLE; } +pgmled { yylval=NULL; return K_PGMLED; } +pollindex { yylval=NULL; return K_POLLINDEX; } +pollmethod { yylval=NULL; return K_POLLMETHOD; } +pollvalue { yylval=NULL; return K_POLLVALUE; } +postdelay { yylval=NULL; return K_POSTDELAY; } +poweroffdelay { yylval=NULL; return K_POWEROFFDELAY; } +pp_controlstack { yylval=NULL; return K_PP_CONTROLSTACK; } +predelay { yylval=NULL; return K_PREDELAY; } +progmodedelay { yylval=NULL; return K_PROGMODEDELAY; } +programfusepolltimeout { yylval=NULL; return K_PROGRAMFUSEPOLLTIMEOUT; } +programfusepulsewidth { yylval=NULL; return K_PROGRAMFUSEPULSEWIDTH; } +programlockpolltimeout { yylval=NULL; return K_PROGRAMLOCKPOLLTIMEOUT; } +programlockpulsewidth { yylval=NULL; return K_PROGRAMLOCKPULSEWIDTH; } +programmer { yylval=NULL; return K_PROGRAMMER; } +pseudo { yylval=new_token(K_PSEUDO); return K_PSEUDO; } +pwroff_after_write { yylval=NULL; return K_PWROFF_AFTER_WRITE; } +rampz { yylval=NULL; return K_RAMPZ; } +rdyled { yylval=NULL; return K_RDYLED; } +read { yylval=new_token(K_READ); return K_READ; } +read_hi { yylval=new_token(K_READ_HI); return K_READ_HI; } +read_lo { yylval=new_token(K_READ_LO); return K_READ_LO; } +readback_p1 { yylval=NULL; return K_READBACK_P1; } +readback_p2 { yylval=NULL; return K_READBACK_P2; } +readsize { yylval=NULL; return K_READSIZE; } +reset { yylval=new_token(K_RESET); return K_RESET; } +resetdelay { yylval=NULL; return K_RESETDELAY; } +resetdelayms { yylval=NULL; return K_RESETDELAYMS; } +resetdelayus { yylval=NULL; return K_RESETDELAYUS; } +retry_pulse { yylval=NULL; return K_RETRY_PULSE; } +sck { yylval=new_token(K_SCK); return K_SCK; } +serial { yylval=NULL; return K_SERIAL; } +signature { yylval=NULL; return K_SIGNATURE; } +size { yylval=NULL; return K_SIZE; } +spmcr { yylval=NULL; return K_SPMCR; } +stabdelay { yylval=NULL; return K_STABDELAY; } +stk500_devcode { yylval=NULL; return K_STK500_DEVCODE; } +synchcycles { yylval=NULL; return K_SYNCHCYCLES; } +synchloops { yylval=NULL; return K_SYNCHLOOPS; } +timeout { yylval=NULL; return K_TIMEOUT; } +togglevtg { yylval=NULL; return K_TOGGLEVTG; } +type { yylval=NULL; return K_TYPE; } +usb { yylval=NULL; return K_USB; } +usbdev { yylval=NULL; return K_USBDEV; } +usbpid { yylval=NULL; return K_USBPID; } +usbproduct { yylval=NULL; return K_USBPRODUCT; } +usbsn { yylval=NULL; return K_USBSN; } +usbvendor { yylval=NULL; return K_USBVENDOR; } +usbvid { yylval=NULL; return K_USBVID; } +vcc { yylval=NULL; return K_VCC; } +vfyled { yylval=NULL; return K_VFYLED; } +write { yylval=new_token(K_WRITE); return K_WRITE; } +write_hi { yylval=new_token(K_WRITE_HI); return K_WRITE_HI; } +write_lo { yylval=new_token(K_WRITE_LO); return K_WRITE_LO; } +writepage { yylval=new_token(K_WRITEPAGE); return K_WRITEPAGE; } +yes { yylval=new_token(K_YES); return K_YES; } + +"," { yylval = NULL; pyytext(); return TKN_COMMA; } +"=" { yylval = NULL; pyytext(); return TKN_EQUAL; } +";" { yylval = NULL; pyytext(); return TKN_SEMI; } +"~" { yylval = NULL; pyytext(); return TKN_TILDE; } +"(" { yylval = NULL; pyytext(); return TKN_LEFT_PAREN; } +")" { yylval = NULL; pyytext(); return TKN_RIGHT_PAREN; } + +"\n" { lineno++; } +[ \r\t]+ { /* ignore whitespace */ } + +c: { yyerror("possible old-style config file entry\n" + " Update your config file (see " CONFIG_DIR + "/avrdude.conf.sample for a sample)"); + return YYERRCODE; } + +. { return YYERRCODE; } + +%% + diff --git a/xs/src/avrdude/libavrdude.h b/xs/src/avrdude/libavrdude.h new file mode 100644 index 000000000..e8197f9c2 --- /dev/null +++ b/xs/src/avrdude/libavrdude.h @@ -0,0 +1,972 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 libavrdude_h +#define libavrdude_h + +/* XXX should go away */ +#include "ac_cfg.h" + +#include +#include +#include + +/* lets try to select at least 32 bits */ +#ifdef HAVE_STDINT_H +#include +typedef uint32_t pinmask_t; +#else +#if UINT_MAX >= 0xFFFFFFFF +typedef unsigned int pinmask_t; +#else +typedef unsigned long pinmask_t; +#endif +#endif + + +// PATH_MAX is used throughout avrdude for various purposes. +// It is problematic though as it may or may not be defined on various systems +// and even when it is, it tends to be somewhat arbitrary. +// So instead we just define a value here that should be fine in most cases. +#ifdef PATH_MAX +#undef PATH_MAX +#endif +#define PATH_MAX 4096 + + +/* formerly lists.h */ + +/*---------------------------------------------------------------------- + General purpose linked list routines - header file declarations. + + Author : Brian Dean + Date : 10 January, 1990 + ----------------------------------------------------------------------*/ + +typedef void * LISTID; +typedef void * LNODEID; + + +/*---------------------------------------------------------------------- + several defines to access the LIST structure as as stack or a queue + --- use for program readability + ----------------------------------------------------------------------*/ +#define STACKID LISTID +#define SNODEID LNODEID +#define QUEUEID LISTID +#define QNODEID LNODEID + + +#define PUSH(s,d) lins_n(s,d,1) /* push 'd' onto the stack */ +#define POP(s) lrmv_n(s,1) /* pop the stack */ +#define LOOKSTACK(s) lget_n(s,1) /* look at the top of the stack, + but don't pop */ + + +#define ENQUEUE(q,d) lins_n(q,d,1) /* put 'd' on the end of the queue */ +#define DEQUEUE(q) lrmv(q) /* remove next item from the front of + the queue */ +#define REQUEUE(q,d) ladd(q,d) /* re-insert (push) item back on the + front of the queue */ +#define LOOKQUEUE(q) lget(q) /* return next item on the queue, + but don't dequeue */ +#define QUEUELEN(q) lsize(q) /* length of the queue */ + + +#define LISTADD(l,d) ladd(l,d) /* add to end of the list */ +#define LISTRMV(l,d) lrmv_d(l,d) /* remove from end of the list */ + + +#ifdef __cplusplus +extern "C" { +#endif + +/* .................... Function Prototypes .................... */ + +LISTID lcreat ( void * liststruct, int poolsize ); +void ldestroy ( LISTID lid ); +void ldestroy_cb ( LISTID lid, void (*ucleanup)(void * data_ptr) ); + +LNODEID lfirst ( LISTID ); /* head of the list */ +LNODEID llast ( LISTID ); /* tail of the list */ +LNODEID lnext ( LNODEID ); /* next item in the list */ +LNODEID lprev ( LNODEID ); /* previous item in the list */ +void * ldata ( LNODEID ); /* data at the current position */ +int lsize ( LISTID ); /* number of elements in the list */ + +int ladd ( LISTID lid, void * p ); +int laddo ( LISTID lid, void *p, + int (*compare)(const void *p1,const void *p2), + LNODEID * firstdup ); +int laddu ( LISTID lid, void * p, + int (*compare)(const void *p1,const void *p2)); +int lins_n ( LISTID lid, void * d, unsigned int n ); +int lins_ln ( LISTID lid, LNODEID lnid, void * data_ptr ); + +void * lget ( LISTID lid ); +void * lget_n ( LISTID lid, unsigned int n ); +LNODEID lget_ln ( LISTID lid, unsigned int n ); + +void * lrmv ( LISTID lid ); +void * lrmv_n ( LISTID lid, unsigned int n ); +void * lrmv_ln ( LISTID lid, LNODEID lnid ); +void * lrmv_d ( LISTID lid, void * data_ptr ); + +LISTID lcat ( LISTID lid1, LISTID lid2 ); + +void lsort ( LISTID lid, int (*compare)(void * p1, void * p2)); + +void * lsrch ( LISTID lid, void * p, int (*compare)(void *p1,void *p2)); + +int lprint ( FILE * f, LISTID lid ); + +#ifdef __cplusplus +} +#endif + +/* formerly avrpart.h */ + +/* + * AVR serial programming instructions + */ +enum { + AVR_OP_READ, + AVR_OP_WRITE, + AVR_OP_READ_LO, + AVR_OP_READ_HI, + AVR_OP_WRITE_LO, + AVR_OP_WRITE_HI, + AVR_OP_LOADPAGE_LO, + AVR_OP_LOADPAGE_HI, + AVR_OP_LOAD_EXT_ADDR, + AVR_OP_WRITEPAGE, + AVR_OP_CHIP_ERASE, + AVR_OP_PGM_ENABLE, + AVR_OP_MAX +}; + + +enum { + AVR_CMDBIT_IGNORE, /* bit is ignored on input and output */ + AVR_CMDBIT_VALUE, /* bit is set to 0 or 1 for input or output */ + AVR_CMDBIT_ADDRESS, /* this bit represents an input address bit */ + AVR_CMDBIT_INPUT, /* this bit is an input bit */ + AVR_CMDBIT_OUTPUT /* this bit is an output bit */ +}; + +enum { /* these are assigned to reset_disposition of AVRPART */ + RESET_DEDICATED, /* reset pin is dedicated */ + RESET_IO /* reset pin might be configured as an I/O pin */ +}; + +enum ctl_stack_t { + CTL_STACK_NONE, /* no control stack defined */ + CTL_STACK_PP, /* parallel programming control stack */ + CTL_STACK_HVSP /* high voltage serial programming control stack */ +}; + +/* + * serial programming instruction bit specifications + */ +typedef struct cmdbit { + int type; /* AVR_CMDBIT_* */ + int bitno; /* which input bit to use for this command bit */ + int value; /* bit value if type == AVR_CMDBIT_VALUD */ +} CMDBIT; + +typedef struct opcode { + CMDBIT bit[32]; /* opcode bit specs */ +} OPCODE; + + +#define AVRPART_SERIALOK 0x0001 /* part supports serial programming */ +#define AVRPART_PARALLELOK 0x0002 /* part supports parallel programming */ +#define AVRPART_PSEUDOPARALLEL 0x0004 /* part has pseudo parallel support */ +#define AVRPART_HAS_JTAG 0x0008 /* part has a JTAG i/f */ +#define AVRPART_ALLOWFULLPAGEBITSTREAM 0x0010 /* JTAG ICE mkII param. */ +#define AVRPART_ENABLEPAGEPROGRAMMING 0x0020 /* JTAG ICE mkII param. */ +#define AVRPART_HAS_DW 0x0040 /* part has a debugWire i/f */ +#define AVRPART_HAS_PDI 0x0080 /* part has PDI i/f rather than ISP (ATxmega) */ +#define AVRPART_AVR32 0x0100 /* part is in AVR32 family */ +#define AVRPART_INIT_SMC 0x0200 /* part will undergo chip erase */ +#define AVRPART_WRITE 0x0400 /* at least one write operation specified */ +#define AVRPART_HAS_TPI 0x0800 /* part has TPI i/f rather than ISP (ATtiny4/5/9/10) */ +#define AVRPART_IS_AT90S1200 0x1000 /* part is an AT90S1200 (needs special treatment) */ + +#define AVR_DESCLEN 64 +#define AVR_IDLEN 32 +#define CTL_STACK_SIZE 32 +#define FLASH_INSTR_SIZE 3 +#define EEPROM_INSTR_SIZE 20 + +#define TAG_ALLOCATED 1 /* memory byte is allocated */ + +typedef struct avrpart { + char desc[AVR_DESCLEN]; /* long part name */ + char id[AVR_IDLEN]; /* short part name */ + int stk500_devcode; /* stk500 device code */ + int avr910_devcode; /* avr910 device code */ + int chip_erase_delay; /* microseconds */ + unsigned char pagel; /* for parallel programming */ + unsigned char bs2; /* for parallel programming */ + unsigned char signature[3]; /* expected value of signature bytes */ + unsigned short usbpid; /* USB DFU product ID (0 = none) */ + int reset_disposition; /* see RESET_ enums */ + int retry_pulse; /* retry program enable by pulsing + this pin (PIN_AVR_*) */ + unsigned flags; /* see AVRPART_ masks */ + + int timeout; /* stk500 v2 xml file parameter */ + int stabdelay; /* stk500 v2 xml file parameter */ + int cmdexedelay; /* stk500 v2 xml file parameter */ + int synchloops; /* stk500 v2 xml file parameter */ + int bytedelay; /* stk500 v2 xml file parameter */ + int pollindex; /* stk500 v2 xml file parameter */ + unsigned char pollvalue; /* stk500 v2 xml file parameter */ + int predelay; /* stk500 v2 xml file parameter */ + int postdelay; /* stk500 v2 xml file parameter */ + int pollmethod; /* stk500 v2 xml file parameter */ + + enum ctl_stack_t 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) */ + + int hventerstabdelay; /* stk500 v2 hv mode parameter */ + int progmodedelay; /* stk500 v2 hv mode parameter */ + int latchcycles; /* stk500 v2 hv mode parameter */ + int togglevtg; /* stk500 v2 hv mode parameter */ + int poweroffdelay; /* stk500 v2 hv mode parameter */ + int resetdelayms; /* stk500 v2 hv mode parameter */ + int resetdelayus; /* stk500 v2 hv mode parameter */ + int hvleavestabdelay; /* stk500 v2 hv mode parameter */ + int resetdelay; /* stk500 v2 hv mode parameter */ + int chiperasepulsewidth; /* stk500 v2 hv mode parameter */ + int chiperasepolltimeout; /* stk500 v2 hv mode parameter */ + int chiperasetime; /* stk500 v2 hv mode parameter */ + int programfusepulsewidth; /* stk500 v2 hv mode parameter */ + int programfusepolltimeout; /* stk500 v2 hv mode parameter */ + int programlockpulsewidth; /* stk500 v2 hv mode parameter */ + int programlockpolltimeout; /* stk500 v2 hv mode parameter */ + int synchcycles; /* stk500 v2 hv mode parameter */ + int hvspcmdexedelay; /* stk500 v2 xml file parameter */ + + unsigned char idr; /* JTAG ICE mkII XML file parameter */ + unsigned char rampz; /* JTAG ICE mkII XML file parameter */ + unsigned char spmcr; /* JTAG ICE mkII XML file parameter */ + unsigned short eecr; /* JTAC ICE mkII XML file parameter */ + unsigned int mcu_base; /* Base address of MCU control block in ATxmega devices */ + unsigned int nvm_base; /* Base address of NVM controller in ATxmega devices */ + int ocdrev; /* OCD revision (JTAGICE3 parameter, from AS6 XML files) */ + + OPCODE * op[AVR_OP_MAX]; /* opcodes */ + + LISTID mem; /* avr memory definitions */ + char config_file[PATH_MAX]; /* config file where defined */ + int lineno; /* config file line number */ +} AVRPART; + +#define AVR_MEMDESCLEN 64 +typedef struct avrmem { + char desc[AVR_MEMDESCLEN]; /* memory description ("flash", "eeprom", etc) */ + int paged; /* page addressed (e.g. ATmega flash) */ + int size; /* total memory size in bytes */ + int page_size; /* size of memory page (if page addressed) */ + int num_pages; /* number of pages (if page addressed) */ + unsigned int offset; /* offset in IO memory (ATxmega) */ + int min_write_delay; /* microseconds */ + int max_write_delay; /* microseconds */ + int pwroff_after_write; /* after this memory type is written to, + the device must be powered off and + back on, see errata + http://www.atmel.com/dyn/resources/prod_documents/doc1280.pdf */ + unsigned char readback[2]; /* polled read-back values */ + + int mode; /* stk500 v2 xml file parameter */ + int delay; /* stk500 v2 xml file parameter */ + int blocksize; /* stk500 v2 xml file parameter */ + int readsize; /* stk500 v2 xml file parameter */ + int pollindex; /* stk500 v2 xml file parameter */ + + unsigned char * buf; /* pointer to memory buffer */ + unsigned char * tags; /* allocation tags */ + OPCODE * op[AVR_OP_MAX]; /* opcodes */ +} AVRMEM; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Functions for OPCODE structures */ +OPCODE * avr_new_opcode(void); +void avr_free_opcode(OPCODE * op); +int avr_set_bits(OPCODE * op, unsigned char * cmd); +int avr_set_addr(OPCODE * op, unsigned char * cmd, unsigned long addr); +int avr_set_input(OPCODE * op, unsigned char * cmd, unsigned char data); +int avr_get_output(OPCODE * op, unsigned char * res, unsigned char * data); +int avr_get_output_index(OPCODE * op); + +/* Functions for AVRMEM structures */ +AVRMEM * avr_new_memtype(void); +int avr_initmem(AVRPART * p); +AVRMEM * avr_dup_mem(AVRMEM * m); +void avr_free_mem(AVRMEM * m); +AVRMEM * avr_locate_mem(AVRPART * p, char * desc); +void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, int type, + int verbose); + +/* Functions for AVRPART structures */ +AVRPART * avr_new_part(void); +AVRPART * avr_dup_part(AVRPART * d); +void avr_free_part(AVRPART * d); +AVRPART * locate_part(LISTID parts, char * partdesc); +AVRPART * locate_part_by_avr910_devcode(LISTID parts, int devcode); +AVRPART * locate_part_by_signature(LISTID parts, unsigned char * sig, + int sigsize); +void avr_display(FILE * f, AVRPART * p, const char * prefix, int verbose); + +typedef void (*walk_avrparts_cb)(const char *name, const char *desc, + const char *cfgname, int cfglineno, + void *cookie); +void walk_avrparts(LISTID avrparts, walk_avrparts_cb cb, void *cookie); +void sort_avrparts(LISTID avrparts); +#ifdef __cplusplus +} +#endif + +/* formerly pindefs.h */ + +enum { + PPI_AVR_VCC = 1, + PPI_AVR_BUFF, + PIN_AVR_RESET, + PIN_AVR_SCK, + PIN_AVR_MOSI, + PIN_AVR_MISO, + PIN_LED_ERR, + PIN_LED_RDY, + PIN_LED_PGM, + PIN_LED_VFY, + N_PINS +}; + +#define PIN_MASK (UINT_MAX>>1) +#define PIN_INVERSE (~(PIN_MASK)) /* flag for inverted pin in serbb */ +#define PIN_MIN 0 /* smallest allowed pin number */ +#define PIN_MAX 31 /* largest allowed pin number */ + +#ifdef HAVE_LINUXGPIO +/* Embedded systems might have a lot more gpio than only 0-31 */ +#undef PIN_MAX +#define PIN_MAX 255 /* largest allowed pin number */ +#endif + +/** Number of pins in each element of the bitfield */ +#define PIN_FIELD_ELEMENT_SIZE (sizeof(pinmask_t) * 8) +/** Numer of elements to store the complete bitfield of all pins */ +#define PIN_FIELD_SIZE ((PIN_MAX + PIN_FIELD_ELEMENT_SIZE)/PIN_FIELD_ELEMENT_SIZE) + +/** + * This sets the corresponding bits to 1 or 0, the inverse mask is used to invert the value in necessary. + * It uses only the lowest element (index=0) of the bitfield, which should be enough for most + * programmers. + * + * @param[in] x input value + * @param[in] pgm the programmer whose pin definitions to use + * @param[in] pinname the logical name of the pin (PIN_AVR_*, ...) + * @param[in] level the logical level (level != 0 => 1, level == 0 => 0), + * if the pin is defined as inverted the resulting bit is also inverted + * @returns the input value with the relevant bits modified + */ +#define SET_BITS_0(x,pgm,pinname,level) (((x) & ~(pgm)->pin[pinname].mask[0]) \ + | (\ + (pgm)->pin[pinname].mask[0] & ( \ + (level) \ + ?~((pgm)->pin[pinname].inverse[0]) \ + : ((pgm)->pin[pinname].inverse[0]) \ + ) \ + ) \ +) + +/** + * Check if the corresponding bit is set (returns != 0) or cleared. + * The inverse mask is used, to invert the relevant bits. + * If the pin definition contains multiple pins, then a single set pin leads to return value != 0. + * Then you have to check the relevant bits of the returned value, if you need more information. + * It uses only the lowest element (index=0) of the bitfield, which should be enough for most + * programmers. + * + * @param[in] x input value + * @param[in] pgm the programmer whose pin definitions to use + * @param[in] pinname the logical name of the pin (PIN_AVR_*, ...) + * @returns the input value with only the relevant bits (which are already inverted, + * so you get always the logical level) + */ +#define GET_BITS_0(x,pgm,pinname) (((x) ^ (pgm)->pin[pinname].inverse[0]) & (pgm)->pin[pinname].mask[0]) + +/** + * Data structure to hold used pins by logical function (PIN_AVR_*, ...) + */ +struct pindef_t { + pinmask_t mask[PIN_FIELD_SIZE]; ///< bitfield of used pins + pinmask_t inverse[PIN_FIELD_SIZE]; ///< bitfield of inverse/normal usage of used pins +}; + +/** + * Data structure to define a checklist of valid pins for each function. + */ +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 +}; + +/** + * Adds a pin in the pin definition as normal or inverse pin. + * + * @param[out] pindef pin definition to update + * @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); + +/** + * Clear all defined pins in pindef. + * + * @param[out] pindef pin definition to clear + */ +void pin_clear_all(struct pindef_t * const pindef); + +struct programmer_t; /* 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); + +/** + * This function checks all pin of pgm against the constraints given in the checklist. + * It checks if + * @li any invalid pins are used + * @li valid pins are used inverted when not allowed + * @li any pins are used by more than one function + * @li any mandatory pin is not set all. + * + * In case of any error it report the wrong function and the pin numbers. + * For verbose >= 2 it also reports the possible correct values. + * For verbose >=3 it shows also which pins were ok. + * + * @param[in] pgm the programmer to check + * @param[in] checklist the constraint for the pins + * @param[in] size the number of entries in checklist + * @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); + +/** + * Returns the name of the pin as string. + * + * @param pinname the pinname which we want as string. + * @returns a string with the pinname, or if pinname is invalid. + */ +const char * avr_pin_name(int pinname); + +/** + * This function returns a string representation of defined pins eg. ~1,2,~4,~5,7 + * 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 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 representated as start-end. + * + * @param[in] pinmask the pin mask for which we want the string representation + * @returns pointer to a static string. + */ +const char * pinmask_to_str(const pinmask_t * const pinmask); + +/* formerly serial.h */ + +/* This is the API for the generic serial interface. The implementations are + actually provided by the target dependant files: + + ser_posix.c : posix serial interface. + ser_win32.c : native win32 serial interface. + + The target file will be selected at configure time. */ + +extern long serial_recv_timeout; +union filedescriptor +{ + int ifd; + void *pfd; + struct + { + void *handle; + int rep; /* bulk read endpoint */ + int wep; /* bulk write endpoint */ + int eep; /* event read endpoint */ + int max_xfer; /* max transfer size */ + int use_interrupt_xfer; /* device uses interrupt transfers */ + } usb; +}; + +union pinfo +{ + long baud; + struct + { + unsigned short vid; + unsigned short pid; + unsigned short flags; +#define PINFO_FL_USEHID 0x0001 +#define PINFO_FL_SILENT 0x0002 /* don't complain if not found */ + } usbinfo; +}; + + +struct serial_device +{ + // open should return -1 on error, other values on success + int (*open)(char * port, union pinfo pinfo, union filedescriptor *fd); + int (*setspeed)(union filedescriptor *fd, long baud); + void (*close)(union filedescriptor *fd); + + int (*send)(union filedescriptor *fd, const unsigned char * buf, size_t buflen); + int (*recv)(union filedescriptor *fd, unsigned char * buf, size_t buflen); + int (*drain)(union filedescriptor *fd, int display); + + int (*set_dtr_rts)(union filedescriptor *fd, int is_on); + + int flags; +#define SERDEV_FL_NONE 0x0000 /* no flags */ +#define SERDEV_FL_CANSETSPEED 0x0001 /* device can change speed */ +}; + +extern struct serial_device *serdev; +extern struct serial_device serial_serdev; +extern struct serial_device usb_serdev; +extern struct serial_device usb_serdev_frame; +extern struct serial_device avrdoper_serdev; +extern struct serial_device usbhid_serdev; + +#define serial_open (serdev->open) +#define serial_setspeed (serdev->setspeed) +#define serial_close (serdev->close) +#define serial_send (serdev->send) +#define serial_recv (serdev->recv) +#define serial_drain (serdev->drain) +#define serial_set_dtr_rts (serdev->set_dtr_rts) + +/* formerly pgm.h */ + +#define ON 1 +#define OFF 0 + +#define PGM_DESCLEN 80 +#define PGM_PORTLEN PATH_MAX +#define PGM_TYPELEN 32 +#define PGM_USBSTRINGLEN 256 + +typedef enum { + EXIT_VCC_UNSPEC, + EXIT_VCC_ENABLED, + EXIT_VCC_DISABLED +} exit_vcc_t; + +typedef enum { + EXIT_RESET_UNSPEC, + EXIT_RESET_ENABLED, + EXIT_RESET_DISABLED +} exit_reset_t; + +typedef enum { + EXIT_DATAHIGH_UNSPEC, + EXIT_DATAHIGH_ENABLED, + EXIT_DATAHIGH_DISABLED +} exit_datahigh_t; + +typedef enum { + CONNTYPE_PARALLEL, + CONNTYPE_SERIAL, + CONNTYPE_USB +} conntype_t; + +typedef struct programmer_t { + LISTID id; + char desc[PGM_DESCLEN]; + char type[PGM_TYPELEN]; + char port[PGM_PORTLEN]; + void (*initpgm)(struct programmer_t * pgm); + unsigned int pinno[N_PINS]; + struct pindef_t pin[N_PINS]; + exit_vcc_t exit_vcc; + exit_reset_t exit_reset; + exit_datahigh_t exit_datahigh; + conntype_t conntype; + int ppidata; + int ppictrl; + int baudrate; + int usbvid; + LISTID usbpid; + char usbdev[PGM_USBSTRINGLEN], usbsn[PGM_USBSTRINGLEN]; + char usbvendor[PGM_USBSTRINGLEN], usbproduct[PGM_USBSTRINGLEN]; + double bitclock; /* JTAG ICE clock period in microseconds */ + int ispdelay; /* ISP clock delay */ + union filedescriptor fd; + int page_size; /* page size if the programmer supports paged write/load */ + int (*rdy_led) (struct programmer_t * pgm, int value); + int (*err_led) (struct programmer_t * pgm, int value); + int (*pgm_led) (struct programmer_t * pgm, int value); + int (*vfy_led) (struct programmer_t * pgm, int value); + int (*initialize) (struct programmer_t * pgm, AVRPART * p); + void (*display) (struct programmer_t * pgm, const char * p); + void (*enable) (struct programmer_t * pgm); + void (*disable) (struct programmer_t * pgm); + void (*powerup) (struct programmer_t * pgm); + void (*powerdown) (struct programmer_t * pgm); + int (*program_enable) (struct programmer_t * pgm, AVRPART * p); + int (*chip_erase) (struct programmer_t * pgm, AVRPART * p); + int (*cmd) (struct programmer_t * pgm, const unsigned char *cmd, + unsigned char *res); + int (*cmd_tpi) (struct programmer_t * pgm, const unsigned char *cmd, + int cmd_len, unsigned char res[], int res_len); + int (*spi) (struct programmer_t * pgm, const unsigned char *cmd, + unsigned char *res, int count); + int (*open) (struct programmer_t * pgm, char * port); + void (*close) (struct programmer_t * pgm); + int (*paged_write) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int baseaddr, + unsigned int n_bytes); + int (*paged_load) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, unsigned int baseaddr, + unsigned int n_bytes); + int (*page_erase) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m, + unsigned int baseaddr); + void (*write_setup) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m); + int (*write_byte) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m, + unsigned long addr, unsigned char value); + int (*read_byte) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m, + unsigned long addr, unsigned char * value); + int (*read_sig_bytes) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m); + void (*print_parms) (struct programmer_t * pgm); + int (*set_vtarget) (struct programmer_t * pgm, double v); + int (*set_varef) (struct programmer_t * pgm, unsigned int chan, double v); + int (*set_fosc) (struct programmer_t * pgm, double v); + int (*set_sck_period) (struct programmer_t * pgm, double v); + int (*setpin) (struct programmer_t * pgm, int pinfunc, int value); + int (*getpin) (struct programmer_t * pgm, int pinfunc); + int (*highpulsepin) (struct programmer_t * pgm, int pinfunc); + int (*parseexitspecs) (struct programmer_t * pgm, char *s); + int (*perform_osccal) (struct programmer_t * pgm); + int (*parseextparams) (struct programmer_t * pgm, LISTID xparams); + void (*setup) (struct programmer_t * pgm); + void (*teardown) (struct programmer_t * pgm); + void (*set_upload_size)(struct programmer_t * pgm, int size); + char config_file[PATH_MAX]; /* config file where defined */ + int lineno; /* config file line number */ + void *cookie; /* for private use by the programmer */ + char flag; /* for private use of the programmer */ +} PROGRAMMER; + +#ifdef __cplusplus +extern "C" { +#endif + +PROGRAMMER * pgm_new(void); +PROGRAMMER * pgm_dup(const PROGRAMMER * const src); +void pgm_free(PROGRAMMER * const p); + +void programmer_display(PROGRAMMER * pgm, const char * p); + +/* show is a mask like this (1< +#else +# include +#endif + + +/* formerly confwin.h */ + +// #if defined(WIN32NATIVE) + +// #ifdef __cplusplus +// extern "C" { +// #endif + +// void win_sys_config_set(char sys_config[PATH_MAX]); +// void win_usr_config_set(char usr_config[PATH_MAX]); + +// #ifdef __cplusplus +// } +// #endif + +// #endif /* WIN32NATIVE */ + + +#endif /* libavrdude_h */ diff --git a/xs/src/avrdude/linux_ppdev.h b/xs/src/avrdude/linux_ppdev.h new file mode 100644 index 000000000..1d2e6e2ec --- /dev/null +++ b/xs/src/avrdude/linux_ppdev.h @@ -0,0 +1,57 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2003, 2005 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 + * 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 linux_ppdev_h +#define linux_ppdev_h + +#define OBSOLETE__IOW _IOW + +#include +#ifdef HAVE_PARPORT +#include +#include +#endif + +#include + +#define ppi_claim(fd) \ + if (ioctl(fd, PPCLAIM)) { \ + avrdude_message(MSG_INFO, "%s: can't claim device \"%s\": %s\n\n", \ + progname, port, strerror(errno)); \ + close(fd); \ + return; \ + } + +#define ppi_release(fd) \ + if (ioctl(fd, PPRELEASE)) { \ + avrdude_message(MSG_INFO, "%s: can't release device: %s\n\n", \ + progname, strerror(errno)); \ + } + +#define DO_PPI_READ(fd, reg, valp) \ + (void)ioctl(fd, \ + (reg) == PPIDATA? PPRDATA: ((reg) == PPICTRL? PPRCONTROL: PPRSTATUS), \ + valp) +#define DO_PPI_WRITE(fd, reg, valp) \ + (void)ioctl(fd, \ + (reg) == PPIDATA? PPWDATA: ((reg) == PPICTRL? PPWCONTROL: PPWSTATUS), \ + valp) + +#endif /* linux_ppdev_h */ diff --git a/xs/src/avrdude/linuxgpio.c b/xs/src/avrdude/linuxgpio.c new file mode 100644 index 000000000..b61631174 --- /dev/null +++ b/xs/src/avrdude/linuxgpio.c @@ -0,0 +1,354 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Support for bitbanging GPIO pins using the /sys/class/gpio interface + * + * Copyright (C) 2013 Radoslav Kolev + * + * 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 +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "bitbang.h" + +#if HAVE_LINUXGPIO + +/* + * GPIO user space helpers + * + * Copyright 2009 Analog Devices Inc. + * Michael Hennerich (hennerich@blackfin.uclinux.org) + * + * Licensed under the GPL-2 or later + */ + +/* + * GPIO user space helpers + * The following functions are acting on an "unsigned gpio" argument, which corresponds to the + * gpio numbering scheme in the kernel (starting from 0). + * The higher level functions use "int pin" to specify the pins with an offset of 1: + * gpio = pin - 1; + */ + +#define GPIO_DIR_IN 0 +#define GPIO_DIR_OUT 1 + +static int linuxgpio_export(unsigned int gpio) +{ + int fd, len, r; + char buf[11]; + + fd = open("/sys/class/gpio/export", O_WRONLY); + if (fd < 0) { + perror("Can't open /sys/class/gpio/export"); + return fd; + } + + len = snprintf(buf, sizeof(buf), "%u", gpio); + r = write(fd, buf, len); + close(fd); + + return r; +} + +static int linuxgpio_unexport(unsigned int gpio) +{ + int fd, len, r; + char buf[11]; + + fd = open("/sys/class/gpio/unexport", O_WRONLY); + if (fd < 0) { + perror("Can't open /sys/class/gpio/unexport"); + return fd; + } + + len = snprintf(buf, sizeof(buf), "%u", gpio); + r = write(fd, buf, len); + close(fd); + + return r; +} + +static int linuxgpio_openfd(unsigned int gpio) +{ + char filepath[60]; + + snprintf(filepath, sizeof(filepath), "/sys/class/gpio/gpio%u/value", gpio); + return (open(filepath, O_RDWR)); +} + +static int linuxgpio_dir(unsigned int gpio, unsigned int dir) +{ + int fd, r; + char buf[60]; + + snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%u/direction", gpio); + + fd = open(buf, O_WRONLY); + if (fd < 0) { + perror("Can't open gpioX/direction"); + return fd; + } + + if (dir == GPIO_DIR_OUT) + r = write(fd, "out", 4); + else + r = write(fd, "in", 3); + + close(fd); + + return r; +} + +static int linuxgpio_dir_out(unsigned int gpio) +{ + return linuxgpio_dir(gpio, GPIO_DIR_OUT); +} + +static int linuxgpio_dir_in(unsigned int gpio) +{ + return linuxgpio_dir(gpio, GPIO_DIR_IN); +} + +/* + * End of GPIO user space helpers + */ + +#define N_GPIO (PIN_MAX + 1) + +/* +* an array which holds open FDs to /sys/class/gpio/gpioXX/value for all needed pins +*/ +static int linuxgpio_fds[N_GPIO] ; + + +static int linuxgpio_setpin(PROGRAMMER * pgm, int pinfunc, int value) +{ + int r; + int pin = pgm->pinno[pinfunc]; // TODO + + if (pin & PIN_INVERSE) + { + value = !value; + pin &= PIN_MASK; + } + + if ( linuxgpio_fds[pin] < 0 ) + return -1; + + if (value) + r = write(linuxgpio_fds[pin], "1", 1); + else + r = write(linuxgpio_fds[pin], "0", 1); + + if (r!=1) return -1; + + if (pgm->ispdelay > 1) + bitbang_delay(pgm->ispdelay); + + return 0; +} + +static int linuxgpio_getpin(PROGRAMMER * pgm, int pinfunc) +{ + unsigned char invert=0; + char c; + int pin = pgm->pinno[pinfunc]; // TODO + + if (pin & PIN_INVERSE) + { + invert = 1; + pin &= PIN_MASK; + } + + if ( linuxgpio_fds[pin] < 0 ) + return -1; + + if (lseek(linuxgpio_fds[pin], 0, SEEK_SET)<0) + return -1; + + if (read(linuxgpio_fds[pin], &c, 1)!=1) + return -1; + + if (c=='0') + return 0+invert; + else if (c=='1') + return 1-invert; + else + return -1; + +} + +static int linuxgpio_highpulsepin(PROGRAMMER * pgm, int pinfunc) +{ + int pin = pgm->pinno[pinfunc]; // TODO + + if ( linuxgpio_fds[pin & PIN_MASK] < 0 ) + return -1; + + linuxgpio_setpin(pgm, pinfunc, 1); + linuxgpio_setpin(pgm, pinfunc, 0); + + return 0; +} + + + +static void linuxgpio_display(PROGRAMMER *pgm, const char *p) +{ + avrdude_message(MSG_INFO, "%sPin assignment : /sys/class/gpio/gpio{n}\n",p); + pgm_display_generic_mask(pgm, p, SHOW_AVR_PINS); +} + +static void linuxgpio_enable(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static void linuxgpio_disable(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static void linuxgpio_powerup(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static void linuxgpio_powerdown(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static int linuxgpio_open(PROGRAMMER *pgm, char *port) +{ + int r, i, pin; + + if (bitbang_check_prerequisites(pgm) < 0) + return -1; + + + for (i=0; ipinno[i] & PIN_MASK) != 0 || + i == PIN_AVR_RESET || + i == PIN_AVR_SCK || + i == PIN_AVR_MOSI || + i == PIN_AVR_MISO ) { + pin = pgm->pinno[i] & PIN_MASK; + if ((r=linuxgpio_export(pin)) < 0) { + avrdude_message(MSG_INFO, "Can't export GPIO %d, already exported/busy?: %s", + pin, strerror(errno)); + return r; + } + if (i == PIN_AVR_MISO) + r=linuxgpio_dir_in(pin); + else + r=linuxgpio_dir_out(pin); + + if (r < 0) + return r; + + if ((linuxgpio_fds[pin]=linuxgpio_openfd(pin)) < 0) + return linuxgpio_fds[pin]; + } + } + + return(0); +} + +static void linuxgpio_close(PROGRAMMER *pgm) +{ + int i, reset_pin; + + reset_pin = pgm->pinno[PIN_AVR_RESET] & PIN_MASK; + + //first configure all pins as input, except RESET + //this should avoid possible conflicts when AVR firmware starts + for (i=0; i= 0 && i != reset_pin) { + close(linuxgpio_fds[i]); + linuxgpio_dir_in(i); + linuxgpio_unexport(i); + } + } + //configure RESET as input, if there's external pull up it will go high + if (linuxgpio_fds[reset_pin] >= 0) { + close(linuxgpio_fds[reset_pin]); + linuxgpio_dir_in(reset_pin); + linuxgpio_unexport(reset_pin); + } +} + +void linuxgpio_initpgm(PROGRAMMER *pgm) +{ + strcpy(pgm->type, "linuxgpio"); + + pgm_fill_old_pins(pgm); // TODO to be removed if old pin data no longer needed + + pgm->rdy_led = bitbang_rdy_led; + pgm->err_led = bitbang_err_led; + pgm->pgm_led = bitbang_pgm_led; + pgm->vfy_led = bitbang_vfy_led; + pgm->initialize = bitbang_initialize; + pgm->display = linuxgpio_display; + pgm->enable = linuxgpio_enable; + pgm->disable = linuxgpio_disable; + pgm->powerup = linuxgpio_powerup; + pgm->powerdown = linuxgpio_powerdown; + pgm->program_enable = bitbang_program_enable; + pgm->chip_erase = bitbang_chip_erase; + pgm->cmd = bitbang_cmd; + pgm->open = linuxgpio_open; + pgm->close = linuxgpio_close; + pgm->setpin = linuxgpio_setpin; + pgm->getpin = linuxgpio_getpin; + pgm->highpulsepin = linuxgpio_highpulsepin; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; +} + +const char linuxgpio_desc[] = "GPIO bitbanging using the Linux sysfs interface"; + +#else /* !HAVE_LINUXGPIO */ + +void linuxgpio_initpgm(PROGRAMMER * pgm) +{ + avrdude_message(MSG_INFO, "%s: Linux sysfs GPIO support not available in this configuration\n", + progname); +} + +const char linuxgpio_desc[] = "GPIO bitbanging using the Linux sysfs interface (not available)"; + +#endif /* HAVE_LINUXGPIO */ diff --git a/xs/src/avrdude/linuxgpio.h b/xs/src/avrdude/linuxgpio.h new file mode 100644 index 000000000..dc477982a --- /dev/null +++ b/xs/src/avrdude/linuxgpio.h @@ -0,0 +1,36 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2013 Radoslav Kolev + * + * 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 + */ + +/* $Id: par.h 722 2007-01-24 22:43:46Z joerg_wunsch $ */ + +#ifndef linuxgpio_h +#define linuxgpio_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char linuxgpio_desc[]; +void linuxgpio_initpgm (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/xs/src/avrdude/lists.c b/xs/src/avrdude/lists.c new file mode 100644 index 000000000..cab88364e --- /dev/null +++ b/xs/src/avrdude/lists.c @@ -0,0 +1,1407 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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$ */ + + + +/*---------------------------------------------------------------------- + Id: lists.c,v 1.4 2001/08/19 23:26:20 bsd Exp $ + ----------------------------------------------------------------------*/ +/*------------------------------------------------------------------------ + lists.c + + General purpose linked list routines. These routines implement a + generic doubly linked list. Any data type may be placed in the + lists. Stacking and Queuing routines are provided via #defines + declared in 'lists.h'. + + Author : Brian Dean + Date : 10 January, 1990 + ------------------------------------------------------------------------*/ + +#include "ac_cfg.h" + +#include +#include + +#include "libavrdude.h" + +#define MAGIC 0xb05b05b0 + +#define CHECK_MAGIC 0 /* set to 1 to enable memory overwrite detection */ + +#ifdef BOS +#define MALLOC(size,x) kmalloc(size,x) +#define FREE kfree +#else +#define MALLOC(size,x) malloc(size) +#define FREE free +#endif + + +/*------------------------------------------------------------ +| required private data structures + ------------------------------------------------------------*/ +typedef struct LISTNODE { +#if CHECK_MAGIC + unsigned int magic1; +#endif + struct LISTNODE * next; /* chain to next item in the list */ + struct LISTNODE * prev; /* chain to previous item in the list */ + void * data; /* pointer to user data */ +#if CHECK_MAGIC + unsigned int magic2; +#endif +} LISTNODE; + + +typedef struct NODEPOOL { +#if CHECK_MAGIC + unsigned int magic1; +#endif + struct NODEPOOL * chain_next; /* chain to next node pool */ + struct NODEPOOL * chain_prev; /* chain to previous node pool */ +#if CHECK_MAGIC + unsigned int magic2; +#endif +} NODEPOOL; + + +typedef struct LIST { +#if CHECK_MAGIC + unsigned int magic1; +#endif + int num; /* number of elements in the list */ + short int free_on_close; /* free the LIST memory on close T/F */ + short int poolsize; /* list node allocation size */ + int n_ln_pool; /* number of listnodes in a pool */ + LISTNODE * top; /* top of the list */ + LISTNODE * bottom; /* bottom of the list */ + LISTNODE * next_ln; /* next available list node */ + NODEPOOL * np_top; /* top of the node pool chain */ + NODEPOOL * np_bottom; /* bottom of the node pool chain */ +#if CHECK_MAGIC + unsigned int magic2; +#endif +} LIST; + + +/* allocate list nodes in 512 byte chunks, giving 42 elements */ +#define DEFAULT_POOLSIZE 512 + + +#if CHECK_MAGIC +#define CKMAGIC(p) { if (p->magic1 != MAGIC) breakpoint(); \ + if (p->magic2 != MAGIC) breakpoint(); } + +#define CKNPMAGIC(p) cknpmagic(p) + +#define CKLNMAGIC(p) cklnmagic(p) + +#define CKLMAGIC(p) cklmagic(p) +#else +#define CKMAGIC(p) + +#define CKNPMAGIC(p) + +#define CKLNMAGIC(p) + +#define CKLMAGIC(p) +#endif + + +static int insert_ln ( LIST * l, LISTNODE * ln, void * data_ptr ); + + +#if CHECK_MAGIC +static int cknpmagic ( LIST * l ) +{ + NODEPOOL * np; + int i; + + i = 0; + np = l->np_top; + while (np) { + i++; + CKMAGIC(np); + np = np->chain_next; + } + + i = 0; + np = l->np_bottom; + while (np) { + i++; + CKMAGIC(np); + np = np->chain_prev; + } + + return 0; +} + + + +static int cklnmagic ( LIST * l ) +{ + LISTNODE * ln; + int i; + + i = 0; + ln = l->top; + while (ln) { + i++; + CKMAGIC(ln); + ln = ln->next; + } + + i = 0; + ln = l->bottom; + while (ln) { + i++; + CKMAGIC(ln); + ln = ln->prev; + } + + return 0; +} + + +static int cklmagic ( LIST * l ) +{ + CKMAGIC(l); + CKNPMAGIC(l); + CKLNMAGIC(l); + CKMAGIC(l); + return 0; +} +#endif + + +/*------------------------------------------------------------ +| new_node_pool +| +| Create and initialize a new pool of list nodes. This is +| just a big block of memory with the first sizeof(NODEPOOL) +| bytes reserved. The first available list node resides at +| offset sizeof(NODEPOOL). + ------------------------------------------------------------*/ +static +NODEPOOL * +new_nodepool ( LIST * l ) +{ + NODEPOOL * np; + LISTNODE * ln; + int i; + + CKLMAGIC(l); + + /*-------------------------------------------------- + | get a block of memory for the new pool + --------------------------------------------------*/ + np = (NODEPOOL *) MALLOC ( l->poolsize, "list node pool" ); + if (np == NULL) { + return NULL; + } + + /*-------------------------------------------------- + | initialize the chaining information at the + | beginning of the pool. + --------------------------------------------------*/ +#if CHECK_MAGIC + np->magic1 = MAGIC; +#endif + np->chain_next = NULL; + np->chain_prev = NULL; +#if CHECK_MAGIC + np->magic2 = MAGIC; +#endif + + /*-------------------------------------------------- + | initialize all the list nodes within the node + | pool, which begin just after the NODEPOOL + | structure at the beginning of the memory block + --------------------------------------------------*/ + ln = (LISTNODE *) (&np[1]); + +#if CHECK_MAGIC + ln[0].magic1 = MAGIC; +#endif + ln[0].data = NULL; + ln[0].next = &ln[1]; + ln[0].prev = NULL; +#if CHECK_MAGIC + ln[0].magic2 = MAGIC; +#endif + + for (i=1; in_ln_pool-1; i++) { +#if CHECK_MAGIC + ln[i].magic1 = MAGIC; +#endif + ln[i].data = NULL; + ln[i].next = &ln[i+1]; + ln[i].prev = &ln[i-1]; +#if CHECK_MAGIC + ln[i].magic2 = MAGIC; +#endif + } + +#if CHECK_MAGIC + ln[l->n_ln_pool-1].magic1 = MAGIC; +#endif + ln[l->n_ln_pool-1].data = NULL; + ln[l->n_ln_pool-1].next = NULL; + ln[l->n_ln_pool-1].prev = &ln[l->n_ln_pool-2]; +#if CHECK_MAGIC + ln[l->n_ln_pool-1].magic2 = MAGIC; +#endif + + CKMAGIC(np); + + CKLMAGIC(l); + + return np; +} + + + +/*------------------------------------------------------------ +| get_listnode +| +| Get the next available list node. If there are no more +| list nodes, another pool of list nodes is allocated. If +| that fails, NULL is returned. + ------------------------------------------------------------*/ +static +LISTNODE * +get_listnode ( LIST * l ) +{ + LISTNODE * ln; + NODEPOOL * np; + + CKLMAGIC(l); + + if (l->next_ln == NULL) { + /*-------------------------------------------------- + | allocate a new node pool and chain to the others + --------------------------------------------------*/ + np = new_nodepool(l); + if (np == NULL) { + CKLMAGIC(l); + return NULL; + } + + if (l->np_top == NULL) { + /*-------------------------------------------------- + | this is the first node pool for this list, + | directly assign to the top and bottom. + --------------------------------------------------*/ + l->np_top = np; + l->np_bottom = np; + np->chain_next = NULL; + np->chain_prev = NULL; + } + else { + /*-------------------------------------------------- + | this is an additional node pool, add it to the + | chain. + --------------------------------------------------*/ + np->chain_next = NULL; + np->chain_prev = l->np_bottom; + l->np_bottom->chain_next = np; + l->np_bottom = np; + } + + /*-------------------------------------------------- + | set the list's pointer to the next available + | list node to the first list node in this new + | pool. + --------------------------------------------------*/ + l->next_ln = (LISTNODE *)&np[1]; + + CKMAGIC(np); + } + + /*-------------------------------------------------- + | get the next available list node, set the list's + | next available list node to the next one in the + | list. + --------------------------------------------------*/ + ln = l->next_ln; + l->next_ln = ln->next; + + CKMAGIC(ln); + + /*-------------------------------------------------- + | initialize the new list node and return + --------------------------------------------------*/ + ln->next = NULL; + ln->prev = NULL; + ln->data = NULL; + + CKLMAGIC(l); + + return ln; +} + + + +/*------------------------------------------------------------ +| free_listnode +| +| Return a list node to the pool of list nodes. This puts +| the node at the head of the free list, so that the next +| call to 'get_listnode', with return the most recently +| freed one. + ------------------------------------------------------------*/ +static +int +free_listnode ( LIST * l, LISTNODE * ln ) +{ + CKLMAGIC(l); + + /*-------------------------------------------------- + | insert the list node at the head of the list of + | free list nodes. + --------------------------------------------------*/ + ln->prev = NULL; + ln->data = NULL; + ln->next = l->next_ln; + l->next_ln = ln; + + CKLMAGIC(l); + + return 0; +} + + + +/*---------------------------------------------------------------------- + lcreat + + Create a new list data structure. + + If liststruct is not NULL, it is used to provide the memory space + for the list structure instance, otherwise, the necessary memory is + malloc'd. + + If elements is zero, the default poolsize is used, otherwise, + poolsizes of 'elements' elements are malloc'd to obtain the memory + for list nodes. Minimum element count is 5. + + The first node pool is not preallocated; instead it is malloc'd at + the time of the first use. + ----------------------------------------------------------------------*/ +LISTID +lcreat ( void * liststruct, int elements ) +{ + LIST * l; + + if (liststruct == NULL) { + /*-------------------------------------------------- + allocate memory for the list itself + --------------------------------------------------*/ + l = (LIST *) MALLOC ( sizeof(LIST), "list struct" ); + if (l == NULL) { + return NULL; + } + l->free_on_close = 1; + } + else { + /*----------------------------------------------------------------- + use the memory given to us for the list structure + -----------------------------------------------------------------*/ + l = liststruct; + l->free_on_close = 0; + } + + /*-------------------------------------------------- + | initialize the list + --------------------------------------------------*/ +#if CHECK_MAGIC + l->magic1 = MAGIC; + l->magic2 = MAGIC; +#endif + l->top = NULL; + l->bottom = NULL; + l->num = 0; + + if (elements == 0) { + l->poolsize = DEFAULT_POOLSIZE; + } + else { + l->poolsize = elements*sizeof(LISTNODE)+sizeof(NODEPOOL); + } + + l->n_ln_pool = (l->poolsize-sizeof(NODEPOOL))/sizeof(LISTNODE); + + if (l->n_ln_pool < 5) { + if (!liststruct) { + FREE(l); + } + return NULL; + } + + l->np_top = NULL; + l->np_bottom = NULL; + l->next_ln = NULL; + + CKLMAGIC(l); + + return (LISTID)l; +} + + +/*-------------------------------------------------- +| ldestroy_cb +| +| destroy an existing list data structure, calling +| the user routine 'ucleanup' on the data pointer +| of each list element. Allows the user to free +| up a list data structure and have this routine +| call their function to free up each list element +| at the same time. + --------------------------------------------------*/ +void +ldestroy_cb ( LISTID lid, void (*ucleanup)(void * data_ptr) ) +{ + LIST * l; + LISTNODE * ln; + + l = (LIST *)lid; + + CKLMAGIC(l); + + ln = l->top; + while (ln != NULL) { + ucleanup ( ln->data ); + ln = ln->next; + } + + ldestroy ( l ); +} + + + +/*-------------------------------------------------- +| ldestroy +| +| destroy an existing list data structure. +| +| assumes that each data element does not need to +| be freed. + --------------------------------------------------*/ +void +ldestroy ( LISTID lid ) +{ + LIST * l; + NODEPOOL * p1, * p2; + + l = (LIST *)lid; + + CKLMAGIC(l); + + /*-------------------------------------------------- + | free each node pool - start at the first node + | pool and free each successive until there are + | no more. + --------------------------------------------------*/ + p1 = l->np_top; + while (p1 != NULL) { + p2 = p1->chain_next; + FREE(p1); + p1 = p2; + } + + /*-------------------------------------------------- + | now free the memory occupied by the list itself + --------------------------------------------------*/ + if (l->free_on_close) { + FREE ( l ); + } +} + + + + +/*------------------------------------------------------------ +| ladd +| +| add list - add item p to the list + ------------------------------------------------------------*/ +int +ladd ( LISTID lid, void * p ) +{ + LIST * l; + LISTNODE *lnptr; + + l = (LIST *)lid; + + CKLMAGIC(l); + + lnptr = get_listnode(l); + if (lnptr==NULL) { +#ifdef BOS + breakpoint(); +#endif + return -1; + } + + CKMAGIC(lnptr); + + lnptr->data = p; + + if (l->top == NULL) { + l->top = lnptr; + l->bottom = lnptr; + lnptr->next = NULL; + lnptr->prev = NULL; + } + else { + lnptr->prev = l->bottom; + lnptr->next = NULL; + l->bottom->next = lnptr; + l->bottom = lnptr; + } + l->num++; + + CKLMAGIC(l); + + return 0; +} + + + +/*------------------------------------------------------------ +| laddo +| +| add list, ordered - add item p to the list, use 'compare' +| function to place 'p' when the comparison 'p' is less than +| the next item. Return 0 if this was a unique entry, +| else return 1 indicating a duplicate entry, i.e., the +| compare function returned 0 while inserting the element. + ------------------------------------------------------------*/ +int +laddo ( LISTID lid, void * p, int (*compare)(const void *p1,const void *p2), + LNODEID * firstdup ) +{ + LIST * l; + LISTNODE * ln; + int dup, cmp; + + l = (LIST *)lid; + + CKLMAGIC(l); + + dup = 0; + ln = l->top; + + while (ln!=NULL) { + CKMAGIC(ln); + cmp = compare(p,ln->data); + if (cmp == 0) { + dup = 1; + if (firstdup) + *firstdup = ln; + } + if (cmp < 0) { + insert_ln(l,ln,p); + CKLMAGIC(l); + return dup; + } + else { + ln = ln->next; + } + } + + ladd(l,p); + + CKLMAGIC(l); + + return dup; +} + + +/*--------------------------------------------------------------------------- +| laddu +| +| add list, ordered, unique - add item p to the list, use 'compare' +| function to place 'p' when the comparison 'p' is less than the next +| item. Return 1 if the item was added, 0 if not. +| + --------------------------------------------------------------------------*/ +int +laddu ( LISTID lid, void * p, int (*compare)(const void *p1,const void *p2) ) +{ + LIST * l; + LISTNODE * ln; + int cmp; + + l = (LIST *)lid; + + CKLMAGIC(l); + + ln = l->top; + + while (ln!=NULL) { + CKMAGIC(ln); + cmp = compare(p,ln->data); + if (cmp == 0) { + CKLMAGIC(l); + return 0; + } + if (cmp < 0) { + insert_ln(l,ln,p); + CKLMAGIC(l); + return 1; + } + else { + ln = ln->next; + } + } + + ladd(l,p); + + CKLMAGIC(l); + + return 1; +} + + + + +LNODEID +lfirst ( LISTID lid ) +{ + CKLMAGIC(((LIST *)lid)); + return ((LIST *)lid)->top; +} + + +LNODEID +llast ( LISTID lid ) +{ + CKLMAGIC(((LIST *)lid)); + return ((LIST *)lid)->bottom; +} + + +LNODEID +lnext ( LNODEID lnid ) +{ + CKMAGIC(((LISTNODE *)lnid)); + return ((LISTNODE *)lnid)->next; +} + + +LNODEID +lprev ( LNODEID lnid ) +{ + CKMAGIC(((LISTNODE *)lnid)); + return ((LISTNODE *)lnid)->prev; +} + + +void * +ldata ( LNODEID lnid ) +{ + CKMAGIC(((LISTNODE *)lnid)); + return ((LISTNODE *)lnid)->data; +} + + + +int +lsize ( LISTID lid ) +{ + CKLMAGIC(((LIST *)lid)); + return ((LIST *)lid)->num; +} + + + +/*------------------------------------------------------------ +| lcat +| +| catenate - catenate l2 to l1, return pointer to l1. + ------------------------------------------------------------*/ +LISTID +lcat ( LISTID lid1, LISTID lid2 ) +{ + CKLMAGIC(((LIST *)lid1)); + CKLMAGIC(((LIST *)lid2)); + while (lsize(lid2)) { + ladd ( lid1, lrmv_n(lid2,1) ); + } + + CKLMAGIC(((LIST *)lid1)); + CKLMAGIC(((LIST *)lid2)); + + return lid1; +} + + + +/*---------------------------------------------------------------------- +| lget +| +| get from list, last item - return pointer to the data of the last +| item in the list, non-destructive + ----------------------------------------------------------------------*/ +void * +lget ( LISTID lid ) +{ + LIST * l; + LISTNODE * p; + + l = (LIST *)lid; + + CKLMAGIC(l); + + p = l->bottom; + + if (p == NULL) { + CKLMAGIC(l); + return NULL; + } + else { + CKLMAGIC(l); + return p->data; + } +} + + + +/*--------------------------------------------------------------- +| lget_n +| +| get from list, index - return the nth list item, +| non-destructive + ---------------------------------------------------------------*/ +void * +lget_n ( LISTID lid, unsigned int n ) +{ + int i; + LIST * l; + LISTNODE * ln; + + l = (LIST *)lid; + + CKLMAGIC(l); + + if ((n<1)||(n>lsize(l))) { + return NULL; + } + + ln = l->top; + i = 1; + while (ln && (i!=n)) { + CKMAGIC(ln); + ln = ln->next; + i++; + } + + if (ln) { + CKLMAGIC(l); + return ln->data; + } + else { + CKLMAGIC(l); + return NULL; + } +} + + + +/*--------------------------------------------------------------- +| lget_ln +| +| get from list, listnode - return the nth list item, the +| listnode is returned instead of the data, non-destructive + ---------------------------------------------------------------*/ +LNODEID +lget_ln ( LISTID lid, unsigned int n ) +{ + int i; + LIST * l; + LISTNODE * ln; + + l = (LIST *)lid; + + CKLMAGIC(l); + + if ((n<1)||(n>lsize(l))) { + return NULL; + } + + ln = l->top; + i = 1; + while (i!=n) { + CKMAGIC(ln); + ln = ln->next; + i++; + } + + CKLMAGIC(l); + return (LNODEID)ln; +} + + + +/*---------------------------------------------------------------------- +| insert_ln +| +| insert data, listnode - insert data just before the list item +| pointed to by 'ln'. +| +| This routine is not intended to be called directly by the user +| because the validity of ln is not checked. This routine is called +| by list manipulation routines within this module, in which ln is +| known to point to a valid list node. + ----------------------------------------------------------------------*/ +static +int +insert_ln ( LIST * l, LISTNODE * ln, void * data_ptr ) +{ + LISTNODE * lnptr; + + CKLMAGIC(l); + + if (ln==NULL) { + ladd ( l, data_ptr ); + CKLMAGIC(l); + return 0; + } + + lnptr = get_listnode(l); + if (lnptr == NULL) { +#ifdef BOS + breakpoint(); +#endif + return -1; + } + + CKMAGIC(lnptr); + + lnptr->data = data_ptr; + + if (ln==l->top) { + /*------------------------------ + | insert before the list head + ------------------------------*/ + lnptr->next = ln; + lnptr->prev = NULL; + ln->prev = lnptr; + l->top = lnptr; + } + else if (ln==NULL) { + /*----------------- + | list was empty + -----------------*/ + lnptr->next = NULL; + lnptr->prev = l->bottom; + l->bottom->next = lnptr; + l->bottom = lnptr; + } + else { + /*----------------------------------- + | insert in the middle of the list + -----------------------------------*/ + lnptr->next = ln; + lnptr->prev = ln->prev; + lnptr->next->prev = lnptr; + lnptr->prev->next = lnptr; + } + + l->num++; + + CKLMAGIC(l); + + return 0; +} + + + +/*----------------------------------------------------------------- +| lins_n +| +| Insert data before the nth item in the list. + -----------------------------------------------------------------*/ +int +lins_n ( LISTID lid, void * data_ptr, unsigned int n ) +{ + int i; + LIST * l; + LISTNODE * ln; + + l = (LIST *)lid; + + CKLMAGIC(l); + + if ((n<1)||(n>(l->num+1))) { + return -1; + } + + if (l->num == 0) { + return ladd ( lid, data_ptr ); + } + + /*---------------------------------- + | locate the nth item in the list + ----------------------------------*/ + ln = l->top; + i = 1; + while (ln && (i!=n)) { + CKMAGIC(ln); + ln = ln->next; + i++; + } + + if (!ln) { + CKLMAGIC(l); + return -1; + } + + CKLMAGIC(l); + + /*----------------------------------------- + | insert before the nth item in the list + -----------------------------------------*/ + return insert_ln ( l, ln, data_ptr ); +} + + +/*----------------------------------------------------------------- +| lins_ln +| +| Insert data before the list node pointed to by ln. + -----------------------------------------------------------------*/ +int +lins_ln ( LISTID lid, LNODEID lnid, void * data_ptr ) +{ + LIST * l; + LISTNODE * ln; + LISTNODE * ln_ptr; + + l = (LIST *)lid; + ln = (LISTNODE *)lnid; + + CKLMAGIC(l); + + CKMAGIC(ln); + + /*----------------------------------------- + | validate that ln is indeed in the list + -----------------------------------------*/ + ln_ptr = l->top; + while ((ln_ptr!=NULL)&&(ln_ptr!=ln)) { + CKMAGIC(ln_ptr); + ln_ptr = ln_ptr->next; + } + + if (ln_ptr == NULL) { + CKLMAGIC(l); + return -1; + } + + CKLMAGIC(l); + + /*-------------------------------- + | insert the data into the list + --------------------------------*/ + return insert_ln ( l, ln, data_ptr ); +} + + + +/*---------------------------------------------------------------------- +| remove_ln +| +| Remove the item in the list pointed to by ln. This routine is not +| intended to be called directly by the user because the validity +| of ln is not checked. This routine is called by list manipulation +| routines within this module, in which ln is known to point to a +| valid list node. + ----------------------------------------------------------------------*/ +static +void * +remove_ln ( LIST * l, LISTNODE * ln ) +{ + void * r; + + CKLMAGIC(l); + + CKMAGIC(ln); + + if (ln==l->top) { + /*------------------------------ + | remove the head of the list + ------------------------------*/ + l->top = ln->next; + if (l->top != NULL) { + l->top->prev = NULL; + } + else { + /*---------------------------------------- + | this was the only item in the list + ----------------------------------------*/ + l->bottom = NULL; + } + } + else if (ln==l->bottom) { + /*------------------------------ + | remove the tail of the list + ------------------------------*/ + l->bottom = ln->prev; + if (l->bottom != NULL) { + l->bottom->next = NULL; + } + } + else { + /*------------------------------------- + | remove from the middle of the list + -------------------------------------*/ + ln->prev->next = ln->next; + ln->next->prev = ln->prev; + } + + /*----------------------------- + | prepare to return the data + -----------------------------*/ + r = ln->data; + + /*----------------------------------------------- + | free the listnode for re-use + -----------------------------------------------*/ + free_listnode(l,ln); + + /*------------------------------------ + | adjust the item count of the list + ------------------------------------*/ + l->num--; + + CKLMAGIC(l); + + return r; +} + + + +/*------------------------------------------------------------------------- +| lrmv_d +| +| remove from list, data - removes the data element from the list, +| destructive + -------------------------------------------------------------------------*/ +void * +lrmv_d ( LISTID lid, void * data_ptr ) +{ + LIST * l; + LISTNODE * ln; + int i; + + l = (LIST *)lid; + + CKLMAGIC(l); + + i = 0; + ln = l->top; + while (ln && (ln->data != data_ptr)) { + i++; + CKMAGIC(ln); + ln = ln->next; + } + + if (ln == NULL) { + CKLMAGIC(l); + return NULL; + } + else { + CKLMAGIC(l); + return remove_ln ( l, ln ); + } +} + + + +/*------------------------------------------------------------------------- +| lrmv_ln +| +| remove from list, by list node - remove the data element pointed to +| by 'ln' from the list, destructive + -------------------------------------------------------------------------*/ +void * +lrmv_ln ( LISTID lid, LNODEID lnid ) +{ + LIST * l; + LISTNODE * ln; + LISTNODE * p; + + l = (LIST *)lid; + ln = (LISTNODE *)lnid; + + CKLMAGIC(l); + + CKMAGIC(ln); + + p = l->top; + while ((p!=NULL)&&(p!=ln)) { + CKMAGIC(p); + p = p->next; + } + + if (p==NULL) { + CKLMAGIC(l); + return NULL; + } + else { + CKLMAGIC(l); + return remove_ln ( l, p ); + } +} + + + +/*---------------------------------------------------------------------- +| lrmv_n +| +| remove from list, by item number - remove the nth element from +| the list. + ----------------------------------------------------------------------*/ +void * +lrmv_n ( LISTID lid, unsigned int n ) +{ + int i; + LIST * l; + LISTNODE * ln; + + l = (LIST *)lid; + + CKLMAGIC(l); + + if ((n<1)||(n>l->num)) { + return NULL; + } + + ln = l->top; + i = 1; + while (ln && (i!=n)) { + CKMAGIC(ln); + ln = ln->next; + i++; + } + + if (ln) { + CKLMAGIC(l); + return remove_ln ( l, ln ); + } + else { + CKLMAGIC(l); + return NULL; + } +} + + +/*---------------------------------------------------------------------- +| lrmv +| +| remove from list, last item - remove the last item from the list, +| destructive + ----------------------------------------------------------------------*/ +void * +lrmv ( LISTID lid ) +{ + LIST * l; + LISTNODE * p; + + l = (LIST *)lid; + + CKLMAGIC(l); + + p = l->bottom; + + if (p == NULL) { + CKLMAGIC(l); + return NULL; + } + else { + CKLMAGIC(l); + return remove_ln ( l, p ); + } +} + + + +/*---------------------------------------------------------------------- +| lsrch +| +| search list - return data element pointed to by 'p', NULL if not +| found + ----------------------------------------------------------------------*/ +void * +lsrch ( LISTID lid, void * p, int (* compare)(void * p1, void * p2) ) +{ + LIST * l; + LISTNODE * ln; + + l = (LIST *)lid; + + CKLMAGIC(l); + + ln = l->top; + + while (ln!=NULL) { + CKMAGIC(ln); + if (compare(p,ln->data) == 0) { + CKLMAGIC(l); + return ln->data; + } + else { + ln = ln->next; + } + } + + CKLMAGIC(l); + return NULL; +} + +/*---------------------------------------------------------------------- +| lsort +| +| sort list - sorts list inplace (using bubble sort) +| + ----------------------------------------------------------------------*/ +void +lsort ( LISTID lid, int (* compare)(void * p1, void * p2) ) +{ + LIST * l; + LISTNODE * lt; /* this */ + LISTNODE * ln; /* next */ + int unsorted = 1; + + l = (LIST *)lid; + + CKLMAGIC(l); + + while(unsorted){ + lt = l->top; + unsorted = 0; + while (lt!=NULL) { + CKMAGIC(lt); + ln = lt->next; + if (ln!= NULL && compare(lt->data,ln->data) > 0) { + void * p = ln->data; + ln->data = lt->data; + lt->data = p; + unsorted = 1; + } + lt = ln; + } + } + + CKLMAGIC(l); +} + + +int lprint ( FILE * f, LISTID lid ) +{ + LIST * l; + LISTNODE * ln; + NODEPOOL * np; + int count; + + l = (LIST *)lid; + + fprintf ( f, "list id %p internal data structures:\n", + lid ); +#if CHECK_MAGIC + if ((l->magic1 != MAGIC) || (l->magic2 != MAGIC)) { + fprintf ( f, " *** WARNING: LIST MAGIC IS CORRUPT ***\n" ); + } + fprintf ( f, + " magic1=0x%08x\n" + " magic2=0x%08x\n", + l->magic1, l->magic2 ); +#endif + fprintf ( f, " num f pool n_ln top bottom next_ln np_top np_bottom\n" ); + fprintf ( f, " ---- - ---- ---- ---------- ---------- ---------- ---------- ----------\n" ); + fprintf ( f, " %4d %1d %4d %4d %10p %10p %10p %10p %10p\n", + l->num, l->free_on_close, l->poolsize, l->n_ln_pool, + l->top, l->bottom, + l->next_ln, l->np_top, l->np_bottom ); + + + fprintf ( f, + " node pools:\n" + " idx np magic1 next prev magic2\n" + " ---- ---------- ---------- ---------- ---------- ----------\n" ); + count = 0; + np = l->np_top; + while (np != NULL) { + count++; + fprintf ( f, " %4d %10p 0x%08x %10p %10p 0x%08x\n", + count, np, +#if CHECK_MAGIC + np->magic1, +#else + 0, +#endif + np->chain_next, np->chain_prev, +#if CHECK_MAGIC + np->magic2 +#else + 0 +#endif + ); + np = np->chain_next; + } + + if (f) { + fprintf ( f, + " list elements:\n" + " n ln magic1 next prev data magic2\n" + " ---- ---------- ---------- ---------- ---------- ---------- ----------\n" ); + count = 0; + ln = l->top; + while (ln != NULL) { + count++; + fprintf ( f, " %4d %10p %10x %10p %10p %10p %10x\n", + count, ln, +#if CHECK_MAGIC + ln->magic1, +#else + 0, +#endif + ln->next, ln->prev, ln->data, +#if CHECK_MAGIC + ln->magic2 +#else + 0 +#endif + ); + ln = lnext(ln); + } + if (count != l->num) { + fprintf ( f, + " *** list count is not correct\n" + " *** list id indicates %d, counted items = %d\n", + l->num, count ); + } + } + + return 0; +} diff --git a/xs/src/avrdude/main.c b/xs/src/avrdude/main.c new file mode 100644 index 000000000..51fdf7268 --- /dev/null +++ b/xs/src/avrdude/main.c @@ -0,0 +1,1510 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2000-2005 Brian S. Dean + * Copyright 2007-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 + * 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$ */ + +/* + * Code to program an Atmel AVR device through one of the supported + * programmers. + * + * For parallel port connected programmers, the pin definitions can be + * changed via a config file. See the config file for instructions on + * how to add a programmer definition. + * + */ + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(WIN32NATIVE) +# include +# include +# include +#endif + +#include "avrdude.h" +#include "libavrdude.h" + +#include "term.h" + + +/* Get VERSION from ac_cfg.h */ +char * version = VERSION "-prusa3d"; + +char * progname; +char progbuf[PATH_MAX]; /* temporary buffer of spaces the same + length as progname; used for lining up + multiline messages */ + +#define MSGBUFFER_SIZE 4096 +char msgbuffer[MSGBUFFER_SIZE]; + +bool cancel_flag = false; + +static void avrdude_message_handler_null(const char *msg, unsigned size, void *user_p) +{ + // Output to stderr by default + (void)size; + (void)user_p; + fputs(msg, stderr); +} + +static void *avrdude_message_handler_user_p = NULL; +static avrdude_message_handler_t avrdude_message_handler = avrdude_message_handler_null; + +void avrdude_message_handler_set(avrdude_message_handler_t newhandler, void *user_p) +{ + if (newhandler != NULL) { + avrdude_message_handler = newhandler; + avrdude_message_handler_user_p = user_p; + } else { + avrdude_message_handler = avrdude_message_handler_null; + avrdude_message_handler_user_p = NULL; + } +} + +int avrdude_message(const int msglvl, const char *format, ...) +{ + static const char *format_error = "avrdude_message: Could not format message"; + + int rc = 0; + va_list ap; + if (verbose >= msglvl) { + va_start(ap, format); + rc = vsnprintf(msgbuffer, MSGBUFFER_SIZE, format, ap); + + if (rc > 0 && rc < MSGBUFFER_SIZE) { + avrdude_message_handler(msgbuffer, rc, avrdude_message_handler_user_p); + } else { + rc = snprintf(msgbuffer, MSGBUFFER_SIZE, "%s: %s", format_error, format); + if (rc > 0 && rc < MSGBUFFER_SIZE) { + avrdude_message_handler(msgbuffer, rc, avrdude_message_handler_user_p); + } else { + avrdude_message_handler(format_error, strlen(format_error), avrdude_message_handler_user_p); + } + } + + va_end(ap); + } + return rc; +} + + +static void avrdude_progress_handler_null(const char *task, unsigned progress, void *user_p) +{ + // By default do nothing + (void)task; + (void)progress; + (void)user_p; +} + +static void *avrdude_progress_handler_user_p = NULL; +static avrdude_progress_handler_t avrdude_progress_handler = avrdude_progress_handler_null; + +void avrdude_progress_handler_set(avrdude_progress_handler_t newhandler, void *user_p) +{ + if (newhandler != NULL) { + avrdude_progress_handler = newhandler; + avrdude_progress_handler_user_p = user_p; + } else { + avrdude_progress_handler = avrdude_progress_handler_null; + avrdude_progress_handler_user_p = NULL; + } +} + +void avrdude_progress_external(const char *task, unsigned progress) +{ + avrdude_progress_handler(task, progress, avrdude_progress_handler_user_p); +} + +void avrdude_cancel() +{ + cancel_flag = true; +} + + +struct list_walk_cookie +{ + FILE *f; + const char *prefix; +}; + +static LISTID updates = NULL; + +static LISTID extended_params = NULL; + +static LISTID additional_config_files = NULL; + +static PROGRAMMER * pgm; +static bool pgm_setup = false; + +/* + * global options + */ +int verbose; /* verbose output */ +int quell_progress; /* un-verebose output */ +int ovsigck; /* 1=override sig check, 0=don't */ + + + + +/* + * usage message + */ +static void usage(void) +{ + avrdude_message(MSG_INFO, + "Usage: %s [options]\n" + "Options:\n" + " -p Required. Specify AVR device.\n" + " -b Override RS-232 baud rate.\n" + " -B Specify JTAG/STK500v2 bit clock period (us).\n" + " -C Specify location of configuration file.\n" + " -c Specify programmer type.\n" + " -D Disable auto erase for flash memory\n" + " -i ISP Clock Delay [in microseconds]\n" + " -P Specify connection port.\n" + " -F Override invalid signature check.\n" + " -e Perform a chip erase.\n" + " -O Perform RC oscillator calibration (see AVR053). \n" + " -U :r|w|v:[:format]\n" + " Memory operation specification.\n" + " Multiple -U options are allowed, each request\n" + " is performed in the order specified.\n" + " -n Do not write anything to the device.\n" + " -V Do not verify.\n" + " -u Disable safemode, default when running from a script.\n" + " -s Silent safemode operation, will not ask you if\n" + " fuses should be changed back.\n" + " -t Enter terminal mode.\n" + " -E [,] List programmer exit specifications.\n" + " -x Pass to programmer.\n" + " -y Count # erase cycles in EEPROM.\n" + " -Y Initialize erase cycle # in EEPROM.\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" + " -? Display this usage.\n" + "\navrdude version %s, URL: \n" + ,progname, version); +} + + +// static void update_progress_tty (int percent, double etime, char *hdr) +// { +// static char hashes[51]; +// static char *header; +// static int last = 0; +// int i; + +// setvbuf(stderr, (char*)NULL, _IONBF, 0); + +// hashes[50] = 0; + +// memset (hashes, ' ', 50); +// for (i=0; i>1)*2; + + // setvbuf(stderr, (char*)NULL, _IONBF, 0); + + if (hdr) { + avrdude_message(MSG_INFO, "\n%s | ", hdr); + last = 0; + done = 0; + header = hdr; + avrdude_progress_external(header, 0); + } + else { + while ((cnt > last) && (done == 0)) { + avrdude_message(MSG_INFO, "#"); + cnt -= 2; + } + + if (done == 0) { + avrdude_progress_external(header, percent > 99 ? 99 : percent); + } + } + + if ((percent == 100) && (done == 0)) { + avrdude_message(MSG_INFO, " | 100%% %0.2fs\n\n", etime); + avrdude_progress_external(header, 100); + last = 0; + done = 1; + } + else + last = (percent>>1)*2; /* Make last a multiple of 2. */ + + // setvbuf(stderr, (char*)NULL, _IOLBF, 0); +} + +static void list_programmers_callback(const char *name, const char *desc, + const char *cfgname, int cfglineno, + void *cookie) +{ + struct list_walk_cookie *c = (struct list_walk_cookie *)cookie; + if (verbose){ + fprintf(c->f, "%s%-16s = %-30s [%s:%d]\n", + c->prefix, name, desc, cfgname, cfglineno); + } else { + fprintf(c->f, "%s%-16s = %-s\n", + c->prefix, name, desc); + } +} + +static void list_programmers(FILE * f, const char *prefix, LISTID programmers) +{ + struct list_walk_cookie c; + + c.f = f; + c.prefix = prefix; + + sort_programmers(programmers); + + walk_programmers(programmers, list_programmers_callback, &c); +} + +static void list_programmer_types_callback(const char *name, const char *desc, + void *cookie) +{ + struct list_walk_cookie *c = (struct list_walk_cookie *)cookie; + fprintf(c->f, "%s%-16s = %-s\n", + c->prefix, name, desc); +} + +static void list_programmer_types(FILE * f, const char *prefix) +{ + struct list_walk_cookie c; + + c.f = f; + c.prefix = prefix; + + walk_programmer_types(list_programmer_types_callback, &c); +} + +static void list_avrparts_callback(const char *name, const char *desc, + const char *cfgname, int cfglineno, + void *cookie) +{ + struct list_walk_cookie *c = (struct list_walk_cookie *)cookie; + + /* hide ids starting with '.' */ + if ((verbose < 2) && (name[0] == '.')) + return; + + if (verbose) { + fprintf(c->f, "%s%-8s = %-18s [%s:%d]\n", + c->prefix, name, desc, cfgname, cfglineno); + } else { + fprintf(c->f, "%s%-8s = %s\n", + c->prefix, name, desc); + } +} + +static void list_parts(FILE * f, const char *prefix, LISTID avrparts) +{ + struct list_walk_cookie c; + + c.f = f; + c.prefix = prefix; + + sort_avrparts(avrparts); + + walk_avrparts(avrparts, list_avrparts_callback, &c); +} + +// static void exithook(void) +// { +// if (pgm->teardown) +// pgm->teardown(pgm); +// } + +static int cleanup_main(int status) +{ + if (pgm_setup && pgm->teardown) { + pgm->teardown(pgm); + } + + if (updates) { + ldestroy_cb(updates, (void(*)(void*))free_update); + updates = NULL; + } + if (extended_params) { + ldestroy(extended_params); + extended_params = NULL; + } + if (additional_config_files) { + ldestroy(additional_config_files); + additional_config_files = NULL; + } + + cleanup_config(); + + return status; +} + +/* + * main routine + */ +int avrdude_main(int argc, char * argv [], const char *sys_config) +{ + int rc; /* general return code checking */ + int exitrc; /* exit code for main() */ + int i; /* general loop counter */ + int ch; /* options flag */ + int len; /* length for various strings */ + struct avrpart * p; /* which avr part we are programming */ + AVRMEM * sig; /* signature data */ + struct stat sb; + UPDATE * upd; + LNODEID * ln; + + + /* options / operating mode variables */ + int erase; /* 1=erase chip, 0=don't */ + int calibrate; /* 1=calibrate RC oscillator, 0=don't */ + char * port; /* device port (/dev/xxx) */ + int terminal; /* 1=enter terminal mode, 0=don't */ + int verify; /* perform a verify operation */ + char * exitspecs; /* exit specs string from command line */ + char * programmer; /* programmer id */ + char * partdesc; /* part id */ + // char sys_config[PATH_MAX]; /* system wide config file */ + char usr_config[PATH_MAX]; /* per-user config file */ + char * e; /* for strtol() error checking */ + int baudrate; /* override default programmer baud rate */ + double bitclock; /* Specify programmer bit clock (JTAG ICE) */ + int ispdelay; /* Specify the delay for ISP clock */ + int safemode; /* Enable safemode, 1=safemode on, 0=normal */ + int silentsafe; /* Don't ask about fuses, 1=silent, 0=normal */ + int init_ok; /* Device initialization worked well */ + int is_open; /* Device open succeeded */ + // char * logfile; /* Use logfile rather than stderr for diagnostics */ + enum updateflags uflags = UF_AUTO_ERASE; /* Flags for do_op() */ + unsigned char safemode_lfuse = 0xff; + unsigned char safemode_hfuse = 0xff; + unsigned char safemode_efuse = 0xff; + unsigned char safemode_fuse = 0xff; + + char * safemode_response; + int fuses_specified = 0; + int fuses_updated = 0; +// #if !defined(WIN32NATIVE) +// char * homedir; +// #endif + + /* + * Set line buffering for file descriptors so we see stdout and stderr + * properly interleaved. + */ + // setvbuf(stdout, (char*)NULL, _IOLBF, 0); + // setvbuf(stderr, (char*)NULL, _IOLBF, 0); + + progname = strrchr(argv[0],'/'); + + cancel_flag = false; + +#if defined (WIN32NATIVE) + /* take care of backslash as dir sep in W32 */ + if (!progname) progname = strrchr(argv[0],'\\'); +#endif /* WIN32NATIVE */ + + if (progname) + progname++; + else + progname = argv[0]; + + default_parallel[0] = 0; + default_serial[0] = 0; + default_bitclock = 0.0; + default_safemode = -1; + + init_config(); + + // atexit(cleanup_main); + + updates = lcreat(NULL, 0); + if (updates == NULL) { + avrdude_message(MSG_INFO, "%s: cannot initialize updater list\n", progname); + return cleanup_main(1); + } + + extended_params = lcreat(NULL, 0); + if (extended_params == NULL) { + avrdude_message(MSG_INFO, "%s: cannot initialize extended parameter list\n", progname); + return cleanup_main(1); + } + + additional_config_files = lcreat(NULL, 0); + if (additional_config_files == NULL) { + avrdude_message(MSG_INFO, "%s: cannot initialize additional config files list\n", progname); + return cleanup_main(1); + } + + partdesc = NULL; + port = NULL; + erase = 0; + calibrate = 0; + p = NULL; + ovsigck = 0; + terminal = 0; + verify = 1; /* on by default */ + quell_progress = 0; + exitspecs = NULL; + pgm = NULL; + programmer = default_programmer; + verbose = 0; + baudrate = 0; + bitclock = 0.0; + ispdelay = 0; + safemode = 1; /* Safemode on by default */ + silentsafe = 0; /* Ask by default */ + is_open = 0; + // logfile = NULL; + +// #if defined(WIN32NATIVE) + +// win_sys_config_set(sys_config); +// win_usr_config_set(usr_config); + +// #else + +// strcpy(sys_config, CONFIG_DIR); +// i = strlen(sys_config); +// if (i && (sys_config[i-1] != '/')) +// strcat(sys_config, "/"); +// strcat(sys_config, "avrdude.conf"); + + usr_config[0] = 0; +// homedir = getenv("HOME"); +// if (homedir != NULL) { +// strcpy(usr_config, homedir); +// i = strlen(usr_config); +// if (i && (usr_config[i-1] != '/')) +// strcat(usr_config, "/"); +// strcat(usr_config, ".avrduderc"); +// } + +// #endif + + len = strlen(progname) + 2; + for (i=0; iop == DEVICE_WRITE) { + upd = dup_update(upd); + upd->op = DEVICE_VERIFY; + ladd(updates, upd); + } + break; + + case 'v': + verbose++; + break; + + case 'V': + verify = 0; + break; + + case 'x': + ladd(extended_params, optarg); + break; + + case 'y': + avrdude_message(MSG_INFO, "%s: erase cycle counter no longer supported\n", + progname); + break; + + case 'Y': + avrdude_message(MSG_INFO, "%s: erase cycle counter no longer supported\n", + progname); + break; + + case '?': /* help */ + usage(); + return cleanup_main(0); + break; + + default: + avrdude_message(MSG_INFO, "%s: invalid option -%c\n\n", progname, ch); + usage(); + return cleanup_main(1); + break; + } + + } + + // if (logfile != NULL) { + // FILE *newstderr = freopen(logfile, "w", stderr); + // if (newstderr == NULL) { + // /* Help! There's no stderr to complain to anymore now. */ + // printf("Cannot create logfile \"%s\": %s\n", + // logfile, strerror(errno)); + // return 1; + // } + // } + + if (quell_progress == 0) { + // if (isatty (STDERR_FILENO)) + // update_progress = update_progress_tty; + // else { + // update_progress = update_progress_no_tty; + // /* disable all buffering of stderr for compatibility with + // software that captures and redirects output to a GUI + // i.e. Programmers Notepad */ + // setvbuf( stderr, NULL, _IONBF, 0 ); + // setvbuf( stdout, NULL, _IONBF, 0 ); + // } + update_progress = update_progress_no_tty; + } + + /* + * Print out an identifying string so folks can tell what version + * they are running + */ + avrdude_message(MSG_NOTICE, "\n%s: Version %s, compiled on %s at %s\n" + "%sCopyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/\n" + "%sCopyright (c) 2007-2014 Joerg Wunsch\n\n", + progname, version, __DATE__, __TIME__, progbuf, progbuf); + avrdude_message(MSG_NOTICE, "%sSystem wide configuration file is \"%s\"\n", + progbuf, sys_config); + + rc = read_config(sys_config); + if (rc) { + avrdude_message(MSG_INFO, "%s: error reading system wide configuration file \"%s\"\n", + progname, sys_config); + return cleanup_main(1); + } + + if (usr_config[0] != 0) { + avrdude_message(MSG_NOTICE, "%sUser configuration file is \"%s\"\n", + progbuf, usr_config); + + rc = stat(usr_config, &sb); + if ((rc < 0) || ((sb.st_mode & S_IFREG) == 0)) { + avrdude_message(MSG_NOTICE, "%sUser configuration file does not exist or is not a " + "regular file, skipping\n", + progbuf); + } + else { + rc = read_config(usr_config); + if (rc) { + avrdude_message(MSG_INFO, "%s: error reading user configuration file \"%s\"\n", + progname, usr_config); + return cleanup_main(1); + } + } + } + + if (lsize(additional_config_files) > 0) { + LNODEID ln1; + const char * p = NULL; + + for (ln1=lfirst(additional_config_files); ln1; ln1=lnext(ln1)) { + p = ldata(ln1); + avrdude_message(MSG_NOTICE, "%sAdditional configuration file is \"%s\"\n", + progbuf, p); + + rc = read_config(p); + if (rc) { + avrdude_message(MSG_INFO, "%s: error reading additional configuration file \"%s\"\n", + progname, p); + return cleanup_main(1); + } + } + } + + // set bitclock from configuration files unless changed by command line + if (default_bitclock > 0 && bitclock == 0.0) { + bitclock = default_bitclock; + } + + avrdude_message(MSG_NOTICE, "\n"); + + if (partdesc) { + if (strcmp(partdesc, "?") == 0) { + avrdude_message(MSG_INFO, "\n"); + avrdude_message(MSG_INFO, "Valid parts are:\n"); + list_parts(stderr, " ", part_list); + avrdude_message(MSG_INFO, "\n"); + return cleanup_main(1); + } + } + + if (programmer) { + if (strcmp(programmer, "?") == 0) { + avrdude_message(MSG_INFO, "\n"); + avrdude_message(MSG_INFO, "Valid programmers are:\n"); + list_programmers(stderr, " ", programmers); + avrdude_message(MSG_INFO, "\n"); + return cleanup_main(1); + } + if (strcmp(programmer, "?type") == 0) { + avrdude_message(MSG_INFO, "\n"); + avrdude_message(MSG_INFO, "Valid programmer types are:\n"); + list_programmer_types(stderr, " "); + avrdude_message(MSG_INFO, "\n"); + return cleanup_main(1); + } + } + + + if (programmer[0] == 0) { + avrdude_message(MSG_INFO, "\n%s: no programmer has been specified on the command line " + "or the config file\n", + progname); + avrdude_message(MSG_INFO, "%sSpecify a programmer using the -c option and try again\n\n", + progbuf); + return cleanup_main(1); + } + + pgm = locate_programmer(programmers, programmer); + if (pgm == NULL) { + avrdude_message(MSG_INFO, "\n"); + avrdude_message(MSG_INFO, "%s: Can't find programmer id \"%s\"\n", + progname, programmer); + avrdude_message(MSG_INFO, "\nValid programmers are:\n"); + list_programmers(stderr, " ", programmers); + avrdude_message(MSG_INFO, "\n"); + return cleanup_main(1); + } + + if (pgm->initpgm) { + pgm->initpgm(pgm); + } else { + avrdude_message(MSG_INFO, "\n%s: Can't initialize the programmer.\n\n", + progname); + return cleanup_main(1); + } + + if (pgm->setup) { + pgm->setup(pgm); + } + pgm_setup = true; // Replaces the atexit hook + // if (pgm->teardown) { + // atexit(exithook); + // } + + if (lsize(extended_params) > 0) { + if (pgm->parseextparams == NULL) { + avrdude_message(MSG_INFO, "%s: WARNING: Programmer doesn't support extended parameters," + " -x option(s) ignored\n", + progname); + } else { + if (pgm->parseextparams(pgm, extended_params) < 0) { + avrdude_message(MSG_INFO, "%s: Error parsing extended parameter list\n", + progname); + return cleanup_main(1); + } + } + } + + if (port == NULL) { + switch (pgm->conntype) + { + case CONNTYPE_PARALLEL: + port = default_parallel; + break; + + case CONNTYPE_SERIAL: + port = default_serial; + break; + + case CONNTYPE_USB: + port = DEFAULT_USB; + break; + } + } + + if (partdesc == NULL) { + avrdude_message(MSG_INFO, "%s: No AVR part has been specified, use \"-p Part\"\n\n", + progname); + avrdude_message(MSG_INFO, "Valid parts are:\n"); + list_parts(stderr, " ", part_list); + avrdude_message(MSG_INFO, "\n"); + return cleanup_main(1); + } + + + p = locate_part(part_list, partdesc); + if (p == NULL) { + avrdude_message(MSG_INFO, "%s: AVR Part \"%s\" not found.\n\n", + progname, partdesc); + avrdude_message(MSG_INFO, "Valid parts are:\n"); + list_parts(stderr, " ", part_list); + avrdude_message(MSG_INFO, "\n"); + return cleanup_main(1); + } + + + if (exitspecs != NULL) { + if (pgm->parseexitspecs == NULL) { + avrdude_message(MSG_INFO, "%s: WARNING: -E option not supported by this programmer type\n", + progname); + exitspecs = NULL; + } + else if (pgm->parseexitspecs(pgm, exitspecs) < 0) { + usage(); + return cleanup_main(1); + } + } + + if (default_safemode == 0) { + /* configuration disables safemode: revert meaning of -u */ + if (safemode == 0) + /* -u was given: enable safemode */ + safemode = 1; + else + /* -u not given: turn off */ + safemode = 0; + } + + if (isatty(STDIN_FILENO) == 0 && silentsafe == 0) + safemode = 0; /* Turn off safemode if this isn't a terminal */ + + + if(p->flags & AVRPART_AVR32) { + safemode = 0; + } + + if(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_TPI)) { + safemode = 0; + } + + + if (avr_initmem(p) != 0) + { + avrdude_message(MSG_INFO, "\n%s: failed to initialize memories\n", + progname); + return cleanup_main(1); + } + + /* + * Now that we know which part we are going to program, locate any + * -U options using the default memory region, and fill in the + * device-dependent default region name, either "application" (for + * Xmega devices), or "flash" (everything else). + */ + for (ln=lfirst(updates); ln; ln=lnext(ln)) { + upd = ldata(ln); + if (upd->memtype == NULL) { + const char *mtype = (p->flags & AVRPART_HAS_PDI)? "application": "flash"; + avrdude_message(MSG_NOTICE2, "%s: defaulting memtype in -U %c:%s option to \"%s\"\n", + progname, + (upd->op == DEVICE_READ)? 'r': (upd->op == DEVICE_WRITE)? 'w': 'v', + upd->filename, mtype); + if ((upd->memtype = strdup(mtype)) == NULL) { + avrdude_message(MSG_INFO, "%s: out of memory\n", progname); + return cleanup_main(1); + } + } + } + + /* + * open the programmer + */ + if (port[0] == 0) { + avrdude_message(MSG_INFO, "\n%s: no port has been specified on the command line " + "or the config file\n", + progname); + avrdude_message(MSG_INFO, "%sSpecify a port using the -P option and try again\n\n", + progbuf); + return cleanup_main(1); + } + + if (verbose) { + avrdude_message(MSG_NOTICE, "%sUsing Port : %s\n", progbuf, port); + avrdude_message(MSG_NOTICE, "%sUsing Programmer : %s\n", progbuf, programmer); + if ((strcmp(pgm->type, "avr910") == 0)) { + avrdude_message(MSG_NOTICE, "%savr910_devcode (avrdude.conf) : ", progbuf); + if(p->avr910_devcode)avrdude_message(MSG_INFO, "0x%x\n", p->avr910_devcode); + else avrdude_message(MSG_NOTICE, "none\n"); + } + } + + if (baudrate != 0) { + avrdude_message(MSG_NOTICE, "%sOverriding Baud Rate : %d\n", progbuf, baudrate); + pgm->baudrate = baudrate; + } + + if (bitclock != 0.0) { + avrdude_message(MSG_NOTICE, "%sSetting bit clk period : %.1f\n", progbuf, bitclock); + pgm->bitclock = bitclock * 1e-6; + } + + if (ispdelay != 0) { + avrdude_message(MSG_NOTICE, "%sSetting isp clock delay : %3i\n", progbuf, ispdelay); + pgm->ispdelay = ispdelay; + } + + rc = pgm->open(pgm, port); + if (rc < 0) { + exitrc = 1; + pgm->ppidata = 0; /* clear all bits at exit */ + goto main_exit; + } + is_open = 1; + + if (calibrate) { + /* + * perform an RC oscillator calibration + * as outlined in appnote AVR053 + */ + if (pgm->perform_osccal == 0) { + avrdude_message(MSG_INFO, "%s: programmer does not support RC oscillator calibration\n", + progname); + exitrc = 1; + } else { + avrdude_message(MSG_INFO, "%s: performing RC oscillator calibration\n", progname); + exitrc = pgm->perform_osccal(pgm); + } + if (exitrc == 0 && quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: calibration value is now stored in EEPROM at address 0\n", + progname); + } + goto main_exit; + } + + if (verbose) { + avr_display(stderr, p, progbuf, verbose); + avrdude_message(MSG_NOTICE, "\n"); + programmer_display(pgm, progbuf); + } + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "\n"); + } + + exitrc = 0; + + /* + * enable the programmer + */ + pgm->enable(pgm); + + /* + * turn off all the status leds + */ + pgm->rdy_led(pgm, OFF); + pgm->err_led(pgm, OFF); + pgm->pgm_led(pgm, OFF); + pgm->vfy_led(pgm, OFF); + + /* + * initialize the chip in preperation for accepting commands + */ + init_ok = (rc = pgm->initialize(pgm, p)) >= 0; + if (!init_ok) { + avrdude_message(MSG_INFO, "%s: initialization failed, rc=%d\n", progname, rc); + if (!ovsigck) { + avrdude_message(MSG_INFO, "%sDouble check connections and try again, " + "or use -F to override\n" + "%sthis check.\n\n", + progbuf, progbuf); + exitrc = 1; + goto main_exit; + } + } + + /* indicate ready */ + pgm->rdy_led(pgm, ON); + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: AVR device initialized and ready to accept instructions\n", + progname); + } + + /* + * Let's read the signature bytes to make sure there is at least a + * chip on the other end that is responding correctly. A check + * against 0xffffff / 0x000000 should ensure that the signature bytes + * are valid. + */ + if(!(p->flags & AVRPART_AVR32)) { + int attempt = 0; + int waittime = 10000; /* 10 ms */ + + sig_again: + usleep(waittime); + if (init_ok) { + rc = avr_signature(pgm, p); + if (rc != 0) { + avrdude_message(MSG_INFO, "%s: error reading signature data, rc=%d\n", + progname, rc); + exitrc = 1; + goto main_exit; + } + } + + sig = avr_locate_mem(p, "signature"); + if (sig == NULL) { + avrdude_message(MSG_INFO, "%s: WARNING: signature data not defined for device \"%s\"\n", + progname, p->desc); + } + + if (sig != NULL) { + int ff, zz; + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: Device signature = 0x", progname); + } + ff = zz = 1; + for (i=0; isize; i++) { + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%02x", sig->buf[i]); + } + if (sig->buf[i] != 0xff) + ff = 0; + if (sig->buf[i] != 0x00) + zz = 0; + } + if (quell_progress < 2) { + AVRPART * part; + + part = locate_part_by_signature(part_list, sig->buf, sig->size); + if (part) { + avrdude_message(MSG_INFO, " (probably %s)", part->id); + } + } + if (ff || zz) { + if (++attempt < 3) { + waittime *= 5; + if (quell_progress < 2) { + avrdude_message(MSG_INFO, " (retrying)\n"); + } + goto sig_again; + } + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "\n"); + } + avrdude_message(MSG_INFO, "%s: Yikes! Invalid device signature.\n", progname); + if (!ovsigck) { + avrdude_message(MSG_INFO, "%sDouble check connections and try again, " + "or use -F to override\n" + "%sthis check.\n\n", + progbuf, progbuf); + exitrc = 1; + goto main_exit; + } + } else { + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "\n"); + } + } + + if (sig->size != 3 || + sig->buf[0] != p->signature[0] || + sig->buf[1] != p->signature[1] || + sig->buf[2] != p->signature[2]) { + avrdude_message(MSG_INFO, "%s: Expected signature for %s is %02X %02X %02X\n", + progname, p->desc, + p->signature[0], p->signature[1], p->signature[2]); + if (!ovsigck) { + avrdude_message(MSG_INFO, "%sDouble check chip, " + "or use -F to override this check.\n", + progbuf); + exitrc = 1; + goto main_exit; + } + } + } + } + + if (init_ok && safemode == 1) { + /* If safemode is enabled, go ahead and read the current low, high, + and extended fuse bytes as needed */ + + rc = safemode_readfuses(&safemode_lfuse, &safemode_hfuse, + &safemode_efuse, &safemode_fuse, pgm, p); + + if (rc != 0) { + + //Check if the programmer just doesn't support reading + if (rc == -5) + { + avrdude_message(MSG_NOTICE, "%s: safemode: Fuse reading not support by programmer.\n" + " Safemode disabled.\n", progname); + } + else + { + + avrdude_message(MSG_INFO, "%s: safemode: To protect your AVR the programming " + "will be aborted\n", + progname); + exitrc = 1; + goto main_exit; + } + } else { + //Save the fuses as default + safemode_memfuses(1, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse); + } + } + + if (uflags & UF_AUTO_ERASE) { + if ((p->flags & AVRPART_HAS_PDI) && pgm->page_erase != NULL && + lsize(updates) > 0) { + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: NOTE: Programmer supports page erase for Xmega devices.\n" + "%sEach page will be erased before programming it, but no chip erase is performed.\n" + "%sTo disable page erases, specify the -D option; for a chip-erase, use the -e option.\n", + progname, progbuf, progbuf); + } + } else { + AVRMEM * m; + const char *memname = (p->flags & AVRPART_HAS_PDI)? "application": "flash"; + + uflags &= ~UF_AUTO_ERASE; + for (ln=lfirst(updates); ln; ln=lnext(ln)) { + upd = ldata(ln); + m = avr_locate_mem(p, upd->memtype); + if (m == NULL) + continue; + if ((strcasecmp(m->desc, memname) == 0) && (upd->op == DEVICE_WRITE)) { + erase = 1; + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: NOTE: \"%s\" memory has been specified, an erase cycle " + "will be performed\n" + "%sTo disable this feature, specify the -D option.\n", + progname, memname, progbuf); + } + break; + } + } + } + } + + if (init_ok && erase) { + /* + * erase the chip's flash and eeprom memories, this is required + * before the chip can accept new programming + */ + if (uflags & UF_NOWRITE) { + avrdude_message(MSG_INFO, "%s: conflicting -e and -n options specified, NOT erasing chip\n", + progname); + } else { + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: erasing chip\n", progname); + } + exitrc = avr_chip_erase(pgm, p); + if(exitrc) goto main_exit; + } + } + + if (terminal) { + /* + * terminal mode + */ + exitrc = terminal_mode(pgm, p); + } + + if (!init_ok) { + /* + * If we came here by the -tF options, bail out now. + */ + exitrc = 1; + goto main_exit; + } + + + for (ln=lfirst(updates); ln; ln=lnext(ln)) { + upd = ldata(ln); + rc = do_op(pgm, p, upd, uflags); + if (rc) { + exitrc = 1; + break; + } + } + + /* Right before we exit programming mode, which will make the fuse + bits active, check to make sure they are still correct */ + if (safemode == 1) { + /* If safemode is enabled, go ahead and read the current low, + * high, and extended fuse bytes as needed */ + unsigned char safemodeafter_lfuse = 0xff; + unsigned char safemodeafter_hfuse = 0xff; + unsigned char safemodeafter_efuse = 0xff; + unsigned char safemodeafter_fuse = 0xff; + unsigned char failures = 0; + char yes[1] = {'y'}; + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "\n"); + } + + //Restore the default fuse values + safemode_memfuses(0, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse); + + /* Try reading back fuses, make sure they are reliable to read back */ + if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse, + &safemodeafter_efuse, &safemodeafter_fuse, pgm, p) != 0) { + /* Uh-oh.. try once more to read back fuses */ + if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse, + &safemodeafter_efuse, &safemodeafter_fuse, pgm, p) != 0) { + avrdude_message(MSG_INFO, "%s: safemode: Sorry, reading back fuses was unreliable. " + "I have given up and exited programming mode\n", + progname); + exitrc = 1; + goto main_exit; + } + } + + /* Now check what fuses are against what they should be */ + if (safemodeafter_fuse != safemode_fuse) { + fuses_updated = 1; + avrdude_message(MSG_INFO, "%s: safemode: fuse changed! Was %x, and is now %x\n", + progname, safemode_fuse, safemodeafter_fuse); + + + /* Ask user - should we change them */ + + if (silentsafe == 0) + safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] "); + else + safemode_response = yes; + + if (tolower((int)(safemode_response[0])) == 'y') { + + /* Enough chit-chat, time to program some fuses and check them */ + if (safemode_writefuse (safemode_fuse, "fuse", pgm, p, + 10) == 0) { + avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname); + } + else { + avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname); + failures++; + } + } + } + + /* Now check what fuses are against what they should be */ + if (safemodeafter_lfuse != safemode_lfuse) { + fuses_updated = 1; + avrdude_message(MSG_INFO, "%s: safemode: lfuse changed! Was %x, and is now %x\n", + progname, safemode_lfuse, safemodeafter_lfuse); + + + /* Ask user - should we change them */ + + if (silentsafe == 0) + safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] "); + else + safemode_response = yes; + + if (tolower((int)(safemode_response[0])) == 'y') { + + /* Enough chit-chat, time to program some fuses and check them */ + if (safemode_writefuse (safemode_lfuse, "lfuse", pgm, p, + 10) == 0) { + avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname); + } + else { + avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname); + failures++; + } + } + } + + /* Now check what fuses are against what they should be */ + if (safemodeafter_hfuse != safemode_hfuse) { + fuses_updated = 1; + avrdude_message(MSG_INFO, "%s: safemode: hfuse changed! Was %x, and is now %x\n", + progname, safemode_hfuse, safemodeafter_hfuse); + + /* Ask user - should we change them */ + if (silentsafe == 0) + safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] "); + else + safemode_response = yes; + if (tolower((int)(safemode_response[0])) == 'y') { + + /* Enough chit-chat, time to program some fuses and check them */ + if (safemode_writefuse(safemode_hfuse, "hfuse", pgm, p, + 10) == 0) { + avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname); + } + else { + avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname); + failures++; + } + } + } + + /* Now check what fuses are against what they should be */ + if (safemodeafter_efuse != safemode_efuse) { + fuses_updated = 1; + avrdude_message(MSG_INFO, "%s: safemode: efuse changed! Was %x, and is now %x\n", + progname, safemode_efuse, safemodeafter_efuse); + + /* Ask user - should we change them */ + if (silentsafe == 0) + safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] "); + else + safemode_response = yes; + if (tolower((int)(safemode_response[0])) == 'y') { + + /* Enough chit-chat, time to program some fuses and check them */ + if (safemode_writefuse (safemode_efuse, "efuse", pgm, p, + 10) == 0) { + avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname); + } + else { + avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname); + failures++; + } + } + } + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: safemode: ", progname); + if (failures == 0) { + avrdude_message(MSG_INFO, "Fuses OK (E:%02X, H:%02X, L:%02X)\n", + safemode_efuse, safemode_hfuse, safemode_lfuse); + } + else { + avrdude_message(MSG_INFO, "Fuses not recovered, sorry\n"); + } + } + + if (fuses_updated && fuses_specified) { + exitrc = 1; + } + + } + + +main_exit: + + /* + * program complete + */ + + if (is_open) { + pgm->powerdown(pgm); + + pgm->disable(pgm); + + pgm->rdy_led(pgm, OFF); + + pgm->close(pgm); + } + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "\n%s done. Thank you.\n\n", progname); + } + + return cleanup_main(exitrc); +} diff --git a/xs/src/avrdude/my_ddk_hidsdi.h b/xs/src/avrdude/my_ddk_hidsdi.h new file mode 100644 index 000000000..46c17d675 --- /dev/null +++ b/xs/src/avrdude/my_ddk_hidsdi.h @@ -0,0 +1,48 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2006 Christian Starkjohann + * + * 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$ */ + +/* +The following is a replacement for hidsdi.h from the Windows DDK. It defines some +of the types and function prototypes of this header for our project. If you +have the Windows DDK version of this file or a version shipped with MinGW, use +that instead. +*/ +#ifndef MY_DDK_HIDSDI_H +#define MY_DDK_HIDSDI_H +#include +#include +#include +typedef struct{ + ULONG Size; + USHORT VendorID; + USHORT ProductID; + USHORT VersionNumber; +}HIDD_ATTRIBUTES; +void __stdcall HidD_GetHidGuid(OUT LPGUID hidGuid); +BOOLEAN __stdcall HidD_GetAttributes(IN HANDLE device, OUT HIDD_ATTRIBUTES *attributes); +BOOLEAN __stdcall HidD_GetManufacturerString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); +BOOLEAN __stdcall HidD_GetProductString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); +BOOLEAN __stdcall HidD_GetSerialNumberString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); +BOOLEAN __stdcall HidD_GetFeature(IN HANDLE device, OUT void *reportBuffer, IN ULONG bufferLen); +BOOLEAN __stdcall HidD_SetFeature(IN HANDLE device, IN void *reportBuffer, IN ULONG bufferLen); +BOOLEAN __stdcall HidD_GetNumInputBuffers(IN HANDLE device, OUT ULONG *numBuffers); +BOOLEAN __stdcall HidD_SetNumInputBuffers(IN HANDLE device, OUT ULONG numBuffers); +#include +#endif /* MY_DDK_HIDSDI_H */ diff --git a/xs/src/avrdude/par.c b/xs/src/avrdude/par.c new file mode 100644 index 000000000..9dcb8db84 --- /dev/null +++ b/xs/src/avrdude/par.c @@ -0,0 +1,411 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 "ac_cfg.h" + +#include +#include +#include +#include +#include +#include + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# include "freebsd_ppi.h" +#elif defined(__linux__) +# include "linux_ppdev.h" +#elif defined(__sun__) || defined(__sun) /* Solaris */ +# include "solaris_ecpp.h" +#endif + +#include "avrdude.h" +#include "libavrdude.h" + +#include "ppi.h" +#include "bitbang.h" +#include "par.h" + +#if HAVE_PARPORT + +struct ppipins_t { + int pin; + int reg; + int bit; + int inverted; +}; + +static struct ppipins_t ppipins[] = { + { 1, PPICTRL, 0x01, 1 }, + { 2, PPIDATA, 0x01, 0 }, + { 3, PPIDATA, 0x02, 0 }, + { 4, PPIDATA, 0x04, 0 }, + { 5, PPIDATA, 0x08, 0 }, + { 6, PPIDATA, 0x10, 0 }, + { 7, PPIDATA, 0x20, 0 }, + { 8, PPIDATA, 0x40, 0 }, + { 9, PPIDATA, 0x80, 0 }, + { 10, PPISTATUS, 0x40, 0 }, + { 11, PPISTATUS, 0x80, 1 }, + { 12, PPISTATUS, 0x20, 0 }, + { 13, PPISTATUS, 0x10, 0 }, + { 14, PPICTRL, 0x02, 1 }, + { 15, PPISTATUS, 0x08, 0 }, + { 16, PPICTRL, 0x04, 0 }, + { 17, PPICTRL, 0x08, 1 } +}; + +#define NPINS (sizeof(ppipins)/sizeof(struct ppipins_t)) + +static int par_setpin_internal(PROGRAMMER * pgm, int pin, int value) +{ + int inverted; + + inverted = pin & PIN_INVERSE; + pin &= PIN_MASK; + + if (pin < 1 || pin > 17) + return -1; + + pin--; + + if (ppipins[pin].inverted) + inverted = !inverted; + + if (inverted) + value = !value; + + if (value) + ppi_set(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit); + else + ppi_clr(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit); + + if (pgm->ispdelay > 1) + bitbang_delay(pgm->ispdelay); + + return 0; +} + +static int par_setpin(PROGRAMMER * pgm, int pinfunc, int value) +{ + return par_setpin_internal(pgm, pgm->pinno[pinfunc], value); +} + +static void par_setmany(PROGRAMMER * pgm, int pinfunc, int value) +{ + int pin, mask; + int pinset = pgm->pinno[pinfunc]; + + /* mask is anything non-pin - needs to be applied to each par_setpin to preserve inversion */ + mask = pinset & (~PIN_MASK); + + for (pin = 1; pin <= 17; pin++) { + if (pinset & (1 << pin)) + par_setpin_internal(pgm, pin | mask, value); + } +} + +static int par_getpin(PROGRAMMER * pgm, int pinfunc) +{ + int value; + int inverted; + int pin = pgm->pinno[pinfunc]; + + inverted = pin & PIN_INVERSE; + pin &= PIN_MASK; + + if (pin < 1 || pin > 17) + return -1; + + pin--; + + value = ppi_get(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit); + + if (value) + value = 1; + + if (ppipins[pin].inverted) + inverted = !inverted; + + if (inverted) + value = !value; + + return value; +} + + +static int par_highpulsepin(PROGRAMMER * pgm, int pinfunc) +{ + int inverted; + int pin = pgm->pinno[pinfunc]; + + inverted = pin & PIN_INVERSE; + pin &= PIN_MASK; + + if (pin < 1 || pin > 17) + return -1; + + pin--; + + if (ppipins[pin].inverted) + inverted = !inverted; + + if (inverted) { + ppi_clr(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit); + if (pgm->ispdelay > 1) + bitbang_delay(pgm->ispdelay); + + ppi_set(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit); + if (pgm->ispdelay > 1) + bitbang_delay(pgm->ispdelay); + } else { + ppi_set(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit); + if (pgm->ispdelay > 1) + bitbang_delay(pgm->ispdelay); + + ppi_clr(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit); + if (pgm->ispdelay > 1) + bitbang_delay(pgm->ispdelay); + } + + return 0; +} + +/* + * apply power to the AVR processor + */ +static void par_powerup(PROGRAMMER * pgm) +{ + par_setmany(pgm, PPI_AVR_VCC, 1); /* power up */ + usleep(100000); +} + + +/* + * remove power from the AVR processor + */ +static void par_powerdown(PROGRAMMER * pgm) +{ + par_setmany(pgm, PPI_AVR_VCC, 0); /* power down */ +} + +static void par_disable(PROGRAMMER * pgm) +{ + par_setmany(pgm, PPI_AVR_BUFF, 1); /* turn off */ +} + +static void par_enable(PROGRAMMER * pgm) +{ + /* + * Prepare to start talking to the connected device - pull reset low + * first, delay a few milliseconds, then enable the buffer. This + * sequence allows the AVR to be reset before the buffer is enabled + * to avoid a short period of time where the AVR may be driving the + * programming lines at the same time the programmer tries to. Of + * course, if a buffer is being used, then the /RESET line from the + * programmer needs to be directly connected to the AVR /RESET line + * and not via the buffer chip. + */ + + par_setpin(pgm, PIN_AVR_RESET, 0); + usleep(1); + + /* + * enable the 74367 buffer, if connected; this signal is active low + */ + par_setmany(pgm, PPI_AVR_BUFF, 0); +} + +static int par_open(PROGRAMMER * pgm, char * port) +{ + int rc; + + if (bitbang_check_prerequisites(pgm) < 0) + return -1; + + ppi_open(port, &pgm->fd); + if (pgm->fd.ifd < 0) { + avrdude_message(MSG_INFO, "%s: failed to open parallel port \"%s\"\n\n", + progname, port); + return -1; + } + + /* + * save pin values, so they can be restored when device is closed + */ + rc = ppi_getall(&pgm->fd, PPIDATA); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: error reading status of ppi data port\n", progname); + return -1; + } + pgm->ppidata = rc; + + rc = ppi_getall(&pgm->fd, PPICTRL); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: error reading status of ppi ctrl port\n", progname); + return -1; + } + pgm->ppictrl = rc; + + return 0; +} + + +static void par_close(PROGRAMMER * pgm) +{ + + /* + * Restore pin values before closing, + * but ensure that buffers are turned off. + */ + ppi_setall(&pgm->fd, PPIDATA, pgm->ppidata); + ppi_setall(&pgm->fd, PPICTRL, pgm->ppictrl); + + par_setmany(pgm, PPI_AVR_BUFF, 1); + + /* + * Handle exit specs. + */ + switch (pgm->exit_reset) { + case EXIT_RESET_ENABLED: + par_setpin(pgm, PIN_AVR_RESET, 0); + break; + + case EXIT_RESET_DISABLED: + par_setpin(pgm, PIN_AVR_RESET, 1); + break; + + case EXIT_RESET_UNSPEC: + /* Leave it alone. */ + break; + } + + switch (pgm->exit_datahigh) { + case EXIT_DATAHIGH_ENABLED: + ppi_setall(&pgm->fd, PPIDATA, 0xff); + break; + + case EXIT_DATAHIGH_DISABLED: + ppi_setall(&pgm->fd, PPIDATA, 0x00); + break; + + case EXIT_DATAHIGH_UNSPEC: + /* Leave it alone. */ + break; + } + + switch (pgm->exit_vcc) { + case EXIT_VCC_ENABLED: + par_setmany(pgm, PPI_AVR_VCC, 1); + break; + + case EXIT_VCC_DISABLED: + par_setmany(pgm, PPI_AVR_VCC, 0); + break; + + case EXIT_VCC_UNSPEC: + /* Leave it alone. */ + break; + } + + ppi_close(&pgm->fd); + pgm->fd.ifd = -1; +} + +/* + * parse the -E string + */ +static int par_parseexitspecs(PROGRAMMER * pgm, char *s) +{ + char *cp; + + while ((cp = strtok(s, ","))) { + if (strcmp(cp, "reset") == 0) { + pgm->exit_reset = EXIT_RESET_ENABLED; + } + else if (strcmp(cp, "noreset") == 0) { + pgm->exit_reset = EXIT_RESET_DISABLED; + } + else if (strcmp(cp, "vcc") == 0) { + pgm->exit_vcc = EXIT_VCC_ENABLED; + } + else if (strcmp(cp, "novcc") == 0) { + pgm->exit_vcc = EXIT_VCC_DISABLED; + } + else if (strcmp(cp, "d_high") == 0) { + pgm->exit_datahigh = EXIT_DATAHIGH_ENABLED; + } + else if (strcmp(cp, "d_low") == 0) { + pgm->exit_datahigh = EXIT_DATAHIGH_DISABLED; + } + else { + return -1; + } + s = 0; /* strtok() should be called with the actual string only once */ + } + + return 0; +} + +void par_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "PPI"); + + pgm_fill_old_pins(pgm); // TODO to be removed if old pin data no longer needed + + pgm->exit_vcc = EXIT_VCC_UNSPEC; + pgm->exit_reset = EXIT_RESET_UNSPEC; + pgm->exit_datahigh = EXIT_DATAHIGH_UNSPEC; + + pgm->rdy_led = bitbang_rdy_led; + pgm->err_led = bitbang_err_led; + pgm->pgm_led = bitbang_pgm_led; + pgm->vfy_led = bitbang_vfy_led; + pgm->initialize = bitbang_initialize; + pgm->display = pgm_display_generic; + pgm->enable = par_enable; + pgm->disable = par_disable; + pgm->powerup = par_powerup; + pgm->powerdown = par_powerdown; + pgm->program_enable = bitbang_program_enable; + pgm->chip_erase = bitbang_chip_erase; + pgm->cmd = bitbang_cmd; + pgm->cmd_tpi = bitbang_cmd_tpi; + pgm->spi = bitbang_spi; + pgm->open = par_open; + pgm->close = par_close; + pgm->setpin = par_setpin; + pgm->getpin = par_getpin; + pgm->highpulsepin = par_highpulsepin; + pgm->parseexitspecs = par_parseexitspecs; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; +} + +#else /* !HAVE_PARPORT */ + +void par_initpgm(PROGRAMMER * pgm) +{ + avrdude_message(MSG_INFO, "%s: parallel port access not available in this configuration\n", + progname); +} + +#endif /* HAVE_PARPORT */ + +const char par_desc[] = "Parallel port bitbanging"; diff --git a/xs/src/avrdude/par.h b/xs/src/avrdude/par.h new file mode 100644 index 000000000..708997037 --- /dev/null +++ b/xs/src/avrdude/par.h @@ -0,0 +1,35 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 par_h +#define par_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char par_desc[]; +void par_initpgm (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/xs/src/avrdude/pgm.c b/xs/src/avrdude/pgm.c new file mode 100644 index 000000000..851ac5a87 --- /dev/null +++ b/xs/src/avrdude/pgm.c @@ -0,0 +1,332 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2002-2004 Brian S. Dean + * Copyright 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 + * 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 "ac_cfg.h" + +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +static int pgm_default_2 (struct programmer_t *, AVRPART *); +static int pgm_default_3 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value); +static void pgm_default_4 (struct programmer_t *); +static int pgm_default_5 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data); +static void pgm_default_6 (struct programmer_t *, const char *); + + +static int pgm_default_open (struct programmer_t *pgm, char * name) +{ + avrdude_message(MSG_INFO, "\n%s: Fatal error: Programmer does not support open()", + progname); + return -1; +} + +static int pgm_default_led (struct programmer_t * pgm, int value) +{ + /* + * If programmer has no LEDs, just do nothing. + */ + return 0; +} + + +static void pgm_default_powerup_powerdown (struct programmer_t * pgm) +{ + /* + * If programmer does not support powerup/down, just do nothing. + */ +} + + +PROGRAMMER * pgm_new(void) +{ + int i; + PROGRAMMER * pgm; + + pgm = (PROGRAMMER *)malloc(sizeof(*pgm)); + if (pgm == NULL) { + avrdude_message(MSG_INFO, "%s: out of memory allocating programmer structure\n", + progname); + return NULL; + } + + memset(pgm, 0, sizeof(*pgm)); + + pgm->id = lcreat(NULL, 0); + pgm->usbpid = lcreat(NULL, 0); + pgm->desc[0] = 0; + pgm->type[0] = 0; + pgm->config_file[0] = 0; + pgm->lineno = 0; + pgm->baudrate = 0; + pgm->initpgm = NULL; + + for (i=0; ipinno[i] = 0; + pin_clear_all(&(pgm->pin[i])); + } + + /* + * mandatory functions - these are called without checking to see + * whether they are assigned or not + */ + pgm->initialize = pgm_default_2; + pgm->display = pgm_default_6; + pgm->enable = pgm_default_4; + pgm->disable = pgm_default_4; + pgm->powerup = pgm_default_powerup_powerdown; + pgm->powerdown = pgm_default_powerup_powerdown; + pgm->program_enable = pgm_default_2; + pgm->chip_erase = pgm_default_2; + pgm->open = pgm_default_open; + pgm->close = pgm_default_4; + pgm->read_byte = pgm_default_3; + pgm->write_byte = pgm_default_5; + + /* + * predefined functions - these functions have a valid default + * implementation. Hence, they don't need to be defined in + * the programmer. + */ + pgm->rdy_led = pgm_default_led; + pgm->err_led = pgm_default_led; + pgm->pgm_led = pgm_default_led; + pgm->vfy_led = pgm_default_led; + + /* + * optional functions - these are checked to make sure they are + * assigned before they are called + */ + pgm->cmd = NULL; + pgm->cmd_tpi = NULL; + pgm->spi = NULL; + pgm->paged_write = NULL; + pgm->paged_load = NULL; + pgm->write_setup = NULL; + pgm->read_sig_bytes = NULL; + pgm->set_vtarget = NULL; + pgm->set_varef = NULL; + pgm->set_fosc = NULL; + pgm->perform_osccal = NULL; + pgm->parseextparams = NULL; + pgm->setup = NULL; + pgm->teardown = NULL; + + return pgm; +} + +void pgm_free(PROGRAMMER * const p) +{ + ldestroy_cb(p->id, free); + ldestroy_cb(p->usbpid, free); + p->id = NULL; + p->usbpid = NULL; + /* this is done by pgm_teardown, but usually cookie is not set to NULL */ + /* if (p->cookie !=NULL) { + free(p->cookie); + p->cookie = NULL; + }*/ + free(p); +} + +PROGRAMMER * pgm_dup(const PROGRAMMER * const src) +{ + PROGRAMMER * pgm; + LNODEID ln; + + pgm = (PROGRAMMER *)malloc(sizeof(*pgm)); + if (pgm == NULL) { + avrdude_message(MSG_INFO, "%s: out of memory allocating programmer structure\n", + progname); + return NULL; + } + + memcpy(pgm, src, sizeof(*pgm)); + + pgm->id = lcreat(NULL, 0); + pgm->usbpid = lcreat(NULL, 0); + + for (ln = lfirst(src->usbpid); ln; ln = lnext(ln)) { + int *ip = malloc(sizeof(int)); + if (ip == NULL) { + avrdude_message(MSG_INFO, "%s: out of memory allocating programmer structure\n", + progname); + exit(1); + } + *ip = *(int *) ldata(ln); + ladd(pgm->usbpid, ip); + } + + return pgm; +} + + +static void pgm_default(void) +{ + avrdude_message(MSG_INFO, "%s: programmer operation not supported\n", progname); +} + + +static int pgm_default_2 (struct programmer_t * pgm, AVRPART * p) +{ + pgm_default(); + return -1; +} + +static int pgm_default_3 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value) +{ + pgm_default(); + return -1; +} + +static void pgm_default_4 (struct programmer_t * pgm) +{ + pgm_default(); +} + +static int pgm_default_5 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + pgm_default(); + return -1; +} + +static void pgm_default_6 (struct programmer_t * pgm, const char * p) +{ + pgm_default(); +} + + +void programmer_display(PROGRAMMER * pgm, const char * p) +{ + avrdude_message(MSG_INFO, "%sProgrammer Type : %s\n", p, pgm->type); + avrdude_message(MSG_INFO, "%sDescription : %s\n", p, pgm->desc); + + pgm->display(pgm, p); +} + + +void pgm_display_generic_mask(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_MOSI])); + if(show & (1<pin[PIN_AVR_MISO])); + 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])); +} + +void pgm_display_generic(PROGRAMMER * pgm, const char * p) +{ + pgm_display_generic_mask(pgm, p, SHOW_ALL_PINS); +} + +PROGRAMMER * locate_programmer(LISTID programmers, const char * configid) +{ + LNODEID ln1, ln2; + PROGRAMMER * p = NULL; + const char * id; + int found; + + found = 0; + + for (ln1=lfirst(programmers); ln1 && !found; ln1=lnext(ln1)) { + p = ldata(ln1); + for (ln2=lfirst(p->id); ln2 && !found; ln2=lnext(ln2)) { + id = ldata(ln2); + if (strcasecmp(configid, id) == 0) + found = 1; + } + } + + if (found) + return p; + + return NULL; +} + +/* + * Iterate over the list of programmers given as "programmers", and + * call the callback function cb for each entry found. cb is being + * passed the following arguments: + * . the name of the programmer (for -c) + * . the descriptive text given in the config file + * . the name of the config file this programmer has been defined in + * . the line number of the config file this programmer has been defined at + * . the "cookie" passed into walk_programmers() (opaque client data) + */ +void walk_programmers(LISTID programmers, walk_programmers_cb cb, void *cookie) +{ + LNODEID ln1; + LNODEID ln2; + PROGRAMMER * p; + + for (ln1 = lfirst(programmers); ln1; ln1 = lnext(ln1)) { + p = ldata(ln1); + for (ln2=lfirst(p->id); ln2; ln2=lnext(ln2)) { + cb(ldata(ln2), p->desc, p->config_file, p->lineno, cookie); + } + } +} + +/* + * Compare function to sort the list of programmers + */ +static int sort_programmer_compare(PROGRAMMER * p1,PROGRAMMER * p2) +{ + char* id1; + char* id2; + if(p1 == NULL || p2 == NULL) { + return 0; + } + id1 = ldata(lfirst(p1->id)); + id2 = ldata(lfirst(p2->id)); + return strncasecmp(id1,id2,AVR_IDLEN); +} + +/* + * Sort the list of programmers given as "programmers" + */ +void sort_programmers(LISTID programmers) +{ + lsort(programmers,(int (*)(void*, void*)) sort_programmer_compare); +} + diff --git a/xs/src/avrdude/pgm_type.c b/xs/src/avrdude/pgm_type.c new file mode 100644 index 000000000..ef27cf900 --- /dev/null +++ b/xs/src/avrdude/pgm_type.c @@ -0,0 +1,153 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2002-2004 Brian S. Dean + * Copyright 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 + * 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: pgm.c 976 2011-08-23 21:03:36Z joerg_wunsch $ */ + +#include "ac_cfg.h" + +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "arduino.h" +#include "avr910.h" +// #include "avrftdi.h" +#include "buspirate.h" +#include "butterfly.h" +// #include "flip1.h" +// #include "flip2.h" +// #include "ft245r.h" +// #include "jtagmkI.h" +// #include "jtagmkII.h" +// #include "jtag3.h" +#include "linuxgpio.h" +// #include "par.h" +#include "pickit2.h" +#include "ppi.h" +#include "serbb.h" +#include "stk500.h" +#include "stk500generic.h" +#include "stk500v2.h" +// #include "usbasp.h" +// #include "usbtiny.h" +#include "wiring.h" + + +const PROGRAMMER_TYPE programmers_types[] = { + {"arduino", arduino_initpgm, arduino_desc}, + {"avr910", avr910_initpgm, avr910_desc}, + // {"avrftdi", avrftdi_initpgm, avrftdi_desc}, + {"buspirate", buspirate_initpgm, buspirate_desc}, + {"buspirate_bb", buspirate_bb_initpgm, buspirate_bb_desc}, + {"butterfly", butterfly_initpgm, butterfly_desc}, + {"butterfly_mk", butterfly_mk_initpgm, butterfly_mk_desc}, + // {"dragon_dw", jtagmkII_dragon_dw_initpgm, jtagmkII_dragon_dw_desc}, + {"dragon_hvsp", stk500v2_dragon_hvsp_initpgm, stk500v2_dragon_hvsp_desc}, + {"dragon_isp", stk500v2_dragon_isp_initpgm, stk500v2_dragon_isp_desc}, + // {"dragon_jtag", jtagmkII_dragon_initpgm, jtagmkII_dragon_desc}, + // {"dragon_pdi", jtagmkII_dragon_pdi_initpgm, jtagmkII_dragon_pdi_desc}, + {"dragon_pp", stk500v2_dragon_pp_initpgm, stk500v2_dragon_pp_desc}, + // {"flip1", flip1_initpgm, flip1_desc}, + // {"flip2", flip2_initpgm, flip2_desc}, + // {"ftdi_syncbb", ft245r_initpgm, ft245r_desc}, + // {"jtagmki", jtagmkI_initpgm, jtagmkI_desc}, + // {"jtagmkii", jtagmkII_initpgm, jtagmkII_desc}, + // {"jtagmkii_avr32", jtagmkII_avr32_initpgm, jtagmkII_avr32_desc}, + // {"jtagmkii_dw", jtagmkII_dw_initpgm, jtagmkII_dw_desc}, + // {"jtagmkii_isp", stk500v2_jtagmkII_initpgm, stk500v2_jtagmkII_desc}, + // {"jtagmkii_pdi", jtagmkII_pdi_initpgm, jtagmkII_pdi_desc}, + // {"jtagice3", jtag3_initpgm, jtag3_desc}, + // {"jtagice3_pdi", jtag3_pdi_initpgm, jtag3_pdi_desc}, + // {"jtagice3_dw", jtag3_dw_initpgm, jtag3_dw_desc}, + // {"jtagice3_isp", stk500v2_jtag3_initpgm, stk500v2_jtag3_desc}, + {"linuxgpio", linuxgpio_initpgm, linuxgpio_desc}, + // {"par", par_initpgm, par_desc}, + {"pickit2", pickit2_initpgm, pickit2_desc}, + {"serbb", serbb_initpgm, serbb_desc}, + {"stk500", stk500_initpgm, stk500_desc}, + {"stk500generic", stk500generic_initpgm, stk500generic_desc}, + {"stk500v2", stk500v2_initpgm, stk500v2_desc}, + {"stk500hvsp", stk500hvsp_initpgm, stk500hvsp_desc}, + {"stk500pp", stk500pp_initpgm, stk500pp_desc}, + {"stk600", stk600_initpgm, stk600_desc}, + {"stk600hvsp", stk600hvsp_initpgm, stk600hvsp_desc}, + {"stk600pp", stk600pp_initpgm, stk600pp_desc}, + // {"usbasp", usbasp_initpgm, usbasp_desc}, + // {"usbtiny", usbtiny_initpgm, usbtiny_desc}, + {"wiring", wiring_initpgm, wiring_desc}, +}; + +const PROGRAMMER_TYPE * locate_programmer_type(const char * id) +{ + const PROGRAMMER_TYPE * p = NULL; + int i; + int found; + + found = 0; + + for (i = 0; i < sizeof(programmers_types)/sizeof(programmers_types[0]) && !found; i++) { + p = &(programmers_types[i]); + if (strcasecmp(id, p->id) == 0) + found = 1; + } + + if (found) + return p; + + return NULL; +} + +/* + * Iterate over the list of programmers given as "programmers", and + * call the callback function cb for each entry found. cb is being + * passed the following arguments: + * . the name of the programmer (for -c) + * . the descriptive text given in the config file + * . the name of the config file this programmer has been defined in + * . the line number of the config file this programmer has been defined at + * . the "cookie" passed into walk_programmers() (opaque client data) + */ + /* +void walk_programmer_types(LISTID programmer_types, walk_programmer_types_cb cb, void *cookie) +{ + LNODEID ln1; + PROGRAMMER * p; + + for (ln1 = lfirst(programmers); ln1; ln1 = lnext(ln1)) { + p = ldata(ln1); + cb(p->id, p->desc, cookie); + } + } +}*/ + +void walk_programmer_types(walk_programmer_types_cb cb, void *cookie) +{ + const PROGRAMMER_TYPE * p; + int i; + + for (i = 0; i < sizeof(programmers_types)/sizeof(programmers_types[0]); i++) { + p = &(programmers_types[i]); + cb(p->id, p->desc, cookie); + } +} + + diff --git a/xs/src/avrdude/pickit2.c b/xs/src/avrdude/pickit2.c new file mode 100644 index 000000000..bbf8b9ad7 --- /dev/null +++ b/xs/src/avrdude/pickit2.c @@ -0,0 +1,1340 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2005 Erik Walthinsen + * Copyright (C) 2002-2004 Brian S. Dean + * Copyright (C) 2006 David Moore + * 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 + * 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: pickit2.c 2010-05-03 dbrown$ */ +/* Based on Id: stk500v2.c 836 2009-07-10 22:39:37Z joerg_wunsch */ + +/* + * avrdude interface for PicKit2 programmer + * + * The PicKit2 programmer is a cheap device capable + * of 2 (bidirectional data line), 3, 4 wire SPI comms + * + * The PICkit2 software license doesn't allow the source to be + * modified to program other devices - nor can we distribute + * their source code. This program is not derived from nor does it + * contain any of the pickit2 source and should be exempt from any + * licensing issues. + * + * ISP Pinout (AVR - PICKit2 (pin)): + * RST - VPP/MCLR (1) + * VDD - VDD Target (2) -- possibly optional if AVR self powered + * GND - GND (3) + * MISO - PGD (4) + * SCLK - PDC (5) + * MOSI - AUX (6) + */ + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#if defined(HAVE_LIBUSB) || (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) + +#if (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) +#include +#if defined(HAVE_DDK_HIDSDI_H) +# include +#else +# include "my_ddk_hidsdi.h" +#endif +#include +#else +#if defined(HAVE_USB_H) +# include +#elif defined(HAVE_LUSB0_USB_H) +# include +#else +# error "libusb needs either or " +#endif +#endif + +#if 0 +#define DEBUG(...) do { avrdude_message(MSG_DEBUG, __VA_ARGS__); } while(0) +#else +#define DEBUG(...) ((void)0) +#endif + +#if 0 +#define DEBUGRECV(...) do { avrdude_message(MSG_DEBUG, __VA_ARGS__); } while(0) +#else +#define DEBUGRECV(...) ((void)0) +#endif + +#define PICKIT2_VID 0x04d8 +#define PICKIT2_PID 0x0033 + +#define SPI_MAX_CHUNK (64 - 10) // max packet size less the command overhead + +// win32native only: +#if (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) +static HANDLE open_hid(unsigned short vid, unsigned short pid); +const char *usb_strerror() +{ + return ""; +} +#else +static int usb_open_device(struct usb_dev_handle **dev, int vid, int pid); +//#define INVALID_HANDLE_VALUE NULL +#define USB_ERROR_NONE 0 +#define USB_ERROR_ACCESS 1 +#define USB_ERROR_NOTFOUND 2 +#define USB_ERROR_BUSY 16 +#define USB_ERROR_IO 5 +#endif // WIN32NATIVE + +static int pickit2_write_report(PROGRAMMER *pgm, const unsigned char report[65]); +static int pickit2_read_report(PROGRAMMER *pgm, unsigned char report[65]); + +#ifndef MIN +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) +#endif + +/* + * Private data for this programmer. + */ +struct pdata +{ +#if (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) + HANDLE usb_handle, write_event, read_event; +#else + struct usb_dev_handle *usb_handle; // LIBUSB STUFF +#endif + uint8_t clock_period; // SPI clock period in us + int transaction_timeout; // usb trans timeout in ms +}; + +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) + +#define CMD_NOP 0x5A +#define CMD_GET_VERSION 0x76 +#define CMD_SET_VDD_4(v) 0xA0, (uint8_t)((v)*2048+672), (uint8_t)(((v)*2048+672)/256), (uint8_t)((v)*36) +#define CMD_SET_VPP_4(v) 0xA1, 0x40, (uint8_t)((v)*18.61), (uint8_t)((v)*13) +#define CMD_READ_VDD_VPP 0xA3 +#define CMD_EXEC_SCRIPT_2(len) 0xA6, (len) +#define CMD_CLR_DLOAD_BUFF 0xA7 +#define CMD_DOWNLOAD_DATA_2(len) 0xA8, (len) +#define CMD_CLR_ULOAD_BUFF 0xA9 +#define CMD_UPLOAD_DATA 0xAA +#define CMD_UPLOAD_DATA_NO_LEN 0xAC +#define CMD_END_OF_BUFFER 0xAD + +#define SCR_VDD_ON 0xFF +#define SCR_VDD_OFF 0xFE +#define SCR_VPP_ON 0xFB +#define SCR_VPP_OFF 0xFA +#define SCR_VPP_PWM_ON 0xF9 +#define SCR_VPP_PWM_OFF 0xF8 +#define SCR_MCLR_GND_ON 0xF7 +#define SCR_MCLR_GND_OFF 0xF6 +#define SCR_BUSY_LED_ON 0xF5 +#define SCR_BUSY_LED_OFF 0xF4 +#define SCR_SET_ICSP_DELAY_2(us) 0xEA,(us) +#define SCR_SET_PINS_2(dd, cd, dv, cv) 0xF3, (((cd)!=0) | (((dd)!=0)<<1) | (((cv)!=0)<<2) | (((dv)!=0)<<3)) +#define SCR_GET_PINS 0xDC +#define SCR_LOOP_3(rel, cnt) 0xE9, rel, cnt +#define SCR_DELAY_2(sec) ((sec)>0.0054528?0xE8:0xE7), (uint8_t)((sec)>0.0054528?(.999+(sec)/.00546):(.999+(sec)/.0000213)) +#define SCR_SET_AUX_2(ad, av) 0xCF, (((ad)!=0) | (((av)!=0)<<1)) +#define SCR_SPI_SETUP_PINS_4 SCR_SET_PINS_2(1,0,0,0), SCR_SET_AUX_2(0,0) +#define SCR_SPI 0xC3 +#define SCR_SPI_LIT_2(v) 0xC7,(v) + +static void pickit2_setup(PROGRAMMER * pgm) +{ + if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) + { + avrdude_message(MSG_INFO, "%s: pickit2_setup(): Out of memory allocating private data\n", + progname); + exit(1); + } + memset(pgm->cookie, 0, sizeof(struct pdata)); + + PDATA(pgm)->transaction_timeout = 1500; // default value, may be overridden with -x timeout=ms + PDATA(pgm)->clock_period = 10; // default value, may be overridden with -x clockrate=us or -B or -i +} + +static void pickit2_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); +} + +static int pickit2_open(PROGRAMMER * pgm, char * port) +{ +#if (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) + PDATA(pgm)->usb_handle = open_hid(PICKIT2_VID, PICKIT2_PID); + + if (PDATA(pgm)->usb_handle == INVALID_HANDLE_VALUE) + { + /* no PICkit2 found */ + avrdude_message(MSG_INFO, "%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n", + progname, PICKIT2_VID, PICKIT2_PID); + return -1; + } + else + { + // get the device description while we're at it + short buff[PGM_DESCLEN-1], i; + HidD_GetProductString(PDATA(pgm)->usb_handle, buff, PGM_DESCLEN-1); + + // convert from wide chars, but do not overwrite trailing '\0' + memset(&(pgm->type), 0, PGM_DESCLEN); + for (i = 0; i < (PGM_DESCLEN-1) && buff[i]; i++) + { + pgm->type[i] = (char)buff[i]; // TODO what about little/big endian??? + } + } +#else + if (usb_open_device(&(PDATA(pgm)->usb_handle), PICKIT2_VID, PICKIT2_PID) < 0) + { + /* no PICkit2 found */ + avrdude_message(MSG_INFO, "%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n", + progname, PICKIT2_VID, PICKIT2_PID); + return -1; + } +#endif + + if (pgm->ispdelay > 0) + { + PDATA(pgm)->clock_period = MIN(pgm->ispdelay, 255); + } + else if (pgm->bitclock > 0.0) + { + PDATA(pgm)->clock_period = MIN(pgm->bitclock * 1e6, 255); + } + + return 0; +} + + +static void pickit2_close(PROGRAMMER * pgm) +{ +#if (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) + CloseHandle(PDATA(pgm)->usb_handle); + CloseHandle(PDATA(pgm)->read_event); + CloseHandle(PDATA(pgm)->write_event); +#else + usb_close(PDATA(pgm)->usb_handle); +#endif // WIN32NATIVE +} + + +static int pickit2_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char temp[4]; + memset(temp, 0, sizeof(temp)); + + int errorCode = 0; + + /* set sck period */ + if (pgm->set_sck_period) + pgm->set_sck_period(pgm, pgm->bitclock); + + /* connect to target device -- we'll just ask for the firmware version */ + static const unsigned char report[65] = {0, CMD_GET_VERSION, CMD_END_OF_BUFFER}; + if ((errorCode = pickit2_write_report(pgm, report)) > 0) + { + unsigned char report[65] = {0}; + //memset(report, 0, sizeof(report)); + if ((errorCode = pickit2_read_report(pgm, report)) >= 4) + { + avrdude_message(MSG_NOTICE, "%s: %s firmware version %d.%d.%d\n", progname, pgm->desc, (int)report[1], (int)report[2], (int)report[3]); + + // set the pins, apply reset, + // TO DO: apply vtarget (if requested though -x option) + unsigned char report[65] = + { + 0, CMD_SET_VDD_4(5), + CMD_SET_VPP_4(5), + CMD_EXEC_SCRIPT_2(24), + SCR_SPI_SETUP_PINS_4, // SDO, SDI, SCK + SCR_SET_ICSP_DELAY_2(PDATA(pgm)->clock_period), // slow down the SPI + SCR_VDD_ON, + SCR_MCLR_GND_OFF, // let reset float high + SCR_VPP_PWM_ON, + SCR_DELAY_2(.1), + SCR_VPP_ON, + SCR_DELAY_2(.1), + SCR_VPP_OFF, + SCR_DELAY_2(.01), + + SCR_MCLR_GND_ON, // reset low - programming mode + SCR_DELAY_2(.1), + + SCR_BUSY_LED_ON, + SCR_DELAY_2(.3), + SCR_BUSY_LED_OFF, + + CMD_CLR_DLOAD_BUFF, + CMD_CLR_ULOAD_BUFF, + + CMD_END_OF_BUFFER + }; + + if (pickit2_write_report(pgm, report) < 0) + { + avrdude_message(MSG_INFO, "pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror()); + return -1; + } + } + else + { + avrdude_message(MSG_INFO, "pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror()); + return -1; + } + } + else + { + avrdude_message(MSG_INFO, "pickit2_write_report failed (ec %d). %s\n", errorCode, usb_strerror()); + return -1; + } + + if (pgm->program_enable) + return pgm->program_enable(pgm, p); + else + return -1; +} + +static void pickit2_disable(PROGRAMMER * pgm) +{ + /* make sure all pins are floating & all voltages are off */ + static const unsigned char report[65] = + { + 0, CMD_EXEC_SCRIPT_2(8), + SCR_SET_PINS_2(1,1,0,0), + SCR_SET_AUX_2(1,0), + SCR_MCLR_GND_OFF, + SCR_VPP_OFF, + SCR_VDD_OFF, + SCR_BUSY_LED_OFF, + CMD_END_OF_BUFFER + }; + + pickit2_write_report(pgm, report); + + return; +} + +static void pickit2_enable(PROGRAMMER * pgm) +{ + /* Do nothing. */ + + return; +} + +static void pickit2_display(PROGRAMMER * pgm, const char * p) +{ + DEBUG( "%s: Found \"%s\" version %d.%d.%d\n", progname, p, 1, 1, 1); + return; +} + +#define sendReport(x) +#define readReport(x) 0 + +#if 0 +static int pickit2_rdy_led (struct programmer_t * pgm, int value) +{ + // no rdy led + return 0; +} + +static int pickit2_err_led(struct programmer_t * pgm, int value) +{ + // there is no error led, so just flash the busy led a few times + uint8_t report[65] = + { + 0, CMD_EXEC_SCRIPT_2(9), + SCR_BUSY_LED_ON, + SCR_DELAY_2(.2), + SCR_BUSY_LED_OFF, + SCR_DELAY_2(.2), + SCR_LOOP_3(6, 9), + CMD_END_OF_BUFFER + }; + + // busy stops flashing by itself, so just return + if (!value) + { + return 0; + } + + return pickit2_write_report(pgm, report) != -1; +} +#endif + +static int pickit2_pgm_led (struct programmer_t * pgm, int value) +{ + // script to set busy led appropriately + uint8_t report[65] = {0, CMD_EXEC_SCRIPT_2(1), + value ? SCR_BUSY_LED_ON : SCR_BUSY_LED_OFF, + CMD_END_OF_BUFFER + }; + + return pickit2_write_report(pgm, report) != -1; +} + +static int pickit2_vfy_led (struct programmer_t * pgm, int value) +{ + // no such thing - maybe just call pgm_led + + return pgm->pgm_led(pgm, value); +} + +static void pickit2_powerup(struct programmer_t * pgm) +{ + // turn vdd on? +} + +static void pickit2_powerdown(struct programmer_t * pgm) +{ + // do what? + pgm->disable(pgm); +} + +static int pickit2_program_enable(struct programmer_t * pgm, AVRPART * p) +{ + unsigned char cmd[4]; + unsigned char res[4]; + + if (p->op[AVR_OP_PGM_ENABLE] == NULL) + { + avrdude_message(MSG_INFO, "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); + pgm->cmd(pgm, cmd, res); + + { + int i; + avrdude_message(MSG_DEBUG, "program_enable(): sending command. Resp = "); + + for (i = 0; i < 4; i++) + { + avrdude_message(MSG_DEBUG, "%x ", (int)res[i]); + } + avrdude_message(MSG_DEBUG, "\n"); + } + + // check for sync character + if (res[2] != cmd[1]) + return -2; + + return 0; +} + +static int pickit2_chip_erase(struct programmer_t * pgm, AVRPART * p) +{ + unsigned char cmd[4]; + unsigned char res[4]; + + if (p->op[AVR_OP_CHIP_ERASE] == NULL) + { + avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n", + p->desc); + return -1; + } + + pgm->pgm_led(pgm, ON); + + 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); + + pgm->pgm_led(pgm, OFF); + + return 0; +} + +static int pickit2_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + // only supporting flash & eeprom page reads + if ((!mem->paged || page_size <= 1) || (strcmp(mem->desc, "flash") != 0 && strcmp(mem->desc, "eeprom") != 0)) + { + return -1; + } + + DEBUG( "paged read ps %d, mem %s\n", page_size, mem->desc); + + OPCODE *readop = 0, *lext = mem->op[AVR_OP_LOAD_EXT_ADDR]; + uint8_t data = 0, cmd[SPI_MAX_CHUNK], res[SPI_MAX_CHUNK]; + unsigned int addr_base; + unsigned int max_addr = addr + n_bytes; + + pgm->pgm_led(pgm, ON); + + for (addr_base = addr; addr_base < max_addr; ) + { + if ((addr_base == 0 || (addr_base % /*ext_address_boundary*/ 65536) == 0) + && lext != NULL) + { + memset(cmd, 0, sizeof(cmd)); + + avr_set_bits(lext, cmd); + avr_set_addr(lext, cmd, addr_base); + pgm->cmd(pgm, cmd, res); + } + + // bytes to send in the next packet -- not necessary as pickit2_spi() handles breaking up + // the data into packets -- but we need to keep transfers frequent so that we can update the + // status indicator bar + uint32_t blockSize = MIN(65536 - (addr_base % 65536), MIN(max_addr - addr_base, SPI_MAX_CHUNK / 4)); + + memset(cmd, 0, sizeof(cmd)); + memset(res, 0, sizeof(res)); + + uint8_t addr_off; + for (addr_off = 0; addr_off < blockSize; addr_off++) + { + int addr = addr_base + addr_off, caddr = addr; + + if (mem->op[AVR_OP_READ_LO] != NULL && mem->op[AVR_OP_READ_HI] != NULL) + { + if (addr & 0x00000001) + readop = mem->op[AVR_OP_READ_HI]; + else + readop = mem->op[AVR_OP_READ_LO]; + + caddr /= 2; + } + else if (mem->op[AVR_OP_READ] != NULL) + { + readop = mem->op[AVR_OP_READ]; + } + else + { + avrdude_message(MSG_INFO, "no read command specified\n"); + return -1; + } + + avr_set_bits(readop, &cmd[addr_off*4]); + avr_set_addr(readop, &cmd[addr_off*4], caddr); + } + + int bytes_read = pgm->spi(pgm, cmd, res, blockSize*4); + + if (bytes_read < 0) + { + avrdude_message(MSG_INFO, "Failed @ pgm->spi()\n"); + pgm->err_led(pgm, ON); + return -1; + } + + DEBUG( "\npaged_load @ %X, wrote: %d, read: %d bytes\n", addr_base, blockSize*4, bytes_read); + + for (addr_off = 0; addr_off < bytes_read / 4; addr_off++) + { + data = 0; + avr_get_output(readop, &res[addr_off*4], &data); + mem->buf[addr_base + addr_off] = data; + + DEBUG( "%2X(%c)", (int)data, data<0x20?'.':data); + } + DEBUG( "\n"); + + addr_base += blockSize; + } + + pgm->pgm_led(pgm, OFF); + + return n_bytes; +} + + +static int pickit2_commit_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr) +{ + OPCODE * wp, * lext; + + wp = mem->op[AVR_OP_WRITEPAGE]; + if (wp == NULL) + { + avrdude_message(MSG_INFO, "pickit2_commit_page(): memory \"%s\" not configured for page writes\n", + mem->desc); + return -1; + } + + // adjust the address if this memory is word-addressable + if ((mem->op[AVR_OP_LOADPAGE_LO]) || (mem->op[AVR_OP_READ_LO])) + addr /= 2; + + unsigned char cmd[8]; + memset(cmd, 0, sizeof(cmd)); + + // use the "load extended address" command, if available + lext = mem->op[AVR_OP_LOAD_EXT_ADDR]; + if (lext != NULL) + { + avr_set_bits(lext, cmd); + avr_set_addr(lext, cmd, addr); + } + + // make up the write page command in the 2nd cmd position + avr_set_bits(wp, &cmd[4]); + avr_set_addr(wp, &cmd[4], addr); + + if (lext != NULL) + { + // write the load extended address cmd && the write_page cmd + pgm->spi(pgm, cmd, NULL, 8); + } + else + { + // write just the write_page cmd + pgm->spi(pgm, &cmd[4], NULL, 4); + } + + // just delay the max (we could do the delay in the PICkit2 if we wanted) + usleep(mem->max_write_delay); + + return 0; +} + +// not actually a paged write, but a bulk/batch write +static int pickit2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned int page_size, unsigned int addr, unsigned int n_bytes) +{ + // only paged write for flash implemented + if (strcmp(mem->desc, "flash") != 0 && strcmp(mem->desc, "eeprom") != 0) + { + avrdude_message(MSG_INFO, "Part does not support %d paged write of %s\n", page_size, mem->desc); + return -1; + } + + DEBUG( "page size %d mem %s supported: %d\n", page_size, mem->desc, mem->paged); + DEBUG( "loadpagehi %x, loadpagelow %x, writepage %x\n", (int)mem->op[AVR_OP_LOADPAGE_HI], (int)mem->op[AVR_OP_LOADPAGE_LO], (int)mem->op[AVR_OP_WRITEPAGE]); + + OPCODE *writeop; + uint8_t cmd[SPI_MAX_CHUNK], res[SPI_MAX_CHUNK]; + unsigned int addr_base; + unsigned int max_addr = addr + n_bytes; + + pgm->pgm_led(pgm, ON); + + for (addr_base = addr; addr_base < max_addr; ) + { + uint32_t blockSize; + + if (mem->paged) + { + blockSize = MIN(page_size - (addr_base % page_size), MIN(max_addr - addr_base, SPI_MAX_CHUNK/4) ); // bytes remaining in page + } + else + { + blockSize = 1; + } + + memset(cmd, 0, sizeof(cmd)); + memset(res, 0, sizeof(res)); + + uint8_t addr_off; + for (addr_off = 0; addr_off < blockSize; addr_off++) + { + int addr = addr_base + addr_off; + int caddr = 0; + + /* + * determine which memory opcode to use + */ + if (mem->paged && mem->op[AVR_OP_LOADPAGE_HI] && mem->op[AVR_OP_LOADPAGE_LO]) + { + if (addr & 0x01) + writeop = mem->op[AVR_OP_LOADPAGE_HI]; + else + writeop = mem->op[AVR_OP_LOADPAGE_LO]; + caddr = addr / 2; + } + else if (mem->paged && mem->op[AVR_OP_LOADPAGE_LO]) + { + writeop = mem->op[AVR_OP_LOADPAGE_LO]; + caddr = addr; + } + else if (mem->op[AVR_OP_WRITE_LO]) + { + writeop = mem->op[AVR_OP_WRITE_LO]; + caddr = addr; // maybe this should divide by 2 & use the write_high opcode also + + avrdude_message(MSG_INFO, "Error AVR_OP_WRITE_LO defined only (where's the HIGH command?)\n"); + return -1; + } + else + { + writeop = mem->op[AVR_OP_WRITE]; + caddr = addr; + } + + if (writeop == NULL) + { + pgm->err_led(pgm, ON); + // not supported! + return -1; + } + + avr_set_bits(writeop, &cmd[addr_off*4]); + avr_set_addr(writeop, &cmd[addr_off*4], caddr); + avr_set_input(writeop, &cmd[addr_off*4], mem->buf[addr]); + } + + int bytes_read = pgm->spi(pgm, cmd, res, blockSize*4); + + if (bytes_read < 0) + { + avrdude_message(MSG_INFO, "Failed @ pgm->spi()\n"); + pgm->err_led(pgm, ON); + return -1; + } + + addr_base += blockSize; + + // write the page - this function looks after extended address also + if (mem->paged && (((addr_base % page_size) == 0) || (addr_base == max_addr))) + { + DEBUG( "Calling pickit2_commit_page()\n"); + pickit2_commit_page(pgm, p, mem, addr_base-1); + } + else if (!mem->paged) + { + usleep(mem->max_write_delay); + } + } + + pgm->pgm_led(pgm, OFF); + + return n_bytes; +} + + +static int pickit2_cmd(struct programmer_t * pgm, const unsigned char *cmd, + unsigned char *res) +{ + return pgm->spi(pgm, cmd, res, 4); +} + +// breaks up the cmd[] data into packets & sends to the pickit2. Data shifted in is stored in res[]. +static int pickit2_spi(struct programmer_t * pgm, const unsigned char *cmd, + unsigned char *res, int n_bytes) +{ + int retval = 0, temp1 = 0, temp2 = 0, count = n_bytes; + + while (count > 0) + { + uint8_t i, blockSize = MIN(count, SPI_MAX_CHUNK); + uint8_t report[65] = {0, CMD_DOWNLOAD_DATA_2(blockSize)}; + uint8_t *repptr = report + 3; + + memset(report + 3, CMD_END_OF_BUFFER, sizeof(report) - 3); + + // append some data to write to SPI + for (i = 0; i < blockSize; i++) + { + *repptr++ = *cmd++; + count--; // 1 less byte to pack + } + + if (blockSize == 1) + { + *repptr++ = 0xa6; //CMD_EXECUTE_SCRIPT; + *repptr++ = 1; + *repptr++ = SCR_SPI; + } + else + { + *repptr++ = 0xa6; //CMD_EXECUTE_SCRIPT_2; + *repptr++ = 4; + *repptr++ = SCR_SPI; + *repptr++ = 0xe9; //SCR_LOOP_3; + *repptr++ = 1; + *repptr++ = blockSize - 1; + } + + // request the data read to be sent to us + *repptr++ = CMD_UPLOAD_DATA; + + // check return values + if ((temp1=pickit2_write_report(pgm, report)) < 0 || + (temp2=pickit2_read_report(pgm, report)) < 0) + { + return -1; + }/* + else + { + int i; + DEBUG( "in spi. wrote %d, read %d\n", temp1, temp2); + + for (i = 0; i < temp2; i++) + { + DEBUG( "%2.2x ", report[i]); + } + + DEBUG( "\n"); + }*/ + + retval = report[1]; // upload-length field + repptr = &report[2]; // actual data starts here + + if (res) // copy data if user has specified a storage location + { + memcpy(res, repptr, retval); + res += retval; + } + } + + return n_bytes; +} + +#if (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) +/* + Func: open_hid() + Desc: finds & opens device having specified VID & PID. + Retn: Handle of open device or INVALID_HANDLE_VALUE on fail + + Note this routine is a modified function from: + usbhidiocDlg.cpp : implementation file + Project: usbhidioc.cpp + Version: 3.0 + Date: 7/18/05 + by Jan Axelson (jan@Lvr.com) +*/ +static HANDLE open_hid(unsigned short vid, unsigned short pid) +{ + //Use a series of API calls to find a HID with a specified Vendor IF and Product ID. + HANDLE returnHandle = INVALID_HANDLE_VALUE; + HIDD_ATTRIBUTES Attributes; +// DWORD DeviceUsage; + SP_DEVICE_INTERFACE_DATA devInfoData; + BOOL LastDevice = FALSE; + int MemberIndex = 0; + LONG Result; + + // were global, now just local scrap + DWORD Length = 0; + PSP_DEVICE_INTERFACE_DETAIL_DATA detailData = NULL; + HANDLE DeviceHandle=NULL; + GUID HidGuid; + HANDLE hDevInfo; + ULONG Required; + BOOL MyDeviceDetected = 0; + + /* + API function: HidD_GetHidGuid + Get the GUID for all system HIDs. + Returns: the GUID in HidGuid. + */ + + HidD_GetHidGuid(&HidGuid); + DEBUG("\nHidD_GetHidGuid returned.\n"); + + /* + API function: SetupDiGetClassDevs + Returns: a handle to a device information set for all installed devices. + Requires: the GUID returned by GetHidGuid. + */ + + hDevInfo=SetupDiGetClassDevs + (&HidGuid, + NULL, + NULL, + DIGCF_PRESENT|DIGCF_INTERFACEDEVICE); + + DEBUG("\nSetupDiGetClassDevs returned 0x%x\n", hDevInfo); + devInfoData.cbSize = sizeof(devInfoData); + + //Step through the available devices looking for the one we want. + //Quit on detecting the desired device or checking all available devices without success. + + MemberIndex = 0; + LastDevice = FALSE; + + do + { + /* + API function: SetupDiEnumDeviceInterfaces + On return, MyDeviceInterfaceData contains the handle to a + SP_DEVICE_INTERFACE_DATA structure for a detected device. + Requires: + The DeviceInfoSet returned in SetupDiGetClassDevs. + The HidGuid returned in GetHidGuid. + An index to specify a device. + */ + + + Result=SetupDiEnumDeviceInterfaces + (hDevInfo, + 0, + &HidGuid, + MemberIndex, + &devInfoData); + + DEBUG("\nSetupDiEnumDeviceInterfaces returned 0x%x\n", Result); + + if (Result != 0) + { + //A device has been detected, so get more information about it. + + /* + API function: SetupDiGetDeviceInterfaceDetail + Returns: an SP_DEVICE_INTERFACE_DETAIL_DATA structure + containing information about a device. + To retrieve the information, call this function twice. + The first time returns the size of the structure in Length. + The second time returns a pointer to the data in DeviceInfoSet. + Requires: + A DeviceInfoSet returned by SetupDiGetClassDevs + The SP_DEVICE_INTERFACE_DATA structure returned by SetupDiEnumDeviceInterfaces. + + The final parameter is an optional pointer to an SP_DEV_INFO_DATA structure. + This application doesn't retrieve or use the structure. + If retrieving the structure, set + MyDeviceInfoData.cbSize = length of MyDeviceInfoData. + and pass the structure's address. + */ + + //Get the Length value. + //The call will return with a "buffer too small" error which can be ignored. + Result = SetupDiGetDeviceInterfaceDetail + (hDevInfo, + &devInfoData, + NULL, + 0, + &Length, + NULL); + + DEBUG("\nSetupDiGetDeviceInterfaceDetail returned 0x%x\n", Result); + + //Allocate memory for the hDevInfo structure, using the returned Length. + + detailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(Length); + + //Set cbSize in the detailData structure. + + detailData -> cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); + + //Call the function again, this time passing it the returned buffer size. + + Result = SetupDiGetDeviceInterfaceDetail + (hDevInfo, + &devInfoData, + detailData, + Length, + &Required, + NULL); + + // Open a handle to the device. + // To enable retrieving information about a system mouse or keyboard, + // don't request Read or Write access for this handle. + + /* + API function: CreateFile + Returns: a handle that enables reading and writing to the device. + Requires: + The DevicePath in the detailData structure + returned by SetupDiGetDeviceInterfaceDetail. + */ + + DeviceHandle=CreateFile + (detailData->DevicePath, + 0, + FILE_SHARE_READ|FILE_SHARE_WRITE, + (LPSECURITY_ATTRIBUTES)NULL, + OPEN_EXISTING, + 0, + NULL); + + DEBUG("CreateFile(): %s\n", detailData->DevicePath); + /* + API function: HidD_GetAttributes + Requests information from the device. + Requires: the handle returned by CreateFile. + Returns: a HIDD_ATTRIBUTES structure containing + the Vendor ID, Product ID, and Product Version Number. + Use this information to decide if the detected device is + the one we're looking for. + */ + + //Set the Size to the number of bytes in the structure. + + Attributes.Size = sizeof(Attributes); + + Result = HidD_GetAttributes + (DeviceHandle, + &Attributes); + + DEBUG("HidD_GetAttributes returned 0x%x\n", Result); + DEBUG("VID: %.4X PID: %.4X\n", Attributes.VendorID, Attributes.ProductID); + + //Is it the desired device? + MyDeviceDetected = FALSE; + if (Attributes.VendorID == vid) + { + if (Attributes.ProductID == pid) + { + //Both the Vendor ID and Product ID match. + + MyDeviceDetected = TRUE; + + // Get a handle for us to use. + + returnHandle = CreateFile + (detailData->DevicePath, + GENERIC_WRITE | GENERIC_READ, + FILE_SHARE_READ|FILE_SHARE_WRITE, + (LPSECURITY_ATTRIBUTES)NULL, + OPEN_EXISTING, + FILE_FLAG_OVERLAPPED, + NULL); + + } //if (Attributes.ProductID == ProductID) + + else + //The Product ID doesn't match. + + CloseHandle(DeviceHandle); + + } //if (Attributes.VendorID == VendorID) + + else + //The Vendor ID doesn't match. + + CloseHandle(DeviceHandle); + + //Free the memory used by the detailData structure (no longer needed). + + free(detailData); + + } //if (Result != 0) + + else + //SetupDiEnumDeviceInterfaces returned 0, so there are no more devices to check. + + LastDevice=TRUE; + + //If we haven't found the device yet, and haven't tried every available device, + //try the next one. + + MemberIndex = MemberIndex + 1; + + } //do + + while ((LastDevice == FALSE) && (MyDeviceDetected == FALSE)); + + if (MyDeviceDetected == FALSE) + DEBUG("Device not detected\n"); + else + DEBUG("Device detected\n"); + + //Free the memory reserved for hDevInfo by SetupDiClassDevs. + + DEBUG("Calling SetupDiDestroyDeviceInfoList\n"); + SetupDiDestroyDeviceInfoList(hDevInfo); + + return returnHandle; +} + +// simple read with timeout +static int usb_read_interrupt(PROGRAMMER *pgm, void *buff, int size, int timeout) +{ + OVERLAPPED ovr; + DWORD bytesRead = 0; + + if (PDATA(pgm)->read_event == NULL) + { + PDATA(pgm)->read_event = CreateEvent(0, 0, 0, 0); + } + + memset(&ovr, 0, sizeof(ovr)); + ovr.hEvent = PDATA(pgm)->read_event; + + ReadFile(PDATA(pgm)->usb_handle, buff, size, &bytesRead, &ovr); + if (WaitForSingleObject(PDATA(pgm)->read_event, timeout) == WAIT_TIMEOUT) + { + CancelIo(PDATA(pgm)->usb_handle); + return -1; + } + + GetOverlappedResult(PDATA(pgm)->usb_handle, &ovr, &bytesRead, 0); + + return bytesRead > 0 ? bytesRead : -1; +} + +// simple write with timeout +static int usb_write_interrupt(PROGRAMMER *pgm, const void *buff, int size, int timeout) +{ + OVERLAPPED ovr; + DWORD bytesWritten = 0; + + if (PDATA(pgm)->write_event == NULL) + { + PDATA(pgm)->write_event = CreateEvent(0, 0, 0, 0); + } + + memset(&ovr, 0, sizeof(ovr)); + ovr.hEvent = PDATA(pgm)->write_event; + + WriteFile(PDATA(pgm)->usb_handle, buff, size, &bytesWritten, &ovr); + if (WaitForSingleObject(PDATA(pgm)->write_event, timeout) == WAIT_TIMEOUT) + { + CancelIo(PDATA(pgm)->usb_handle); + return -1; + } + + GetOverlappedResult(PDATA(pgm)->usb_handle, &ovr, &bytesWritten, 0); + + return bytesWritten > 0 ? bytesWritten : -1; +} + +static int pickit2_write_report(PROGRAMMER * pgm, const unsigned char report[65]) +{ + return usb_write_interrupt(pgm, report, 65, PDATA(pgm)->transaction_timeout); // XXX +} + +static int pickit2_read_report(PROGRAMMER * pgm, unsigned char report[65]) +{ + return usb_read_interrupt(pgm, report, 65, PDATA(pgm)->transaction_timeout); +} + +#else // WIN32NATIVE +/* taken (modified) from avrdude usbasp.c */ +static int usb_open_device(struct usb_dev_handle **device, int vendor, int product) +{ + struct usb_bus *bus; + struct usb_device *dev; + usb_dev_handle *handle = NULL; + int errorCode = USB_ERROR_NOTFOUND; + static int didUsbInit = 0; + + if (!didUsbInit) + { + didUsbInit = 1; + usb_init(); + } + usb_find_busses(); + usb_find_devices(); + for (bus=usb_get_busses(); bus; bus=bus->next) + { + for (dev=bus->devices; dev; dev=dev->next) + { + DEBUG( "Enumerating device list.. VID: 0x%4.4x, PID: 0x%4.4x\n", dev->descriptor.idVendor, dev->descriptor.idProduct); + if (dev->descriptor.idVendor == vendor && dev->descriptor.idProduct == product) + { + /* we need to open the device in order to query strings */ + handle = usb_open(dev); + if (handle == NULL) + { + errorCode = USB_ERROR_ACCESS; + avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n", progname, usb_strerror()); + continue; + } + + // return with opened device handle + else + { + avrdude_message(MSG_NOTICE, "Device %p seemed to open OK.\n", handle); + + if ((errorCode = usb_set_configuration(handle, 1)) < 0) + { + avrdude_message(MSG_INFO, "Could not set configuration. Error code %d, %s.\n" + "You may need to run avrdude as root or set up correct usb port permissions.", errorCode, usb_strerror()); + } + + if ((errorCode = usb_claim_interface(handle, 0)) < 0) + { + avrdude_message(MSG_INFO, "Could not claim interface. Error code %d, %s\n" + "You may need to run avrdude as root or set up correct usb port permissions.", errorCode, usb_strerror()); + } + + errorCode = 0; + *device = handle; + return 0; + } + } + } + } + + return -1; +} + +static int pickit2_write_report(PROGRAMMER * pgm, const unsigned char report[65]) +{ + // endpoint 1 OUT?? + return usb_interrupt_write(PDATA(pgm)->usb_handle, USB_ENDPOINT_OUT | 1, (const char*)(report+1), 64, PDATA(pgm)->transaction_timeout); +} + +static int pickit2_read_report(PROGRAMMER * pgm, unsigned char report[65]) +{ + // endpoint 1 IN?? + return usb_interrupt_read(PDATA(pgm)->usb_handle, USB_ENDPOINT_IN | 1, (char*)(report+1), 64, PDATA(pgm)->transaction_timeout); +} +#endif // WIN323NATIVE + +static int pickit2_parseextparams(struct programmer_t * pgm, LISTID extparms) +{ + LNODEID ln; + const char *extended_param; + int rv = 0; + + for (ln = lfirst(extparms); ln; ln = lnext(ln)) + { + extended_param = ldata(ln); + + if (strncmp(extended_param, "clockrate=", strlen("clockrate=")) == 0) + { + int clock_rate; + if (sscanf(extended_param, "clockrate=%i", &clock_rate) != 1 || clock_rate <= 0) + { + avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid clockrate '%s'\n", + progname, extended_param); + rv = -1; + continue; + } + + 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 + + avrdude_message(MSG_NOTICE2, "%s: pickit2_parseextparms(): clockrate set to 0x%02x\n", + progname, clock_rate); + PDATA(pgm)->clock_period = clock_period; + + continue; + } + + if (strncmp(extended_param, "timeout=", strlen("timeout=")) == 0) + { + int timeout; + if (sscanf(extended_param, "timeout=%i", &timeout) != 1 || timeout <= 0) + { + avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid timeout '%s'\n", + progname, extended_param); + rv = -1; + continue; + } + + avrdude_message(MSG_NOTICE2, "%s: pickit2_parseextparms(): usb timeout set to 0x%02x\n", + progname, timeout); + PDATA(pgm)->transaction_timeout = timeout; + + continue; + } + + avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid extended parameter '%s'\n", + progname, extended_param); + rv = -1; + } + + return rv; +} + + +void pickit2_initpgm (PROGRAMMER * pgm) +{ + /* + * mandatory functions - these are called without checking to see + * whether they are assigned or not + */ + + pgm->initialize = pickit2_initialize; + pgm->display = pickit2_display; + pgm->enable = pickit2_enable; + pgm->disable = pickit2_disable; + pgm->powerup = pickit2_powerup; + pgm->powerdown = pickit2_powerdown; + pgm->program_enable = pickit2_program_enable; + pgm->chip_erase = pickit2_chip_erase; + pgm->open = pickit2_open; + pgm->close = pickit2_close; + + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; + + /* + * predefined functions - these functions have a valid default + * implementation. Hence, they don't need to be defined in + * the programmer. + */ + //pgm->rdy_led = pickit2_rdy_led; + //pgm->err_led = pickit2_err_led; + pgm->pgm_led = pickit2_pgm_led; + pgm->vfy_led = pickit2_vfy_led; + + /* + * optional functions - these are checked to make sure they are + * assigned before they are called + */ + + pgm->cmd = pickit2_cmd; + pgm->spi = pickit2_spi; + pgm->paged_write = pickit2_paged_write; + pgm->paged_load = pickit2_paged_load; + //pgm->write_setup = NULL; + //pgm->read_sig_bytes = NULL; + //pgm->set_vtarget = NULL;//pickit2_vtarget; + //pgm->set_varef = NULL; + //pgm->set_fosc = NULL; + //pgm->perform_osccal = NULL; + + pgm->parseextparams = pickit2_parseextparams; + + pgm->setup = pickit2_setup; + pgm->teardown = pickit2_teardown; + // pgm->page_size = 256; // not sure what this does... maybe the max page size that the page read/write function can handle + + strncpy(pgm->type, "pickit2", sizeof(pgm->type)); +} +#else +static int pickit2_nousb_open (struct programmer_t *pgm, char * name) { + avrdude_message(MSG_INFO, +#ifdef WIN32NATIVE + "%s: error: no usb or hid support. Please compile again with libusb or HID support from Win32 DDK installed.\n", +#else + "%s: error: no usb support. Please compile again with libusb installed.\n", +#endif + progname); + + return -1; +} + +void pickit2_initpgm (PROGRAMMER * pgm) +{ + /* + * mandatory functions - these are called without checking to see + * whether they are assigned or not + */ + + pgm->open = pickit2_nousb_open; + + strncpy(pgm->type, "pickit2", sizeof(pgm->type)); +} + +#endif /* defined(HAVE_LIBUSB) || (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) */ + +const char pickit2_desc[] = "Microchip's PICkit2 Programmer"; + diff --git a/xs/src/avrdude/pickit2.h b/xs/src/avrdude/pickit2.h new file mode 100644 index 000000000..cdd58d96d --- /dev/null +++ b/xs/src/avrdude/pickit2.h @@ -0,0 +1,35 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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: pickit2.h 2010-05-03 dbrown $ */ + +#ifndef pickit2_h +#define pickit2_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char pickit2_desc[]; +void pickit2_initpgm (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif // pickit2_h diff --git a/xs/src/avrdude/pindefs.c b/xs/src/avrdude/pindefs.c new file mode 100644 index 000000000..5753fc67b --- /dev/null +++ b/xs/src/avrdude/pindefs.c @@ -0,0 +1,370 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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: pindefs.h 1132 2013-01-09 19:23:30Z rliebscher $ */ + +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +/** + * Adds a pin in the pin definition as normal or inverse pin. + * + * @param[out] pindef pin definition to update + * @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) { + + pindef->mask[pin / PIN_FIELD_ELEMENT_SIZE] |= 1 << (pin % PIN_FIELD_ELEMENT_SIZE); + if(inverse) { + pindef->inverse[pin / PIN_FIELD_ELEMENT_SIZE] |= (1 << (pin % PIN_FIELD_ELEMENT_SIZE)); + } else { + pindef->inverse[pin / PIN_FIELD_ELEMENT_SIZE] &= ~(1 << (pin % PIN_FIELD_ELEMENT_SIZE)); + } +} + +/** + * Clear all defined pins in pindef. + * + * @param[out] pindef pin definition to clear + */ +void pin_clear_all(struct pindef_t * const pindef) { + memset(pindef, 0, sizeof(struct pindef_t)); +} + +/** + * Convert new pin definition to old pin number + * + * @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) { + bool found = false; + int i; + for(i = 0; i < PIN_MAX; i++) { + if(pindef->mask[i / PIN_FIELD_ELEMENT_SIZE] & (1 << (i % PIN_FIELD_ELEMENT_SIZE))) { + if(found) { + avrdude_message(MSG_INFO, "Multiple pins found\n"); //TODO + return -1; + } + found = true; + *pinno = i; + if(pindef->inverse[i / PIN_FIELD_ELEMENT_SIZE] & (1 << (i % PIN_FIELD_ELEMENT_SIZE))) { + *pinno |= PIN_INVERSE; + } + } + } + return 0; +} + +/** + * Convert new pin definition to old pinlist, does not support mixed inverted/non-inverted pin + * + * @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) { + int i; + + for(i = 0; i < PIN_FIELD_SIZE; i++) { + if(i == 0) { + if((pindef->mask[i] & ~PIN_MASK) != 0) { + avrdude_message(MSG_INFO, "Pins of higher index than max field size for old pinno found\n"); + return -1; + } + if (pindef->mask[i] == 0) { + /* this pin function is not using any pins */ + *pinno = 0; + } else if(pindef->mask[i] == pindef->inverse[i]) { /* all set bits in mask are set in inverse */ + *pinno = pindef->mask[i]; + *pinno |= PIN_INVERSE; + } else if(pindef->mask[i] == ((~pindef->inverse[i]) & pindef->mask[i])) { /* all set bits in mask are cleared in inverse */ + *pinno = pindef->mask[i]; + } else { + avrdude_message(MSG_INFO, "pins have different polarity set\n"); + return -1; + } + } else if(pindef->mask[i] != 0) { + avrdude_message(MSG_INFO, "Pins have higher number than fit in old format\n"); + return -1; + } + } + return 0; +} + + +/** + * 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) { + + if (pin_fill_old_pinlist(&(pgm->pin[PPI_AVR_VCC]), &(pgm->pinno[PPI_AVR_VCC])) < 0) + return -1; + if (pin_fill_old_pinlist(&(pgm->pin[PPI_AVR_BUFF]), &(pgm->pinno[PPI_AVR_BUFF])) < 0) + return -1; + if (pin_fill_old_pinno(&(pgm->pin[PIN_AVR_RESET]), &(pgm->pinno[PIN_AVR_RESET])) < 0) + return -1; + if (pin_fill_old_pinno(&(pgm->pin[PIN_AVR_SCK]), &(pgm->pinno[PIN_AVR_SCK])) < 0) + return -1; + if (pin_fill_old_pinno(&(pgm->pin[PIN_AVR_MOSI]), &(pgm->pinno[PIN_AVR_MOSI])) < 0) + return -1; + if (pin_fill_old_pinno(&(pgm->pin[PIN_AVR_MISO]), &(pgm->pinno[PIN_AVR_MISO])) < 0) + return -1; + if (pin_fill_old_pinno(&(pgm->pin[PIN_LED_ERR]), &(pgm->pinno[PIN_LED_ERR])) < 0) + return -1; + if (pin_fill_old_pinno(&(pgm->pin[PIN_LED_RDY]), &(pgm->pinno[PIN_LED_RDY])) < 0) + return -1; + if (pin_fill_old_pinno(&(pgm->pin[PIN_LED_PGM]), &(pgm->pinno[PIN_LED_PGM])) < 0) + return -1; + if (pin_fill_old_pinno(&(pgm->pin[PIN_LED_VFY]), &(pgm->pinno[PIN_LED_VFY])) < 0) + return -1; + + return 0; +} + +/** + * 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 representated as start-end. + * + * @param[in] pinmask the pin mask for which we want the string representation + * @returns pointer to a static string. + */ +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 *p = buf; + int n; + int pin; + const char * fmt; + int start = -1; + int end = -1; + + 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(pinmask[index] & (1 << bit)) { + bool output = false; + if(start == -1) { + output = true; + start = pin; + end = start; + } else if(pin == end + 1) { + end = pin; + } else { + if(start != end) { + n = sprintf(p, "-%d", end); + p += n; + } + output = true; + start = pin; + end = start; + } + if(output) { + fmt = (buf[0] == 0) ? "%d" : ",%d"; + n = sprintf(p, fmt, pin); + p += n; + } + } + } + if(start != end) { + n = sprintf(p, "-%d", end); + p += n; + } + + if(buf[0] == 0) + return "(no pins)"; + + return buf; +} + + +/** + * This function checks all pin of pgm against the constraints given in the checklist. + * It checks if + * @li any invalid pins are used + * @li valid pins are used inverted when not allowed + * @li any pins are used by more than one function + * @li any mandatory pin is not set all. + * + * In case of any error it report the wrong function and the pin numbers. + * For verbose >= 2 it also reports the possible correct values. + * For verbose >=3 it shows also which pins were ok. + * + * @param[in] pgm the programmer to check + * @param[in] checklist the constraint for the pins + * @param[in] size the number of entries in checklist + * @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, bool output) { + static const struct pindef_t 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 + // loop over all possible pinnames + for(pinname = 0; pinname < N_PINS; pinname++) { + bool used = false; + bool invalid = false; + bool inverse = false; + int index; + int segment; + 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}; + const struct pindef_t * valid_pins = &no_valid_pins; + bool is_mandatory = false; + bool is_ok = true; + //find corresponding check pattern + for(index = 0; index < size; index++) { + if(checklist[index].pinname == pinname) { + valid_pins = checklist[index].valid_pins; + is_mandatory = checklist[index].mandatory; + break; + } + } + + for(segment = 0; segment < PIN_FIELD_SIZE; segment++) { + // check if for mandatory any pin is defined + invalid_used[segment] = pgm->pin[pinname].mask[segment] & ~valid_pins->mask[segment]; + if(is_mandatory && (0 != (pgm->pin[pinname].mask[segment] & valid_pins->mask[segment]))) { + mandatory_used = true; + } + // check if it does not use any non valid pins + invalid_used[segment] = pgm->pin[pinname].mask[segment] & ~valid_pins->mask[segment]; + if(invalid_used[segment]) { + invalid = true; + } + // check if it does not use any valid pins as inverse if not allowed + inverse_used[segment] = pgm->pin[pinname].inverse[segment] & valid_pins->mask[segment] & ~valid_pins->inverse[segment]; + if(inverse_used[segment]) { + inverse = true; + } + // check if it does not use same pins as other function + already_used[segment] = pgm->pin[pinname].mask[segment] & already_used_all[segment]; + if(already_used[segment]) { + used = true; + } + already_used_all[segment] |= pgm->pin[pinname].mask[segment]; + } + if(invalid) { + if(output) { + avrdude_message(MSG_INFO, "%s: %s: Following pins are not valid pins for this function: %s\n", + progname, avr_pin_name(pinname), pinmask_to_str(invalid_used)); + avrdude_message(MSG_NOTICE2, "%s: %s: Valid pins for this function are: %s\n", + progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->mask)); + } + is_ok = false; + } + if(inverse) { + if(output) { + avrdude_message(MSG_INFO, "%s: %s: Following pins are not usable as inverse pins for this function: %s\n", + progname, avr_pin_name(pinname), pinmask_to_str(inverse_used)); + avrdude_message(MSG_NOTICE2, "%s: %s: Valid inverse pins for this function are: %s\n", + progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->inverse)); + } + is_ok = false; + } + if(used) { + if(output) { + avrdude_message(MSG_INFO, "%s: %s: Following pins are set for other functions too: %s\n", + progname, avr_pin_name(pinname), pinmask_to_str(already_used)); + is_ok = false; + } + } + if(!mandatory_used && is_mandatory && !invalid) { + if(output) { + avrdude_message(MSG_INFO, "%s: %s: Mandatory pin is not defined.\n", + progname, avr_pin_name(pinname)); + } + is_ok = false; + } + if(!is_ok) { + rv = -1; + } else if(output) { + avrdude_message(MSG_DEBUG, "%s: %s: Pin is ok.\n", + progname, avr_pin_name(pinname)); + } + } + return rv; +} + +/** + * This function returns a string representation of defined pins eg. ~1,2,~4,~5,7 + * 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; +} + +/** + * Returns the name of the pin as string. + * + * @param pinname the pinname which we want as string. + * @returns a string with the pinname, or if pinname is invalid. + */ +const char * avr_pin_name(int pinname) { + switch(pinname) { + case PPI_AVR_VCC : return "VCC"; + case PPI_AVR_BUFF : return "BUFF"; + case PIN_AVR_RESET : return "RESET"; + case PIN_AVR_SCK : return "SCK"; + case PIN_AVR_MOSI : return "MOSI"; + case PIN_AVR_MISO : return "MISO"; + case PIN_LED_ERR : return "ERRLED"; + case PIN_LED_RDY : return "RDYLED"; + case PIN_LED_PGM : return "PGMLED"; + case PIN_LED_VFY : return "VFYLED"; + default : return ""; + } +} + + diff --git a/xs/src/avrdude/ppi.c b/xs/src/avrdude/ppi.c new file mode 100644 index 000000000..2706b850e --- /dev/null +++ b/xs/src/avrdude/ppi.c @@ -0,0 +1,236 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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$ */ + + +#if !defined(WIN32NATIVE) + +#include "ac_cfg.h" + +#if HAVE_PARPORT + +#include +#include +#include +#include +#include +#include + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# include "freebsd_ppi.h" +#elif defined(__linux__) +# include "linux_ppdev.h" +#elif defined(__sun__) || defined(__sun) /* Solaris */ +# include "solaris_ecpp.h" +#endif + +#include "avrdude.h" +#include "libavrdude.h" + +#include "ppi.h" + +enum { + PPI_READ, + PPI_WRITE, + PPI_SHADOWREAD +}; + +static int ppi_shadow_access(union filedescriptor *fdp, int reg, + unsigned char *v, unsigned char action) +{ + static unsigned char shadow[3]; + int shadow_num; + + switch (reg) { + case PPIDATA: + shadow_num = 0; + break; + case PPICTRL: + shadow_num = 1; + break; + case PPISTATUS: + shadow_num = 2; + break; + default: + avrdude_message(MSG_INFO, "%s: avr_set(): invalid register=%d\n", + progname, reg); + return -1; + break; + } + + switch (action) { + case PPI_SHADOWREAD: + *v = shadow[shadow_num]; + break; + case PPI_READ: + DO_PPI_READ(fdp->ifd, reg, v); + shadow[shadow_num]=*v; + break; + case PPI_WRITE: + shadow[shadow_num]=*v; + DO_PPI_WRITE(fdp->ifd, reg, v); + break; + } + return 0; +} + +/* + * set the indicated bit of the specified register. + */ +int ppi_set(union filedescriptor *fdp, int reg, int bit) +{ + unsigned char v; + int rc; + + rc = ppi_shadow_access(fdp, reg, &v, PPI_SHADOWREAD); + v |= bit; + rc |= ppi_shadow_access(fdp, reg, &v, PPI_WRITE); + + if (rc) + return -1; + + return 0; +} + + +/* + * clear the indicated bit of the specified register. + */ +int ppi_clr(union filedescriptor *fdp, int reg, int bit) +{ + unsigned char v; + int rc; + + rc = ppi_shadow_access(fdp, reg, &v, PPI_SHADOWREAD); + v &= ~bit; + rc |= ppi_shadow_access(fdp, reg, &v, PPI_WRITE); + + if (rc) + return -1; + + return 0; +} + + +/* + * get the indicated bit of the specified register. + */ +int ppi_get(union filedescriptor *fdp, int reg, int bit) +{ + unsigned char v; + int rc; + + rc = ppi_shadow_access(fdp, reg, &v, PPI_READ); + v &= bit; + + if (rc) + return -1; + + return v; /* v == bit */ +} + +/* + * toggle the indicated bit of the specified register. + */ +int ppi_toggle(union filedescriptor *fdp, int reg, int bit) +{ + unsigned char v; + int rc; + + rc = ppi_shadow_access(fdp, reg, &v, PPI_SHADOWREAD); + v ^= bit; + rc |= ppi_shadow_access(fdp, reg, &v, PPI_WRITE); + + if (rc) + return -1; + + return 0; +} + + +/* + * get all bits of the specified register. + */ +int ppi_getall(union filedescriptor *fdp, int reg) +{ + unsigned char v; + int rc; + + rc = ppi_shadow_access(fdp, reg, &v, PPI_READ); + + if (rc) + return -1; + + return v; /* v == bit */ +} + +/* + * set all bits of the specified register to val. + */ +int ppi_setall(union filedescriptor *fdp, int reg, int val) +{ + unsigned char v; + int rc; + + v = val; + rc = ppi_shadow_access(fdp, reg, &v, PPI_WRITE); + + if (rc) + return -1; + + return 0; +} + + +void ppi_open(char * port, union filedescriptor *fdp) +{ + int fd; + unsigned char v; + + fd = open(port, O_RDWR); + if (fd < 0) { + avrdude_message(MSG_INFO, "%s: can't open device \"%s\": %s\n", + progname, port, strerror(errno)); + fdp->ifd = -1; + return; + } + + ppi_claim (fd); + + /* + * Initialize shadow registers + */ + + ppi_shadow_access (fdp, PPIDATA, &v, PPI_READ); + ppi_shadow_access (fdp, PPICTRL, &v, PPI_READ); + ppi_shadow_access (fdp, PPISTATUS, &v, PPI_READ); + + fdp->ifd = fd; +} + + +void ppi_close(union filedescriptor *fdp) +{ + ppi_release (fdp->ifd); + close(fdp->ifd); +} + +#endif /* HAVE_PARPORT */ + +#endif /* !WIN32NATIVE */ diff --git a/xs/src/avrdude/ppi.h b/xs/src/avrdude/ppi.h new file mode 100644 index 000000000..38fc1e8b5 --- /dev/null +++ b/xs/src/avrdude/ppi.h @@ -0,0 +1,59 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 ppi_h +#define ppi_h + +/* + * PPI registers + */ +enum { + PPIDATA, + PPICTRL, + PPISTATUS +}; + +#ifdef __cplusplus +extern "C" { +#endif + +int ppi_get (union filedescriptor *fdp, int reg, int bit); + +int ppi_set (union filedescriptor *fdp, int reg, int bit); + +int ppi_clr (union filedescriptor *fdp, int reg, int bit); + +int ppi_getall (union filedescriptor *fdp, int reg); + +int ppi_setall (union filedescriptor *fdp, int reg, int val); + +int ppi_toggle (union filedescriptor *fdp, int reg, int bit); + +void ppi_open (char * port, union filedescriptor *fdp); + +void ppi_close (union filedescriptor *fdp); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/xs/src/avrdude/ppiwin.c b/xs/src/avrdude/ppiwin.c new file mode 100644 index 000000000..7811288c0 --- /dev/null +++ b/xs/src/avrdude/ppiwin.c @@ -0,0 +1,417 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2003, 2004, 2006 + * Eric B. Weddington + * Copyright 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 + * 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$ */ + +/* +This is the parallel port interface for Windows built using Cygwin. + +In the ppi_* functions that access the parallel port registers, +fd = parallel port address +reg = register as defined in an enum in ppi.h. This must be converted + to a proper offset of the base address. +*/ + + +#include "ac_cfg.h" + +#if defined (WIN32NATIVE) + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "ppi.h" + +#define DEVICE_LPT1 "lpt1" +#define DEVICE_LPT2 "lpt2" +#define DEVICE_LPT3 "lpt3" + +#define DEVICE_MAX 3 + +typedef struct +{ + const char *name; + int base_address; +} winpp; + +static const winpp winports[DEVICE_MAX] = +{ + {DEVICE_LPT1, 0x378}, + {DEVICE_LPT2, 0x278}, + {DEVICE_LPT3, 0x3BC}, +}; + + + + + +/* FUNCTION PROTOTYPES */ +static int winnt_pp_open(void); +static unsigned short port_get(union filedescriptor *fdp, int reg); +static unsigned char reg2offset(int reg); +static unsigned char inb(unsigned short port); +static void outb(unsigned char value, unsigned short port); + + + +/* FUNCTION DEFINITIONS */ + +void ppi_open(char *port, union filedescriptor *fdp) +{ + unsigned char i; + int fd; + + fd = winnt_pp_open(); + + if(fd < 0) + { + avrdude_message(MSG_INFO, "%s: can't open device \"giveio\"\n\n", progname); + fdp->ifd = -1; + return; + } + + /* Search the windows port names for a match */ + fd = -1; + for(i = 0; i < DEVICE_MAX; i++) + { + if(strcmp(winports[i].name, port) == 0) + { + /* Set the file descriptor with the Windows parallel port base address. */ + fd = winports[i].base_address; + break; + } + } + if(fd == -1) + { + /* + * Supplied port name did not match any of the pre-defined + * names. Try interpreting it as a numeric + * (hexadecimal/decimal/octal) address. + */ + char *cp; + + fd = strtol(port, &cp, 0); + if(*port == '\0' || *cp != '\0') + { + avrdude_message(MSG_INFO, "%s: port name \"%s\" is neither lpt1/2/3 nor valid number\n", + progname, port); + fd = -1; + } + } + if(fd < 0) + { + avrdude_message(MSG_INFO, "%s: can't open device \"%s\"\n\n", progname, port); + fdp->ifd = -1; + return; + } + + fdp->ifd = fd; +} + + +#define DRIVERNAME "\\\\.\\giveio" +static int winnt_pp_open(void) +{ + // Only try to use giveio under Windows NT/2000/XP. + OSVERSIONINFO ver_info; + + memset(&ver_info, 0, sizeof(ver_info)); + + ver_info.dwOSVersionInfoSize = sizeof(ver_info); + + if(!GetVersionEx(&ver_info)) + { + return(-1); + } + else if(ver_info.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + HANDLE h = CreateFileA(DRIVERNAME, + GENERIC_READ, + 0, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if(h == INVALID_HANDLE_VALUE) + { + return(-1); + } + + /* Close immediately. The process now has the rights it needs. */ + if(h != NULL) + { + CloseHandle(h); + } + } + return(0); +} + + + + +void ppi_close(union filedescriptor *fdp) +{ + return; +} + + + +/* + * set the indicated bit of the specified register. + */ +int ppi_set(union filedescriptor *fdp, int reg, int bit) +{ + unsigned char v; + unsigned short port; + + port = port_get(fdp, reg); + v = inb(port); + v |= bit; + outb(v, port); + return 0; +} + + +/* + * clear the indicated bit of the specified register. + */ +int ppi_clr(union filedescriptor *fdp, int reg, int bit) +{ + unsigned char v; + unsigned short port; + + port = port_get(fdp, reg); + v = inb(port); + v &= ~bit; + outb(v, port); + + return 0; +} + + +/* + * get the indicated bit of the specified register. + */ +int ppi_get(union filedescriptor *fdp, int reg, int bit) +{ + unsigned char v; + + v = inb(port_get(fdp, reg)); + v &= bit; + + return(v); +} + + + + +/* + * toggle the indicated bit of the specified register. + */ +int ppi_toggle(union filedescriptor *fdp, int reg, int bit) +{ + unsigned char v; + unsigned short port; + + port = port_get(fdp, reg); + + v = inb(port); + v ^= bit; + outb(v, port); + + return 0; +} + + +/* + * get all bits of the specified register. + */ +int ppi_getall(union filedescriptor *fdp, int reg) +{ + unsigned char v; + + v = inb(port_get(fdp, reg)); + + return((int)v); +} + + + + +/* + * set all bits of the specified register to val. + */ +int ppi_setall(union filedescriptor *fdp, int reg, int val) +{ + outb((unsigned char)val, port_get(fdp, reg)); + return 0; +} + + + + +/* Calculate port address to access. */ +static unsigned short port_get(union filedescriptor *fdp, int reg) +{ + return((unsigned short)(fdp->ifd + reg2offset(reg))); +} + + +/* Convert register enum to offset of base address. */ +static unsigned char reg2offset(int reg) +{ + unsigned char offset = 0; + + switch(reg) + { + case PPIDATA: + { + offset = 0; + break; + } + case PPISTATUS: + { + offset = 1; + break; + } + case PPICTRL: + { + offset = 2; + break; + } + } + + return(offset); +} + + +/* Read in value from port. */ +static unsigned char inb(unsigned short port) +{ + unsigned char t; + + asm volatile ("in %1, %0" + : "=a" (t) + : "d" (port)); + + return t; +} + + +/* Write value to port. */ +static void outb(unsigned char value, unsigned short port) +{ + asm volatile ("out %1, %0" + : + : "d" (port), "a" (value) ); + + return; +} + +#if !defined(HAVE_GETTIMEOFDAY) +struct timezone; +int gettimeofday(struct timeval *tv, struct timezone *unused){ +// i've found only ms resolution, avrdude expects us + + SYSTEMTIME st; + GetSystemTime(&st); + + tv->tv_sec=(long)(st.wSecond+st.wMinute*60+st.wHour*3600); + tv->tv_usec=(long)(st.wMilliseconds*1000); + + return 0; +} +#endif /* HAVE_GETTIMEOFDAY */ + +// #define W32USLEEPDBG + +#ifdef W32USLEEPDBG + +# define DEBUG_QueryPerformanceCounter(arg) QueryPerformanceCounter(arg) +# define DEBUG_DisplayTimingInfo(start, stop, freq, us, has_highperf) \ + do { \ + unsigned long dt; \ + dt = (unsigned long)((stop.QuadPart - start.QuadPart) * 1000 * 1000 \ + / freq.QuadPart); \ + avrdude_message(MSG_INFO, \ + "hpt:%i usleep usec:%lu sleep msec:%lu timed usec:%lu\n", \ + has_highperf, us, ((us + 999) / 1000), dt); \ + } while (0) + +#else + +# define DEBUG_QueryPerformanceCounter(arg) +# define DEBUG_DisplayTimingInfo(start, stop, freq, us, has_highperf) + +#endif + +#if !defined(HAVE_USLEEP) +int usleep(unsigned int us) +{ + int has_highperf; + LARGE_INTEGER freq,start,stop,loopend; + + // workaround: although usleep is very precise if using + // high-performance-timers there are sometimes problems with + // verify - increasing the delay helps sometimes but not + // realiably. There must be some other problem. Maybe just + // with my test-hardware maybe in the code-base. + //// us=(unsigned long) (us*1.5); + + has_highperf=QueryPerformanceFrequency(&freq); + + //has_highperf=0; // debug + + if (has_highperf) { + QueryPerformanceCounter(&start); + loopend.QuadPart=start.QuadPart+freq.QuadPart*us/(1000*1000); + do { + QueryPerformanceCounter(&stop); + } while (stop.QuadPart<=loopend.QuadPart); + } + else { + DEBUG_QueryPerformanceCounter(&start); + + Sleep(1); + Sleep( (DWORD)((us+999)/1000) ); + + DEBUG_QueryPerformanceCounter(&stop); + } + + DEBUG_DisplayTimingInfo(start, stop, freq, us, has_highperf); + + return 0; +} +#endif /* !HAVE_USLEEP */ + +#endif + + diff --git a/xs/src/avrdude/safemode.c b/xs/src/avrdude/safemode.c new file mode 100644 index 000000000..b530a5fcb --- /dev/null +++ b/xs/src/avrdude/safemode.c @@ -0,0 +1,318 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * avrdude is Copyright (C) 2000-2004 Brian S. Dean + * + * This file: Copyright (C) 2005-2007 Colin O'Flynn + * + * 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 "ac_cfg.h" + +#include "avrdude.h" +#include "libavrdude.h" + +/* This value from ac_cfg.h */ +/* + * Writes the specified fuse in fusename (can be "lfuse", "hfuse", or + * "efuse") and verifies it. Will try up to tries amount of times + * before giving up + */ +int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm, + AVRPART * p, int tries) +{ + AVRMEM * m; + unsigned char fuseread; + int returnvalue = -1; + + m = avr_locate_mem(p, fusename); + if (m == NULL) { + return -1; + } + + /* Keep trying to write then read back the fuse values */ + while (tries > 0) { + if (avr_write_byte(pgm, p, m, 0, fuse) != 0) + { + continue; + } + if (pgm->read_byte(pgm, p, m, 0, &fuseread) != 0) + { + continue; + } + + /* Report information to user if needed */ + avrdude_message(MSG_NOTICE, "%s: safemode: Wrote %s to %x, read as %x. %d attempts left\n", + progname, fusename, fuse, fuseread, tries-1); + + /* If fuse wrote OK, no need to keep going */ + if (fuse == fuseread) { + tries = 0; + returnvalue = 0; + } + tries--; + } + + return returnvalue; +} + +/* + * Reads the fuses three times, checking that all readings are the + * same. This will ensure that the before values aren't in error! + */ +int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse, + unsigned char * efuse, unsigned char * fuse, + PROGRAMMER * pgm, AVRPART * p) +{ + + unsigned char value; + unsigned char fusegood = 0; + unsigned char allowfuseread = 1; + unsigned char safemode_lfuse; + unsigned char safemode_hfuse; + unsigned char safemode_efuse; + unsigned char safemode_fuse; + AVRMEM * m; + + safemode_lfuse = *lfuse; + safemode_hfuse = *hfuse; + safemode_efuse = *efuse; + safemode_fuse = *fuse; + + + /* Read fuse three times */ + fusegood = 2; /* If AVR device doesn't support this fuse, don't want + to generate a verify error */ + m = avr_locate_mem(p, "fuse"); + if (m != NULL) { + fusegood = 0; /* By default fuse is a failure */ + if(pgm->read_byte(pgm, p, m, 0, &safemode_fuse) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 1, fuse value: %x\n",progname, safemode_fuse); + if(pgm->read_byte(pgm, p, m, 0, &value) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 2, fuse value: %x\n",progname, value); + if (value == safemode_fuse) { + if (pgm->read_byte(pgm, p, m, 0, &value) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 3, fuse value: %x\n",progname, value); + if (value == safemode_fuse) + { + fusegood = 1; /* Fuse read OK three times */ + } + } + } + + //Programmer does not allow fuse reading.... no point trying anymore + if (allowfuseread == 0) + { + return -5; + } + + if (fusegood == 0) { + avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read fuse properly. " + "Programmer may not be reliable.\n", progname); + return -1; + } + else if (fusegood == 1) { + avrdude_message(MSG_NOTICE, "%s: safemode: fuse reads as %X\n", progname, safemode_fuse); + } + + + /* Read lfuse three times */ + fusegood = 2; /* If AVR device doesn't support this fuse, don't want + to generate a verify error */ + m = avr_locate_mem(p, "lfuse"); + if (m != NULL) { + fusegood = 0; /* By default fuse is a failure */ + if (pgm->read_byte(pgm, p, m, 0, &safemode_lfuse) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 1, lfuse value: %x\n",progname, safemode_lfuse); + if (pgm->read_byte(pgm, p, m, 0, &value) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 2, lfuse value: %x\n",progname, value); + if (value == safemode_lfuse) { + if (pgm->read_byte(pgm, p, m, 0, &value) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 3, lfuse value: %x\n",progname, value); + if (value == safemode_lfuse){ + fusegood = 1; /* Fuse read OK three times */ + } + } + } + + //Programmer does not allow fuse reading.... no point trying anymore + if (allowfuseread == 0) + { + return -5; + } + + + if (fusegood == 0) { + avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read lfuse properly. " + "Programmer may not be reliable.\n", progname); + return -1; + } + else if (fusegood == 1) { + avrdude_message(MSG_DEBUG, "%s: safemode: lfuse reads as %X\n", progname, safemode_lfuse); + } + + /* Read hfuse three times */ + fusegood = 2; /* If AVR device doesn't support this fuse, don't want + to generate a verify error */ + m = avr_locate_mem(p, "hfuse"); + if (m != NULL) { + fusegood = 0; /* By default fuse is a failure */ + if (pgm->read_byte(pgm, p, m, 0, &safemode_hfuse) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 1, hfuse value: %x\n",progname, safemode_hfuse); + if (pgm->read_byte(pgm, p, m, 0, &value) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 2, hfuse value: %x\n",progname, value); + if (value == safemode_hfuse) { + if (pgm->read_byte(pgm, p, m, 0, &value) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 3, hfuse value: %x\n",progname, value); + if (value == safemode_hfuse){ + fusegood = 1; /* Fuse read OK three times */ + } + } + } + + //Programmer does not allow fuse reading.... no point trying anymore + if (allowfuseread == 0) + { + return -5; + } + + if (fusegood == 0) { + avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read hfuse properly. " + "Programmer may not be reliable.\n", progname); + return -2; + } + else if (fusegood == 1){ + avrdude_message(MSG_NOTICE, "%s: safemode: hfuse reads as %X\n", progname, safemode_hfuse); + } + + /* Read efuse three times */ + fusegood = 2; /* If AVR device doesn't support this fuse, don't want + to generate a verify error */ + m = avr_locate_mem(p, "efuse"); + if (m != NULL) { + fusegood = 0; /* By default fuse is a failure */ + if (pgm->read_byte(pgm, p, m, 0, &safemode_efuse) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 1, efuse value: %x\n",progname, safemode_efuse); + if (pgm->read_byte(pgm, p, m, 0, &value) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 2, efuse value: %x\n",progname, value); + if (value == safemode_efuse) { + if (pgm->read_byte(pgm, p, m, 0, &value) != 0) + { + allowfuseread = 0; + } + avrdude_message(MSG_DEBUG, "%s: safemode read 3, efuse value: %x\n",progname, value); + if (value == safemode_efuse){ + fusegood = 1; /* Fuse read OK three times */ + } + } + } + + //Programmer does not allow fuse reading.... no point trying anymore + if (allowfuseread == 0) + { + return -5; + } + + if (fusegood == 0) { + avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read efuse properly. " + "Programmer may not be reliable.\n", progname); + return -3; + } + else if (fusegood == 1) { + avrdude_message(MSG_NOTICE, "%s: safemode: efuse reads as %X\n", progname, safemode_efuse); + } + + *lfuse = safemode_lfuse; + *hfuse = safemode_hfuse; + *efuse = safemode_efuse; + *fuse = safemode_fuse; + + return 0; +} + + +/* + * This routine will store the current values pointed to by lfuse, + * hfuse, and efuse into an internal buffer in this routine when save + * is set to 1. When save is 0 (or not 1 really) it will copy the + * values from the internal buffer into the locations pointed to be + * lfuse, hfuse, and efuse. This allows you to change the fuse bits if + * needed from another routine (ie: have it so if user requests fuse + * bits are changed, the requested value is now verified + */ +int safemode_memfuses (int save, unsigned char * lfuse, unsigned char * hfuse, + unsigned char * efuse, unsigned char * fuse) +{ + static unsigned char safemode_lfuse = 0xff; + static unsigned char safemode_hfuse = 0xff; + static unsigned char safemode_efuse = 0xff; + static unsigned char safemode_fuse = 0xff; + + switch (save) { + + /* Save the fuses as safemode setting */ + case 1: + safemode_lfuse = *lfuse; + safemode_hfuse = *hfuse; + safemode_efuse = *efuse; + safemode_fuse = *fuse; + + break; + /* Read back the fuses */ + default: + *lfuse = safemode_lfuse; + *hfuse = safemode_hfuse; + *efuse = safemode_efuse; + *fuse = safemode_fuse; + break; + } + + return 0; +} diff --git a/xs/src/avrdude/ser_avrdoper.c b/xs/src/avrdude/ser_avrdoper.c new file mode 100644 index 000000000..71080b7c7 --- /dev/null +++ b/xs/src/avrdude/ser_avrdoper.c @@ -0,0 +1,661 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2003-2004 Theodore A. Roth + * Copyright (C) 2006 Joerg Wunsch + * Copyright (C) 2006 Christian Starkjohann + * + * 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$ */ + +/* + * Serial Interface emulation for USB programmer "AVR-Doper" in HID mode. + */ + +#include "ac_cfg.h" + +#if defined(HAVE_LIBUSB) || (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) + +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +/* ------------------------------------------------------------------------ */ + +/* Numeric constants for 'reportType' parameters */ +#define USB_HID_REPORT_TYPE_INPUT 1 +#define USB_HID_REPORT_TYPE_OUTPUT 2 +#define USB_HID_REPORT_TYPE_FEATURE 3 + +/* These are the error codes which can be returned by functions of this + * module. + */ +#define USB_ERROR_NONE 0 +#define USB_ERROR_ACCESS 1 +#define USB_ERROR_NOTFOUND 2 +#define USB_ERROR_BUSY 16 +#define USB_ERROR_IO 5 + +#define USB_VENDOR_ID 0x16c0 +#define USB_PRODUCT_ID 0x05df + +static 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 */ + +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ + +#if defined(WIN32NATIVE) && defined(HAVE_LIBHID) + +#include +#include + +#if defined(HAVE_DDK_HIDSDI_H) +# include +#else +# include "my_ddk_hidsdi.h" +#endif +#include + +#ifdef USB_DEBUG +#define DEBUG_PRINT(arg) printf arg +#else +#define DEBUG_PRINT(arg) +#endif + +/* ------------------------------------------------------------------------ */ + +static void convertUniToAscii(char *buffer) +{ + unsigned short *uni = (void *)buffer; + char *ascii = buffer; + + while(*uni != 0){ + if(*uni >= 256){ + *ascii++ = '?'; + uni++; + }else{ + *ascii++ = *uni++; + } + } + *ascii++ = 0; +} + +static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName, + int product, char *productName, int usesReportIDs) +{ + GUID hidGuid; /* GUID for HID driver */ + HDEVINFO deviceInfoList; + SP_DEVICE_INTERFACE_DATA deviceInfo; + SP_DEVICE_INTERFACE_DETAIL_DATA *deviceDetails = NULL; + DWORD size; + int i, openFlag = 0; /* may be FILE_FLAG_OVERLAPPED */ + int errorCode = USB_ERROR_NOTFOUND; + HANDLE handle = INVALID_HANDLE_VALUE; + HIDD_ATTRIBUTES deviceAttributes; + + HidD_GetHidGuid(&hidGuid); + deviceInfoList = SetupDiGetClassDevs(&hidGuid, NULL, NULL, + DIGCF_PRESENT | DIGCF_INTERFACEDEVICE); + deviceInfo.cbSize = sizeof(deviceInfo); + for(i=0;;i++){ + if(handle != INVALID_HANDLE_VALUE){ + CloseHandle(handle); + handle = INVALID_HANDLE_VALUE; + } + if(!SetupDiEnumDeviceInterfaces(deviceInfoList, 0, &hidGuid, i, &deviceInfo)) + break; /* no more entries */ + /* first do a dummy call just to determine the actual size required */ + SetupDiGetDeviceInterfaceDetail(deviceInfoList, &deviceInfo, NULL, 0, &size, NULL); + if(deviceDetails != NULL) + free(deviceDetails); + deviceDetails = malloc(size); + deviceDetails->cbSize = sizeof(*deviceDetails); + /* this call is for real: */ + SetupDiGetDeviceInterfaceDetail(deviceInfoList, &deviceInfo, deviceDetails, + size, &size, NULL); + DEBUG_PRINT(("checking HID path \"%s\"\n", deviceDetails->DevicePath)); + /* attempt opening for R/W -- we don't care about devices which can't be accessed */ + handle = CreateFile(deviceDetails->DevicePath, GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, + openFlag, NULL); + if(handle == INVALID_HANDLE_VALUE){ + DEBUG_PRINT(("opening failed: %d\n", (int)GetLastError())); + /* errorCode = USB_ERROR_ACCESS; opening will always fail for mouse -- ignore */ + continue; + } + deviceAttributes.Size = sizeof(deviceAttributes); + HidD_GetAttributes(handle, &deviceAttributes); + DEBUG_PRINT(("device attributes: vid=%d pid=%d\n", + deviceAttributes.VendorID, deviceAttributes.ProductID)); + if(deviceAttributes.VendorID != vendor || deviceAttributes.ProductID != product) + continue; /* ignore this device */ + errorCode = USB_ERROR_NOTFOUND; + if(vendorName != NULL && productName != NULL){ + char buffer[512]; + if(!HidD_GetManufacturerString(handle, buffer, sizeof(buffer))){ + DEBUG_PRINT(("error obtaining vendor name\n")); + errorCode = USB_ERROR_IO; + continue; + } + convertUniToAscii(buffer); + DEBUG_PRINT(("vendorName = \"%s\"\n", buffer)); + if(strcmp(vendorName, buffer) != 0) + continue; + if(!HidD_GetProductString(handle, buffer, sizeof(buffer))){ + DEBUG_PRINT(("error obtaining product name\n")); + errorCode = USB_ERROR_IO; + continue; + } + convertUniToAscii(buffer); + DEBUG_PRINT(("productName = \"%s\"\n", buffer)); + if(strcmp(productName, buffer) != 0) + continue; + } + break; /* we have found the device we are looking for! */ + } + SetupDiDestroyDeviceInfoList(deviceInfoList); + if(deviceDetails != NULL) + free(deviceDetails); + if(handle != INVALID_HANDLE_VALUE){ + fdp->pfd = (void *)handle; + errorCode = 0; + } + return errorCode; +} + +/* ------------------------------------------------------------------------ */ + +static void usbCloseDevice(union filedescriptor *fdp) +{ + CloseHandle((HANDLE)fdp->pfd); +} + +/* ------------------------------------------------------------------------ */ + +static int usbSetReport(union filedescriptor *fdp, int reportType, char *buffer, int len) +{ + HANDLE handle = (HANDLE)fdp->pfd; + BOOLEAN rval = 0; + DWORD bytesWritten; + + switch(reportType){ + case USB_HID_REPORT_TYPE_INPUT: + break; + case USB_HID_REPORT_TYPE_OUTPUT: + rval = WriteFile(handle, buffer, len, &bytesWritten, NULL); + break; + case USB_HID_REPORT_TYPE_FEATURE: + rval = HidD_SetFeature(handle, buffer, len); + break; + } + return rval == 0 ? USB_ERROR_IO : 0; +} + +/* ------------------------------------------------------------------------ */ + +static int usbGetReport(union filedescriptor *fdp, int reportType, int reportNumber, + char *buffer, int *len) +{ + HANDLE handle = (HANDLE)fdp->pfd; + BOOLEAN rval = 0; + DWORD bytesRead; + + switch(reportType){ + case USB_HID_REPORT_TYPE_INPUT: + buffer[0] = reportNumber; + rval = ReadFile(handle, buffer, *len, &bytesRead, NULL); + if(rval) + *len = bytesRead; + break; + case USB_HID_REPORT_TYPE_OUTPUT: + break; + case USB_HID_REPORT_TYPE_FEATURE: + buffer[0] = reportNumber; + rval = HidD_GetFeature(handle, buffer, *len); + break; + } + return rval == 0 ? USB_ERROR_IO : 0; +} + +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ + +#else /* !(WIN32NATIVE && HAVE_LIBHID) */ + +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ + +#if defined(HAVE_USB_H) +# include +#elif defined(HAVE_LUSB0_USB_H) +# include +#else +# error "libusb needs either or " +#endif + +/* ------------------------------------------------------------------------- */ + +#define USBRQ_HID_GET_REPORT 0x01 +#define USBRQ_HID_SET_REPORT 0x09 + +static int usesReportIDs; + +/* ------------------------------------------------------------------------- */ + +static int usbGetStringAscii(usb_dev_handle *dev, int index, int langid, char *buf, int buflen) +{ + char buffer[256]; + int rval, i; + + if((rval = usb_control_msg(dev, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, + (USB_DT_STRING << 8) + index, langid, buffer, + sizeof(buffer), 1000)) < 0) + return rval; + if(buffer[1] != USB_DT_STRING) + return 0; + if((unsigned char)buffer[0] < rval) + rval = (unsigned char)buffer[0]; + rval /= 2; + /* lossy conversion to ISO Latin1 */ + for(i=1;i buflen) /* destination buffer overflow */ + break; + buf[i-1] = buffer[2 * i]; + if(buffer[2 * i + 1] != 0) /* outside of ISO Latin1 range */ + buf[i-1] = '?'; + } + buf[i-1] = 0; + return i-1; +} + +static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName, + int product, char *productName, int doReportIDs) +{ + struct usb_bus *bus; + struct usb_device *dev; + usb_dev_handle *handle = NULL; + int errorCode = USB_ERROR_NOTFOUND; + static int didUsbInit = 0; + + if(!didUsbInit){ + usb_init(); + didUsbInit = 1; + } + usb_find_busses(); + usb_find_devices(); + for(bus=usb_get_busses(); bus; bus=bus->next){ + for(dev=bus->devices; dev; dev=dev->next){ + if(dev->descriptor.idVendor == vendor && dev->descriptor.idProduct == product){ + char string[256]; + int len; + handle = usb_open(dev); /* we need to open the device in order to query strings */ + if(!handle){ + errorCode = USB_ERROR_ACCESS; + avrdude_message(MSG_INFO, "Warning: cannot open USB device: %s\n", + usb_strerror()); + continue; + } + if(vendorName == NULL && productName == NULL){ /* name does not matter */ + break; + } + /* now check whether the names match: */ + len = usbGetStringAscii(handle, dev->descriptor.iManufacturer, + 0x0409, string, sizeof(string)); + if(len < 0){ + errorCode = USB_ERROR_IO; + avrdude_message(MSG_INFO, "Warning: cannot query manufacturer for device: %s\n", + usb_strerror()); + }else{ + errorCode = USB_ERROR_NOTFOUND; + /* avrdude_message(MSG_INFO, "seen device from vendor ->%s<-\n", string); */ + if(strcmp(string, vendorName) == 0){ + len = usbGetStringAscii(handle, dev->descriptor.iProduct, + 0x0409, string, sizeof(string)); + if(len < 0){ + errorCode = USB_ERROR_IO; + avrdude_message(MSG_INFO, "Warning: cannot query product for device: %s\n", + usb_strerror()); + }else{ + errorCode = USB_ERROR_NOTFOUND; + /* avrdude_message(MSG_INFO, "seen product ->%s<-\n", string); */ + if(strcmp(string, productName) == 0) + break; + } + } + } + usb_close(handle); + handle = NULL; + } + } + if(handle) + break; + } + if(handle != NULL){ + int rval, retries = 3; + if(usb_set_configuration(handle, 1)){ + avrdude_message(MSG_INFO, "Warning: could not set configuration: %s\n", + usb_strerror()); + } + /* now try to claim the interface and detach the kernel HID driver on + * linux and other operating systems which support the call. + */ + while((rval = usb_claim_interface(handle, 0)) != 0 && retries-- > 0){ +#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP + if(usb_detach_kernel_driver_np(handle, 0) < 0){ + avrdude_message(MSG_INFO, "Warning: could not detach kernel HID driver: %s\n", + usb_strerror()); + } +#endif + } + if(rval != 0) + avrdude_message(MSG_INFO, "Warning: could not claim interface\n"); +/* Continue anyway, even if we could not claim the interface. Control transfers + * should still work. + */ + errorCode = 0; + fdp->pfd = (void *)handle; + usesReportIDs = doReportIDs; + } + return errorCode; +} + +/* ------------------------------------------------------------------------- */ + +static void usbCloseDevice(union filedescriptor *fdp) +{ + usb_close((usb_dev_handle *)fdp->pfd); +} + +/* ------------------------------------------------------------------------- */ + +static int usbSetReport(union filedescriptor *fdp, int reportType, char *buffer, int len) +{ + int bytesSent; + + if(!usesReportIDs){ + buffer++; /* skip dummy report ID */ + len--; + } + bytesSent = usb_control_msg((usb_dev_handle *)fdp->pfd, USB_TYPE_CLASS | + USB_RECIP_INTERFACE | USB_ENDPOINT_OUT, USBRQ_HID_SET_REPORT, + reportType << 8 | buffer[0], 0, buffer, len, 5000); + if(bytesSent != len){ + if(bytesSent < 0) + avrdude_message(MSG_INFO, "Error sending message: %s\n", usb_strerror()); + return USB_ERROR_IO; + } + return 0; +} + +/* ------------------------------------------------------------------------- */ + +static int usbGetReport(union filedescriptor *fdp, int reportType, int reportNumber, + char *buffer, int *len) +{ + int bytesReceived, maxLen = *len; + + if(!usesReportIDs){ + buffer++; /* make room for dummy report ID */ + maxLen--; + } + bytesReceived = usb_control_msg((usb_dev_handle *)fdp->pfd, USB_TYPE_CLASS | + USB_RECIP_INTERFACE | USB_ENDPOINT_IN, USBRQ_HID_GET_REPORT, + reportType << 8 | reportNumber, 0, buffer, maxLen, 5000); + if(bytesReceived < 0){ + avrdude_message(MSG_INFO, "Error sending message: %s\n", usb_strerror()); + return USB_ERROR_IO; + } + *len = bytesReceived; + if(!usesReportIDs){ + buffer[-1] = reportNumber; /* add dummy report ID */ + len++; + } + return 0; +} + +#endif /* WIN32NATIVE */ + +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ + +/* ------------------------------------------------------------------------- */ + +static void dumpBlock(const char *prefix, const unsigned char *buf, int len) +{ + int i; + + if(len <= 8){ /* more compact format for short blocks */ + avrdude_message(MSG_INFO, "%s: %d bytes: ", prefix, len); + for(i = 0; i < len; i++){ + avrdude_message(MSG_INFO, "%02x ", buf[i]); + } + avrdude_message(MSG_INFO, " \""); + for(i = 0; i < len; i++){ + if(buf[i] >= 0x20 && buf[i] < 0x7f){ + fputc(buf[i], stderr); + }else{ + fputc('.', stderr); + } + } + avrdude_message(MSG_INFO, "\"\n"); + }else{ + avrdude_message(MSG_INFO, "%s: %d bytes:\n", prefix, len); + while(len > 0){ + for(i = 0; i < 16; i++){ + if(i < len){ + avrdude_message(MSG_INFO, "%02x ", buf[i]); + }else{ + avrdude_message(MSG_INFO, " "); + } + if(i == 7) + fputc(' ', stderr); + } + avrdude_message(MSG_INFO, " \""); + for(i = 0; i < 16; i++){ + if(i < len){ + if(buf[i] >= 0x20 && buf[i] < 0x7f){ + fputc(buf[i], stderr); + }else{ + fputc('.', stderr); + } + } + } + avrdude_message(MSG_INFO, "\"\n"); + buf += 16; + len -= 16; + } + } +} + +static char *usbErrorText(int usbErrno) +{ + static char buffer[32]; + + 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: + sprintf(buffer, "Unknown error %d.", usbErrno); + return buffer; + } +} + +/* ------------------------------------------------------------------------- */ + +static int avrdoper_open(char *port, union pinfo pinfo, union filedescriptor *fdp) +{ + int rval; + char *vname = "obdev.at"; + char *devname = "AVR-Doper"; + + rval = usbOpenDevice(fdp, USB_VENDOR_ID, vname, USB_PRODUCT_ID, devname, 1); + if(rval != 0){ + avrdude_message(MSG_INFO, "%s: avrdoper_open(): %s\n", progname, usbErrorText(rval)); + return -1; + } + return 0; +} + +/* ------------------------------------------------------------------------- */ + +static void avrdoper_close(union filedescriptor *fdp) +{ + usbCloseDevice(fdp); +} + +/* ------------------------------------------------------------------------- */ + +static int chooseDataSize(int len) +{ + int i; + + for(i = 0; i < sizeof(reportDataSizes)/sizeof(reportDataSizes[0]); i++){ + if(reportDataSizes[i] >= len) + return i; + } + return i - 1; +} + +static int avrdoper_send(union filedescriptor *fdp, const unsigned char *buf, size_t buflen) +{ + if(verbose > 3) + dumpBlock("Send", buf, buflen); + while(buflen > 0){ + unsigned char buffer[256]; + int rval, lenIndex = chooseDataSize(buflen); + int thisLen = buflen > reportDataSizes[lenIndex] ? + reportDataSizes[lenIndex] : buflen; + buffer[0] = lenIndex + 1; /* report ID */ + buffer[1] = thisLen; + memcpy(buffer + 2, buf, thisLen); + avrdude_message(MSG_TRACE, "Sending %d bytes data chunk\n", thisLen); + rval = usbSetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, (char *)buffer, + reportDataSizes[lenIndex] + 2); + if(rval != 0){ + avrdude_message(MSG_INFO, "%s: avrdoper_send(): %s\n", progname, usbErrorText(rval)); + return -1; + } + buflen -= thisLen; + buf += thisLen; + } + return 0; +} + +/* ------------------------------------------------------------------------- */ + +static int avrdoperFillBuffer(union filedescriptor *fdp) +{ + int bytesPending = reportDataSizes[1]; /* guess how much data is buffered in device */ + + avrdoperRxPosition = avrdoperRxLength = 0; + while(bytesPending > 0){ + int len, usbErr, lenIndex = chooseDataSize(bytesPending); + unsigned char buffer[128]; + len = sizeof(avrdoperRxBuffer) - avrdoperRxLength; /* bytes remaining */ + if(reportDataSizes[lenIndex] + 2 > len) /* requested data would not fit into buffer */ + break; + len = reportDataSizes[lenIndex] + 2; + usbErr = usbGetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, lenIndex + 1, + (char *)buffer, &len); + if(usbErr != 0){ + avrdude_message(MSG_INFO, "%s: avrdoperFillBuffer(): %s\n", progname, usbErrorText(usbErr)); + return -1; + } + avrdude_message(MSG_TRACE, "Received %d bytes data chunk of total %d\n", len - 2, buffer[1]); + len -= 2; /* compensate for report ID and length byte */ + bytesPending = buffer[1] - len; /* amount still buffered */ + if(len > buffer[1]) /* cut away padding */ + len = buffer[1]; + if(avrdoperRxLength + len > sizeof(avrdoperRxBuffer)){ + avrdude_message(MSG_INFO, "%s: avrdoperFillBuffer(): internal error: buffer overflow\n", + progname); + return -1; + } + memcpy(avrdoperRxBuffer + avrdoperRxLength, buffer + 2, len); + avrdoperRxLength += len; + } + return 0; +} + +static int avrdoper_recv(union filedescriptor *fdp, unsigned char *buf, size_t buflen) +{ + unsigned char *p = buf; + int remaining = buflen; + + while(remaining > 0){ + int len, available = avrdoperRxLength - avrdoperRxPosition; + if(available <= 0){ /* buffer is empty */ + if (avrdoperFillBuffer(fdp) < 0) + return -1; + continue; + } + len = remaining < available ? remaining : available; + memcpy(p, avrdoperRxBuffer + avrdoperRxPosition, len); + p += len; + remaining -= len; + avrdoperRxPosition += len; + } + if(verbose > 3) + dumpBlock("Receive", buf, buflen); + return 0; +} + +/* ------------------------------------------------------------------------- */ + +static int avrdoper_drain(union filedescriptor *fdp, int display) +{ + do{ + if (avrdoperFillBuffer(fdp) < 0) + return -1; + }while(avrdoperRxLength > 0); + return 0; +} + +/* ------------------------------------------------------------------------- */ + +static int avrdoper_set_dtr_rts(union filedescriptor *fdp, int is_on) +{ + avrdude_message(MSG_INFO, "%s: AVR-Doper doesn't support DTR/RTS setting\n", progname); + return -1; +} + +/* ------------------------------------------------------------------------- */ + +struct serial_device avrdoper_serdev = +{ + .open = avrdoper_open, + .close = avrdoper_close, + .send = avrdoper_send, + .recv = avrdoper_recv, + .drain = avrdoper_drain, + .set_dtr_rts = avrdoper_set_dtr_rts, + .flags = SERDEV_FL_NONE, +}; + +#endif /* defined(HAVE_LIBUSB) || (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) */ diff --git a/xs/src/avrdude/ser_posix.c b/xs/src/avrdude/ser_posix.c new file mode 100644 index 000000000..91b18e945 --- /dev/null +++ b/xs/src/avrdude/ser_posix.c @@ -0,0 +1,520 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2003-2004 Theodore A. Roth + * 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 + * 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$ */ + +/* + * Posix serial interface for avrdude. + */ + +#if !defined(WIN32NATIVE) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +long serial_recv_timeout = 5000; /* ms */ +#define MAX_ZERO_READS 512 + +struct baud_mapping { + long baud; + 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 [] = { + { 1200, B1200 }, + { 2400, B2400 }, + { 4800, B4800 }, + { 9600, B9600 }, + { 19200, B19200 }, + { 38400, B38400 }, +#ifdef B57600 + { 57600, B57600 }, +#endif +#ifdef B115200 + { 115200, B115200 }, +#endif +#ifdef B230400 + { 230400, B230400 }, +#endif + { 0, 0 } /* Terminator. */ +}; + +static struct termios original_termios; +static int saved_original_termios; + +static speed_t serial_baud_lookup(long baud) +{ + struct baud_mapping *map = baud_lookup_table; + + while (map->baud) { + 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 + */ + avrdude_message(MSG_NOTICE, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld", + progname, baud); + + return baud; +} + +static int ser_setspeed(union filedescriptor *fd, long baud) +{ + int rc; + struct termios termios; + speed_t speed = serial_baud_lookup (baud); + + if (!isatty(fd->ifd)) + return -ENOTTY; + + /* + * initialize terminal modes + */ + rc = tcgetattr(fd->ifd, &termios); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: ser_setspeed(): tcgetattr() failed", + progname); + return -errno; + } + + /* + * copy termios for ser_close if we haven't already + */ + if (! saved_original_termios++) { + original_termios = termios; + } + + termios.c_iflag = IGNBRK; + termios.c_oflag = 0; + termios.c_lflag = 0; + termios.c_cflag = (CS8 | CREAD | CLOCAL); + termios.c_cc[VMIN] = 1; + termios.c_cc[VTIME] = 0; + + cfsetospeed(&termios, speed); + cfsetispeed(&termios, speed); + + rc = tcsetattr(fd->ifd, TCSANOW, &termios); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: ser_setspeed(): tcsetattr() failed\n", + progname); + return -errno; + } + + /* + * Everything is now set up for a local line without modem control + * or flow control, so clear O_NONBLOCK again. + */ + rc = fcntl(fd->ifd, F_GETFL, 0); + if (rc != -1) + fcntl(fd->ifd, F_SETFL, rc & ~O_NONBLOCK); + + return 0; +} + +/* + * Given a port description of the form :, open a TCP + * connection to the specified destination, which is assumed to be a + * terminal/console server with serial parameters configured + * appropriately (e. g. 115200-8-N-1 for a STK500.) + */ +static int +net_open(const char *port, union filedescriptor *fdp) +{ + char *hstr, *pstr, *end; + unsigned int pnum; + int fd; + struct sockaddr_in sockaddr; + struct hostent *hp; + + if ((hstr = strdup(port)) == NULL) { + avrdude_message(MSG_INFO, "%s: net_open(): Out of memory!\n", + progname); + return -1; + } + + if (((pstr = strchr(hstr, ':')) == NULL) || (pstr == hstr)) { + avrdude_message(MSG_INFO, "%s: net_open(): Mangled host:port string \"%s\"\n", + progname, hstr); + free(hstr); + return -1; + } + + /* + * Terminate the host section of the description. + */ + *pstr++ = '\0'; + + pnum = strtoul(pstr, &end, 10); + + if ((*pstr == '\0') || (*end != '\0') || (pnum == 0) || (pnum > 65535)) { + avrdude_message(MSG_INFO, "%s: net_open(): Bad port number \"%s\"\n", + progname, pstr); + free(hstr); + return -1; + } + + if ((hp = gethostbyname(hstr)) == NULL) { + avrdude_message(MSG_INFO, "%s: net_open(): unknown host \"%s\"\n", + progname, hstr); + free(hstr); + return -1; + } + + free(hstr); + + if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { + avrdude_message(MSG_INFO, "%s: net_open(): Cannot open socket: %s\n", + progname, strerror(errno)); + return -1; + } + + memset(&sockaddr, 0, sizeof(struct sockaddr_in)); + sockaddr.sin_family = AF_INET; + sockaddr.sin_port = htons(pnum); + memcpy(&(sockaddr.sin_addr.s_addr), hp->h_addr, sizeof(struct in_addr)); + + if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))) { + avrdude_message(MSG_INFO, "%s: net_open(): Connect failed: %s\n", + progname, strerror(errno)); + return -1; + } + + fdp->ifd = fd; + return 0; +} + + +static int ser_set_dtr_rts(union filedescriptor *fdp, int is_on) +{ + unsigned int ctl; + int r; + + r = ioctl(fdp->ifd, TIOCMGET, &ctl); + if (r < 0) { + perror("ioctl(\"TIOCMGET\")"); + return -1; + } + + if (is_on) { + /* Set DTR and RTS */ + ctl |= (TIOCM_DTR | TIOCM_RTS); + } + else { + /* Clear DTR and RTS */ + ctl &= ~(TIOCM_DTR | TIOCM_RTS); + } + + r = ioctl(fdp->ifd, TIOCMSET, &ctl); + if (r < 0) { + perror("ioctl(\"TIOCMSET\")"); + return -1; + } + + return 0; +} + +static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp) +{ + int rc; + int fd; + + /* + * If the port is of the form "net::", then + * handle it as a TCP connection to a terminal server. + */ + if (strncmp(port, "net:", strlen("net:")) == 0) { + return net_open(port + strlen("net:"), fdp); + } + + /* + * open the serial port + */ + fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK); + if (fd < 0) { + avrdude_message(MSG_INFO, "%s: ser_open(): can't open device \"%s\": %s\n", + progname, port, strerror(errno)); + return -1; + } + + fdp->ifd = fd; + + /* + * set serial line attributes + */ + rc = ser_setspeed(fdp, pinfo.baud); + if (rc) { + avrdude_message(MSG_INFO, "%s: ser_open(): can't set attributes for device \"%s\": %s\n", + progname, port, strerror(-rc)); + close(fd); + return -1; + } + return 0; +} + + +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) { + avrdude_message(MSG_INFO, "%s: ser_close(): can't reset attributes for device: %s\n", + progname, strerror(errno)); + } + saved_original_termios = 0; + } + + close(fd->ifd); +} + + +static int ser_send(union filedescriptor *fd, const unsigned char * buf, size_t buflen) +{ + int rc; + const unsigned char * p = buf; + size_t len = buflen; + + if (!len) + return 0; + + if (verbose > 3) + { + avrdude_message(MSG_TRACE, "%s: Send: ", progname); + + while (buflen) { + unsigned char c = *buf; + if (isprint(c)) { + avrdude_message(MSG_TRACE, "%c ", c); + } + else { + avrdude_message(MSG_TRACE, ". "); + } + avrdude_message(MSG_TRACE, "[%02x] ", c); + + buf++; + buflen--; + } + + avrdude_message(MSG_TRACE, "\n"); + } + + while (len) { + RETURN_IF_CANCEL(); + rc = write(fd->ifd, p, (len > 1024) ? 1024 : len); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: ser_send(): write error: %s\n", + progname, strerror(errno)); + return -1; + } + p += rc; + len -= rc; + } + + return 0; +} + + +static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen) +{ + struct timeval timeout, to2; + fd_set rfds; + int nfds; + int rc; + unsigned char * p = buf; + size_t len = 0; + unsigned zero_reads = 0; + + timeout.tv_sec = serial_recv_timeout / 1000L; + timeout.tv_usec = (serial_recv_timeout % 1000L) * 1000; + to2 = timeout; + + while (len < buflen) { + reselect: + RETURN_IF_CANCEL(); + FD_ZERO(&rfds); + FD_SET(fd->ifd, &rfds); + + nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &to2); + if (nfds == 0) { + avrdude_message(MSG_NOTICE2, "%s: ser_recv(): programmer is not responding\n", + progname); + return -1; + } + else if (nfds == -1) { + if (errno == EINTR || errno == EAGAIN) { + avrdude_message(MSG_INFO, "%s: ser_recv(): programmer is not responding,reselecting\n", + progname); + goto reselect; + } + else { + avrdude_message(MSG_INFO, "%s: ser_recv(): select(): %s\n", + progname, strerror(errno)); + return -1; + } + } + + rc = read(fd->ifd, p, (buflen - len > 1024) ? 1024 : buflen - len); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: ser_recv(): read error: %s\n", + progname, strerror(errno)); + return -1; + } else if (rc == 0) { + zero_reads++; + if (zero_reads > MAX_ZERO_READS) { + avrdude_message(MSG_NOTICE2, "%s: ser_recv(): programmer is not responding (too many zero reads)\n", + progname); + return -1; + } + } else { + zero_reads = 0; + p += rc; + len += rc; + } + } + + p = buf; + + if (verbose > 3) + { + avrdude_message(MSG_TRACE, "%s: Recv: ", progname); + + while (len) { + unsigned char c = *p; + if (isprint(c)) { + avrdude_message(MSG_TRACE, "%c ", c); + } + else { + avrdude_message(MSG_TRACE, ". "); + } + avrdude_message(MSG_TRACE, "[%02x] ", c); + + p++; + len--; + } + avrdude_message(MSG_TRACE, "\n"); + } + + return 0; +} + + +static int ser_drain(union filedescriptor *fd, int display) +{ + struct timeval timeout; + fd_set rfds; + int nfds; + int rc; + unsigned char buf; + unsigned zero_reads = 0; + + timeout.tv_sec = 0; + timeout.tv_usec = 250000; + + if (display) { + avrdude_message(MSG_INFO, "drain>"); + } + + while (1) { + FD_ZERO(&rfds); + FD_SET(fd->ifd, &rfds); + + reselect: + RETURN_IF_CANCEL(); + nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &timeout); + if (nfds == 0) { + if (display) { + avrdude_message(MSG_INFO, "ifd, &buf, 1); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: ser_drain(): read error: %s\n", + progname, strerror(errno)); + return -1; + } else if (rc == 0) { + zero_reads++; + if (zero_reads > MAX_ZERO_READS) { + avrdude_message(MSG_NOTICE2, "%s: ser_drain(): programmer is not responding (too many zero reads)\n", + progname); + return -1; + } + } else { + zero_reads = 0; + } + if (display) { + avrdude_message(MSG_INFO, "%02x ", buf); + } + } + + return 0; +} + +struct serial_device serial_serdev = +{ + .open = ser_open, + .setspeed = ser_setspeed, + .close = ser_close, + .send = ser_send, + .recv = ser_recv, + .drain = ser_drain, + .set_dtr_rts = ser_set_dtr_rts, + .flags = SERDEV_FL_CANSETSPEED, +}; + +struct serial_device *serdev = &serial_serdev; + +#endif /* WIN32NATIVE */ diff --git a/xs/src/avrdude/ser_win32.c b/xs/src/avrdude/ser_win32.c new file mode 100644 index 000000000..20d085d13 --- /dev/null +++ b/xs/src/avrdude/ser_win32.c @@ -0,0 +1,706 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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$ */ + +/* + * Native Win32 serial interface for avrdude. + */ + +#include "ac_cfg.h" + +#if defined(WIN32NATIVE) + +#ifdef HAVE_LIBWS2_32 +/* winsock2.h must be included before windows.h from avrdude.h... */ +# include +#endif + +#include +#include +#include /* for isprint */ +#include /* ENOTTY */ + +#include "avrdude.h" +#include "libavrdude.h" + +long serial_recv_timeout = 5000; /* ms */ + +#define W32SERBUFSIZE 1024 + +struct baud_mapping { + long baud; + DWORD speed; +}; + +static unsigned char serial_over_ethernet = 0; + +/* HANDLE hComPort=INVALID_HANDLE_VALUE; */ + +static struct baud_mapping baud_lookup_table [] = { + { 1200, CBR_1200 }, + { 2400, CBR_2400 }, + { 4800, CBR_4800 }, + { 9600, CBR_9600 }, + { 19200, CBR_19200 }, + { 38400, CBR_38400 }, + { 57600, CBR_57600 }, + { 115200, CBR_115200 }, + { 0, 0 } /* Terminator. */ +}; + +static DWORD serial_baud_lookup(long baud) +{ + struct baud_mapping *map = baud_lookup_table; + + while (map->baud) { + 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 + */ + avrdude_message(MSG_NOTICE, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld", + progname, baud); + + return baud; +} + + +static BOOL serial_w32SetTimeOut(HANDLE hComPort, DWORD timeout) // in ms +{ + COMMTIMEOUTS ctmo; + ZeroMemory (&ctmo, sizeof(COMMTIMEOUTS)); + // Don't use the two other two values, set them to zero. This way a constant timeout is used + // for the following reads. + // ctmo.ReadIntervalTimeout = timeout; + // ctmo.ReadTotalTimeoutMultiplier = timeout; + ctmo.ReadTotalTimeoutConstant = timeout; + + return SetCommTimeouts(hComPort, &ctmo); +} + +static int ser_setspeed(union filedescriptor *fd, long baud) +{ + if (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; + dcb.ByteSize = 8; + dcb.Parity = NOPARITY; + dcb.StopBits = ONESTOPBIT; + + if (!SetCommState(hComPort, &dcb)) + return -1; + + return 0; + } +} + +#ifdef HAVE_LIBWS2_32 +static int +net_open(const char *port, union filedescriptor *fdp) +{ + WSADATA wsaData; + LPVOID lpMsgBuf; + + char *hstr, *pstr, *end; + unsigned int pnum; + int fd; + struct sockaddr_in sockaddr; + struct hostent *hp; + + if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) { + avrdude_message(MSG_INFO, "%s: net_open(): WSAStartup() failed\n", progname); + return -1; + } + + if ((hstr = strdup(port)) == NULL) { + avrdude_message(MSG_INFO, "%s: net_open(): Out of memory!\n", progname); + return -1; + } + + if (((pstr = strchr(hstr, ':')) == NULL) || (pstr == hstr)) { + avrdude_message(MSG_INFO, "%s: net_open(): Mangled host:port string \"%s\"\n", progname, hstr); + free(hstr); + return -1; + } + + /* + * Terminate the host section of the description. + */ + *pstr++ = '\0'; + + pnum = strtoul(pstr, &end, 10); + + if ((*pstr == '\0') || (*end != '\0') || (pnum == 0) || (pnum > 65535)) { + avrdude_message(MSG_INFO, "%s: net_open(): Bad port number \"%s\"\n", progname, pstr); + free(hstr); + return -1; + } + + if ((hp = gethostbyname(hstr)) == NULL) { + avrdude_message(MSG_INFO, "%s: net_open(): unknown host \"%s\"\n", progname, hstr); + free(hstr); + return -1; + } + + free(hstr); + + if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + WSAGetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&lpMsgBuf, + 0, + NULL); + avrdude_message(MSG_INFO, "%s: net_open(): Cannot open socket: %s\n", progname, (char *)lpMsgBuf); + LocalFree(lpMsgBuf); + return -1; + } + + memset(&sockaddr, 0, sizeof(struct sockaddr_in)); + sockaddr.sin_family = AF_INET; + sockaddr.sin_port = htons(pnum); + memcpy(&(sockaddr.sin_addr.s_addr), hp->h_addr, sizeof(struct in_addr)); + + if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))) { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + WSAGetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&lpMsgBuf, + 0, + NULL); + avrdude_message(MSG_INFO, "%s: net_open(): Connect failed: %s\n", progname, (char *)lpMsgBuf); + LocalFree(lpMsgBuf); + return -1; + } + + fdp->ifd = fd; + + serial_over_ethernet = 1; + return 0; +} +#endif + + +static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp) +{ + LPVOID lpMsgBuf; + HANDLE hComPort=INVALID_HANDLE_VALUE; + char *newname = 0; + + /* + * If the port is of the form "net::", then + * handle it as a TCP connection to a terminal server. + */ + if (strncmp(port, "net:", strlen("net:")) == 0) { +#ifdef HAVE_LIBWS2_32 + return net_open(port + strlen("net:"), fdp); +#else + avrdude_message(MSG_INFO, "%s: ser_open(): " + "not configured for TCP connections\n", + progname); + return -1; +#endif + } + + if (strncasecmp(port, "com", strlen("com")) == 0) { + + // prepend "\\\\.\\" to name, required for port # >= 10 + newname = malloc(strlen("\\\\.\\") + strlen(port) + 1); + + if (newname == 0) { + avrdude_message(MSG_INFO, "%s: ser_open(): out of memory\n", + progname); + exit(1); + } + strcpy(newname, "\\\\.\\"); + strcat(newname, port); + + port = newname; + } + + hComPort = CreateFileA(port, GENERIC_READ | GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (hComPort == INVALID_HANDLE_VALUE) { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL); + avrdude_message(MSG_INFO, "%s: ser_open(): can't open device \"%s\": %s\n", + progname, port, (char*)lpMsgBuf); + LocalFree( lpMsgBuf ); + return -1; + } + + if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE)) + { + CloseHandle(hComPort); + avrdude_message(MSG_INFO, "%s: ser_open(): can't set buffers for \"%s\"\n", + progname, port); + return -1; + } + + fdp->pfd = (void *)hComPort; + if (ser_setspeed(fdp, pinfo.baud) != 0) + { + CloseHandle(hComPort); + avrdude_message(MSG_INFO, "%s: ser_open(): can't set com-state for \"%s\"\n", + progname, port); + return -1; + } + + if (!serial_w32SetTimeOut(hComPort,0)) + { + CloseHandle(hComPort); + avrdude_message(MSG_INFO, "%s: ser_open(): can't set initial timeout for \"%s\"\n", + progname, port); + return -1; + } + + if (newname != 0) { + free(newname); + } + return 0; +} + + +static void ser_close(union filedescriptor *fd) +{ + if (serial_over_ethernet) { + closesocket(fd->ifd); + WSACleanup(); + } else { + HANDLE hComPort=(HANDLE)fd->pfd; + if (hComPort != INVALID_HANDLE_VALUE) + CloseHandle (hComPort); + + hComPort = INVALID_HANDLE_VALUE; + } +} + +static int ser_set_dtr_rts(union filedescriptor *fd, int is_on) +{ + if (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; + } +} + +#ifdef HAVE_LIBWS2_32 +static int net_send(union filedescriptor *fd, const unsigned char * buf, size_t buflen) +{ + LPVOID lpMsgBuf; + int rc; + const unsigned char *p = buf; + size_t len = buflen; + + if (fd->ifd < 0) { + avrdude_message(MSG_NOTICE, "%s: net_send(): connection not open\n", progname); + exit(1); + } + + if (!len) { + return 0; + } + + if (verbose > 3) { + avrdude_message(MSG_TRACE, "%s: Send: ", progname); + + while (buflen) { + unsigned char c = *buf; + if (isprint(c)) { + avrdude_message(MSG_TRACE, "%c ", c); + } else { + avrdude_message(MSG_TRACE, ". "); + } + avrdude_message(MSG_TRACE, "[%02x] ", c); + + buf++; + buflen--; + } + + avrdude_message(MSG_TRACE, "\n"); + } + + while (len) { + rc = send(fd->ifd, p, (len > 1024) ? 1024 : len, 0); + if (rc < 0) { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + WSAGetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&lpMsgBuf, + 0, + NULL); + avrdude_message(MSG_INFO, "%s: net_send(): send error: %s\n", progname, (char *)lpMsgBuf); + LocalFree(lpMsgBuf); + exit(1); + } + p += rc; + len -= rc; + } + + return 0; +} +#endif + + +static int ser_send(union filedescriptor *fd, const unsigned char * buf, size_t buflen) +{ +#ifdef HAVE_LIBWS2_32 + if (serial_over_ethernet) { + return net_send(fd, buf, buflen); + } +#endif + + size_t len = buflen; + unsigned char c='\0'; + DWORD written; + const unsigned char * b = buf; + + RETURN_IF_CANCEL(); + + HANDLE hComPort=(HANDLE)fd->pfd; + + if (hComPort == INVALID_HANDLE_VALUE) { + avrdude_message(MSG_INFO, "%s: ser_send(): port not open\n", + progname); + return -1; + } + + if (!len) + return 0; + + if (verbose > 3) + { + avrdude_message(MSG_TRACE, "%s: Send: ", progname); + + while (len) { + c = *b; + if (isprint(c)) { + avrdude_message(MSG_TRACE, "%c ", c); + } + else { + avrdude_message(MSG_TRACE, ". "); + } + avrdude_message(MSG_TRACE, "[%02x] ", c); + b++; + len--; + } + avrdude_message(MSG_INFO, "\n"); + } + + serial_w32SetTimeOut(hComPort,500); + + if (!WriteFile (hComPort, buf, buflen, &written, NULL)) { + avrdude_message(MSG_INFO, "%s: ser_send(): write error: %s\n", + progname, "sorry no info avail"); // TODO + return -1; + } + + if (written != buflen) { + avrdude_message(MSG_INFO, "%s: ser_send(): size/send mismatch\n", + progname); + return -1; + } + + return 0; +} + + +#ifdef HAVE_LIBWS2_32 +static int net_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen) +{ + LPVOID lpMsgBuf; + struct timeval timeout, to2; + fd_set rfds; + int nfds; + int rc; + unsigned char *p = buf; + size_t len = 0; + + if (fd->ifd < 0) { + avrdude_message(MSG_INFO, "%s: net_recv(): connection not open\n", progname); + exit(1); + } + + timeout.tv_sec = serial_recv_timeout / 1000L; + timeout.tv_usec = (serial_recv_timeout % 1000L) * 1000; + to2 = timeout; + + while (len < buflen) { +reselect: + FD_ZERO(&rfds); + FD_SET(fd->ifd, &rfds); + + nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &to2); + if (nfds == 0) { + if (verbose > 1) { + avrdude_message(MSG_NOTICE, "%s: ser_recv(): programmer is not responding\n", progname); + } + return -1; + } else if (nfds == -1) { + if (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEINPROGRESS) { + avrdude_message(MSG_NOTICE, "%s: ser_recv(): programmer is not responding, reselecting\n", progname); + goto reselect; + } else { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + WSAGetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&lpMsgBuf, + 0, + NULL); + avrdude_message(MSG_INFO, "%s: ser_recv(): select(): %s\n", progname, (char *)lpMsgBuf); + LocalFree(lpMsgBuf); + exit(1); + } + } + + rc = recv(fd->ifd, p, (buflen - len > 1024) ? 1024 : buflen - len, 0); + if (rc < 0) { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + WSAGetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&lpMsgBuf, + 0, + NULL); + avrdude_message(MSG_INFO, "%s: ser_recv(): read error: %s\n", progname, (char *)lpMsgBuf); + LocalFree(lpMsgBuf); + exit(1); + } + p += rc; + len += rc; + } + + p = buf; + + if (verbose > 3) { + avrdude_message(MSG_TRACE, "%s: Recv: ", progname); + + while (len) { + unsigned char c = *p; + if (isprint(c)) { + avrdude_message(MSG_TRACE, "%c ", c); + } else { + avrdude_message(MSG_TRACE, ". "); + } + avrdude_message(MSG_TRACE, "[%02x] ", c); + + p++; + len--; + } + avrdude_message(MSG_TRACE, "\n"); + } + + return 0; +} +#endif + +static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen) +{ +#ifdef HAVE_LIBWS2_32 + if (serial_over_ethernet) { + return net_recv(fd, buf, buflen); + } +#endif + + unsigned char c; + unsigned char * p = buf; + DWORD read; + + RETURN_IF_CANCEL(); + + HANDLE hComPort=(HANDLE)fd->pfd; + + if (hComPort == INVALID_HANDLE_VALUE) { + avrdude_message(MSG_INFO, "%s: ser_read(): port not open\n", + progname); + return -1; + } + + serial_w32SetTimeOut(hComPort, serial_recv_timeout); + + if (!ReadFile(hComPort, buf, buflen, &read, NULL)) { + LPVOID lpMsgBuf; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL ); + avrdude_message(MSG_INFO, "%s: ser_recv(): read error: %s\n", + progname, (char*)lpMsgBuf); + LocalFree( lpMsgBuf ); + return -1; + } + + /* time out detected */ + if (read == 0) { + avrdude_message(MSG_NOTICE2, "%s: ser_recv(): programmer is not responding\n", + progname); + return -1; + } + + p = buf; + + if (verbose > 3) + { + avrdude_message(MSG_TRACE, "%s: Recv: ", progname); + + while (read) { + c = *p; + if (isprint(c)) { + avrdude_message(MSG_TRACE, "%c ", c); + } + else { + avrdude_message(MSG_TRACE, ". "); + } + avrdude_message(MSG_TRACE, "[%02x] ", c); + + p++; + read--; + } + avrdude_message(MSG_INFO, "\n"); + } + return 0; +} + + +static int ser_drain(union filedescriptor *fd, int display) +{ + // int rc; + unsigned char buf[10]; + BOOL readres; + DWORD read; + + HANDLE hComPort=(HANDLE)fd->pfd; + + if (hComPort == INVALID_HANDLE_VALUE) { + avrdude_message(MSG_INFO, "%s: ser_drain(): port not open\n", + progname); + return -1; + } + + serial_w32SetTimeOut(hComPort,250); + + if (display) { + avrdude_message(MSG_INFO, "drain>"); + } + + while (1) { + RETURN_IF_CANCEL(); + + readres=ReadFile(hComPort, buf, 1, &read, NULL); + if (!readres) { + LPVOID lpMsgBuf; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL ); + avrdude_message(MSG_INFO, "%s: ser_drain(): read error: %s\n", + progname, (char*)lpMsgBuf); + LocalFree( lpMsgBuf ); + return -1; + } + + if (read) { // data avail + if (display) avrdude_message(MSG_INFO, "%02x ", buf[0]); + } + else { // no more data + if (display) avrdude_message(MSG_INFO, " + * Copyright (C) 2005 Michael Holzt + * + * 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 serbb_h +#define serbb_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char serbb_desc[]; +void serbb_initpgm (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/xs/src/avrdude/serbb_posix.c b/xs/src/avrdude/serbb_posix.c new file mode 100644 index 000000000..319cfc9e4 --- /dev/null +++ b/xs/src/avrdude/serbb_posix.c @@ -0,0 +1,321 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean + * Copyright (C) 2005 Michael Holzt + * 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 + * 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$ */ + +/* + * Posix serial bitbanging interface for avrdude. + */ + +#if !defined(WIN32NATIVE) + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "bitbang.h" +#include "serbb.h" + +#undef DEBUG + +static struct termios oldmode; + +/* + serial port/pin mapping + + 1 cd <- + 2 (rxd) <- + 3 txd -> + 4 dtr -> + 5 GND + 6 dsr <- + 7 rts -> + 8 cts <- + 9 ri <- +*/ + +#define DB9PINS 9 + +static 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] = + { "NONE", "CD", "RXD", "TXD", "DTR", "GND", "DSR", "RTS", "CTS", "RI" }; +#endif + +static int serbb_setpin(PROGRAMMER * pgm, int pinfunc, int value) +{ + unsigned int ctl; + int r; + int pin = pgm->pinno[pinfunc]; // get its value + + if (pin & PIN_INVERSE) + { + value = !value; + pin &= PIN_MASK; + } + + if ( pin < 1 || pin > DB9PINS ) + return -1; + +#ifdef DEBUG + printf("%s to %d\n",serpins[pin],value); +#endif + + switch ( pin ) + { + case 3: /* txd */ + r = ioctl(pgm->fd.ifd, value ? TIOCSBRK : TIOCCBRK, 0); + if (r < 0) { + perror("ioctl(\"TIOCxBRK\")"); + return -1; + } + break; + + case 4: /* dtr */ + case 7: /* rts */ + r = ioctl(pgm->fd.ifd, TIOCMGET, &ctl); + if (r < 0) { + perror("ioctl(\"TIOCMGET\")"); + return -1; + } + if ( value ) + ctl |= serregbits[pin]; + else + ctl &= ~(serregbits[pin]); + r = ioctl(pgm->fd.ifd, TIOCMSET, &ctl); + if (r < 0) { + perror("ioctl(\"TIOCMSET\")"); + return -1; + } + break; + + default: /* impossible */ + return -1; + } + + if (pgm->ispdelay > 1) + bitbang_delay(pgm->ispdelay); + + return 0; +} + +static int serbb_getpin(PROGRAMMER * pgm, int pinfunc) +{ + unsigned int ctl; + unsigned char invert; + int r; + int pin = pgm->pinno[pinfunc]; // get its value + + if (pin & PIN_INVERSE) + { + invert = 1; + pin &= PIN_MASK; + } else + invert = 0; + + if ( pin < 1 || pin > DB9PINS ) + return(-1); + + switch ( pin ) + { + case 2: /* rxd, currently not implemented, FIXME */ + return(-1); + + case 1: /* cd */ + case 6: /* dsr */ + case 8: /* cts */ + case 9: /* ri */ + r = ioctl(pgm->fd.ifd, TIOCMGET, &ctl); + if (r < 0) { + perror("ioctl(\"TIOCMGET\")"); + return -1; + } + if ( !invert ) + { +#ifdef DEBUG + printf("%s is %d\n",serpins[pin],(ctl & serregbits[pin]) ? 1 : 0 ); +#endif + return ( (ctl & serregbits[pin]) ? 1 : 0 ); + } + else + { +#ifdef DEBUG + printf("%s is %d (~)\n",serpins[pin],(ctl & serregbits[pin]) ? 0 : 1 ); +#endif + return (( ctl & serregbits[pin]) ? 0 : 1 ); + } + + default: /* impossible */ + return(-1); + } +} + +static int serbb_highpulsepin(PROGRAMMER * pgm, int pinfunc) +{ + int pin = pgm->pinno[pinfunc]; // replace pin name by its value + + if ( (pin & PIN_MASK) < 1 || (pin & PIN_MASK) > DB9PINS ) + return -1; + + serbb_setpin(pgm, pinfunc, 1); + serbb_setpin(pgm, pinfunc, 0); + + return 0; +} + + + +static void serbb_display(PROGRAMMER *pgm, const char *p) +{ + /* MAYBE */ +} + +static void serbb_enable(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static void serbb_disable(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static void serbb_powerup(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static void serbb_powerdown(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static int serbb_open(PROGRAMMER *pgm, char *port) +{ + struct termios mode; + int flags; + int r; + + if (bitbang_check_prerequisites(pgm) < 0) + return -1; + + /* adapted from uisp code */ + + pgm->fd.ifd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK); + + if (pgm->fd.ifd < 0) { + perror(port); + return(-1); + } + + r = tcgetattr(pgm->fd.ifd, &mode); + if (r < 0) { + avrdude_message(MSG_INFO, "%s: ", port); + perror("tcgetattr"); + return(-1); + } + oldmode = mode; + + mode.c_iflag = IGNBRK | IGNPAR; + mode.c_oflag = 0; + mode.c_cflag = CLOCAL | CREAD | CS8 | B9600; + mode.c_cc [VMIN] = 1; + mode.c_cc [VTIME] = 0; + + r = tcsetattr(pgm->fd.ifd, TCSANOW, &mode); + if (r < 0) { + avrdude_message(MSG_INFO, "%s: ", port); + perror("tcsetattr"); + return(-1); + } + + /* Clear O_NONBLOCK flag. */ + flags = fcntl(pgm->fd.ifd, F_GETFL, 0); + if (flags == -1) + { + avrdude_message(MSG_INFO, "%s: Can not get flags: %s\n", + progname, strerror(errno)); + return(-1); + } + flags &= ~O_NONBLOCK; + if (fcntl(pgm->fd.ifd, F_SETFL, flags) == -1) + { + avrdude_message(MSG_INFO, "%s: Can not clear nonblock flag: %s\n", + progname, strerror(errno)); + return(-1); + } + + return(0); +} + +static void serbb_close(PROGRAMMER *pgm) +{ + if (pgm->fd.ifd != -1) + { + (void)tcsetattr(pgm->fd.ifd, TCSANOW, &oldmode); + pgm->setpin(pgm, PIN_AVR_RESET, 1); + close(pgm->fd.ifd); + } + return; +} + +const char serbb_desc[] = "Serial port bitbanging"; + +void serbb_initpgm(PROGRAMMER *pgm) +{ + strcpy(pgm->type, "SERBB"); + + pgm_fill_old_pins(pgm); // TODO to be removed if old pin data no longer needed + + pgm->rdy_led = bitbang_rdy_led; + pgm->err_led = bitbang_err_led; + pgm->pgm_led = bitbang_pgm_led; + pgm->vfy_led = bitbang_vfy_led; + pgm->initialize = bitbang_initialize; + pgm->display = serbb_display; + pgm->enable = serbb_enable; + pgm->disable = serbb_disable; + pgm->powerup = serbb_powerup; + pgm->powerdown = serbb_powerdown; + pgm->program_enable = bitbang_program_enable; + pgm->chip_erase = bitbang_chip_erase; + pgm->cmd = bitbang_cmd; + pgm->cmd_tpi = bitbang_cmd_tpi; + pgm->open = serbb_open; + pgm->close = serbb_close; + pgm->setpin = serbb_setpin; + pgm->getpin = serbb_getpin; + pgm->highpulsepin = serbb_highpulsepin; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; +} + +#endif /* WIN32NATIVE */ diff --git a/xs/src/avrdude/serbb_win32.c b/xs/src/avrdude/serbb_win32.c new file mode 100644 index 000000000..4f1069c85 --- /dev/null +++ b/xs/src/avrdude/serbb_win32.c @@ -0,0 +1,366 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2003, 2004 Martin J. Thomas + * Copyright (C) 2005 Michael Holzt + * Copyright (C) 2005, 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 + * 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$ */ + +/* + * Win32 serial bitbanging interface for avrdude. + */ + +#include "avrdude.h" + +#if defined(WIN32NATIVE) + + +#include "ac_cfg.h" + +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "bitbang.h" +#include "serbb.h" + +/* cached status lines */ +static int dtr, rts, txd; + +#define W32SERBUFSIZE 1024 + +/* + serial port/pin mapping + + 1 cd <- + 2 (rxd) <- + 3 txd -> + 4 dtr -> + 5 GND + 6 dsr <- + 7 rts -> + 8 cts <- + 9 ri <- +*/ + +#define DB9PINS 9 + +static int serbb_setpin(PROGRAMMER * pgm, int pinfunc, int value) +{ + int pin = pgm->pinno[pinfunc]; + HANDLE hComPort = (HANDLE)pgm->fd.pfd; + LPVOID lpMsgBuf; + DWORD dwFunc; + const char *name; + + if (pin & PIN_INVERSE) + { + value = !value; + pin &= PIN_MASK; + } + + if (pin < 1 || pin > DB9PINS) + return -1; + + switch (pin) + { + case 3: /* txd */ + dwFunc = value? SETBREAK: CLRBREAK; + name = value? "SETBREAK": "CLRBREAK"; + txd = value; + break; + + case 4: /* dtr */ + dwFunc = value? SETDTR: CLRDTR; + name = value? "SETDTR": "CLRDTR"; + dtr = value; + break; + + case 7: /* rts */ + dwFunc = value? SETRTS: CLRRTS; + name = value? "SETRTS": "CLRRTS"; + break; + + default: + avrdude_message(MSG_NOTICE, "%s: serbb_setpin(): unknown pin %d\n", + progname, pin + 1); + return -1; + } + avrdude_message(MSG_TRACE2, "%s: serbb_setpin(): EscapeCommFunction(%s)\n", + progname, name); + if (!EscapeCommFunction(hComPort, dwFunc)) + { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL); + avrdude_message(MSG_INFO, "%s: serbb_setpin(): SetCommState() failed: %s\n", + progname, (char *)lpMsgBuf); + CloseHandle(hComPort); + LocalFree(lpMsgBuf); + return -1; + } + + if (pgm->ispdelay > 1) + bitbang_delay(pgm->ispdelay); + + return 0; +} + +static int serbb_getpin(PROGRAMMER * pgm, int pinfunc) +{ + int pin = pgm->pinno[pinfunc]; + HANDLE hComPort = (HANDLE)pgm->fd.pfd; + LPVOID lpMsgBuf; + int invert, rv; + const char *name; + DWORD modemstate; + + if (pin & PIN_INVERSE) + { + invert = 1; + pin &= PIN_MASK; + } else + invert = 0; + + if (pin < 1 || pin > DB9PINS) + return -1; + + if (pin == 1 /* cd */ || pin == 6 /* dsr */ || pin == 8 /* cts */) + { + if (!GetCommModemStatus(hComPort, &modemstate)) + { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL); + avrdude_message(MSG_INFO, "%s: serbb_setpin(): GetCommModemStatus() failed: %s\n", + progname, (char *)lpMsgBuf); + CloseHandle(hComPort); + LocalFree(lpMsgBuf); + return -1; + } + avrdude_message(MSG_TRACE2, "%s: serbb_getpin(): GetCommState() => 0x%lx\n", + progname, modemstate); + switch (pin) + { + case 1: + modemstate &= MS_RLSD_ON; + break; + case 6: + modemstate &= MS_DSR_ON; + break; + case 8: + modemstate &= MS_CTS_ON; + break; + } + rv = modemstate != 0; + if (invert) + rv = !rv; + + return rv; + } + + switch (pin) + { + case 3: /* txd */ + rv = txd; + name = "TXD"; + break; + case 4: /* dtr */ + rv = dtr; + name = "DTR"; + break; + case 7: /* rts */ + rv = rts; + name = "RTS"; + break; + default: + avrdude_message(MSG_NOTICE, "%s: serbb_getpin(): unknown pin %d\n", + progname, pin + 1); + return -1; + } + avrdude_message(MSG_TRACE2, "%s: serbb_getpin(): return cached state for %s\n", + progname, name); + if (invert) + rv = !rv; + + return rv; +} + +static int serbb_highpulsepin(PROGRAMMER * pgm, int pinfunc) +{ + int pin = pgm->pinno[pinfunc]; + if ( (pin & PIN_MASK) < 1 || (pin & PIN_MASK) > DB9PINS ) + return -1; + + serbb_setpin(pgm, pinfunc, 1); + serbb_setpin(pgm, pinfunc, 0); + + return 0; +} + + +static void serbb_display(PROGRAMMER *pgm, const char *p) +{ + /* MAYBE */ +} + +static void serbb_enable(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static void serbb_disable(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static void serbb_powerup(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static void serbb_powerdown(PROGRAMMER *pgm) +{ + /* nothing */ +} + +static int serbb_open(PROGRAMMER *pgm, char *port) +{ + DCB dcb; + LPVOID lpMsgBuf; + HANDLE hComPort = INVALID_HANDLE_VALUE; + + if (bitbang_check_prerequisites(pgm) < 0) + return -1; + + hComPort = CreateFileA(port, GENERIC_READ | GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (hComPort == INVALID_HANDLE_VALUE) { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL); + avrdude_message(MSG_INFO, "%s: ser_open(): can't open device \"%s\": %s\n", + progname, port, (char*)lpMsgBuf); + LocalFree(lpMsgBuf); + return -1; + } + + if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE)) + { + CloseHandle(hComPort); + avrdude_message(MSG_INFO, "%s: ser_open(): can't set buffers for \"%s\"\n", + progname, port); + return -1; + } + + + ZeroMemory(&dcb, sizeof(DCB)); + dcb.DCBlength = sizeof(DCB); + dcb.BaudRate = CBR_9600; + dcb.fBinary = 1; + dcb.fDtrControl = DTR_CONTROL_DISABLE; + dcb.fRtsControl = RTS_CONTROL_DISABLE; + dcb.ByteSize = 8; + dcb.Parity = NOPARITY; + dcb.StopBits = ONESTOPBIT; + + if (!SetCommState(hComPort, &dcb)) + { + CloseHandle(hComPort); + avrdude_message(MSG_INFO, "%s: ser_open(): can't set com-state for \"%s\"\n", + progname, port); + return -1; + } + avrdude_message(MSG_DEBUG, "%s: ser_open(): opened comm port \"%s\", handle 0x%x\n", + progname, port, (int)hComPort); + + pgm->fd.pfd = (void *)hComPort; + + dtr = rts = txd = 0; + + return 0; +} + +static void serbb_close(PROGRAMMER *pgm) +{ + HANDLE hComPort=(HANDLE)pgm->fd.pfd; + if (hComPort != INVALID_HANDLE_VALUE) + { + pgm->setpin(pgm, PIN_AVR_RESET, 1); + CloseHandle (hComPort); + } + avrdude_message(MSG_DEBUG, "%s: ser_close(): closed comm port handle 0x%x\n", + progname, (int)hComPort); + + hComPort = INVALID_HANDLE_VALUE; +} + +const char serbb_desc[] = "Serial port bitbanging"; + +void serbb_initpgm(PROGRAMMER *pgm) +{ + strcpy(pgm->type, "SERBB"); + + pgm_fill_old_pins(pgm); // TODO to be removed if old pin data no longer needed + + pgm->rdy_led = bitbang_rdy_led; + pgm->err_led = bitbang_err_led; + pgm->pgm_led = bitbang_pgm_led; + pgm->vfy_led = bitbang_vfy_led; + pgm->initialize = bitbang_initialize; + pgm->display = serbb_display; + pgm->enable = serbb_enable; + pgm->disable = serbb_disable; + pgm->powerup = serbb_powerup; + pgm->powerdown = serbb_powerdown; + pgm->program_enable = bitbang_program_enable; + pgm->chip_erase = bitbang_chip_erase; + pgm->cmd = bitbang_cmd; + pgm->cmd_tpi = bitbang_cmd_tpi; + pgm->open = serbb_open; + pgm->close = serbb_close; + pgm->setpin = serbb_setpin; + pgm->getpin = serbb_getpin; + pgm->highpulsepin = serbb_highpulsepin; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; +} + +#endif /* WIN32NATIVE */ diff --git a/xs/src/avrdude/solaris_ecpp.h b/xs/src/avrdude/solaris_ecpp.h new file mode 100644 index 000000000..7db040d14 --- /dev/null +++ b/xs/src/avrdude/solaris_ecpp.h @@ -0,0 +1,50 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2005 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 + * 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 solaris_ecpp_h +#define solaris_ecpp_h + +#include + +#define ppi_claim(fd) \ + do { \ + struct ecpp_transfer_parms p; \ + (void)ioctl(fd, ECPPIOC_GETPARMS, &p); \ + p.mode = ECPP_DIAG_MODE; \ + (void)ioctl(fd, ECPPIOC_SETPARMS, &p); \ + } while(0); + +#define ppi_release(fd) + +#define DO_PPI_READ(fd, reg, valp) \ + do { struct ecpp_regs r; \ + if ((reg) == PPIDATA) { (void)ioctl(fd, ECPPIOC_GETDATA, valp); } \ + else { (void)ioctl(fd, ECPPIOC_GETREGS, &r); \ + *(valp) = ((reg) == PPICTRL)? r.dcr: r.dsr; } \ + } while(0) +#define DO_PPI_WRITE(fd, reg, valp) \ + do { struct ecpp_regs r; \ + if ((reg) == PPIDATA) { (void)ioctl(fd, ECPPIOC_SETDATA, valp); } \ + else { if ((reg) == PPICTRL) r.dcr = *(valp); else r.dsr = *(valp); \ + (void)ioctl(fd, ECPPIOC_SETREGS, &r); } \ + } while(0) + + +#endif /* solaris_ecpp_h */ diff --git a/xs/src/avrdude/stk500.c b/xs/src/avrdude/stk500.c new file mode 100644 index 000000000..5d2d3c1df --- /dev/null +++ b/xs/src/avrdude/stk500.c @@ -0,0 +1,1320 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2002-2004 Brian S. Dean + * 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 + * 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$ */ + +/* + * avrdude interface for Atmel STK500 programmer + * + * Note: most commands use the "universal command" feature of the + * programmer in a "pass through" mode, exceptions are "program + * enable", "paged read", and "paged write". + * + */ + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "stk500.h" +#include "stk500_private.h" + +#define STK500_XTAL 7372800U +#define MAX_SYNC_ATTEMPTS 10 + +struct pdata +{ + unsigned char ext_addr_byte; /* Record ext-addr byte set in the + * target device (if used) */ +}; + +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) + + +static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value); +static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value); +static void stk500_print_parms1(PROGRAMMER * pgm, const char * p); + + +static int stk500_send(PROGRAMMER * pgm, unsigned char * buf, size_t len) +{ + return serial_send(&pgm->fd, buf, len); +} + + +static int stk500_recv(PROGRAMMER * pgm, unsigned char * buf, size_t len) +{ + int rv; + + rv = serial_recv(&pgm->fd, buf, len); + if (rv < 0) { + avrdude_message(MSG_INFO, "%s: stk500_recv(): programmer is not responding\n", + progname); + return -1; + } + return 0; +} + + +int stk500_drain(PROGRAMMER * pgm, int display) +{ + return serial_drain(&pgm->fd, display); +} + + +int stk500_getsync(PROGRAMMER * pgm) +{ + unsigned char buf[32], resp[32]; + int attempt; + + /* + * get in sync */ + buf[0] = Cmnd_STK_GET_SYNC; + buf[1] = Sync_CRC_EOP; + + /* + * First send and drain a few times to get rid of line noise + */ + + stk500_send(pgm, buf, 2); + stk500_drain(pgm, 0); + stk500_send(pgm, buf, 2); + stk500_drain(pgm, 0); + + for (attempt = 0; attempt < MAX_SYNC_ATTEMPTS; attempt++) { + stk500_send(pgm, buf, 2); + stk500_recv(pgm, resp, 1); + if (resp[0] == Resp_STK_INSYNC){ + break; + } + avrdude_message(MSG_INFO, "%s: stk500_getsync() attempt %d of %d: not in sync: resp=0x%02x\n", + progname, attempt + 1, MAX_SYNC_ATTEMPTS, resp[0]); + } + if (attempt == MAX_SYNC_ATTEMPTS) { + stk500_drain(pgm, 0); + return -1; + } + + if (stk500_recv(pgm, resp, 1) < 0) + return -1; + if (resp[0] != Resp_STK_OK) { + avrdude_message(MSG_INFO, "%s: stk500_getsync(): can't communicate with device: " + "resp=0x%02x\n", + progname, resp[0]); + return -1; + } + + return 0; +} + + +/* + * transmit an AVR device command and return the results; 'cmd' and + * 'res' must point to at least a 4 byte data buffer + */ +static int stk500_cmd(PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res) +{ + unsigned char buf[32]; + + buf[0] = Cmnd_STK_UNIVERSAL; + buf[1] = cmd[0]; + buf[2] = cmd[1]; + buf[3] = cmd[2]; + buf[4] = cmd[3]; + buf[5] = Sync_CRC_EOP; + + stk500_send(pgm, buf, 6); + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "%s: stk500_cmd(): programmer is out of sync\n", progname); + return -1; + } + + res[0] = cmd[1]; + res[1] = cmd[2]; + res[2] = cmd[3]; + if (stk500_recv(pgm, &res[3], 1) < 0) + return -1; + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] != Resp_STK_OK) { + avrdude_message(MSG_INFO, "%s: stk500_cmd(): protocol error\n", progname); + return -1; + } + + return 0; +} + + + +/* + * issue the 'chip erase' command to the AVR device + */ +static int stk500_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char cmd[4]; + unsigned char res[4]; + + if (pgm->cmd == NULL) { + avrdude_message(MSG_INFO, "%s: Error: %s programmer uses stk500_chip_erase() but does not\n" + "provide a cmd() method.\n", + progname, pgm->type); + return -1; + } + + if (p->op[AVR_OP_CHIP_ERASE] == NULL) { + avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n", + p->desc); + return -1; + } + + pgm->pgm_led(pgm, ON); + + 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); + + pgm->pgm_led(pgm, OFF); + + return 0; +} + +/* + * issue the 'program enable' command to the AVR device + */ +static int stk500_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char buf[16]; + int tries=0; + + retry: + + tries++; + + buf[0] = Cmnd_STK_ENTER_PROGMODE; + buf[1] = Sync_CRC_EOP; + + stk500_send(pgm, buf, 2); + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_NOSYNC) { + if (tries > 33) { + avrdude_message(MSG_INFO, "%s: stk500_program_enable(): can't get into sync\n", + progname); + return -1; + } + if (stk500_getsync(pgm) < 0) + return -1; + goto retry; + } + else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "%s: stk500_program_enable(): protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -1; + } + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_OK) { + return 0; + } + else if (buf[0] == Resp_STK_NODEVICE) { + avrdude_message(MSG_INFO, "%s: stk500_program_enable(): no device\n", + progname); + return -1; + } + + if(buf[0] == Resp_STK_FAILED) + { + avrdude_message(MSG_INFO, "%s: stk500_program_enable(): failed to enter programming mode\n", + progname); + return -1; + } + + + avrdude_message(MSG_INFO, "%s: stk500_program_enable(): unknown response=0x%02x\n", + progname, buf[0]); + + return -1; +} + + + +static int stk500_set_extended_parms(PROGRAMMER * pgm, int n, + unsigned char * cmd) +{ + unsigned char buf[16]; + int tries=0; + int i; + + retry: + + tries++; + + buf[0] = Cmnd_STK_SET_DEVICE_EXT; + for (i=0; i 33) { + avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): can't get into sync\n", + progname); + return -1; + } + if (stk500_getsync(pgm) < 0) + return -1; + goto retry; + } + else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -1; + } + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_OK) { + return 0; + } + else if (buf[0] == Resp_STK_NODEVICE) { + avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): no device\n", + progname); + return -1; + } + + if(buf[0] == Resp_STK_FAILED) + { + avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): failed to set extended " + "device programming parameters\n", + progname); + return -1; + } + + + avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): unknown response=0x%02x\n", + progname, buf[0]); + + return -1; +} + +/* + * Crossbow MIB510 initialization and shutdown. Use cmd = 1 to + * initialize, cmd = 0 to close. + */ +static int mib510_isp(PROGRAMMER * pgm, unsigned char cmd) +{ + unsigned char buf[9]; + int tries = 0; + + buf[0] = 0xaa; + buf[1] = 0x55; + buf[2] = 0x55; + buf[3] = 0xaa; + buf[4] = 0x17; + buf[5] = 0x51; + buf[6] = 0x31; + buf[7] = 0x13; + buf[8] = cmd; + + + retry: + + tries++; + + stk500_send(pgm, buf, 9); + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_NOSYNC) { + if (tries > 33) { + avrdude_message(MSG_INFO, "%s: mib510_isp(): can't get into sync\n", + progname); + return -1; + } + if (stk500_getsync(pgm) < 0) + return -1; + goto retry; + } + else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "%s: mib510_isp(): protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -1; + } + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_OK) { + return 0; + } + else if (buf[0] == Resp_STK_NODEVICE) { + avrdude_message(MSG_INFO, "%s: mib510_isp(): no device\n", + progname); + return -1; + } + + if (buf[0] == Resp_STK_FAILED) + { + avrdude_message(MSG_INFO, "%s: mib510_isp(): command %d failed\n", + progname, cmd); + return -1; + } + + + avrdude_message(MSG_INFO, "%s: mib510_isp(): unknown response=0x%02x\n", + progname, buf[0]); + + return -1; +} + + +/* + * initialize the AVR device and prepare it to accept commands + */ +static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char buf[32]; + AVRMEM * m; + int tries; + unsigned maj, min; + int rc; + int n_extparms; + + stk500_getparm(pgm, Parm_STK_SW_MAJOR, &maj); + stk500_getparm(pgm, Parm_STK_SW_MINOR, &min); + + // MIB510 does not need extparams + if (strcmp(ldata(lfirst(pgm->id)), "mib510") == 0) + n_extparms = 0; + else if ((maj > 1) || ((maj == 1) && (min > 10))) + n_extparms = 4; + else + n_extparms = 3; + + tries = 0; + + retry: + tries++; + + memset(buf, 0, sizeof(buf)); + + /* + * set device programming parameters + */ + buf[0] = Cmnd_STK_SET_DEVICE; + + buf[1] = p->stk500_devcode; + buf[2] = 0; /* device revision */ + + if ((p->flags & AVRPART_SERIALOK) && (p->flags & AVRPART_PARALLELOK)) + buf[3] = 0; /* device supports parallel and serial programming */ + else + buf[3] = 1; /* device supports parallel only */ + + if (p->flags & AVRPART_PARALLELOK) { + if (p->flags & AVRPART_PSEUDOPARALLEL) { + buf[4] = 0; /* pseudo parallel interface */ + n_extparms = 0; + } + else { + buf[4] = 1; /* full parallel interface */ + } + } + +#if 0 + avrdude_message(MSG_INFO, "%s: stk500_initialize(): n_extparms = %d\n", + progname, n_extparms); +#endif + + buf[5] = 1; /* polling supported - XXX need this in config file */ + buf[6] = 1; /* programming is self-timed - XXX need in config file */ + + m = avr_locate_mem(p, "lock"); + if (m) + buf[7] = m->size; + else + buf[7] = 0; + + /* + * number of fuse bytes + */ + buf[8] = 0; + m = avr_locate_mem(p, "fuse"); + if (m) + buf[8] += m->size; + m = avr_locate_mem(p, "lfuse"); + if (m) + buf[8] += m->size; + m = avr_locate_mem(p, "hfuse"); + if (m) + buf[8] += m->size; + m = avr_locate_mem(p, "efuse"); + if (m) + buf[8] += m->size; + + m = avr_locate_mem(p, "flash"); + if (m) { + buf[9] = m->readback[0]; + buf[10] = m->readback[1]; + if (m->paged) { + buf[13] = (m->page_size >> 8) & 0x00ff; + buf[14] = m->page_size & 0x00ff; + } + buf[17] = (m->size >> 24) & 0xff; + buf[18] = (m->size >> 16) & 0xff; + buf[19] = (m->size >> 8) & 0xff; + buf[20] = m->size & 0xff; + } + else { + buf[9] = 0xff; + buf[10] = 0xff; + buf[13] = 0; + buf[14] = 0; + buf[17] = 0; + buf[18] = 0; + buf[19] = 0; + buf[20] = 0; + } + + m = avr_locate_mem(p, "eeprom"); + if (m) { + buf[11] = m->readback[0]; + buf[12] = m->readback[1]; + buf[15] = (m->size >> 8) & 0x00ff; + buf[16] = m->size & 0x00ff; + } + else { + buf[11] = 0xff; + buf[12] = 0xff; + buf[15] = 0; + buf[16] = 0; + } + + buf[21] = Sync_CRC_EOP; + + stk500_send(pgm, buf, 22); + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_NOSYNC) { + avrdude_message(MSG_INFO, "%s: stk500_initialize(): programmer not in sync, resp=0x%02x\n", + progname, buf[0]); + if (tries > 33) + return -1; + if (stk500_getsync(pgm) < 0) + return -1; + goto retry; + } + else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "%s: stk500_initialize(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -1; + } + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] != Resp_STK_OK) { + avrdude_message(MSG_INFO, "%s: stk500_initialize(): (b) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_OK, buf[0]); + return -1; + } + + if (n_extparms) { + if ((p->pagel == 0) || (p->bs2 == 0)) { + avrdude_message(MSG_NOTICE2, "%s: PAGEL and BS2 signals not defined in the configuration " + "file for part %s, using dummy values\n", + progname, p->desc); + buf[2] = 0xD7; /* they look somehow possible, */ + buf[3] = 0xA0; /* don't they? ;) */ + } + else { + buf[2] = p->pagel; + buf[3] = p->bs2; + } + buf[0] = n_extparms+1; + + /* + * m is currently pointing to eeprom memory if the part has it + */ + if (m) + buf[1] = m->page_size; + else + buf[1] = 0; + + + if (n_extparms == 4) { + if (p->reset_disposition == RESET_DEDICATED) + buf[4] = 0; + else + buf[4] = 1; + } + + rc = stk500_set_extended_parms(pgm, n_extparms+1, buf); + if (rc) { + avrdude_message(MSG_INFO, "%s: stk500_initialize(): failed\n", progname); + return -1; + } + } + + return pgm->program_enable(pgm, p); +} + + +static void stk500_disable(PROGRAMMER * pgm) +{ + unsigned char buf[16]; + int tries=0; + + retry: + + tries++; + + buf[0] = Cmnd_STK_LEAVE_PROGMODE; + buf[1] = Sync_CRC_EOP; + + stk500_send(pgm, buf, 2); + if (stk500_recv(pgm, buf, 1) < 0) + return; + if (buf[0] == Resp_STK_NOSYNC) { + if (tries > 33) { + avrdude_message(MSG_INFO, "%s: stk500_disable(): can't get into sync\n", + progname); + return; + } + if (stk500_getsync(pgm) < 0) + return; + goto retry; + } + else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "%s: stk500_disable(): protocol error, expect=0x%02x, " + "resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return; + } + + if (stk500_recv(pgm, buf, 1) < 0) + return; + if (buf[0] == Resp_STK_OK) { + return; + } + else if (buf[0] == Resp_STK_NODEVICE) { + avrdude_message(MSG_INFO, "%s: stk500_disable(): no device\n", + progname); + return; + } + + avrdude_message(MSG_INFO, "%s: stk500_disable(): unknown response=0x%02x\n", + progname, buf[0]); + + return; +} + +static void stk500_enable(PROGRAMMER * pgm) +{ + return; +} + + +static int stk500_open(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo; + strcpy(pgm->port, port); + pinfo.baud = pgm->baudrate? pgm->baudrate: 115200; + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + stk500_drain(pgm, 0); + + // MIB510 init + if (strcmp(ldata(lfirst(pgm->id)), "mib510") == 0 && + mib510_isp(pgm, 1) != 0) + return -1; + + if (stk500_getsync(pgm) < 0) + return -1; + + return 0; +} + + +static void stk500_close(PROGRAMMER * pgm) +{ + // MIB510 close + if (strcmp(ldata(lfirst(pgm->id)), "mib510") == 0) + (void)mib510_isp(pgm, 0); + + serial_close(&pgm->fd); + pgm->fd.ifd = -1; +} + + +static int stk500_loadaddr(PROGRAMMER * pgm, AVRMEM * mem, unsigned int addr) +{ + unsigned char buf[16]; + int tries; + unsigned char ext_byte; + OPCODE * lext; + + tries = 0; + retry: + tries++; + + /* To support flash > 64K words the correct Extended Address Byte is needed */ + lext = mem->op[AVR_OP_LOAD_EXT_ADDR]; + if (lext != NULL) { + ext_byte = (addr >> 16) & 0xff; + if (ext_byte != PDATA(pgm)->ext_addr_byte) { + /* Either this is the first addr load, or a 64K word boundary is + * crossed, so set the ext addr byte */ + avr_set_bits(lext, buf); + avr_set_addr(lext, buf, addr); + stk500_cmd(pgm, buf, buf); + PDATA(pgm)->ext_addr_byte = ext_byte; + } + } + + buf[0] = Cmnd_STK_LOAD_ADDRESS; + buf[1] = addr & 0xff; + buf[2] = (addr >> 8) & 0xff; + buf[3] = Sync_CRC_EOP; + + stk500_send(pgm, buf, 4); + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_NOSYNC) { + if (tries > 33) { + avrdude_message(MSG_INFO, "%s: stk500_loadaddr(): can't get into sync\n", + progname); + return -1; + } + if (stk500_getsync(pgm) < 0) + return -1; + goto retry; + } + else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "%s: stk500_loadaddr(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -1; + } + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_OK) { + return 0; + } + + avrdude_message(MSG_INFO, "%s: loadaddr(): (b) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + + return -1; +} + + +static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned char *buf = alloca(page_size + 16); + int memtype; + int a_div; + int block_size; + int tries; + unsigned int n; + unsigned int i; + + if (strcmp(m->desc, "flash") == 0) { + memtype = 'F'; + } + else if (strcmp(m->desc, "eeprom") == 0) { + memtype = 'E'; + } + else { + return -2; + } + + if ((m->op[AVR_OP_LOADPAGE_LO]) || (m->op[AVR_OP_READ_LO])) + a_div = 2; + else + a_div = 1; + + n = addr + n_bytes; +#if 0 + avrdude_message(MSG_INFO, "n_bytes = %d\n" + "n = %u\n" + "a_div = %d\n" + "page_size = %d\n", + n_bytes, n, a_div, page_size); +#endif + + for (; addr < n; addr += block_size) { + // MIB510 uses fixed blocks size of 256 bytes + if (strcmp(ldata(lfirst(pgm->id)), "mib510") == 0) { + block_size = 256; + } else { + if (n - addr < page_size) + block_size = n - addr; + else + block_size = page_size; + } + tries = 0; + retry: + tries++; + stk500_loadaddr(pgm, m, addr/a_div); + + /* build command block and avoid multiple send commands as it leads to a crash + of the silabs usb serial driver on mac os x */ + i = 0; + buf[i++] = Cmnd_STK_PROG_PAGE; + buf[i++] = (block_size >> 8) & 0xff; + buf[i++] = block_size & 0xff; + buf[i++] = memtype; + memcpy(&buf[i], &m->buf[addr], block_size); + i += block_size; + buf[i++] = Sync_CRC_EOP; + stk500_send( pgm, buf, i); + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_NOSYNC) { + if (tries > 33) { + avrdude_message(MSG_INFO, "\n%s: stk500_paged_write(): can't get into sync\n", + progname); + return -3; + } + if (stk500_getsync(pgm) < 0) + return -1; + goto retry; + } + else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "\n%s: stk500_paged_write(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -4; + } + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] != Resp_STK_OK) { + avrdude_message(MSG_INFO, "\n%s: stk500_paged_write(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -5; + } + } + + return n_bytes; +} + +static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned char buf[16]; + int memtype; + int a_div; + int tries; + unsigned int n; + int block_size; + + if (strcmp(m->desc, "flash") == 0) { + memtype = 'F'; + } + else if (strcmp(m->desc, "eeprom") == 0) { + memtype = 'E'; + } + else { + return -2; + } + + if ((m->op[AVR_OP_LOADPAGE_LO]) || (m->op[AVR_OP_READ_LO])) + a_div = 2; + else + a_div = 1; + + n = addr + n_bytes; + for (; addr < n; addr += block_size) { + // MIB510 uses fixed blocks size of 256 bytes + if (strcmp(ldata(lfirst(pgm->id)), "mib510") == 0) { + block_size = 256; + } else { + if (n - addr < page_size) + block_size = n - addr; + else + block_size = page_size; + } + + tries = 0; + retry: + tries++; + stk500_loadaddr(pgm, m, addr/a_div); + buf[0] = Cmnd_STK_READ_PAGE; + buf[1] = (block_size >> 8) & 0xff; + buf[2] = block_size & 0xff; + buf[3] = memtype; + buf[4] = Sync_CRC_EOP; + stk500_send(pgm, buf, 5); + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_NOSYNC) { + if (tries > 33) { + avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): can't get into sync\n", + progname); + return -3; + } + if (stk500_getsync(pgm) < 0) + return -1; + goto retry; + } + else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -4; + } + + if (stk500_recv(pgm, &m->buf[addr], block_size) < 0) + return -1; + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + + if(strcmp(ldata(lfirst(pgm->id)), "mib510") == 0) { + if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -5; + } + } + else { + if (buf[0] != Resp_STK_OK) { + avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_OK, buf[0]); + return -5; + } + } + } + + return n_bytes; +} + + +static int stk500_set_vtarget(PROGRAMMER * pgm, double v) +{ + unsigned uaref, utarg; + + utarg = (unsigned)((v + 0.049) * 10); + + if (stk500_getparm(pgm, Parm_STK_VADJUST, &uaref) != 0) { + avrdude_message(MSG_INFO, "%s: stk500_set_vtarget(): cannot obtain V[aref]\n", + progname); + return -1; + } + + if (uaref > utarg) { + avrdude_message(MSG_INFO, "%s: stk500_set_vtarget(): reducing V[aref] from %.1f to %.1f\n", + progname, uaref / 10.0, v); + if (stk500_setparm(pgm, Parm_STK_VADJUST, utarg) + != 0) + return -1; + } + return stk500_setparm(pgm, Parm_STK_VTARGET, utarg); +} + + +static int stk500_set_varef(PROGRAMMER * pgm, unsigned int chan /* unused */, + double v) +{ + unsigned uaref, utarg; + + uaref = (unsigned)((v + 0.049) * 10); + + if (stk500_getparm(pgm, Parm_STK_VTARGET, &utarg) != 0) { + avrdude_message(MSG_INFO, "%s: stk500_set_varef(): cannot obtain V[target]\n", + progname); + return -1; + } + + if (uaref > utarg) { + avrdude_message(MSG_INFO, "%s: stk500_set_varef(): V[aref] must not be greater than " + "V[target] = %.1f\n", + progname, utarg / 10.0); + return -1; + } + return stk500_setparm(pgm, Parm_STK_VADJUST, uaref); +} + + +static int stk500_set_fosc(PROGRAMMER * pgm, double v) +{ + unsigned prescale, cmatch, fosc; + static unsigned ps[] = { + 1, 8, 32, 64, 128, 256, 1024 + }; + int idx, rc; + + prescale = cmatch = 0; + if (v > 0.0) { + if (v > STK500_XTAL / 2) { + const char *unit; + if (v > 1e6) { + v /= 1e6; + unit = "MHz"; + } else if (v > 1e3) { + v /= 1e3; + unit = "kHz"; + } else + unit = "Hz"; + avrdude_message(MSG_INFO, "%s: stk500_set_fosc(): f = %.3f %s too high, using %.3f MHz\n", + progname, v, unit, STK500_XTAL / 2e6); + fosc = STK500_XTAL / 2; + } else + fosc = (unsigned)v; + + for (idx = 0; idx < sizeof(ps) / sizeof(ps[0]); idx++) { + if (fosc >= STK500_XTAL / (256 * ps[idx] * 2)) { + /* this prescaler value can handle our frequency */ + prescale = idx + 1; + cmatch = (unsigned)(STK500_XTAL / (2 * fosc * ps[idx])) - 1; + break; + } + } + if (idx == sizeof(ps) / sizeof(ps[0])) { + avrdude_message(MSG_INFO, "%s: stk500_set_fosc(): f = %u Hz too low, %u Hz min\n", + progname, fosc, STK500_XTAL / (256 * 1024 * 2)); + return -1; + } + } + + if ((rc = stk500_setparm(pgm, Parm_STK_OSC_PSCALE, prescale)) != 0 + || (rc = stk500_setparm(pgm, Parm_STK_OSC_CMATCH, cmatch)) != 0) + return rc; + + return 0; +} + + +/* This code assumes that each count of the SCK duration parameter + represents 8/f, where f is the clock frequency of the STK500 master + processors (not the target). This number comes from Atmel + application note AVR061. It appears that the STK500 bit bangs SCK. + For small duration values, the actual SCK width is larger than + expected. As the duration value increases, the SCK width error + diminishes. */ +static int stk500_set_sck_period(PROGRAMMER * pgm, double v) +{ + int dur; + double min, max; + + min = 8.0 / STK500_XTAL; + max = 255 * min; + dur = v / min + 0.5; + + if (v < min) { + dur = 1; + avrdude_message(MSG_INFO, "%s: stk500_set_sck_period(): p = %.1f us too small, using %.1f us\n", + progname, v / 1e-6, dur * min / 1e-6); + } else if (v > max) { + dur = 255; + avrdude_message(MSG_INFO, "%s: stk500_set_sck_period(): p = %.1f us too large, using %.1f us\n", + progname, v / 1e-6, dur * min / 1e-6); + } + + return stk500_setparm(pgm, Parm_STK_SCK_DURATION, dur); +} + + +static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value) +{ + unsigned char buf[16]; + unsigned v; + int tries = 0; + + retry: + tries++; + buf[0] = Cmnd_STK_GET_PARAMETER; + buf[1] = parm; + buf[2] = Sync_CRC_EOP; + + stk500_send(pgm, buf, 3); + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_NOSYNC) { + if (tries > 33) { + avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): can't get into sync\n", + progname); + return -1; + } + if (stk500_getsync(pgm) < 0) + return -1; + goto retry; + } + else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -2; + } + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + v = buf[0]; + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_FAILED) { + avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): parameter 0x%02x failed\n", + progname, v); + return -3; + } + else if (buf[0] != Resp_STK_OK) { + avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -3; + } + + *value = v; + + return 0; +} + + +static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value) +{ + unsigned char buf[16]; + int tries = 0; + + retry: + tries++; + buf[0] = Cmnd_STK_SET_PARAMETER; + buf[1] = parm; + buf[2] = value; + buf[3] = Sync_CRC_EOP; + + stk500_send(pgm, buf, 4); + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_NOSYNC) { + if (tries > 33) { + avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): can't get into sync\n", + progname); + return -1; + } + if (stk500_getsync(pgm) < 0) + return -1; + goto retry; + } + else if (buf[0] != Resp_STK_INSYNC) { + avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -2; + } + + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_OK) + return 0; + + parm = buf[0]; /* if not STK_OK, we've been echoed parm here */ + if (stk500_recv(pgm, buf, 1) < 0) + return -1; + if (buf[0] == Resp_STK_FAILED) { + avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): parameter 0x%02x failed\n", + progname, parm); + return -3; + } + else { + avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): (a) protocol error, " + "expect=0x%02x, resp=0x%02x\n", + progname, Resp_STK_INSYNC, buf[0]); + return -3; + } +} + + +static void stk500_display(PROGRAMMER * pgm, const char * p) +{ + unsigned maj, min, hdw, topcard; + + stk500_getparm(pgm, Parm_STK_HW_VER, &hdw); + stk500_getparm(pgm, Parm_STK_SW_MAJOR, &maj); + stk500_getparm(pgm, Parm_STK_SW_MINOR, &min); + stk500_getparm(pgm, Param_STK500_TOPCARD_DETECT, &topcard); + + avrdude_message(MSG_INFO, "%sHardware Version: %d\n", p, hdw); + avrdude_message(MSG_INFO, "%sFirmware Version: %d.%d\n", p, maj, min); + if (topcard < 3) { + const char *n = "Unknown"; + + switch (topcard) { + case 1: + n = "STK502"; + break; + + case 2: + n = "STK501"; + break; + } + avrdude_message(MSG_INFO, "%sTopcard : %s\n", p, n); + } + stk500_print_parms1(pgm, p); + + return; +} + + +static void stk500_print_parms1(PROGRAMMER * pgm, const char * p) +{ + unsigned vtarget, vadjust, osc_pscale, osc_cmatch, sck_duration; + + stk500_getparm(pgm, Parm_STK_VTARGET, &vtarget); + stk500_getparm(pgm, Parm_STK_VADJUST, &vadjust); + stk500_getparm(pgm, Parm_STK_OSC_PSCALE, &osc_pscale); + stk500_getparm(pgm, Parm_STK_OSC_CMATCH, &osc_cmatch); + stk500_getparm(pgm, Parm_STK_SCK_DURATION, &sck_duration); + + avrdude_message(MSG_INFO, "%sVtarget : %.1f V\n", p, vtarget / 10.0); + avrdude_message(MSG_INFO, "%sVaref : %.1f V\n", p, vadjust / 10.0); + avrdude_message(MSG_INFO, "%sOscillator : ", p); + if (osc_pscale == 0) + avrdude_message(MSG_INFO, "Off\n"); + else { + int prescale = 1; + double f = STK500_XTAL / 2; + const char *unit; + + switch (osc_pscale) { + case 2: prescale = 8; break; + case 3: prescale = 32; break; + case 4: prescale = 64; break; + case 5: prescale = 128; break; + case 6: prescale = 256; break; + case 7: prescale = 1024; break; + } + f /= prescale; + f /= (osc_cmatch + 1); + if (f > 1e6) { + f /= 1e6; + unit = "MHz"; + } else if (f > 1e3) { + f /= 1000; + unit = "kHz"; + } else + unit = "Hz"; + avrdude_message(MSG_INFO, "%.3f %s\n", f, unit); + } + avrdude_message(MSG_INFO, "%sSCK period : %.1f us\n", p, + sck_duration * 8.0e6 / STK500_XTAL + 0.05); + + return; +} + + +static void stk500_print_parms(PROGRAMMER * pgm) +{ + stk500_print_parms1(pgm, ""); +} + +static void stk500_setup(PROGRAMMER * pgm) +{ + if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + avrdude_message(MSG_INFO, "%s: stk500_setup(): Out of memory allocating private data\n", + progname); + return; + } + memset(pgm->cookie, 0, sizeof(struct pdata)); + PDATA(pgm)->ext_addr_byte = 0xff; /* Ensures it is programmed before + * first memory address */ +} + +static void stk500_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); +} + +const char stk500_desc[] = "Atmel STK500 Version 1.x firmware"; + +void stk500_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "STK500"); + + /* + * mandatory functions + */ + pgm->initialize = stk500_initialize; + pgm->display = stk500_display; + pgm->enable = stk500_enable; + pgm->disable = stk500_disable; + pgm->program_enable = stk500_program_enable; + pgm->chip_erase = stk500_chip_erase; + pgm->cmd = stk500_cmd; + pgm->open = stk500_open; + pgm->close = stk500_close; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; + + /* + * optional functions + */ + pgm->paged_write = stk500_paged_write; + pgm->paged_load = stk500_paged_load; + pgm->print_parms = stk500_print_parms; + pgm->set_vtarget = stk500_set_vtarget; + pgm->set_varef = stk500_set_varef; + pgm->set_fosc = stk500_set_fosc; + pgm->set_sck_period = stk500_set_sck_period; + pgm->setup = stk500_setup; + pgm->teardown = stk500_teardown; + pgm->page_size = 256; +} diff --git a/xs/src/avrdude/stk500.h b/xs/src/avrdude/stk500.h new file mode 100644 index 000000000..d0bce452d --- /dev/null +++ b/xs/src/avrdude/stk500.h @@ -0,0 +1,41 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 stk500_h +#define stk500_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char stk500_desc[]; +void stk500_initpgm (PROGRAMMER * pgm); + +/* used by arduino.c to avoid duplicate code */ +int stk500_getsync(PROGRAMMER * pgm); +int stk500_drain(PROGRAMMER * pgm, int display); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/xs/src/avrdude/stk500_private.h b/xs/src/avrdude/stk500_private.h new file mode 100644 index 000000000..7efe866c4 --- /dev/null +++ b/xs/src/avrdude/stk500_private.h @@ -0,0 +1,103 @@ +//**** ATMEL AVR - A P P L I C A T I O N N O T E ************************ +//* +//* Title: AVR061 - STK500 Communication Protocol +//* Filename: command.h +//* Version: 1.0 +//* Last updated: 09.09.2002 +//* +//* Support E-mail: avr@atmel.com +//* +//************************************************************************** + +// *****************[ STK Message constants ]*************************** + +#define STK_SIGN_ON_MESSAGE "AVR STK" // Sign on string for Cmnd_STK_GET_SIGN_ON + +// *****************[ STK Response constants ]*************************** + +#define Resp_STK_OK 0x10 // ' ' +#define Resp_STK_FAILED 0x11 // ' ' +#define Resp_STK_UNKNOWN 0x12 // ' ' +#define Resp_STK_NODEVICE 0x13 // ' ' +#define Resp_STK_INSYNC 0x14 // ' ' +#define Resp_STK_NOSYNC 0x15 // ' ' + +#define Resp_ADC_CHANNEL_ERROR 0x16 // ' ' +#define Resp_ADC_MEASURE_OK 0x17 // ' ' +#define Resp_PWM_CHANNEL_ERROR 0x18 // ' ' +#define Resp_PWM_ADJUST_OK 0x19 // ' ' + +// *****************[ STK Special constants ]*************************** + +#define Sync_CRC_EOP 0x20 // 'SPACE' + +// *****************[ STK Command constants ]*************************** + +#define Cmnd_STK_GET_SYNC 0x30 // ' ' +#define Cmnd_STK_GET_SIGN_ON 0x31 // ' ' + +#define Cmnd_STK_SET_PARAMETER 0x40 // ' ' +#define Cmnd_STK_GET_PARAMETER 0x41 // ' ' +#define Cmnd_STK_SET_DEVICE 0x42 // ' ' +#define Cmnd_STK_SET_DEVICE_EXT 0x45 // ' ' + +#define Cmnd_STK_ENTER_PROGMODE 0x50 // ' ' +#define Cmnd_STK_LEAVE_PROGMODE 0x51 // ' ' +#define Cmnd_STK_CHIP_ERASE 0x52 // ' ' +#define Cmnd_STK_CHECK_AUTOINC 0x53 // ' ' +#define Cmnd_STK_LOAD_ADDRESS 0x55 // ' ' +#define Cmnd_STK_UNIVERSAL 0x56 // ' ' +#define Cmnd_STK_UNIVERSAL_MULTI 0x57 // ' ' + +#define Cmnd_STK_PROG_FLASH 0x60 // ' ' +#define Cmnd_STK_PROG_DATA 0x61 // ' ' +#define Cmnd_STK_PROG_FUSE 0x62 // ' ' +#define Cmnd_STK_PROG_LOCK 0x63 // ' ' +#define Cmnd_STK_PROG_PAGE 0x64 // ' ' +#define Cmnd_STK_PROG_FUSE_EXT 0x65 // ' ' + +#define Cmnd_STK_READ_FLASH 0x70 // ' ' +#define Cmnd_STK_READ_DATA 0x71 // ' ' +#define Cmnd_STK_READ_FUSE 0x72 // ' ' +#define Cmnd_STK_READ_LOCK 0x73 // ' ' +#define Cmnd_STK_READ_PAGE 0x74 // ' ' +#define Cmnd_STK_READ_SIGN 0x75 // ' ' +#define Cmnd_STK_READ_OSCCAL 0x76 // ' ' +#define Cmnd_STK_READ_FUSE_EXT 0x77 // ' ' +#define Cmnd_STK_READ_OSCCAL_EXT 0x78 // ' ' + +// *****************[ STK Parameter constants ]*************************** + +#define Parm_STK_HW_VER 0x80 // ' ' - R +#define Parm_STK_SW_MAJOR 0x81 // ' ' - R +#define Parm_STK_SW_MINOR 0x82 // ' ' - R +#define Parm_STK_LEDS 0x83 // ' ' - R/W +#define Parm_STK_VTARGET 0x84 // ' ' - R/W +#define Parm_STK_VADJUST 0x85 // ' ' - R/W +#define Parm_STK_OSC_PSCALE 0x86 // ' ' - R/W +#define Parm_STK_OSC_CMATCH 0x87 // ' ' - R/W +#define Parm_STK_RESET_DURATION 0x88 // ' ' - R/W +#define Parm_STK_SCK_DURATION 0x89 // ' ' - R/W + +#define Parm_STK_BUFSIZEL 0x90 // ' ' - R/W, Range {0..255} +#define Parm_STK_BUFSIZEH 0x91 // ' ' - R/W, Range {0..255} +#define Parm_STK_DEVICE 0x92 // ' ' - R/W, Range {0..255} +#define Parm_STK_PROGMODE 0x93 // ' ' - 'P' or 'S' +#define Parm_STK_PARAMODE 0x94 // ' ' - TRUE or FALSE +#define Parm_STK_POLLING 0x95 // ' ' - TRUE or FALSE +#define Parm_STK_SELFTIMED 0x96 // ' ' - TRUE or FALSE +#define Param_STK500_TOPCARD_DETECT 0x98 // ' ' - Detect top-card attached + +// *****************[ STK status bit definitions ]*************************** + +#define Stat_STK_INSYNC 0x01 // INSYNC status bit, '1' - INSYNC +#define Stat_STK_PROGMODE 0x02 // Programming mode, '1' - PROGMODE +#define Stat_STK_STANDALONE 0x04 // Standalone mode, '1' - SM mode +#define Stat_STK_RESET 0x08 // RESET button, '1' - Pushed +#define Stat_STK_PROGRAM 0x10 // Program button, ' 1' - Pushed +#define Stat_STK_LEDG 0x20 // Green LED status, '1' - Lit +#define Stat_STK_LEDR 0x40 // Red LED status, '1' - Lit +#define Stat_STK_LEDBLINK 0x80 // LED blink ON/OFF, '1' - Blink + + +// *****************************[ End Of COMMAND.H ]************************** diff --git a/xs/src/avrdude/stk500generic.c b/xs/src/avrdude/stk500generic.c new file mode 100644 index 000000000..9c1ea4036 --- /dev/null +++ b/xs/src/avrdude/stk500generic.c @@ -0,0 +1,90 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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$ */ + +/* + * avrdude interface for Atmel STK500 programmer + * + * This is a wrapper around the STK500[v1] and STK500v2 programmers. + * Try to select the programmer type that actually responds, and + * divert to the actual programmer implementation if successful. + */ + +#include "ac_cfg.h" + +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "stk500generic.h" +#include "stk500.h" +#include "stk500v2.h" + +static int stk500generic_open(PROGRAMMER * pgm, char * port) +{ + stk500_initpgm(pgm); + if (pgm->open(pgm, port) >= 0) + { + avrdude_message(MSG_INFO, "%s: successfully opened stk500v1 device -- please use -c stk500v1\n", + progname); + return 0; + } + + pgm->close(pgm); + + stk500v2_initpgm(pgm); + if (pgm->open(pgm, port) >= 0) + { + avrdude_message(MSG_INFO, "%s: successfully opened stk500v2 device -- please use -c stk500v2\n", + progname); + return 0; + } + + avrdude_message(MSG_INFO, "%s: cannot open either stk500v1 or stk500v2 programmer\n", + progname); + return -1; +} + +static void stk500generic_setup(PROGRAMMER * pgm) +{ + /* + * Only STK500v2 needs setup/teardown. + */ + stk500v2_initpgm(pgm); + pgm->setup(pgm); +} + +static void stk500generic_teardown(PROGRAMMER * pgm) +{ + stk500v2_initpgm(pgm); + pgm->teardown(pgm); +} + +const char stk500generic_desc[] = "Atmel STK500, autodetect firmware version"; + +void stk500generic_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "STK500GENERIC"); + + pgm->open = stk500generic_open; + pgm->setup = stk500generic_setup; + pgm->teardown = stk500generic_teardown; +} diff --git a/xs/src/avrdude/stk500generic.h b/xs/src/avrdude/stk500generic.h new file mode 100644 index 000000000..0c0590129 --- /dev/null +++ b/xs/src/avrdude/stk500generic.h @@ -0,0 +1,29 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 stk500generic_h__ +#define stk500generic_h__ + +extern const char stk500generic_desc[]; +void stk500generic_initpgm (PROGRAMMER * pgm); + +#endif + + diff --git a/xs/src/avrdude/stk500v2.c b/xs/src/avrdude/stk500v2.c new file mode 100644 index 000000000..d3acb639c --- /dev/null +++ b/xs/src/avrdude/stk500v2.c @@ -0,0 +1,4802 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2005 Erik Walthinsen + * Copyright (C) 2002-2004 Brian S. Dean + * Copyright (C) 2006 David Moore + * 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 + * 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$ */ +/* Based on Id: stk500.c,v 1.46 2004/12/22 01:52:45 bdean Exp */ + +/* + * avrdude interface for Atmel STK500V2 programmer + * + * As the AVRISP mkII device is basically an STK500v2 one that can + * only talk across USB, and that misses any kind of framing protocol, + * this is handled here as well. + * + * Note: most commands use the "universal command" feature of the + * programmer in a "pass through" mode, exceptions are "program + * enable", "paged read", and "paged write". + * + */ + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(WIN32NATIVE) +# include +#endif + +#include "avrdude.h" +#include "libavrdude.h" + +#include "stk500_private.h" // temp until all code converted +#include "stk500v2.h" +#include "stk500v2_private.h" +#include "usbdevs.h" + +/* + * We need to import enough from the JTAG ICE mkII definitions to be + * able to talk to the ICE, query some parameters etc. The macro + * JTAGMKII_PRIVATE_EXPORTED limits the amount of definitions that + * jtagmkII_private.h will export, so to avoid conflicts with those + * names that are identical to the STK500v2 ones. + */ +#include "jtagmkII.h" // public interfaces from jtagmkII.c +#define JTAGMKII_PRIVATE_EXPORTED +#include "jtagmkII_private.h" + +#include "jtag3.h" // public interfaces from jtagmkII.c +#define JTAG3_PRIVATE_EXPORTED +#include "jtag3_private.h" + +#define STK500V2_XTAL 7372800U + +// Timeout (in seconds) for waiting for serial response +#define SERIAL_TIMEOUT 2 + +// Retry count +#define RETRIES 5 + +#if 0 +#define DEBUG(...) avrdude_message(MSG_INFO, __VA_ARGS__) +#else +#define DEBUG(...) +#endif + +#if 0 +#define DEBUGRECV(...) avrdude_message(MSG_INFO, __VA_ARGS__) +#else +#define DEBUGRECV(...) +#endif + +enum hvmode +{ + PPMODE, HVSPMODE +}; + + +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) + + +/* + * Data structure for displaying STK600 routing and socket cards. + */ +struct carddata +{ + int id; + const char *name; +}; + +static const char *pgmname[] = +{ + "unknown", + "STK500", + "AVRISP", + "AVRISP mkII", + "JTAG ICE mkII", + "STK600", + "JTAGICE3", +}; + +struct jtagispentry +{ + unsigned char cmd; + unsigned short size; +#define SZ_READ_FLASH_EE USHRT_MAX +#define SZ_SPI_MULTI (USHRT_MAX - 1) +}; + +static const struct jtagispentry jtagispcmds[] = { + /* generic */ + { CMD_SET_PARAMETER, 2 }, + { CMD_GET_PARAMETER, 3 }, + { CMD_OSCCAL, 2 }, + { CMD_LOAD_ADDRESS, 2 }, + /* ISP mode */ + { CMD_ENTER_PROGMODE_ISP, 2 }, + { CMD_LEAVE_PROGMODE_ISP, 2 }, + { CMD_CHIP_ERASE_ISP, 2 }, + { CMD_PROGRAM_FLASH_ISP, 2 }, + { CMD_READ_FLASH_ISP, SZ_READ_FLASH_EE }, + { CMD_PROGRAM_EEPROM_ISP, 2 }, + { CMD_READ_EEPROM_ISP, SZ_READ_FLASH_EE }, + { CMD_PROGRAM_FUSE_ISP, 3 }, + { CMD_READ_FUSE_ISP, 4 }, + { CMD_PROGRAM_LOCK_ISP, 3 }, + { CMD_READ_LOCK_ISP, 4 }, + { CMD_READ_SIGNATURE_ISP, 4 }, + { CMD_READ_OSCCAL_ISP, 4 }, + { CMD_SPI_MULTI, SZ_SPI_MULTI }, + /* all HV modes */ + { CMD_SET_CONTROL_STACK, 2 }, + /* HVSP mode */ + { CMD_ENTER_PROGMODE_HVSP, 2 }, + { CMD_LEAVE_PROGMODE_HVSP, 2 }, + { CMD_CHIP_ERASE_HVSP, 2 }, + { CMD_PROGRAM_FLASH_HVSP, 2 }, + { CMD_READ_FLASH_HVSP, SZ_READ_FLASH_EE }, + { CMD_PROGRAM_EEPROM_HVSP, 2 }, + { CMD_READ_EEPROM_HVSP, SZ_READ_FLASH_EE }, + { CMD_PROGRAM_FUSE_HVSP, 2 }, + { CMD_READ_FUSE_HVSP, 3 }, + { CMD_PROGRAM_LOCK_HVSP, 2 }, + { CMD_READ_LOCK_HVSP, 3 }, + { CMD_READ_SIGNATURE_HVSP, 3 }, + { CMD_READ_OSCCAL_HVSP, 3 }, + /* PP mode */ + { CMD_ENTER_PROGMODE_PP, 2 }, + { CMD_LEAVE_PROGMODE_PP, 2 }, + { CMD_CHIP_ERASE_PP, 2 }, + { CMD_PROGRAM_FLASH_PP, 2 }, + { CMD_READ_FLASH_PP, SZ_READ_FLASH_EE }, + { CMD_PROGRAM_EEPROM_PP, 2 }, + { CMD_READ_EEPROM_PP, SZ_READ_FLASH_EE }, + { CMD_PROGRAM_FUSE_PP, 2 }, + { CMD_READ_FUSE_PP, 3 }, + { CMD_PROGRAM_LOCK_PP, 2 }, + { CMD_READ_LOCK_PP, 3 }, + { CMD_READ_SIGNATURE_PP, 3 }, + { CMD_READ_OSCCAL_PP, 3 }, +}; + +/* + * From XML file: + + 0 + 56 + 0 + 1 + + */ +/* + * These two tables can be semi-automatically updated from + * targetboards.xml using tools/get-stk600-cards.xsl. + */ +static const struct carddata routing_cards[] = +{ + { 0x01, "STK600-RC020T-1" }, + { 0x03, "STK600-RC028T-3" }, + { 0x05, "STK600-RC040M-5" }, + { 0x08, "STK600-RC020T-8" }, + { 0x0A, "STK600-RC040M-4" }, + { 0x0C, "STK600-RC008T-2" }, + { 0x0D, "STK600-RC028M-6" }, + { 0x10, "STK600-RC064M-10" }, + { 0x11, "STK600-RC100M-11" }, + { 0x13, "STK600-RC100X-13" }, + { 0x15, "STK600-RC044X-15" }, + { 0x18, "STK600-RC100M-18" }, + { 0x19, "STK600-RCPWM-19" }, + { 0x1A, "STK600-RC064X-14" }, + { 0x1B, "STK600-RC032U-20" }, + { 0x1C, "STK600-RC014T-12" }, + { 0x1E, "STK600-RC064U-17" }, + { 0x1F, "STK600-RCuC3B0-21" }, + { 0x20, "STK600-RCPWM-22" }, + { 0x21, "STK600-RC020T-23" }, + { 0x22, "STK600-RC044M-24" }, + { 0x23, "STK600-RC044U-25" }, + { 0x24, "STK600-RCPWM-26" }, + { 0x25, "STK600-RCuC3B48-27" }, + { 0x27, "STK600-RC032M-29" }, + { 0x28, "STK600-RC044M-30" }, + { 0x29, "STK600-RC044M-31" }, + { 0x2A, "STK600-RC014T-42" }, + { 0x2B, "STK600-RC020T-43" }, + { 0x30, "STK600-RCUC3A144-32" }, + { 0x34, "STK600-RCUC3L0-34" }, + { 0x38, "STK600-RCUC3C0-36" }, + { 0x3B, "STK600-RCUC3C0-37" }, + { 0x3E, "STK600-RCUC3A144-33" }, + { 0x46, "STK600-RCuC3A100-28" }, + { 0x55, "STK600-RC064M-9" }, + { 0x88, "STK600-RCUC3C1-38" }, + { 0x8B, "STK600-RCUC3C1-39" }, + { 0xA0, "STK600-RC008T-7" }, + { 0xB8, "STK600-RCUC3C2-40" }, + { 0xBB, "STK600-RCUC3C2-41" }, +}; + +static const struct carddata socket_cards[] = +{ + { 0x01, "STK600-TQFP48" }, + { 0x02, "STK600-TQFP32" }, + { 0x03, "STK600-TQFP100" }, + { 0x04, "STK600-SOIC" }, + { 0x06, "STK600-TQFP144" }, + { 0x09, "STK600-TinyX3U" }, + { 0x0C, "STK600-TSSOP44" }, + { 0x0D, "STK600-TQFP44" }, + { 0x0E, "STK600-TQFP64-2" }, + { 0x0F, "STK600-ATMEGA2560" }, + { 0x15, "STK600-MLF64" }, + { 0x16, "STK600-ATXMEGAT0" }, + { 0x18, "QT600-ATMEGA324-QM64" }, + { 0x19, "STK600-ATMEGA128RFA1" }, + { 0x1A, "QT600-ATTINY88-QT8" }, + { 0x1B, "QT600-ATXMEGA128A1-QT16" }, + { 0x1C, "QT600-AT32UC3L-QM64" }, + { 0x1D, "STK600-HVE2" }, + { 0x1E, "STK600-ATTINY10" }, + { 0x55, "STK600-TQFP64" }, + { 0x69, "STK600-uC3-144" }, + { 0xF0, "STK600-ATXMEGA1281A1" }, + { 0xF1, "STK600-DIP" }, +}; + +static int stk500v2_getparm(PROGRAMMER * pgm, unsigned char parm, unsigned char * value); +static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char value); +static int stk500v2_getparm2(PROGRAMMER * pgm, unsigned char parm, unsigned int * value); +static int stk500v2_setparm2(PROGRAMMER * pgm, unsigned char parm, unsigned int value); +static int stk500v2_setparm_real(PROGRAMMER * pgm, unsigned char parm, unsigned char value); +static void stk500v2_print_parms1(PROGRAMMER * pgm, const char * p); +static int stk500v2_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes); +static int stk500v2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes); + +static unsigned int stk500v2_mode_for_pagesize(unsigned int pagesize); + +static double stk500v2_sck_to_us(PROGRAMMER * pgm, unsigned char dur); +static int stk500v2_set_sck_period_mk2(PROGRAMMER * pgm, double v); + +static int stk600_set_sck_period(PROGRAMMER * pgm, double v); + +static void stk600_setup_xprog(PROGRAMMER * pgm); +static void stk600_setup_isp(PROGRAMMER * pgm); +static int stk600_xprog_program_enable(PROGRAMMER * pgm, AVRPART * p); + +void stk500v2_setup(PROGRAMMER * pgm) +{ + if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_setup(): Out of memory allocating private data\n", + progname); + exit(1); + } + memset(pgm->cookie, 0, sizeof(struct pdata)); + PDATA(pgm)->command_sequence = 1; + PDATA(pgm)->boot_start = ULONG_MAX; +} + +static void stk500v2_jtagmkII_setup(PROGRAMMER * pgm) +{ + // void *mycookie, *theircookie; + + // if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + // avrdude_message(MSG_INFO, "%s: stk500v2_setup(): Out of memory allocating private data\n", + // progname); + // exit(1); + // } + // memset(pgm->cookie, 0, sizeof(struct pdata)); + // PDATA(pgm)->command_sequence = 1; + + // /* + // * Now, have the JTAG ICE mkII backend allocate its own private + // * data. Store our own cookie in a safe place for the time being. + // */ + // mycookie = pgm->cookie; + // jtagmkII_setup(pgm); + // theircookie = pgm->cookie; + // pgm->cookie = mycookie; + // PDATA(pgm)->chained_pdata = theircookie; +} + +static void stk500v2_jtag3_setup(PROGRAMMER * pgm) +{ + // void *mycookie, *theircookie; + + // if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + // avrdude_message(MSG_INFO, "%s: stk500v2_setup(): Out of memory allocating private data\n", + // progname); + // exit(1); + // } + // memset(pgm->cookie, 0, sizeof(struct pdata)); + // PDATA(pgm)->command_sequence = 1; + + // /* + // * Now, have the JTAGICE3 backend allocate its own private + // * data. Store our own cookie in a safe place for the time being. + // */ + // mycookie = pgm->cookie; + // jtag3_setup(pgm); + // theircookie = pgm->cookie; + // pgm->cookie = mycookie; + // PDATA(pgm)->chained_pdata = theircookie; +} + +void stk500v2_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); +} + +static void stk500v2_jtagmkII_teardown(PROGRAMMER * pgm) +{ + // void *mycookie; + + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // jtagmkII_teardown(pgm); + + // free(mycookie); +} + +static void stk500v2_jtag3_teardown(PROGRAMMER * pgm) +{ + // void *mycookie; + + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // jtag3_teardown(pgm); + + // free(mycookie); +} + + +static unsigned short +b2_to_u16(unsigned char *b) +{ + unsigned short l; + l = b[0]; + l += (unsigned)b[1] << 8; + + return l; +} + +static int stk500v2_send_mk2(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + if (serial_send(&pgm->fd, data, len) != 0) { + avrdude_message(MSG_INFO, "%s: stk500_send_mk2(): failed to send command to serial port\n",progname); + return -1; + } + + return 0; +} + +static unsigned short get_jtagisp_return_size(unsigned char cmd) +{ + int i; + + for (i = 0; i < sizeof jtagispcmds / sizeof jtagispcmds[0]; i++) + if (jtagispcmds[i].cmd == cmd) + return jtagispcmds[i].size; + + return 0; +} + +/* + * Send the data as a JTAG ICE mkII encapsulated ISP packet. + * Unlike what AVR067 says, the packet gets a length of our + * response buffer prepended, and replies with RSP_SPI_DATA + * if successful. + */ +static int stk500v2_jtagmkII_send(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + return -1; + // unsigned char *cmdbuf; + // int rv; + // unsigned short sz; + // void *mycookie; + + // sz = get_jtagisp_return_size(data[0]); + // if (sz == 0) { + // avrdude_message(MSG_INFO, "%s: unsupported encapsulated ISP command: %#x\n", + // progname, data[0]); + // return -1; + // } + // if (sz == SZ_READ_FLASH_EE) { + // /* + // * For CMND_READ_FLASH_ISP and CMND_READ_EEPROM_ISP, extract the + // * size of the return data from the request. Note that the + // * request itself has the size in big endian format, while we are + // * supposed to deliver it in little endian. + // */ + // sz = 3 + (data[1] << 8) + data[2]; + // } else if (sz == SZ_SPI_MULTI) { + // /* + // * CMND_SPI_MULTI has the Rx size encoded in its 3rd byte. + // */ + // sz = 3 + data[2]; + // } + + // if ((cmdbuf = malloc(len + 3)) == NULL) { + // avrdude_message(MSG_INFO, "%s: out of memory for command packet\n", + // progname); + // exit(1); + // } + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // cmdbuf[0] = CMND_ISP_PACKET; + // cmdbuf[1] = sz & 0xff; + // cmdbuf[2] = (sz >> 8) & 0xff; + // memcpy(cmdbuf + 3, data, len); + // rv = jtagmkII_send(pgm, cmdbuf, len + 3); + // free(cmdbuf); + // pgm->cookie = mycookie; + + // return rv; +} + +/* + * Send the data as a JTAGICE3 encapsulated ISP packet. + */ +static int stk500v2_jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + return -1; + // unsigned char *cmdbuf; + // int rv; + // void *mycookie; + + // if ((cmdbuf = malloc(len + 1)) == NULL) { + // avrdude_message(MSG_INFO, "%s: out of memory for command packet\n", + // progname); + // exit(1); + // } + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // cmdbuf[0] = SCOPE_AVR_ISP; + // memcpy(cmdbuf + 1, data, len); + // rv = jtag3_send(pgm, cmdbuf, len + 1); + // free(cmdbuf); + // pgm->cookie = mycookie; + + // return rv; +} + +static int stk500v2_send(PROGRAMMER * pgm, unsigned char * data, size_t len) +{ + unsigned char buf[275 + 6]; // max MESSAGE_BODY of 275 bytes, 6 bytes overhead + int i; + + if (PDATA(pgm)->pgmtype == PGMTYPE_AVRISP_MKII || + PDATA(pgm)->pgmtype == PGMTYPE_STK600) + return stk500v2_send_mk2(pgm, data, len); + else if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII) + return stk500v2_jtagmkII_send(pgm, data, len); + else if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE3) + return stk500v2_jtag3_send(pgm, data, len); + + buf[0] = MESSAGE_START; + buf[1] = PDATA(pgm)->command_sequence; + buf[2] = len / 256; + buf[3] = len % 256; + buf[4] = TOKEN; + memcpy(buf+5, data, len); + + // calculate the XOR checksum + buf[5+len] = 0; + for (i=0;i<5+len;i++) + buf[5+len] ^= buf[i]; + + DEBUG("STK500V2: stk500v2_send("); + for (i=0;ifd, buf, len+6) != 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_send(): failed to send command to serial port\n",progname); + return -1; + } + + return 0; +} + + +int stk500v2_drain(PROGRAMMER * pgm, int display) +{ + return serial_drain(&pgm->fd, display); +} + +static int stk500v2_recv_mk2(PROGRAMMER * pgm, unsigned char *msg, + size_t maxsize) +{ + int rv; + + rv = serial_recv(&pgm->fd, msg, maxsize); + if (rv < 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_recv_mk2: error in USB receive\n", progname); + return -1; + } + + return rv; +} + +static int stk500v2_jtagmkII_recv(PROGRAMMER * pgm, unsigned char *msg, + size_t maxsize) +{ + return -1; + // int rv; + // unsigned char *jtagmsg; + // void *mycookie; + + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // rv = jtagmkII_recv(pgm, &jtagmsg); + // pgm->cookie = mycookie; + // if (rv <= 0) { + // avrdude_message(MSG_INFO, "%s: stk500v2_jtagmkII_recv(): error in jtagmkII_recv()\n", + // progname); + // return -1; + // } + // if (rv - 1 > maxsize) { + // avrdude_message(MSG_INFO, "%s: stk500v2_jtagmkII_recv(): got %u bytes, have only room for %u bytes\n", + // progname, (unsigned)rv - 1, (unsigned)maxsize); + // rv = maxsize; + // } + // switch (jtagmsg[0]) { + // case RSP_SPI_DATA: + // break; + // case RSP_FAILED: + // avrdude_message(MSG_INFO, "%s: stk500v2_jtagmkII_recv(): failed\n", + // progname); + // return -1; + // case RSP_ILLEGAL_MCU_STATE: + // avrdude_message(MSG_INFO, "%s: stk500v2_jtagmkII_recv(): illegal MCU state\n", + // progname); + // return -1; + // default: + // avrdude_message(MSG_INFO, "%s: stk500v2_jtagmkII_recv(): unknown status %d\n", + // progname, jtagmsg[0]); + // return -1; + // } + // memcpy(msg, jtagmsg + 1, rv - 1); + // return rv; +} + +static int stk500v2_jtag3_recv(PROGRAMMER * pgm, unsigned char *msg, + size_t maxsize) +{ + return -1; + // int rv; + // unsigned char *jtagmsg; + // void *mycookie; + + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // rv = jtag3_recv(pgm, &jtagmsg); + // pgm->cookie = mycookie; + // if (rv <= 0) { + // avrdude_message(MSG_INFO, "%s: stk500v2_jtag3_recv(): error in jtagmkII_recv()\n", + // progname); + // return -1; + // } + // /* Getting more data than expected is a normal case for the EDBG + // implementation of JTAGICE3, as they always request a full 512 + // octets from the ICE. Thus, only complain at high verbose + // levels. */ + // if (rv - 1 > maxsize) { + // avrdude_message(MSG_DEBUG, "%s: stk500v2_jtag3_recv(): got %u bytes, have only room for %u bytes\n", + // progname, (unsigned)rv - 1, (unsigned)maxsize); + // rv = maxsize; + // } + // if (jtagmsg[0] != SCOPE_AVR_ISP) { + // avrdude_message(MSG_INFO, "%s: stk500v2_jtag3_recv(): message is not AVR ISP: 0x%02x\n", + // progname, jtagmsg[0]); + // free(jtagmsg); + // return -1; + // } + // memcpy(msg, jtagmsg + 1, rv - 1); + // free(jtagmsg); + // return rv; +} + +static int stk500v2_recv(PROGRAMMER * pgm, unsigned char *msg, size_t maxsize) { + enum states { sINIT, sSTART, sSEQNUM, sSIZE1, sSIZE2, sTOKEN, sDATA, sCSUM, sDONE } state = sSTART; + unsigned int msglen = 0; + unsigned int curlen = 0; + int timeout = 0; + unsigned char c, checksum = 0; + + /* + * The entire timeout handling here is not very consistent, see + * + * https://savannah.nongnu.org/bugs/index.php?43626 + */ + long timeoutval = SERIAL_TIMEOUT; // seconds + struct timeval tv; + double tstart, tnow; + + if (PDATA(pgm)->pgmtype == PGMTYPE_AVRISP_MKII || + PDATA(pgm)->pgmtype == PGMTYPE_STK600) + return stk500v2_recv_mk2(pgm, msg, maxsize); + else if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII) + return stk500v2_jtagmkII_recv(pgm, msg, maxsize); + else if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE3) + return stk500v2_jtag3_recv(pgm, msg, maxsize); + + DEBUG("STK500V2: stk500v2_recv(): "); + + gettimeofday(&tv, NULL); + tstart = tv.tv_sec; + + while ( (state != sDONE ) && (!timeout) ) { + RETURN_IF_CANCEL(); + if (serial_recv(&pgm->fd, &c, 1) < 0) + goto timedout; + DEBUG("0x%02x ",c); + checksum ^= c; + + switch (state) { + case sSTART: + DEBUGRECV("hoping for start token..."); + if (c == MESSAGE_START) { + DEBUGRECV("got it\n"); + checksum = MESSAGE_START; + state = sSEQNUM; + } else + DEBUGRECV("sorry\n"); + break; + case sSEQNUM: + DEBUGRECV("hoping for sequence...\n"); + if (c == PDATA(pgm)->command_sequence) { + DEBUGRECV("got it, incrementing\n"); + state = sSIZE1; + PDATA(pgm)->command_sequence++; + } else { + DEBUGRECV("sorry\n"); + state = sSTART; + } + break; + case sSIZE1: + DEBUGRECV("hoping for size LSB\n"); + msglen = (unsigned)c * 256; + state = sSIZE2; + break; + case sSIZE2: + DEBUGRECV("hoping for size MSB..."); + msglen += (unsigned)c; + DEBUG(" msg is %u bytes\n",msglen); + state = sTOKEN; + break; + case sTOKEN: + if (c == TOKEN) state = sDATA; + else state = sSTART; + break; + case sDATA: + if (curlen < maxsize) { + msg[curlen] = c; + } else { + avrdude_message(MSG_INFO, "%s: stk500v2_recv(): buffer too small, received %d byte into %u byte buffer\n", + progname,curlen,(unsigned int)maxsize); + return -2; + } + if ((curlen == 0) && (msg[0] == ANSWER_CKSUM_ERROR)) { + avrdude_message(MSG_INFO, "%s: stk500v2_recv(): previous packet sent with wrong checksum\n", + progname); + return -3; + } + curlen++; + if (curlen == msglen) state = sCSUM; + break; + case sCSUM: + if (checksum == 0) { + state = sDONE; + } else { + state = sSTART; + avrdude_message(MSG_INFO, "%s: stk500v2_recv(): checksum error\n", + progname); + return -4; + } + break; + default: + avrdude_message(MSG_INFO, "%s: stk500v2_recv(): unknown state\n", + progname); + return -5; + } /* switch */ + + gettimeofday(&tv, NULL); + tnow = tv.tv_sec; + if (tnow-tstart > timeoutval) { // wuff - signed/unsigned/overflow + timedout: + avrdude_message(MSG_INFO, "%s: stk500v2_recv(): timeout\n", + progname); + return -1; + } + + } /* while */ + DEBUG("\n"); + + return (int)(msglen+6); +} + + + +static int stk500v2_getsync_internal(PROGRAMMER * pgm, int retries) { + int tries = 0; + unsigned char buf[1], resp[32]; + int status; + + DEBUG("STK500V2: stk500v2_getsync()\n"); + + if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII || + PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE3) + return 0; + +retry: + tries++; + + RETURN_IF_CANCEL(); + + // send the sync command and see if we can get there + buf[0] = CMD_SIGN_ON; + if (stk500v2_send(pgm, buf, 1) != 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_getsync(): can't communicate with device\n", progname); + return -1; + } + + RETURN_IF_CANCEL(); + + // try to get the response back and see where we got + status = stk500v2_recv(pgm, resp, sizeof(resp)); + + RETURN_IF_CANCEL(); + + // if we got bytes returned, check to see what came back + if (status > 0) { + if ((resp[0] == CMD_SIGN_ON) && (resp[1] == STATUS_CMD_OK) && + (status > 3)) { + // success! + unsigned int siglen = resp[2]; + if (siglen >= strlen("STK500_2") && + memcmp(resp + 3, "STK500_2", strlen("STK500_2")) == 0) { + PDATA(pgm)->pgmtype = PGMTYPE_STK500; + } else if (siglen >= strlen("AVRISP_2") && + memcmp(resp + 3, "AVRISP_2", strlen("AVRISP_2")) == 0) { + PDATA(pgm)->pgmtype = PGMTYPE_AVRISP; + } else if (siglen >= strlen("AVRISP_MK2") && + memcmp(resp + 3, "AVRISP_MK2", strlen("AVRISP_MK2")) == 0) { + PDATA(pgm)->pgmtype = PGMTYPE_AVRISP_MKII; + } else if (siglen >= strlen("STK600") && + memcmp(resp + 3, "STK600", strlen("STK600")) == 0) { + PDATA(pgm)->pgmtype = PGMTYPE_STK600; + } else { + resp[siglen + 3] = 0; + avrdude_message(MSG_NOTICE, "%s: stk500v2_getsync(): got response from unknown " + "programmer %s, assuming STK500\n", + progname, resp + 3); + PDATA(pgm)->pgmtype = PGMTYPE_STK500; + } + avrdude_message(MSG_DEBUG, "%s: stk500v2_getsync(): found %s programmer\n", + progname, pgmname[PDATA(pgm)->pgmtype]); + return 0; + } else { + if (tries > retries) { + avrdude_message(MSG_INFO, "%s: stk500v2_getsync(): can't communicate with device: resp=0x%02x\n", + progname, resp[0]); + return -6; + } else + goto retry; + } + + // or if we got a timeout + } else if (status == -1) { + if (tries > retries) { + avrdude_message(MSG_INFO, "%s: stk500v2_getsync(): timeout communicating with programmer\n", + progname); + return -1; + } else + goto retry; + + // or any other error + } else { + if (tries > retries) { + avrdude_message(MSG_INFO, "%s: stk500v2_getsync(): error communicating with programmer: (%d)\n", + progname,status); + } else + goto retry; + } + + return 0; +} + +int stk500v2_getsync(PROGRAMMER * pgm) { + // This is to avoid applying RETRIES exponentially + return stk500v2_getsync_internal(pgm, RETRIES); +} + +static int stk500v2_command(PROGRAMMER * pgm, unsigned char * buf, + size_t len, size_t maxlen) { + int i; + int tries = 0; + int status; + + DEBUG("STK500V2: stk500v2_command("); + for (i=0;i 0) { + DEBUG(" = %d\n",status); + if (status < 2) { + avrdude_message(MSG_INFO, "%s: stk500v2_command(): short reply\n", progname); + return -1; + } + if (buf[0] == CMD_XPROG_SETMODE || buf[0] == CMD_XPROG) { + /* + * Decode XPROG wrapper errors. + */ + const char *msg; + int i; + + /* + * For CMD_XPROG_SETMODE, the status is returned in buf[1]. + * For CMD_XPROG, buf[1] contains the XPRG_CMD_* command, and + * buf[2] contains the status. + */ + i = buf[0] == CMD_XPROG_SETMODE? 1: 2; + + if (buf[i] != XPRG_ERR_OK) { + switch (buf[i]) { + case XPRG_ERR_FAILED: msg = "Failed"; break; + case XPRG_ERR_COLLISION: msg = "Collision"; break; + case XPRG_ERR_TIMEOUT: msg = "Timeout"; break; + default: msg = "Unknown"; break; + } + avrdude_message(MSG_INFO, "%s: stk500v2_command(): error in %s: %s\n", + progname, + (buf[0] == CMD_XPROG_SETMODE? "CMD_XPROG_SETMODE": "CMD_XPROG"), + msg); + return -1; + } + return 0; + } else { + /* + * Decode STK500v2 errors. + */ + if (buf[1] >= STATUS_CMD_TOUT && buf[1] < 0xa0) { + const char *msg; + char msgbuf[30]; + switch (buf[1]) { + case STATUS_CMD_TOUT: + msg = "Command timed out"; + break; + + case STATUS_RDY_BSY_TOUT: + msg = "Sampling of the RDY/nBSY pin timed out"; + break; + + case STATUS_SET_PARAM_MISSING: + msg = "The `Set Device Parameters' have not been " + "executed in advance of this command"; + + default: + sprintf(msgbuf, "unknown, code 0x%02x", buf[1]); + msg = msgbuf; + break; + } + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: stk500v2_command(): warning: %s\n", + progname, msg); + } + } else if (buf[1] == STATUS_CMD_OK) { + return status; + } else if (buf[1] == STATUS_CMD_FAILED) { + avrdude_message(MSG_INFO, "%s: stk500v2_command(): command failed\n", + progname); + } else if (buf[1] == STATUS_CMD_UNKNOWN) { + avrdude_message(MSG_INFO, "%s: stk500v2_command(): unknown command\n", + progname); + } else { + avrdude_message(MSG_INFO, "%s: stk500v2_command(): unknown status 0x%02x\n", + progname, buf[1]); + } + return -1; + } + } + + // otherwise try to sync up again + status = stk500v2_getsync_internal(pgm, 1); + if (status != 0) { + if (tries > RETRIES) { + avrdude_message(MSG_INFO, "%s: stk500v2_command(): failed miserably to execute command 0x%02x\n", + progname,buf[0]); + return -1; + } else + goto retry; + } + + DEBUG(" = 0\n"); + return 0; +} + +static int stk500v2_cmd(PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res) +{ + unsigned char buf[8]; + int result; + + DEBUG("STK500V2: stk500v2_cmd(%02x,%02x,%02x,%02x)\n",cmd[0],cmd[1],cmd[2],cmd[3]); + + buf[0] = CMD_SPI_MULTI; + buf[1] = 4; + buf[2] = 4; + buf[3] = 0; + buf[4] = cmd[0]; + buf[5] = cmd[1]; + buf[6] = cmd[2]; + buf[7] = cmd[3]; + + result = stk500v2_command(pgm, buf, 8, sizeof(buf)); + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_cmd(): failed to send command\n", + progname); + return -1; + } else if (result < 6) { + avrdude_message(MSG_INFO, "%s: stk500v2_cmd(): short reply, len = %d\n", + progname, result); + return -1; + } + + res[0] = buf[2]; + res[1] = buf[3]; + res[2] = buf[4]; + res[3] = buf[5]; + + return 0; +} + + +static int stk500v2_jtag3_cmd(PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res) +{ + avrdude_message(MSG_INFO, "%s: stk500v2_jtag3_cmd(): Not available in JTAGICE3\n", + progname); + + return -1; +} + + +/* + * issue the 'chip erase' command to the AVR device + */ +static int stk500v2_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + int result; + unsigned char buf[16]; + + if (p->op[AVR_OP_CHIP_ERASE] == NULL) { + avrdude_message(MSG_INFO, "%s: stk500v2_chip_erase: chip erase instruction not defined for part \"%s\"\n", + progname, p->desc); + return -1; + } + + pgm->pgm_led(pgm, ON); + + buf[0] = CMD_CHIP_ERASE_ISP; + buf[1] = p->chip_erase_delay / 1000; + buf[2] = 0; // use delay (?) + avr_set_bits(p->op[AVR_OP_CHIP_ERASE], buf+3); + result = stk500v2_command(pgm, buf, 7, sizeof(buf)); + usleep(p->chip_erase_delay); + pgm->initialize(pgm, p); + + pgm->pgm_led(pgm, OFF); + + return result >= 0? 0: -1; +} + +/* + * issue the 'chip erase' command to the AVR device, generic HV mode + */ +static int stk500hv_chip_erase(PROGRAMMER * pgm, AVRPART * p, enum hvmode mode) +{ + int result; + unsigned char buf[3]; + + pgm->pgm_led(pgm, ON); + + if (mode == PPMODE) { + buf[0] = CMD_CHIP_ERASE_PP; + buf[1] = p->chiperasepulsewidth; + buf[2] = p->chiperasepolltimeout; + } else { + buf[0] = CMD_CHIP_ERASE_HVSP; + buf[1] = p->chiperasepolltimeout; + buf[2] = p->chiperasetime; + } + result = stk500v2_command(pgm, buf, 3, sizeof(buf)); + usleep(p->chip_erase_delay); + pgm->initialize(pgm, p); + + pgm->pgm_led(pgm, OFF); + + return result >= 0? 0: -1; +} + +/* + * issue the 'chip erase' command to the AVR device, parallel mode + */ +static int stk500pp_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + return stk500hv_chip_erase(pgm, p, PPMODE); +} + +/* + * issue the 'chip erase' command to the AVR device, HVSP mode + */ +static int stk500hvsp_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + return stk500hv_chip_erase(pgm, p, HVSPMODE); +} + +static struct +{ + unsigned int state; + const char *description; +} connection_status[] = +{ + { STATUS_CONN_FAIL_MOSI, "MOSI fail" }, + { STATUS_CONN_FAIL_RST, "RST fail" }, + { STATUS_CONN_FAIL_SCK, "SCK fail" }, + { STATUS_TGT_NOT_DETECTED, "Target not detected" }, + { STATUS_TGT_REVERSE_INSERTED, "Target reverse inserted" }, +}; + +/* + * Max length of returned message is the sum of all the description + * strings in the table above, plus 2 characters for separation. + * Currently, this is 76 chars. + */ +static void +stk500v2_translate_conn_status(unsigned char status, char *msg) +{ + size_t i; + int need_comma; + + *msg = 0; + need_comma = 0; + + for (i = 0; + i < sizeof connection_status / sizeof connection_status[0]; + i++) + { + if ((status & connection_status[i].state) != 0) + { + if (need_comma) + strcat(msg, ", "); + strcat(msg, connection_status[i].description); + need_comma = 1; + } + } + if (*msg == 0) + sprintf(msg, "Unknown status 0x%02x", status); +} + + +/* + * issue the 'program enable' command to the AVR device + */ +static int stk500v2_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char buf[16]; + char msg[100]; /* see remarks above about size needed */ + int rv, tries; + + PDATA(pgm)->lastpart = p; + + if (p->op[AVR_OP_PGM_ENABLE] == NULL) { + avrdude_message(MSG_INFO, "%s: stk500v2_program_enable(): program enable instruction not defined for part \"%s\"\n", + progname, p->desc); + return -1; + } + + if (PDATA(pgm)->pgmtype == PGMTYPE_STK500 || + PDATA(pgm)->pgmtype == PGMTYPE_STK600) + /* Activate AVR-style (low active) RESET */ + stk500v2_setparm_real(pgm, PARAM_RESET_POLARITY, 0x01); + + tries = 0; +// retry: + buf[0] = CMD_ENTER_PROGMODE_ISP; + buf[1] = p->timeout; + buf[2] = p->stabdelay; + buf[3] = p->cmdexedelay; + buf[4] = p->synchloops; + buf[5] = p->bytedelay; + buf[6] = p->pollvalue; + buf[7] = p->pollindex; + avr_set_bits(p->op[AVR_OP_PGM_ENABLE], buf+8); + buf[10] = buf[11] = 0; + + rv = stk500v2_command(pgm, buf, 12, sizeof(buf)); + + if (rv < 0) { + switch (PDATA(pgm)->pgmtype) + { + case PGMTYPE_STK600: + case PGMTYPE_AVRISP_MKII: + if (stk500v2_getparm(pgm, PARAM_STATUS_TGT_CONN, &buf[0]) != 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_program_enable(): cannot get connection status\n", + progname); + } else { + stk500v2_translate_conn_status(buf[0], msg); + avrdude_message(MSG_INFO, "%s: stk500v2_program_enable():" + " bad AVRISPmkII connection status: %s\n", + progname, msg); + } + break; + + case PGMTYPE_JTAGICE3: + return -1; + // if (buf[1] == STATUS_CMD_FAILED && + // (p->flags & AVRPART_HAS_DW) != 0) { + // void *mycookie; + // unsigned char cmd[4], *resp; + + // /* Try debugWIRE, and MONCON_DISABLE */ + // avrdude_message(MSG_NOTICE2, "%s: No response in ISP mode, trying debugWIRE\n", + // progname); + + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + + // cmd[0] = PARM3_CONN_DW; + // if (jtag3_setparm(pgm, SCOPE_AVR, 1, PARM3_CONNECTION, cmd, 1) < 0) { + // pgm->cookie = mycookie; + // break; + // } + + // cmd[0] = SCOPE_AVR; + + // cmd[1] = CMD3_SIGN_ON; + // cmd[2] = cmd[3] = 0; + // if (jtag3_command(pgm, cmd, 4, &resp, "AVR sign-on") >= 0) { + // free(resp); + + // cmd[1] = CMD3_START_DW_DEBUG; + // if (jtag3_command(pgm, cmd, 4, &resp, "start DW debug") >= 0) { + // free(resp); + + // cmd[1] = CMD3_MONCON_DISABLE; + // if (jtag3_command(pgm, cmd, 3, &resp, "MonCon disable") >= 0) + // free(resp); + // } + // } + // pgm->cookie = mycookie; + // if (tries++ > 3) { + // avrdude_message(MSG_INFO, "%s: Failed to return from debugWIRE to ISP.\n", + // progname); + // break; + // } + // avrdude_message(MSG_INFO, "%s: Target prepared for ISP, signed off.\n" + // "%s: Now retrying without power-cycling the target.\n", + // progname, progname); + // goto retry; + // } + break; + + default: + /* cannot report anything for other pgmtypes */ + break; + } + } + + return rv; +} + +/* + * issue the 'program enable' command to the AVR device, parallel mode + */ +static int stk500pp_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char buf[16]; + + PDATA(pgm)->lastpart = p; + + buf[0] = CMD_ENTER_PROGMODE_PP; + buf[1] = p->hventerstabdelay; + buf[2] = p->progmodedelay; + buf[3] = p->latchcycles; + buf[4] = p->togglevtg; + buf[5] = p->poweroffdelay; + buf[6] = p->resetdelayms; + buf[7] = p->resetdelayus; + + return stk500v2_command(pgm, buf, 8, sizeof(buf)); +} + +/* + * issue the 'program enable' command to the AVR device, HVSP mode + */ +static int stk500hvsp_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char buf[16]; + + PDATA(pgm)->lastpart = p; + + buf[0] = PDATA(pgm)->pgmtype == PGMTYPE_STK600? + CMD_ENTER_PROGMODE_HVSP_STK600: + CMD_ENTER_PROGMODE_HVSP; + buf[1] = p->hventerstabdelay; + buf[2] = p->hvspcmdexedelay; + buf[3] = p->synchcycles; + buf[4] = p->latchcycles; + buf[5] = p->togglevtg; + buf[6] = p->poweroffdelay; + buf[7] = p->resetdelayms; + buf[8] = p->resetdelayus; + + return stk500v2_command(pgm, buf, 9, sizeof(buf)); +} + + +/* + * initialize the AVR device and prepare it to accept commands + */ +static int stk500v2_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + + LNODEID ln; + AVRMEM * m; + + if ((PDATA(pgm)->pgmtype == PGMTYPE_STK600 || + PDATA(pgm)->pgmtype == PGMTYPE_AVRISP_MKII || + PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII) != 0 + && (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_TPI)) != 0) { + /* + * This is an ATxmega device, must use XPROG protocol for the + * remaining actions. + */ + if ((p->flags & AVRPART_HAS_PDI) != 0) { + /* + * Find out where the border between application and boot area + * is. + */ + AVRMEM *bootmem = avr_locate_mem(p, "boot"); + AVRMEM *flashmem = avr_locate_mem(p, "flash"); + if (bootmem == NULL || flashmem == NULL) { + avrdude_message(MSG_INFO, "%s: stk500v2_initialize(): Cannot locate \"flash\" and \"boot\" memories in description\n", + progname); + } else { + PDATA(pgm)->boot_start = bootmem->offset - flashmem->offset; + } + } + stk600_setup_xprog(pgm); + } else { + stk600_setup_isp(pgm); + } + + /* + * Examine the avrpart's memory definitions, and initialize the page + * caches. For devices/memory that are not page oriented, treat + * them as page size 1 for EEPROM, and 2 for flash. + */ + PDATA(pgm)->flash_pagesize = 2; + PDATA(pgm)->eeprom_pagesize = 1; + for (ln = lfirst(p->mem); ln; ln = lnext(ln)) { + m = ldata(ln); + if (strcmp(m->desc, "flash") == 0) { + if (m->page_size > 0) { + if (m->page_size > 256) + PDATA(pgm)->flash_pagesize = 256; + else + PDATA(pgm)->flash_pagesize = m->page_size; + } + } else if (strcmp(m->desc, "eeprom") == 0) { + if (m->page_size > 0) + PDATA(pgm)->eeprom_pagesize = m->page_size; + } + } + free(PDATA(pgm)->flash_pagecache); + free(PDATA(pgm)->eeprom_pagecache); + if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: stk500v2_initialize(): Out of memory\n", + progname); + return -1; + } + if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: stk500v2_initialize(): Out of memory\n", + progname); + free(PDATA(pgm)->flash_pagecache); + return -1; + } + PDATA(pgm)->flash_pageaddr = PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + + if (p->flags & AVRPART_IS_AT90S1200) { + /* + * AT90S1200 needs a positive reset pulse after a chip erase. + */ + pgm->disable(pgm); + usleep(10000); + } + return pgm->program_enable(pgm, p); +} + + + +/* + * initialize the AVR device and prepare it to accept commands + */ +static int stk500v2_jtag3_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + return -1; + // unsigned char parm[4], *resp; + // LNODEID ln; + // AVRMEM * m; + // void *mycookie; + + // if ((p->flags & AVRPART_HAS_PDI) || + // (p->flags & AVRPART_HAS_TPI)) { + // avrdude_message(MSG_INFO, "%s: jtag3_initialize(): part %s has no ISP interface\n", + // progname, p->desc); + // return -1; + // } + + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + + // if (p->flags & AVRPART_HAS_DW) + // parm[0] = PARM3_ARCH_TINY; + // else + // parm[0] = PARM3_ARCH_MEGA; + // if (jtag3_setparm(pgm, SCOPE_AVR, 0, PARM3_ARCH, parm, 1) < 0) { + // pgm->cookie = mycookie; + // return -1; + // } + + // parm[0] = PARM3_SESS_PROGRAMMING; + // if (jtag3_setparm(pgm, SCOPE_AVR, 0, PARM3_SESS_PURPOSE, parm, 1) < 0) { + // pgm->cookie = mycookie; + // return -1; + // } + + // parm[0] = PARM3_CONN_ISP; + // if (jtag3_setparm(pgm, SCOPE_AVR, 1, PARM3_CONNECTION, parm, 1) < 0) { + // pgm->cookie = mycookie; + // return -1; + // } + + // parm[0] = SCOPE_AVR_ISP; + // parm[1] = 0x1e; + // jtag3_send(pgm, parm, 2); + + // if (jtag3_recv(pgm, &resp) > 0) + // free(resp); + + // pgm->cookie = mycookie; + + // /* + // * Examine the avrpart's memory definitions, and initialize the page + // * caches. For devices/memory that are not page oriented, treat + // * them as page size 1 for EEPROM, and 2 for flash. + // */ + // PDATA(pgm)->flash_pagesize = 2; + // PDATA(pgm)->eeprom_pagesize = 1; + // for (ln = lfirst(p->mem); ln; ln = lnext(ln)) { + // m = ldata(ln); + // if (strcmp(m->desc, "flash") == 0) { + // if (m->page_size > 0) { + // if (m->page_size > 256) + // PDATA(pgm)->flash_pagesize = 256; + // else + // PDATA(pgm)->flash_pagesize = m->page_size; + // } + // } else if (strcmp(m->desc, "eeprom") == 0) { + // if (m->page_size > 0) + // PDATA(pgm)->eeprom_pagesize = m->page_size; + // } + // } + // free(PDATA(pgm)->flash_pagecache); + // free(PDATA(pgm)->eeprom_pagecache); + // if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) { + // avrdude_message(MSG_INFO, "%s: stk500hv_initialize(): Out of memory\n", + // progname); + // return -1; + // } + // if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { + // avrdude_message(MSG_INFO, "%s: stk500hv_initialize(): Out of memory\n", + // progname); + // free(PDATA(pgm)->flash_pagecache); + // return -1; + // } + // PDATA(pgm)->flash_pageaddr = PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + + // return pgm->program_enable(pgm, p); +} + + +/* + * initialize the AVR device and prepare it to accept commands, generic HV mode + */ +static int stk500hv_initialize(PROGRAMMER * pgm, AVRPART * p, enum hvmode mode) +{ + unsigned char buf[CTL_STACK_SIZE + 1]; + int result; + LNODEID ln; + AVRMEM * m; + + if (p->ctl_stack_type != (mode == PPMODE? CTL_STACK_PP: CTL_STACK_HVSP)) { + avrdude_message(MSG_INFO, "%s: stk500hv_initialize(): " + "%s programming control stack not defined for part \"%s\"\n", + progname, + (mode == PPMODE? "parallel": "high-voltage serial"), + p->desc); + return -1; + } + + buf[0] = CMD_SET_CONTROL_STACK; + memcpy(buf + 1, p->controlstack, CTL_STACK_SIZE); + + result = stk500v2_command(pgm, buf, CTL_STACK_SIZE + 1, sizeof(buf)); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500hv_initalize(): " + "failed to set control stack\n", + progname); + return -1; + } + + /* + * Examine the avrpart's memory definitions, and initialize the page + * caches. For devices/memory that are not page oriented, treat + * them as page size 1 for EEPROM, and 2 for flash. + */ + PDATA(pgm)->flash_pagesize = 2; + PDATA(pgm)->eeprom_pagesize = 1; + for (ln = lfirst(p->mem); ln; ln = lnext(ln)) { + m = ldata(ln); + if (strcmp(m->desc, "flash") == 0) { + if (m->page_size > 0) { + if (m->page_size > 256) + PDATA(pgm)->flash_pagesize = 256; + else + PDATA(pgm)->flash_pagesize = m->page_size; + } + } else if (strcmp(m->desc, "eeprom") == 0) { + if (m->page_size > 0) + PDATA(pgm)->eeprom_pagesize = m->page_size; + } + } + free(PDATA(pgm)->flash_pagecache); + free(PDATA(pgm)->eeprom_pagecache); + if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: stk500hv_initialize(): Out of memory\n", + progname); + return -1; + } + if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { + avrdude_message(MSG_INFO, "%s: stk500hv_initialize(): Out of memory\n", + progname); + free(PDATA(pgm)->flash_pagecache); + return -1; + } + PDATA(pgm)->flash_pageaddr = PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + + return pgm->program_enable(pgm, p); +} + +/* + * initialize the AVR device and prepare it to accept commands, PP mode + */ +static int stk500pp_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + return stk500hv_initialize(pgm, p, PPMODE); +} + +/* + * initialize the AVR device and prepare it to accept commands, HVSP mode + */ +static int stk500hvsp_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + return stk500hv_initialize(pgm, p, HVSPMODE); +} + +static void stk500v2_jtag3_disable(PROGRAMMER * pgm) +{ + unsigned char buf[16]; + int result; + + free(PDATA(pgm)->flash_pagecache); + PDATA(pgm)->flash_pagecache = NULL; + free(PDATA(pgm)->eeprom_pagecache); + PDATA(pgm)->eeprom_pagecache = NULL; + + buf[0] = CMD_LEAVE_PROGMODE_ISP; + buf[1] = 1; // preDelay; + buf[2] = 1; // postDelay; + + result = stk500v2_command(pgm, buf, 3, sizeof(buf)); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_disable(): failed to leave programming mode\n", + progname); + } + + return; +} + +static void stk500v2_disable(PROGRAMMER * pgm) +{ + unsigned char buf[16]; + int result; + + buf[0] = CMD_LEAVE_PROGMODE_ISP; + buf[1] = 1; // preDelay; + buf[2] = 1; // postDelay; + + result = stk500v2_command(pgm, buf, 3, sizeof(buf)); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_disable(): failed to leave programming mode\n", + progname); + } + + return; +} + +/* + * Leave programming mode, generic HV mode + */ +static void stk500hv_disable(PROGRAMMER * pgm, enum hvmode mode) +{ + unsigned char buf[16]; + int result; + + free(PDATA(pgm)->flash_pagecache); + PDATA(pgm)->flash_pagecache = NULL; + free(PDATA(pgm)->eeprom_pagecache); + PDATA(pgm)->eeprom_pagecache = NULL; + + buf[0] = mode == PPMODE? CMD_LEAVE_PROGMODE_PP: + (PDATA(pgm)->pgmtype == PGMTYPE_STK600? + CMD_LEAVE_PROGMODE_HVSP_STK600: + CMD_LEAVE_PROGMODE_HVSP); + buf[1] = 15; // p->hvleavestabdelay; + buf[2] = 15; // p->resetdelay; + + result = stk500v2_command(pgm, buf, 3, sizeof(buf)); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500hv_disable(): " + "failed to leave programming mode\n", + progname); + } + + return; +} + +/* + * Leave programming mode, PP mode + */ +static void stk500pp_disable(PROGRAMMER * pgm) +{ + stk500hv_disable(pgm, PPMODE); +} + +/* + * Leave programming mode, HVSP mode + */ +static void stk500hvsp_disable(PROGRAMMER * pgm) +{ + stk500hv_disable(pgm, HVSPMODE); +} + +static void stk500v2_enable(PROGRAMMER * pgm) +{ + return; +} + + +static int stk500v2_open(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo = { .baud = 115200 }; + + DEBUG("STK500V2: stk500v2_open()\n"); + + if (pgm->baudrate) + pinfo.baud = pgm->baudrate; + + PDATA(pgm)->pgmtype = PGMTYPE_UNKNOWN; + + if(strcasecmp(port, "avrdoper") == 0){ +#if defined(HAVE_LIBUSB) || (defined(WIN32NATIVE) && defined(HAVE_LIBHID)) + serdev = &avrdoper_serdev; + PDATA(pgm)->pgmtype = PGMTYPE_STK500; +#else + avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); + return -1; +#endif + } + + /* + * If the port name starts with "usb", divert the serial routines + * to the USB ones. The serial_open() function for USB overrides + * the meaning of the "baud" parameter to be the USB device ID to + * search for. + */ + if (strncmp(port, "usb", 3) == 0) { +#if defined(HAVE_LIBUSB) + serdev = &usb_serdev_frame; + pinfo.usbinfo.vid = USB_VENDOR_ATMEL; + pinfo.usbinfo.flags = 0; + pinfo.usbinfo.pid = USB_DEVICE_AVRISPMKII; + PDATA(pgm)->pgmtype = PGMTYPE_AVRISP_MKII; + pgm->set_sck_period = stk500v2_set_sck_period_mk2; + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; + pgm->fd.usb.eep = 0; /* no seperate EP for events */ +#else + avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); + return -1; +#endif + } + + strcpy(pgm->port, port); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + stk500v2_drain(pgm, 0); + + stk500v2_getsync(pgm); + + stk500v2_drain(pgm, 0); + + if (pgm->bitclock != 0.0) { + if (pgm->set_sck_period(pgm, pgm->bitclock) != 0) + return -1; + } + + return 0; +} + + +static int stk600_open(PROGRAMMER * pgm, char * port) +{ + union pinfo pinfo = { .baud = 115200 }; + + DEBUG("STK500V2: stk600_open()\n"); + + if (pgm->baudrate) + pinfo.baud = pgm->baudrate; + + PDATA(pgm)->pgmtype = PGMTYPE_UNKNOWN; + + /* + * If the port name starts with "usb", divert the serial routines + * to the USB ones. The serial_open() function for USB overrides + * the meaning of the "baud" parameter to be the USB device ID to + * search for. + */ + if (strncmp(port, "usb", 3) == 0) { +#if defined(HAVE_LIBUSB) + serdev = &usb_serdev_frame; + pinfo.usbinfo.vid = USB_VENDOR_ATMEL; + pinfo.usbinfo.flags = 0; + pinfo.usbinfo.pid = USB_DEVICE_STK600; + PDATA(pgm)->pgmtype = PGMTYPE_STK600; + pgm->set_sck_period = stk600_set_sck_period; + pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; + pgm->fd.usb.rep = USBDEV_BULK_EP_READ_STK600; + pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_STK600; + pgm->fd.usb.eep = 0; /* no seperate EP for events */ +#else + avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); + return -1; +#endif + } + + strcpy(pgm->port, port); + if (serial_open(port, pinfo, &pgm->fd)==-1) { + return -1; + } + + /* + * drain any extraneous input + */ + stk500v2_drain(pgm, 0); + + stk500v2_getsync(pgm); + + stk500v2_drain(pgm, 0); + + if (pgm->bitclock != 0.0) { + if (pgm->set_sck_period(pgm, pgm->bitclock) != 0) + return -1; + } + + return 0; +} + + +static void stk500v2_close(PROGRAMMER * pgm) +{ + DEBUG("STK500V2: stk500v2_close()\n"); + + serial_close(&pgm->fd); + pgm->fd.ifd = -1; +} + + +static int stk500v2_loadaddr(PROGRAMMER * pgm, unsigned int addr) +{ + unsigned char buf[16]; + int result; + + DEBUG("STK500V2: stk500v2_loadaddr(%d)\n",addr); + + buf[0] = CMD_LOAD_ADDRESS; + buf[1] = (addr >> 24) & 0xff; + buf[2] = (addr >> 16) & 0xff; + buf[3] = (addr >> 8) & 0xff; + buf[4] = addr & 0xff; + + result = stk500v2_command(pgm, buf, 5, sizeof(buf)); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_loadaddr(): failed to set load address\n", + progname); + return -1; + } + + return 0; +} + + +/* + * Read a single byte, generic HV mode + */ +static int stk500hv_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value, + enum hvmode mode) +{ + int result, cmdlen = 2; + unsigned char buf[266]; + unsigned long paddr = 0UL, *paddr_ptr = NULL; + unsigned int pagesize = 0, use_ext_addr = 0, addrshift = 0; + unsigned char *cache_ptr = NULL; + + avrdude_message(MSG_NOTICE2, "%s: stk500hv_read_byte(.., %s, 0x%lx, ...)\n", + progname, mem->desc, addr); + + if (strcmp(mem->desc, "flash") == 0) { + buf[0] = mode == PPMODE? CMD_READ_FLASH_PP: CMD_READ_FLASH_HVSP; + cmdlen = 3; + pagesize = PDATA(pgm)->flash_pagesize; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->flash_pageaddr; + cache_ptr = PDATA(pgm)->flash_pagecache; + addrshift = 1; + /* + * If bit 31 is set, this indicates that the following read/write + * operation will be performed on a memory that is larger than + * 64KBytes. This is an indication to STK500 that a load extended + * address must be executed. + */ + if (mem->op[AVR_OP_LOAD_EXT_ADDR] != NULL) { + use_ext_addr = (1U << 31); + } + } else if (strcmp(mem->desc, "eeprom") == 0) { + buf[0] = mode == PPMODE? CMD_READ_EEPROM_PP: CMD_READ_EEPROM_HVSP; + cmdlen = 3; + pagesize = mem->page_size; + if (pagesize == 0) + pagesize = 1; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->eeprom_pageaddr; + cache_ptr = PDATA(pgm)->eeprom_pagecache; + } else if (strcmp(mem->desc, "lfuse") == 0 || + strcmp(mem->desc, "fuse") == 0) { + buf[0] = mode == PPMODE? CMD_READ_FUSE_PP: CMD_READ_FUSE_HVSP; + addr = 0; + } else if (strcmp(mem->desc, "hfuse") == 0) { + buf[0] = mode == PPMODE? CMD_READ_FUSE_PP: CMD_READ_FUSE_HVSP; + addr = 1; + } else if (strcmp(mem->desc, "efuse") == 0) { + buf[0] = mode == PPMODE? CMD_READ_FUSE_PP: CMD_READ_FUSE_HVSP; + addr = 2; + } else if (strcmp(mem->desc, "lock") == 0) { + buf[0] = mode == PPMODE? CMD_READ_LOCK_PP: CMD_READ_LOCK_HVSP; + } else if (strcmp(mem->desc, "calibration") == 0) { + buf[0] = mode == PPMODE? CMD_READ_OSCCAL_PP: CMD_READ_OSCCAL_HVSP; + } else if (strcmp(mem->desc, "signature") == 0) { + buf[0] = mode == PPMODE? CMD_READ_SIGNATURE_PP: CMD_READ_SIGNATURE_HVSP; + } + + /* + * In HV mode, we have to use paged reads for flash and + * EEPROM, and cache the results in a page cache. + * + * Page cache validation is based on "{flash,eeprom}_pageaddr" + * (holding the base address of the most recent cache fill + * operation). This variable is set to (unsigned long)-1L when the + * cache needs to be invalidated. + */ + if (pagesize && paddr == *paddr_ptr) { + *value = cache_ptr[addr & (pagesize - 1)]; + return 0; + } + + if (cmdlen == 3) { + /* long command, fill in # of bytes */ + buf[1] = (pagesize >> 8) & 0xff; + buf[2] = pagesize & 0xff; + + /* flash and EEPROM reads require the load address command */ + if (stk500v2_loadaddr(pgm, use_ext_addr | (paddr >> addrshift)) < 0) + return -1; + } else { + buf[1] = addr; + } + + avrdude_message(MSG_NOTICE2, "%s: stk500hv_read_byte(): Sending read memory command: ", + progname); + + result = stk500v2_command(pgm, buf, cmdlen, sizeof(buf)); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500hv_read_byte(): " + "timeout/error communicating with programmer\n", + progname); + return -1; + } + + if (pagesize) { + *paddr_ptr = paddr; + memcpy(cache_ptr, buf + 2, pagesize); + *value = cache_ptr[addr & (pagesize - 1)]; + } else { + *value = buf[2]; + } + + return 0; +} + +/* + * Read a single byte, PP mode + */ +static int stk500pp_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value) +{ + return stk500hv_read_byte(pgm, p, mem, addr, value, PPMODE); +} + +/* + * Read a single byte, HVSP mode + */ +static int stk500hvsp_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value) +{ + return stk500hv_read_byte(pgm, p, mem, addr, value, HVSPMODE); +} + +/* + * Read a single byte, ISP mode + * + * By now, only used on the JTAGICE3 which does not implement the + * CMD_SPI_MULTI SPI passthrough command. + */ +static int stk500isp_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value) +{ + int result, pollidx; + unsigned char buf[6]; + unsigned long paddr = 0UL, *paddr_ptr = NULL; + unsigned int pagesize = 0; + unsigned char *cache_ptr = NULL; + OPCODE *op; + + avrdude_message(MSG_NOTICE2, "%s: stk500isp_read_byte(.., %s, 0x%lx, ...)\n", + progname, mem->desc, addr); + + if (strcmp(mem->desc, "flash") == 0 || + strcmp(mem->desc, "eeprom") == 0) { + // use paged access, and cache result + if (strcmp(mem->desc, "flash") == 0) { + pagesize = PDATA(pgm)->flash_pagesize; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->flash_pageaddr; + cache_ptr = PDATA(pgm)->flash_pagecache; + } else { + pagesize = mem->page_size; + if (pagesize == 0) + pagesize = 1; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->eeprom_pageaddr; + cache_ptr = PDATA(pgm)->eeprom_pagecache; + } + + if (paddr == *paddr_ptr) { + *value = cache_ptr[addr & (pagesize - 1)]; + return 0; + } + + if (stk500v2_paged_load(pgm, p, mem, pagesize, paddr, pagesize) < 0) + return -1; + + *paddr_ptr = paddr; + memcpy(cache_ptr, &mem->buf[paddr], pagesize); + *value = cache_ptr[addr & (pagesize - 1)]; + + return 0; + } + + if (strcmp(mem->desc, "lfuse") == 0 || + strcmp(mem->desc, "fuse") == 0) { + buf[0] = CMD_READ_FUSE_ISP; + addr = 0; + } else if (strcmp(mem->desc, "hfuse") == 0) { + buf[0] = CMD_READ_FUSE_ISP; + addr = 1; + } else if (strcmp(mem->desc, "efuse") == 0) { + buf[0] = CMD_READ_FUSE_ISP; + addr = 2; + } else if (strcmp(mem->desc, "lock") == 0) { + buf[0] = CMD_READ_LOCK_ISP; + } else if (strcmp(mem->desc, "calibration") == 0) { + buf[0] = CMD_READ_OSCCAL_ISP; + } else if (strcmp(mem->desc, "signature") == 0) { + buf[0] = CMD_READ_SIGNATURE_ISP; + } + + memset(buf + 1, 0, 5); + if ((op = mem->op[AVR_OP_READ]) == NULL) { + avrdude_message(MSG_INFO, "%s: stk500isp_read_byte(): invalid operation AVR_OP_READ on %s memory\n", + progname, mem->desc); + return -1; + } + avr_set_bits(op, buf + 2); + if ((pollidx = avr_get_output_index(op)) == -1) { + avrdude_message(MSG_INFO, "%s: stk500isp_read_byte(): cannot determine pollidx to read %s memory\n", + progname, mem->desc); + pollidx = 3; + } + buf[1] = pollidx + 1; + avr_set_addr(op, buf + 2, addr); + + avrdude_message(MSG_NOTICE2, "%s: stk500isp_read_byte(): Sending read memory command: ", + progname); + + result = stk500v2_command(pgm, buf, 6, sizeof(buf)); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500isp_read_byte(): " + "timeout/error communicating with programmer\n", + progname); + return -1; + } + + *value = buf[2]; + + return 0; +} + +/* + * Write one byte, generic HV mode + */ +static int stk500hv_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data, + enum hvmode mode) +{ + int result, cmdlen, timeout = 0, pulsewidth = 0; + unsigned char buf[266]; + unsigned long paddr = 0UL, *paddr_ptr = NULL; + unsigned int pagesize = 0, use_ext_addr = 0, addrshift = 0; + unsigned char *cache_ptr = NULL; + + avrdude_message(MSG_NOTICE2, "%s: stk500hv_write_byte(.., %s, 0x%lx, ...)\n", + progname, mem->desc, addr); + + if (strcmp(mem->desc, "flash") == 0) { + buf[0] = mode == PPMODE? CMD_PROGRAM_FLASH_PP: CMD_PROGRAM_FLASH_HVSP; + pagesize = PDATA(pgm)->flash_pagesize; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->flash_pageaddr; + cache_ptr = PDATA(pgm)->flash_pagecache; + addrshift = 1; + /* + * If bit 31 is set, this indicates that the following read/write + * operation will be performed on a memory that is larger than + * 64KBytes. This is an indication to STK500 that a load extended + * address must be executed. + */ + if (mem->op[AVR_OP_LOAD_EXT_ADDR] != NULL) { + use_ext_addr = (1U << 31); + } + } else if (strcmp(mem->desc, "eeprom") == 0) { + buf[0] = mode == PPMODE? CMD_PROGRAM_EEPROM_PP: CMD_PROGRAM_EEPROM_HVSP; + pagesize = mem->page_size; + if (pagesize == 0) + pagesize = 1; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->eeprom_pageaddr; + cache_ptr = PDATA(pgm)->eeprom_pagecache; + } else if (strcmp(mem->desc, "lfuse") == 0 || + strcmp(mem->desc, "fuse") == 0) { + buf[0] = mode == PPMODE? CMD_PROGRAM_FUSE_PP: CMD_PROGRAM_FUSE_HVSP; + addr = 0; + pulsewidth = p->programfusepulsewidth; + timeout = p->programfusepolltimeout; + } else if (strcmp(mem->desc, "hfuse") == 0) { + buf[0] = mode == PPMODE? CMD_PROGRAM_FUSE_PP: CMD_PROGRAM_FUSE_HVSP; + addr = 1; + pulsewidth = p->programfusepulsewidth; + timeout = p->programfusepolltimeout; + } else if (strcmp(mem->desc, "efuse") == 0) { + buf[0] = mode == PPMODE? CMD_PROGRAM_FUSE_PP: CMD_PROGRAM_FUSE_HVSP; + addr = 2; + pulsewidth = p->programfusepulsewidth; + timeout = p->programfusepolltimeout; + } else if (strcmp(mem->desc, "lock") == 0) { + buf[0] = mode == PPMODE? CMD_PROGRAM_LOCK_PP: CMD_PROGRAM_LOCK_HVSP; + pulsewidth = p->programlockpulsewidth; + timeout = p->programlockpolltimeout; + } else { + avrdude_message(MSG_INFO, "%s: stk500hv_write_byte(): " + "unsupported memory type: %s\n", + progname, mem->desc); + return -1; + } + + cmdlen = 5 + pagesize; + + /* + * In HV mode, we have to use paged writes for flash and + * EEPROM. As both, flash and EEPROM cells can only be programmed + * from `1' to `0' bits (even EEPROM does not support auto-erase in + * parallel mode), we just pre-fill the page cache with 0xff, so all + * those cells that are outside our current address will remain + * unaffected. + */ + if (pagesize) { + memset(cache_ptr, 0xff, pagesize); + cache_ptr[addr & (pagesize - 1)] = data; + + /* long command, fill in # of bytes */ + buf[1] = (pagesize >> 8) & 0xff; + buf[2] = pagesize & 0xff; + + /* + * Synthesize the mode byte. This is simpler than adding yet + * another parameter to the avrdude.conf file. We calculate the + * bits corresponding to the page size, as explained in AVR068. + * We set bit 7, to indicate this is to actually write the page to + * the target device. We set bit 6 to indicate this is the very + * last page to be programmed, whatever this means -- we just + * pretend we don't know any better. ;-) Bit 0 is set if this is + * a paged memory, which means it has a page size of more than 2. + */ + buf[3] = 0x80 | 0x40; + if (pagesize > 2) { + unsigned int rv = stk500v2_mode_for_pagesize(pagesize); + if (rv == 0) + return -1; + buf[3] |= rv; + buf[3] |= 0x01; + } + buf[4] = mem->delay; + memcpy(buf + 5, cache_ptr, pagesize); + + /* flash and EEPROM reads require the load address command */ + if (stk500v2_loadaddr(pgm, use_ext_addr | (paddr >> addrshift)) < 0) + return -1; + } else { + buf[1] = addr; + buf[2] = data; + if (mode == PPMODE) { + buf[3] = pulsewidth; + buf[4] = timeout; + } else { + buf[3] = timeout; + cmdlen--; + } + } + + avrdude_message(MSG_NOTICE2, "%s: stk500hv_write_byte(): Sending write memory command: ", + progname); + + result = stk500v2_command(pgm, buf, cmdlen, sizeof(buf)); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500hv_write_byte(): " + "timeout/error communicating with programmer\n", + progname); + return -1; + } + + if (pagesize) { + /* Invalidate the page cache. */ + *paddr_ptr = (unsigned long)-1L; + } + + return 0; +} + +/* + * Write one byte, PP mode + */ +static int stk500pp_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + return stk500hv_write_byte(pgm, p, mem, addr, data, PPMODE); +} + +/* + * Write one byte, HVSP mode + */ +static int stk500hvsp_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + return stk500hv_write_byte(pgm, p, mem, addr, data, HVSPMODE); +} + + +/* + * Write one byte, ISP mode + */ +static int stk500isp_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + int result; + unsigned char buf[5]; + unsigned long paddr = 0UL, *paddr_ptr = NULL; + unsigned int pagesize = 0; + unsigned char *cache_ptr = NULL; + OPCODE *op; + + avrdude_message(MSG_NOTICE2, "%s: stk500isp_write_byte(.., %s, 0x%lx, ...)\n", + progname, mem->desc, addr); + + if (strcmp(mem->desc, "flash") == 0 || + strcmp(mem->desc, "eeprom") == 0) { + if (strcmp(mem->desc, "flash") == 0) { + pagesize = PDATA(pgm)->flash_pagesize; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->flash_pageaddr; + cache_ptr = PDATA(pgm)->flash_pagecache; + } else { + pagesize = mem->page_size; + if (pagesize == 0) + pagesize = 1; + paddr = addr & ~(pagesize - 1); + paddr_ptr = &PDATA(pgm)->eeprom_pageaddr; + cache_ptr = PDATA(pgm)->eeprom_pagecache; + } + + /* + * We use paged writes for flash and EEPROM, reading back the + * current page first, modify the byte to write, and write out the + * entire page. + */ + if (stk500v2_paged_load(pgm, p, mem, pagesize, paddr, pagesize) < 0) + return -1; + + memcpy(cache_ptr, mem->buf + paddr, pagesize); + *paddr_ptr = paddr; + cache_ptr[addr & (pagesize - 1)] = data; + memcpy(mem->buf + paddr, cache_ptr, pagesize); + + stk500v2_paged_write(pgm, p, mem, pagesize, paddr, pagesize); + + return 0; + } + + memset(buf, 0, sizeof buf); + if (strcmp(mem->desc, "lfuse") == 0 || + strcmp(mem->desc, "fuse") == 0) { + buf[0] = CMD_PROGRAM_FUSE_ISP; + addr = 0; + } else if (strcmp(mem->desc, "hfuse") == 0) { + buf[0] = CMD_PROGRAM_FUSE_ISP; + addr = 1; + } else if (strcmp(mem->desc, "efuse") == 0) { + buf[0] = CMD_PROGRAM_FUSE_ISP; + addr = 2; + } else if (strcmp(mem->desc, "lock") == 0) { + buf[0] = CMD_PROGRAM_LOCK_ISP; + } else { + avrdude_message(MSG_INFO, "%s: stk500isp_write_byte(): " + "unsupported memory type: %s\n", + progname, mem->desc); + return -1; + } + + if ((op = mem->op[AVR_OP_WRITE]) == NULL) { + avrdude_message(MSG_INFO, "%s: stk500isp_write_byte(): " + "no AVR_OP_WRITE for %s memory\n", + progname, mem->desc); + return -1; + } + + avr_set_bits(op, buf + 1); + avr_set_addr(op, buf + 1, addr); + avr_set_input(op, buf + 1, data); + + avrdude_message(MSG_NOTICE2, "%s: stk500isp_write_byte(): Sending write memory command: ", + progname); + + result = stk500v2_command(pgm, buf, 5, sizeof(buf)); + + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500isp_write_byte(): " + "timeout/error communicating with programmer\n", + progname); + return -1; + } + + /* + * Prevent verification readback to be too fast, see + * https://savannah.nongnu.org/bugs/index.php?42267 + * + * After all, this is just an ugly hack working around some + * brokeness in the Atmel firmware starting with the AVRISPmkII (the + * old JTAGICEmkII isn't affected). Let's hope 10 ms of additional + * delay are good enough for everyone. + */ + usleep(10000); + + return 0; +} + +static int stk500v2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ +static int page = 0; + unsigned int block_size, last_addr, addrshift, use_ext_addr; + unsigned int maxaddr = addr + n_bytes; + unsigned char commandbuf[10]; + unsigned char buf[266]; + unsigned char cmds[4]; + int result; + OPCODE * rop, * wop; + + // Prusa3D workaround for a bug in the USB communication controller. The semicolon character is used as an initial character + // for special command sequences for the USB communication chip. The early releases of the USB communication chip had + // a bug, which produced a 0x0ff character after the semicolon. The patch is to program the semicolons by flashing + // firmware blocks twice: First the low nibbles of semicolons, second the high nibbles of the semicolon characters. + // + // Inside the 2nd round of a firmware block flashing? + bool prusa3d_semicolon_workaround_round2 = false; + // Buffer containing the other nibbles of semicolons to be flashed in the 2nd round. + unsigned char prusa3d_semicolon_workaround_round2_data[256]; + + DEBUG("STK500V2: stk500v2_paged_write(..,%s,%u,%u,%u)\n", + m->desc, page_size, addr, n_bytes); + + if (page_size == 0) page_size = 256; + addrshift = 0; + use_ext_addr = 0; + + // determine which command is to be used + if (strcmp(m->desc, "flash") == 0) { + addrshift = 1; + commandbuf[0] = CMD_PROGRAM_FLASH_ISP; + /* + * If bit 31 is set, this indicates that the following read/write + * operation will be performed on a memory that is larger than + * 64KBytes. This is an indication to STK500 that a load extended + * address must be executed. + */ + if (m->op[AVR_OP_LOAD_EXT_ADDR] != NULL) { + use_ext_addr = (1U << 31); + } + } else if (strcmp(m->desc, "eeprom") == 0) { + commandbuf[0] = CMD_PROGRAM_EEPROM_ISP; + } + commandbuf[4] = m->delay; + + if (addrshift == 0) { + wop = m->op[AVR_OP_WRITE]; + rop = m->op[AVR_OP_READ]; + } + else { + wop = m->op[AVR_OP_WRITE_LO]; + rop = m->op[AVR_OP_READ_LO]; + } + + // if the memory is paged, load the appropriate commands into the buffer + if (m->mode & 0x01) { + commandbuf[3] = m->mode | 0x80; // yes, write the page to flash + + if (m->op[AVR_OP_LOADPAGE_LO] == NULL) { + avrdude_message(MSG_INFO, "%s: stk500v2_paged_write: loadpage instruction not defined for part \"%s\"\n", + progname, p->desc); + return -1; + } + avr_set_bits(m->op[AVR_OP_LOADPAGE_LO], cmds); + commandbuf[5] = cmds[0]; + + if (m->op[AVR_OP_WRITEPAGE] == NULL) { + avrdude_message(MSG_INFO, "%s: stk500v2_paged_write: write page instruction not defined for part \"%s\"\n", + progname, p->desc); + return -1; + } + avr_set_bits(m->op[AVR_OP_WRITEPAGE], cmds); + commandbuf[6] = cmds[0]; + + // otherwise, we need to load different commands in + } + else { + commandbuf[3] = m->mode | 0x80; // yes, write the words to flash + + if (wop == NULL) { + avrdude_message(MSG_INFO, "%s: stk500v2_paged_write: write instruction not defined for part \"%s\"\n", + progname, p->desc); + return -1; + } + avr_set_bits(wop, cmds); + commandbuf[5] = cmds[0]; + commandbuf[6] = 0; + } + + // the read command is common to both methods + if (rop == NULL) { + avrdude_message(MSG_INFO, "%s: stk500v2_paged_write: read instruction not defined for part \"%s\"\n", + progname, p->desc); + return -1; + } + avr_set_bits(rop, cmds); + commandbuf[7] = cmds[0]; + + commandbuf[8] = m->readback[0]; + commandbuf[9] = m->readback[1]; + + last_addr=UINT_MAX; /* impossible address */ + + for (; addr < maxaddr; addr += prusa3d_semicolon_workaround_round2 ? 0 : page_size) { + if ((maxaddr - addr) < page_size) + block_size = maxaddr - addr; + else + block_size = page_size; + + DEBUG("block_size at addr %d is %d\n",addr,block_size); + + memcpy(buf,commandbuf,sizeof(commandbuf)); + + buf[1] = block_size >> 8; + buf[2] = block_size & 0xff; + + if((last_addr==UINT_MAX)||(last_addr+block_size != addr)||prusa3d_semicolon_workaround_round2){ + if (stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift)) < 0) + return -1; + } + last_addr=addr; + + if (prusa3d_semicolon_workaround_round2) { + // printf("Round 2: address %d\r\n", addr); + memcpy(buf+10, prusa3d_semicolon_workaround_round2_data, block_size); + prusa3d_semicolon_workaround_round2 = false; + } else { + for (size_t i = 0; i < block_size; ++ i) { + unsigned char b = m->buf[addr+i]; + if (b == ';') { + // printf("semicolon at %d %d\r\n", addr, i); + prusa3d_semicolon_workaround_round2_data[i] = b | 0x0f0; + b |= 0x0f; + prusa3d_semicolon_workaround_round2 = true; + } else + prusa3d_semicolon_workaround_round2_data[i] = 0x0ff; + buf[i+10] = b; + } + } + + result = stk500v2_command(pgm,buf,block_size+10, sizeof(buf)); + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_paged_write: write command failed\n", + progname); + return -1; + } + } + + return n_bytes; +} + +/* + * Write pages of flash/EEPROM, generic HV mode + */ +static int stk500hv_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes, + enum hvmode mode) +{ + unsigned int block_size, last_addr, addrshift, use_ext_addr; + unsigned int maxaddr = addr + n_bytes; + unsigned char commandbuf[5], buf[266]; + int result; + + DEBUG("STK500V2: stk500hv_paged_write(..,%s,%u,%u)\n", + m->desc, page_size, addr, n_bytes); + + addrshift = 0; + use_ext_addr = 0; + + // determine which command is to be used + if (strcmp(m->desc, "flash") == 0) { + addrshift = 1; + PDATA(pgm)->flash_pageaddr = (unsigned long)-1L; + commandbuf[0] = mode == PPMODE? CMD_PROGRAM_FLASH_PP: CMD_PROGRAM_FLASH_HVSP; + /* + * If bit 31 is set, this indicates that the following read/write + * operation will be performed on a memory that is larger than + * 64KBytes. This is an indication to STK500 that a load extended + * address must be executed. + */ + if (m->op[AVR_OP_LOAD_EXT_ADDR] != NULL) { + use_ext_addr = (1U << 31); + } + } else if (strcmp(m->desc, "eeprom") == 0) { + PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; + commandbuf[0] = mode == PPMODE? CMD_PROGRAM_EEPROM_PP: CMD_PROGRAM_EEPROM_HVSP; + } + /* + * Synthesize the mode byte. This is simpler than adding yet + * another parameter to the avrdude.conf file. We calculate the + * bits corresponding to the page size, as explained in AVR068. We + * set bit 7, to indicate this is to actually write the page to the + * target device. We set bit 6 to indicate this is the very last + * page to be programmed, whatever this means -- we just pretend we + * don't know any better. ;-) Finally, we set bit 0 to say this is + * a paged memory, after all, that's why we got here at all. + */ + commandbuf[3] = 0x80 | 0x40; + if (page_size > 2) { + unsigned int rv = stk500v2_mode_for_pagesize(page_size); + if (rv == 0) + return -1; + commandbuf[3] |= rv; + commandbuf[3] |= 0x01; + } + commandbuf[4] = m->delay; + + if (page_size == 0) page_size = 256; + + last_addr = UINT_MAX; /* impossible address */ + + for (; addr < maxaddr; addr += page_size) { + if ((maxaddr - addr) < page_size) + block_size = maxaddr - addr; + else + block_size = page_size; + + DEBUG("block_size at addr %d is %d\n",addr,block_size); + + memcpy(buf, commandbuf, sizeof(commandbuf)); + + buf[1] = page_size >> 8; + buf[2] = page_size & 0xff; + + if ((last_addr == UINT_MAX) || (last_addr + block_size != addr)) { + if (stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift)) < 0) + return -1; + } + last_addr=addr; + + memcpy(buf + 5, m->buf + addr, block_size); + if (block_size != page_size) + memset(buf + 5 + block_size, 0xff, page_size - block_size); + + result = stk500v2_command(pgm, buf, page_size + 5, sizeof(buf)); + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500hv_paged_write: write command failed\n", + progname); + return -1; + } + } + + return n_bytes; +} + +/* + * Write pages of flash/EEPROM, PP mode + */ +static int stk500pp_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + return stk500hv_paged_write(pgm, p, m, page_size, addr, n_bytes, PPMODE); +} + +/* + * Write pages of flash/EEPROM, HVSP mode + */ +static int stk500hvsp_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + return stk500hv_paged_write(pgm, p, m, page_size, addr, n_bytes, HVSPMODE); +} + +static int stk500v2_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int block_size, hiaddr, addrshift, use_ext_addr; + unsigned int maxaddr = addr + n_bytes; + unsigned char commandbuf[4]; + unsigned char buf[275]; // max buffer size for stk500v2 at this point + unsigned char cmds[4]; + int result; + OPCODE * rop; + + DEBUG("STK500V2: stk500v2_paged_load(..,%s,%u,%u,%u)\n", + m->desc, page_size, addr, n_bytes); + + page_size = m->readsize; + + rop = m->op[AVR_OP_READ]; + + hiaddr = UINT_MAX; + addrshift = 0; + use_ext_addr = 0; + + // determine which command is to be used + if (strcmp(m->desc, "flash") == 0) { + commandbuf[0] = CMD_READ_FLASH_ISP; + rop = m->op[AVR_OP_READ_LO]; + addrshift = 1; + /* + * If bit 31 is set, this indicates that the following read/write + * operation will be performed on a memory that is larger than + * 64KBytes. This is an indication to STK500 that a load extended + * address must be executed. + */ + if (m->op[AVR_OP_LOAD_EXT_ADDR] != NULL) { + use_ext_addr = (1U << 31); + } + } + else if (strcmp(m->desc, "eeprom") == 0) { + commandbuf[0] = CMD_READ_EEPROM_ISP; + } + + // the read command is common to both methods + if (rop == NULL) { + avrdude_message(MSG_INFO, "%s: stk500v2_paged_load: read instruction not defined for part \"%s\"\n", + progname, p->desc); + return -1; + } + avr_set_bits(rop, cmds); + commandbuf[3] = cmds[0]; + + for (; addr < maxaddr; addr += page_size) { + if ((maxaddr - addr) < page_size) + block_size = maxaddr - addr; + else + block_size = page_size; + DEBUG("block_size at addr %d is %d\n",addr,block_size); + + memcpy(buf,commandbuf,sizeof(commandbuf)); + + buf[1] = block_size >> 8; + buf[2] = block_size & 0xff; + + // Ensure a new "load extended address" will be issued + // when crossing a 64 KB boundary in flash. + if (hiaddr != (addr & ~0xFFFF)) { + hiaddr = addr & ~0xFFFF; + if (stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift)) < 0) + return -1; + } + + result = stk500v2_command(pgm,buf,4,sizeof(buf)); + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_paged_load: read command failed\n", + progname); + return -1; + } +#if 0 + for (i=0;ibuf[addr], &buf[2], block_size); + } + + return n_bytes; +} + + +/* + * Read pages of flash/EEPROM, generic HV mode + */ +static int stk500hv_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes, + enum hvmode mode) +{ + unsigned int block_size, hiaddr, addrshift, use_ext_addr; + unsigned int maxaddr = addr + n_bytes; + unsigned char commandbuf[3], buf[266]; + int result; + + DEBUG("STK500V2: stk500hv_paged_load(..,%s,%u,%u,%u)\n", + m->desc, page_size, addr, n_bytes); + + page_size = m->readsize; + + hiaddr = UINT_MAX; + addrshift = 0; + use_ext_addr = 0; + + // determine which command is to be used + if (strcmp(m->desc, "flash") == 0) { + commandbuf[0] = mode == PPMODE? CMD_READ_FLASH_PP: CMD_READ_FLASH_HVSP; + addrshift = 1; + /* + * If bit 31 is set, this indicates that the following read/write + * operation will be performed on a memory that is larger than + * 64KBytes. This is an indication to STK500 that a load extended + * address must be executed. + */ + if (m->op[AVR_OP_LOAD_EXT_ADDR] != NULL) { + use_ext_addr = (1U << 31); + } + } + else if (strcmp(m->desc, "eeprom") == 0) { + commandbuf[0] = mode == PPMODE? CMD_READ_EEPROM_PP: CMD_READ_EEPROM_HVSP; + } + + for (; addr < maxaddr; addr += page_size) { + if ((maxaddr - addr) < page_size) + block_size = maxaddr - addr; + else + block_size = page_size; + DEBUG("block_size at addr %d is %d\n",addr,block_size); + + memcpy(buf, commandbuf, sizeof(commandbuf)); + + buf[1] = block_size >> 8; + buf[2] = block_size & 0xff; + + // Ensure a new "load extended address" will be issued + // when crossing a 64 KB boundary in flash. + if (hiaddr != (addr & ~0xFFFF)) { + hiaddr = addr & ~0xFFFF; + if (stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift)) < 0) + return -1; + } + + result = stk500v2_command(pgm, buf, 3, sizeof(buf)); + if (result < 0) { + avrdude_message(MSG_INFO, "%s: stk500hv_paged_load: read command failed\n", + progname); + return -1; + } +#if 0 + for (i = 0; i < page_size; i++) { + avrdude_message(MSG_INFO, "%02X", buf[2 + i]); + if (i % 16 == 15) avrdude_message(MSG_INFO, "\n"); + } +#endif + + memcpy(&m->buf[addr], &buf[2], block_size); + } + + return n_bytes; +} + +/* + * Read pages of flash/EEPROM, PP mode + */ +static int stk500pp_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + return stk500hv_paged_load(pgm, p, m, page_size, addr, n_bytes, PPMODE); +} + +/* + * Read pages of flash/EEPROM, HVSP mode + */ +static int stk500hvsp_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + return stk500hv_paged_load(pgm, p, m, page_size, addr, n_bytes, HVSPMODE); +} + + +static int stk500v2_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int addr) +{ + avrdude_message(MSG_INFO, "%s: stk500v2_page_erase(): this function must never be called\n", + progname); + return -1; +} + +static int stk500v2_set_vtarget(PROGRAMMER * pgm, double v) +{ + unsigned char uaref, utarg; + + utarg = (unsigned)((v + 0.049) * 10); + + if (stk500v2_getparm(pgm, PARAM_VADJUST, &uaref) != 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_vtarget(): cannot obtain V[aref]\n", + progname); + return -1; + } + + if (uaref > utarg) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_vtarget(): reducing V[aref] from %.1f to %.1f\n", + progname, uaref / 10.0, v); + if (stk500v2_setparm(pgm, PARAM_VADJUST, utarg) + != 0) + return -1; + } + return stk500v2_setparm(pgm, PARAM_VTARGET, utarg); +} + + +static int stk500v2_set_varef(PROGRAMMER * pgm, unsigned int chan /* unused */, + double v) +{ + unsigned char uaref, utarg; + + uaref = (unsigned)((v + 0.049) * 10); + + if (stk500v2_getparm(pgm, PARAM_VTARGET, &utarg) != 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_varef(): cannot obtain V[target]\n", + progname); + return -1; + } + + if (uaref > utarg) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_varef(): V[aref] must not be greater than " + "V[target] = %.1f\n", + progname, utarg / 10.0); + return -1; + } + return stk500v2_setparm(pgm, PARAM_VADJUST, uaref); +} + + +static int stk500v2_set_fosc(PROGRAMMER * pgm, double v) +{ + int fosc; + unsigned char prescale, cmatch; + static unsigned ps[] = { + 1, 8, 32, 64, 128, 256, 1024 + }; + int idx, rc; + + prescale = cmatch = 0; + if (v > 0.0) { + if (v > STK500V2_XTAL / 2) { + const char *unit; + if (v > 1e6) { + v /= 1e6; + unit = "MHz"; + } else if (v > 1e3) { + v /= 1e3; + unit = "kHz"; + } else + unit = "Hz"; + avrdude_message(MSG_INFO, "%s: stk500v2_set_fosc(): f = %.3f %s too high, using %.3f MHz\n", + progname, v, unit, STK500V2_XTAL / 2e6); + fosc = STK500V2_XTAL / 2; + } else + fosc = (unsigned)v; + + for (idx = 0; idx < sizeof(ps) / sizeof(ps[0]); idx++) { + if (fosc >= STK500V2_XTAL / (256 * ps[idx] * 2)) { + /* this prescaler value can handle our frequency */ + prescale = idx + 1; + cmatch = (unsigned)(STK500V2_XTAL / (2 * fosc * ps[idx])) - 1; + break; + } + } + if (idx == sizeof(ps) / sizeof(ps[0])) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_fosc(): f = %u Hz too low, %u Hz min\n", + progname, fosc, STK500V2_XTAL / (256 * 1024 * 2)); + return -1; + } + } + + if ((rc = stk500v2_setparm(pgm, PARAM_OSC_PSCALE, prescale)) != 0 + || (rc = stk500v2_setparm(pgm, PARAM_OSC_CMATCH, cmatch)) != 0) + return rc; + + return 0; +} + +/* The list of SCK frequencies supported by the AVRISP mkII, as listed + * in AVR069 */ +static double avrispmkIIfreqs[] = { + 8000000, 4000000, 2000000, 1000000, 500000, 250000, 125000, + 96386, 89888, 84211, 79208, 74767, 70797, 67227, 64000, + 61069, 58395, 55945, 51613, 49690, 47905, 46243, 43244, + 41885, 39409, 38278, 36200, 34335, 32654, 31129, 29740, + 28470, 27304, 25724, 24768, 23461, 22285, 21221, 20254, + 19371, 18562, 17583, 16914, 16097, 15356, 14520, 13914, + 13224, 12599, 12031, 11511, 10944, 10431, 9963, 9468, + 9081, 8612, 8239, 7851, 7498, 7137, 6809, 6478, 6178, + 5879, 5607, 5359, 5093, 4870, 4633, 4418, 4209, 4019, + 3823, 3645, 3474, 3310, 3161, 3011, 2869, 2734, 2611, + 2484, 2369, 2257, 2152, 2052, 1956, 1866, 1779, 1695, + 1615, 1539, 1468, 1398, 1333, 1271, 1212, 1155, 1101, + 1049, 1000, 953, 909, 866, 826, 787, 750, 715, 682, + 650, 619, 590, 563, 536, 511, 487, 465, 443, 422, + 402, 384, 366, 349, 332, 317, 302, 288, 274, 261, + 249, 238, 226, 216, 206, 196, 187, 178, 170, 162, + 154, 147, 140, 134, 128, 122, 116, 111, 105, 100, + 95.4, 90.9, 86.6, 82.6, 78.7, 75.0, 71.5, 68.2, + 65.0, 61.9, 59.0, 56.3, 53.6, 51.1 +}; + +static int stk500v2_set_sck_period_mk2(PROGRAMMER * pgm, double v) +{ + int i; + + for (i = 0; i < sizeof(avrispmkIIfreqs); i++) { + if (1 / avrispmkIIfreqs[i] >= v) + break; + } + + avrdude_message(MSG_NOTICE2, "Using p = %.2f us for SCK (param = %d)\n", + 1000000 / avrispmkIIfreqs[i], i); + + return stk500v2_setparm(pgm, PARAM_SCK_DURATION, i); +} + +/* + * Return the "mode" value for the parallel and HVSP modes that + * corresponds to the pagesize. + */ +static unsigned int stk500v2_mode_for_pagesize(unsigned int pagesize) +{ + switch (pagesize) + { + case 256: return 0u << 1; + case 2: return 1u << 1; + case 4: return 2u << 1; + case 8: return 3u << 1; + case 16: return 4u << 1; + case 32: return 5u << 1; + case 64: return 6u << 1; + case 128: return 7u << 1; + } + avrdude_message(MSG_INFO, "%s: stk500v2_mode_for_pagesize(): invalid pagesize: %u\n", + progname, pagesize); + return 0; +} + +/* + * See pseudo-code in AVR068 + * + * This algorithm only fits for the STK500 itself. For the (old) + * AVRISP, the resulting ISP clock is only half. While this would be + * easy to fix in the algorithm, we'd need to add another + * configuration flag for this to the config file. Given the old + * AVRISP devices are virtually no longer around (and the AVRISPmkII + * uses a different algorithm below), it's probably not worth the + * hassle. + */ +static int stk500v2_set_sck_period(PROGRAMMER * pgm, double v) +{ + unsigned int d; + unsigned char dur; + double f = 1 / v; + + if (f >= 1.8432E6) + d = 0; + else if (f > 460.8E3) + d = 1; + else if (f > 115.2E3) + d = 2; + else if (f > 57.6E3) + d = 3; + else + d = (unsigned int)ceil(1 / (24 * f / (double)STK500V2_XTAL) - 10.0 / 12.0); + if (d >= 255) + d = 254; + dur = d; + + return stk500v2_setparm(pgm, PARAM_SCK_DURATION, dur); +} + +static double stk500v2_sck_to_us(PROGRAMMER * pgm, unsigned char dur) +{ + double x; + + if (dur == 0) + return 0.5425; + if (dur == 1) + return 2.17; + if (dur == 2) + return 8.68; + if (dur == 3) + return 17.36; + + x = (double)dur + 10.0 / 12.0; + x = 1.0 / x; + x /= 24.0; + x *= (double)STK500V2_XTAL; + return 1E6 / x; +} + + +static int stk600_set_vtarget(PROGRAMMER * pgm, double v) +{ + unsigned char utarg; + unsigned int uaref; + int rv; + + utarg = (unsigned)((v + 0.049) * 10); + + if (stk500v2_getparm2(pgm, PARAM2_AREF0, &uaref) != 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_vtarget(): cannot obtain V[aref][0]\n", + progname); + return -1; + } + + if (uaref > (unsigned)utarg * 10) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_vtarget(): reducing V[aref][0] from %.2f to %.1f\n", + progname, uaref / 100.0, v); + uaref = 10 * (unsigned)utarg; + if (stk500v2_setparm2(pgm, PARAM2_AREF0, uaref) + != 0) + return -1; + } + + if (stk500v2_getparm2(pgm, PARAM2_AREF1, &uaref) != 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_vtarget(): cannot obtain V[aref][1]\n", + progname); + return -1; + } + + if (uaref > (unsigned)utarg * 10) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_vtarget(): reducing V[aref][1] from %.2f to %.1f\n", + progname, uaref / 100.0, v); + uaref = 10 * (unsigned)utarg; + if (stk500v2_setparm2(pgm, PARAM2_AREF1, uaref) + != 0) + return -1; + } + + /* + * Vtarget on the STK600 can only be adjusted while not being in + * programming mode. + */ + if (PDATA(pgm)->lastpart) + pgm->disable(pgm); + rv = stk500v2_setparm(pgm, PARAM_VTARGET, utarg); + if (PDATA(pgm)->lastpart) + pgm->program_enable(pgm, PDATA(pgm)->lastpart); + + return rv; +} + + +static int stk600_set_varef(PROGRAMMER * pgm, unsigned int chan, double v) +{ + unsigned char utarg; + unsigned int uaref; + + uaref = (unsigned)((v + 0.0049) * 100); + + if (stk500v2_getparm(pgm, PARAM_VTARGET, &utarg) != 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_varef(): cannot obtain V[target]\n", + progname); + return -1; + } + + if (uaref > (unsigned)utarg * 10) { + avrdude_message(MSG_INFO, "%s: stk500v2_set_varef(): V[aref] must not be greater than " + "V[target] = %.1f\n", + progname, utarg / 10.0); + return -1; + } + + switch (chan) + { + case 0: + return stk500v2_setparm2(pgm, PARAM2_AREF0, uaref); + + case 1: + return stk500v2_setparm2(pgm, PARAM2_AREF1, uaref); + + default: + avrdude_message(MSG_INFO, "%s: stk500v2_set_varef(): invalid channel %d\n", + progname, chan); + return -1; + } +} + + +static int stk600_set_fosc(PROGRAMMER * pgm, double v) +{ + unsigned int oct, dac; + + oct = 1.443 * log(v / 1039.0); + dac = 2048 - (2078.0 * pow(2, (double)(10 + oct))) / v; + + return stk500v2_setparm2(pgm, PARAM2_CLOCK_CONF, (oct << 12) | (dac << 2)); +} + +static int stk600_set_sck_period(PROGRAMMER * pgm, double v) +{ + unsigned int sck; + + sck = ceil((16e6 / (2 * 1.0 / v)) - 1); + + if (sck >= 4096) + sck = 4095; + + return stk500v2_setparm2(pgm, PARAM2_SCK_DURATION, sck); +} + +static int stk500v2_jtag3_set_sck_period(PROGRAMMER * pgm, double v) +{ + unsigned char value[3]; + unsigned int sck; + + if (v < 1E-6) + sck = 0x400; + else if (v > 1E-3) + sck = 1; + else + sck = 1.0 / (1000.0 * v); + + value[0] = CMD_SET_SCK; + value[1] = sck & 0xff; + value[2] = (sck >> 8) & 0xff; + + if (stk500v2_jtag3_send(pgm, value, 3) < 0) + return -1; + if (stk500v2_jtag3_recv(pgm, value, 3) < 0) + return -1; + return 0; +} + +static int stk500v2_getparm(PROGRAMMER * pgm, unsigned char parm, unsigned char * value) +{ + unsigned char buf[32]; + + buf[0] = CMD_GET_PARAMETER; + buf[1] = parm; + + if (stk500v2_command(pgm, buf, 2, sizeof(buf)) < 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_getparm(): failed to get parameter 0x%02x\n", + progname, parm); + return -1; + } + + *value = buf[2]; + + return 0; +} + +static int stk500v2_setparm_real(PROGRAMMER * pgm, unsigned char parm, unsigned char value) +{ + unsigned char buf[32]; + + buf[0] = CMD_SET_PARAMETER; + buf[1] = parm; + buf[2] = value; + + if (stk500v2_command(pgm, buf, 3, sizeof(buf)) < 0) { + avrdude_message(MSG_INFO, "\n%s: stk500v2_setparm(): failed to set parameter 0x%02x\n", + progname, parm); + return -1; + } + + return 0; +} + +static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char value) +{ + unsigned char current_value; + int res; + + res = stk500v2_getparm(pgm, parm, ¤t_value); + if (res < 0) + avrdude_message(MSG_INFO, "%s: Unable to get parameter 0x%02x\n", progname, parm); + + // don't issue a write if the correct value is already set. + if (value == current_value) { + avrdude_message(MSG_NOTICE2, "%s: Skipping parameter write; parameter value already set.\n", progname); + return 0; + } + + return stk500v2_setparm_real(pgm, parm, value); +} + +static int stk500v2_getparm2(PROGRAMMER * pgm, unsigned char parm, unsigned int * value) +{ + unsigned char buf[32]; + + buf[0] = CMD_GET_PARAMETER; + buf[1] = parm; + + if (stk500v2_command(pgm, buf, 2, sizeof(buf)) < 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_getparm2(): failed to get parameter 0x%02x\n", + progname, parm); + return -1; + } + + *value = ((unsigned)buf[2] << 8) | buf[3]; + + return 0; +} + +static int stk500v2_setparm2(PROGRAMMER * pgm, unsigned char parm, unsigned int value) +{ + unsigned char buf[32]; + + buf[0] = CMD_SET_PARAMETER; + buf[1] = parm; + buf[2] = value >> 8; + buf[3] = value; + + if (stk500v2_command(pgm, buf, 4, sizeof(buf)) < 0) { + avrdude_message(MSG_INFO, "\n%s: stk500v2_setparm2(): failed to set parameter 0x%02x\n", + progname, parm); + return -1; + } + + return 0; +} + +static const char *stk600_get_cardname(const struct carddata *table, + size_t nele, int id) +{ + const struct carddata *cdp; + + if (id == 0xFF) + /* 0xFF means this card is not present at all. */ + return "Not present"; + + for (cdp = table; nele > 0; cdp++, nele--) + if (cdp->id == id) + return cdp->name; + + return "Unknown"; +} + + +static void stk500v2_display(PROGRAMMER * pgm, const char * p) +{ + unsigned char maj, min, hdw, topcard, maj_s1, min_s1, maj_s2, min_s2; + unsigned int rev; + const char *topcard_name, *pgmname; + + switch (PDATA(pgm)->pgmtype) { + case PGMTYPE_UNKNOWN: pgmname = "Unknown"; break; + case PGMTYPE_STK500: pgmname = "STK500"; break; + case PGMTYPE_AVRISP: pgmname = "AVRISP"; break; + case PGMTYPE_AVRISP_MKII: pgmname = "AVRISP mkII"; break; + case PGMTYPE_STK600: pgmname = "STK600"; break; + default: pgmname = "None"; + } + if (PDATA(pgm)->pgmtype != PGMTYPE_JTAGICE_MKII && + PDATA(pgm)->pgmtype != PGMTYPE_JTAGICE3) { + avrdude_message(MSG_INFO, "%sProgrammer Model: %s\n", p, pgmname); + stk500v2_getparm(pgm, PARAM_HW_VER, &hdw); + stk500v2_getparm(pgm, PARAM_SW_MAJOR, &maj); + stk500v2_getparm(pgm, PARAM_SW_MINOR, &min); + avrdude_message(MSG_INFO, "%sHardware Version: %d\n", p, hdw); + avrdude_message(MSG_INFO, "%sFirmware Version Master : %d.%02d\n", p, maj, min); + if (PDATA(pgm)->pgmtype == PGMTYPE_STK600) { + stk500v2_getparm(pgm, PARAM_SW_MAJOR_SLAVE1, &maj_s1); + stk500v2_getparm(pgm, PARAM_SW_MINOR_SLAVE1, &min_s1); + stk500v2_getparm(pgm, PARAM_SW_MAJOR_SLAVE2, &maj_s2); + stk500v2_getparm(pgm, PARAM_SW_MINOR_SLAVE2, &min_s2); + avrdude_message(MSG_INFO, "%sFirmware Version Slave 1: %d.%02d\n", p, maj_s1, min_s1); + avrdude_message(MSG_INFO, "%sFirmware Version Slave 2: %d.%02d\n", p, maj_s2, min_s2); + } + } + + if (PDATA(pgm)->pgmtype == PGMTYPE_STK500) { + stk500v2_getparm(pgm, PARAM_TOPCARD_DETECT, &topcard); + switch (topcard) { + case 0xAA: topcard_name = "STK501"; break; + case 0x55: topcard_name = "STK502"; break; + case 0xFA: topcard_name = "STK503"; break; + case 0xEE: topcard_name = "STK504"; break; + case 0xE4: topcard_name = "STK505"; break; + case 0xDD: topcard_name = "STK520"; break; + default: topcard_name = "Unknown"; break; + } + avrdude_message(MSG_INFO, "%sTopcard : %s\n", p, topcard_name); + } else if (PDATA(pgm)->pgmtype == PGMTYPE_STK600) { + stk500v2_getparm(pgm, PARAM_ROUTINGCARD_ID, &topcard); + avrdude_message(MSG_INFO, "%sRouting card : %s\n", p, + stk600_get_cardname(routing_cards, + sizeof routing_cards / sizeof routing_cards[0], + topcard)); + stk500v2_getparm(pgm, PARAM_SOCKETCARD_ID, &topcard); + avrdude_message(MSG_INFO, "%sSocket card : %s\n", p, + stk600_get_cardname(socket_cards, + sizeof socket_cards / sizeof socket_cards[0], + topcard)); + stk500v2_getparm2(pgm, PARAM2_RC_ID_TABLE_REV, &rev); + avrdude_message(MSG_INFO, "%sRC_ID table rev : %d\n", p, rev); + stk500v2_getparm2(pgm, PARAM2_EC_ID_TABLE_REV, &rev); + avrdude_message(MSG_INFO, "%sEC_ID table rev : %d\n", p, rev); + } + stk500v2_print_parms1(pgm, p); + + return; +} + +static double +f_to_kHz_MHz(double f, const char **unit) +{ + if (f > 1e6) { + f /= 1e6; + *unit = "MHz"; + } else if (f > 1e3) { + f /= 1000; + *unit = "kHz"; + } else + *unit = "Hz"; + + return f; +} + +static void stk500v2_print_parms1(PROGRAMMER * pgm, const char * p) +{ + unsigned char vtarget, vadjust, osc_pscale, osc_cmatch, sck_duration =0; //XXX 0 is not correct, check caller + unsigned int sck_stk600, clock_conf, dac, oct, varef; + unsigned char vtarget_jtag[4]; + int prescale; + double f; + const char *unit; + void *mycookie; + + if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII) { + return; + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // jtagmkII_getparm(pgm, PAR_OCD_VTARGET, vtarget_jtag); + // pgm->cookie = mycookie; + // avrdude_message(MSG_INFO, "%sVtarget : %.1f V\n", p, + // b2_to_u16(vtarget_jtag) / 1000.0); + } else if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE3) { + return; + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VTARGET, vtarget_jtag, 2); + // pgm->cookie = mycookie; + // avrdude_message(MSG_INFO, "%sVtarget : %.1f V\n", p, + // b2_to_u16(vtarget_jtag) / 1000.0); + + } else { + stk500v2_getparm(pgm, PARAM_VTARGET, &vtarget); + avrdude_message(MSG_INFO, "%sVtarget : %.1f V\n", p, vtarget / 10.0); + } + + switch (PDATA(pgm)->pgmtype) { + case PGMTYPE_STK500: + stk500v2_getparm(pgm, PARAM_SCK_DURATION, &sck_duration); + stk500v2_getparm(pgm, PARAM_VADJUST, &vadjust); + stk500v2_getparm(pgm, PARAM_OSC_PSCALE, &osc_pscale); + stk500v2_getparm(pgm, PARAM_OSC_CMATCH, &osc_cmatch); + avrdude_message(MSG_INFO, "%sSCK period : %.1f us\n", p, + stk500v2_sck_to_us(pgm, sck_duration)); + avrdude_message(MSG_INFO, "%sVaref : %.1f V\n", p, vadjust / 10.0); + avrdude_message(MSG_INFO, "%sOscillator : ", p); + if (osc_pscale == 0) + avrdude_message(MSG_INFO, "Off\n"); + else { + prescale = 1; + f = STK500V2_XTAL / 2; + + switch (osc_pscale) { + case 2: prescale = 8; break; + case 3: prescale = 32; break; + case 4: prescale = 64; break; + case 5: prescale = 128; break; + case 6: prescale = 256; break; + case 7: prescale = 1024; break; + } + f /= prescale; + f /= (osc_cmatch + 1); + f = f_to_kHz_MHz(f, &unit); + avrdude_message(MSG_INFO, "%.3f %s\n", f, unit); + } + break; + + case PGMTYPE_AVRISP_MKII: + case PGMTYPE_JTAGICE_MKII: + stk500v2_getparm(pgm, PARAM_SCK_DURATION, &sck_duration); + avrdude_message(MSG_INFO, "%sSCK period : %.2f us\n", p, + (float) 1000000 / avrispmkIIfreqs[sck_duration]); + break; + + case PGMTYPE_JTAGICE3: + { + unsigned char cmd[4]; + + cmd[0] = CMD_GET_SCK; + if (stk500v2_jtag3_send(pgm, cmd, 1) >= 0 && + stk500v2_jtag3_recv(pgm, cmd, 4) >= 2) { + unsigned int sck = cmd[1] | (cmd[2] << 8); + avrdude_message(MSG_INFO, "%sSCK period : %.2f us\n", p, + (float)(1E6 / (1000.0 * sck))); + } + } + break; + + case PGMTYPE_STK600: + stk500v2_getparm2(pgm, PARAM2_AREF0, &varef); + avrdude_message(MSG_INFO, "%sVaref 0 : %.2f V\n", p, varef / 100.0); + stk500v2_getparm2(pgm, PARAM2_AREF1, &varef); + avrdude_message(MSG_INFO, "%sVaref 1 : %.2f V\n", p, varef / 100.0); + stk500v2_getparm2(pgm, PARAM2_SCK_DURATION, &sck_stk600); + avrdude_message(MSG_INFO, "%sSCK period : %.2f us\n", p, + (float) (sck_stk600 + 1) / 8.0); + stk500v2_getparm2(pgm, PARAM2_CLOCK_CONF, &clock_conf); + oct = (clock_conf & 0xf000) >> 12u; + dac = (clock_conf & 0x0ffc) >> 2u; + f = pow(2, (double)oct) * 2078.0 / (2 - (double)dac / 1024.0); + f = f_to_kHz_MHz(f, &unit); + avrdude_message(MSG_INFO, "%sOscillator : %.3f %s\n", + p, f, unit); + break; + + default: + avrdude_message(MSG_INFO, "%sSCK period : %.1f us\n", p, + sck_duration * 8.0e6 / STK500V2_XTAL + 0.05); + break; + } + + return; +} + + +static void stk500v2_print_parms(PROGRAMMER * pgm) +{ + stk500v2_print_parms1(pgm, ""); +} + +static int stk500v2_perform_osccal(PROGRAMMER * pgm) +{ + unsigned char buf[32]; + int rv; + + buf[0] = CMD_OSCCAL; + + rv = stk500v2_command(pgm, buf, 1, sizeof(buf)); + if (rv < 0) { + avrdude_message(MSG_INFO, "%s: stk500v2_perform_osccal(): failed\n", + progname); + return -1; + } + + return 0; +} + +/* + * Wrapper functions for the JTAG ICE mkII in ISP mode. This mode + * uses the normal JTAG ICE mkII packet stream to communicate with the + * ICE, but then encapsulates AVRISP mkII commands using + * CMND_ISP_PACKET. + */ + +/* + * Open a JTAG ICE mkII in ISP mode. + */ +static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port) +{ + return -1; +// union pinfo pinfo; +// void *mycookie; +// int rv; + +// avrdude_message(MSG_NOTICE2, "%s: stk500v2_jtagmkII_open()\n", progname); + +// /* +// * The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon +// * attaching. If the config file or command-line parameters specify +// * a higher baud rate, we switch to it later on, after establishing +// * the connection with the ICE. +// */ +// pinfo.baud = 19200; + +// /* +// * If the port name starts with "usb", divert the serial routines +// * to the USB ones. The serial_open() function for USB overrides +// * the meaning of the "baud" parameter to be the USB device ID to +// * search for. +// */ +// if (strncmp(port, "usb", 3) == 0) { +// #if defined(HAVE_LIBUSB) +// serdev = &usb_serdev; +// pinfo.usbinfo.vid = USB_VENDOR_ATMEL; +// pinfo.usbinfo.flags = 0; +// pinfo.usbinfo.pid = USB_DEVICE_JTAGICEMKII; +// pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; +// pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; +// pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; +// pgm->fd.usb.eep = 0; /* no seperate EP for events */ +// #else +// avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); +// return -1; +// #endif +// } + +// strcpy(pgm->port, port); +// if (serial_open(port, pinfo, &pgm->fd)==-1) { +// return -1; +// } + +// /* +// * drain any extraneous input +// */ +// stk500v2_drain(pgm, 0); + +// mycookie = pgm->cookie; +// pgm->cookie = PDATA(pgm)->chained_pdata; +// if ((rv = jtagmkII_getsync(pgm, EMULATOR_MODE_SPI)) != 0) { +// if (rv != JTAGII_GETSYNC_FAIL_GRACEFUL) +// avrdude_message(MSG_INFO, "%s: failed to sync with the JTAG ICE mkII in ISP mode\n", +// progname); +// pgm->cookie = mycookie; +// return -1; +// } +// pgm->cookie = mycookie; + +// PDATA(pgm)->pgmtype = PGMTYPE_JTAGICE_MKII; + +// if (pgm->bitclock != 0.0) { +// if (pgm->set_sck_period(pgm, pgm->bitclock) != 0) +// return -1; +// } + +// return 0; +} + + +/* + * Close an AVR Dragon or JTAG ICE mkII in ISP/HVSP/PP mode. + */ +static void stk500v2_jtagmkII_close(PROGRAMMER * pgm) +{ + // void *mycookie; + + // avrdude_message(MSG_NOTICE2, "%s: stk500v2_jtagmkII_close()\n", progname); + + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // jtagmkII_close(pgm); + // pgm->cookie = mycookie; +} + + +/* + * Close JTAGICE3. + */ +static void stk500v2_jtag3_close(PROGRAMMER * pgm) +{ + // void *mycookie; + + // avrdude_message(MSG_NOTICE2, "%s: stk500v2_jtag3_close()\n", progname); + + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // jtag3_close(pgm); + // pgm->cookie = mycookie; +} + + +/* + * Wrapper functions for the AVR Dragon in ISP mode. This mode + * uses the normal JTAG ICE mkII packet stream to communicate with the + * ICE, but then encapsulates AVRISP mkII commands using + * CMND_ISP_PACKET. + */ + +/* + * Open an AVR Dragon in ISP mode. + */ +static int stk500v2_dragon_isp_open(PROGRAMMER * pgm, char * port) +{ + return -1; +// union pinfo pinfo; +// void *mycookie; + +// avrdude_message(MSG_NOTICE2, "%s: stk500v2_dragon_isp_open()\n", progname); + +// /* +// * The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon +// * attaching. If the config file or command-line parameters specify +// * a higher baud rate, we switch to it later on, after establishing +// * the connection with the ICE. +// */ +// pinfo.baud = 19200; + +// /* +// * If the port name starts with "usb", divert the serial routines +// * to the USB ones. The serial_open() function for USB overrides +// * the meaning of the "baud" parameter to be the USB device ID to +// * search for. +// */ +// if (strncmp(port, "usb", 3) == 0) { +// #if defined(HAVE_LIBUSB) +// serdev = &usb_serdev; +// pinfo.usbinfo.vid = USB_VENDOR_ATMEL; +// pinfo.usbinfo.flags = 0; +// pinfo.usbinfo.pid = USB_DEVICE_AVRDRAGON; +// pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; +// pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; +// pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; +// pgm->fd.usb.eep = 0; /* no seperate EP for events */ +// #else +// avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); +// return -1; +// #endif +// } + +// strcpy(pgm->port, port); +// if (serial_open(port, pinfo, &pgm->fd)==-1) { +// return -1; +// } + +// /* +// * drain any extraneous input +// */ +// stk500v2_drain(pgm, 0); + +// mycookie = pgm->cookie; +// pgm->cookie = PDATA(pgm)->chained_pdata; +// if (jtagmkII_getsync(pgm, EMULATOR_MODE_SPI) != 0) { +// avrdude_message(MSG_INFO, "%s: failed to sync with the AVR Dragon in ISP mode\n", +// progname); +// pgm->cookie = mycookie; +// return -1; +// } +// pgm->cookie = mycookie; + +// PDATA(pgm)->pgmtype = PGMTYPE_JTAGICE_MKII; + +// if (pgm->bitclock != 0.0) { +// if (pgm->set_sck_period(pgm, pgm->bitclock) != 0) +// return -1; +// } + +// return 0; +} + + +/* + * Wrapper functions for the AVR Dragon in HV mode. This mode + * uses the normal JTAG ICE mkII packet stream to communicate with the + * ICE, but then encapsulates AVRISP mkII commands using + * CMND_ISP_PACKET. + */ + +/* + * Open an AVR Dragon in HV mode (HVSP or parallel). + */ +static int stk500v2_dragon_hv_open(PROGRAMMER * pgm, char * port) +{ + return -1; +// union pinfo pinfo; +// void *mycookie; + +// avrdude_message(MSG_NOTICE2, "%s: stk500v2_dragon_hv_open()\n", progname); + +// /* +// * The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon +// * attaching. If the config file or command-line parameters specify +// * a higher baud rate, we switch to it later on, after establishing +// * the connection with the ICE. +// */ +// pinfo.baud = 19200; + +// /* +// * If the port name starts with "usb", divert the serial routines +// * to the USB ones. The serial_open() function for USB overrides +// * the meaning of the "baud" parameter to be the USB device ID to +// * search for. +// */ +// if (strncmp(port, "usb", 3) == 0) { +// #if defined(HAVE_LIBUSB) +// serdev = &usb_serdev; +// pinfo.usbinfo.vid = USB_VENDOR_ATMEL; +// pinfo.usbinfo.flags = 0; +// pinfo.usbinfo.pid = USB_DEVICE_AVRDRAGON; +// pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; +// pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; +// pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; +// pgm->fd.usb.eep = 0; /* no seperate EP for events */ +// #else +// avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n"); +// return -1; +// #endif +// } + +// strcpy(pgm->port, port); +// if (serial_open(port, pinfo, &pgm->fd)==-1) { +// return -1; +// } + +// /* +// * drain any extraneous input +// */ +// stk500v2_drain(pgm, 0); + +// mycookie = pgm->cookie; +// pgm->cookie = PDATA(pgm)->chained_pdata; +// if (jtagmkII_getsync(pgm, EMULATOR_MODE_HV) != 0) { +// avrdude_message(MSG_INFO, "%s: failed to sync with the AVR Dragon in HV mode\n", +// progname); +// pgm->cookie = mycookie; +// return -1; +// } +// pgm->cookie = mycookie; + +// PDATA(pgm)->pgmtype = PGMTYPE_JTAGICE_MKII; + +// if (pgm->bitclock != 0.0) { +// if (pgm->set_sck_period(pgm, pgm->bitclock) != 0) +// return -1; +// } + +// return 0; +} + +/* + * Wrapper functions for the JTAGICE3 in ISP mode. This mode + * uses the normal JTAGICE3 packet stream to communicate with the + * ICE, but then encapsulates AVRISP mkII commands using + * scope AVRISP. + */ + +/* + * Open a JTAGICE3 in ISP mode. + */ +static int stk500v2_jtag3_open(PROGRAMMER * pgm, char * port) +{ + return -1; + // void *mycookie; + // int rv; + + // avrdude_message(MSG_NOTICE2, "%s: stk500v2_jtag3_open()\n", progname); + + // if (jtag3_open_common(pgm, port) < 0) + // return -1; + + // mycookie = pgm->cookie; + // pgm->cookie = PDATA(pgm)->chained_pdata; + // if ((rv = jtag3_getsync(pgm, 42)) != 0) { + // if (rv != JTAGII_GETSYNC_FAIL_GRACEFUL) + // avrdude_message(MSG_INFO, "%s: failed to sync with the JTAGICE3 in ISP mode\n", + // progname); + // pgm->cookie = mycookie; + // return -1; + // } + // pgm->cookie = mycookie; + + // PDATA(pgm)->pgmtype = PGMTYPE_JTAGICE3; + + // if (pgm->bitclock != 0.0) { + // if (pgm->set_sck_period(pgm, pgm->bitclock) != 0) + // return -1; + // } + + // return 0; +} + + +/* + * XPROG wrapper + */ +static int stk600_xprog_command(PROGRAMMER * pgm, unsigned char *b, + unsigned int cmdsize, unsigned int responsesize) +{ + unsigned char *newb; + unsigned int s; + int rv; + + if (cmdsize < responsesize) + s = responsesize; + else + s = cmdsize; + + if ((newb = malloc(s + 1)) == 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_cmd(): out of memory\n", + progname); + return -1; + } + + newb[0] = CMD_XPROG; + memcpy(newb + 1, b, cmdsize); + rv = stk500v2_command(pgm, newb, cmdsize + 1, responsesize + 1); + if (rv == 0) { + memcpy(b, newb + 1, responsesize); + } + + free(newb); + + return rv; +} + + +/* + * issue the 'program enable' command to the AVR device, XPROG version + */ +static int stk600_xprog_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char buf[16]; + unsigned int eepagesize = 42; + unsigned int nvm_base; + AVRMEM *mem = NULL; + int use_tpi; + + use_tpi = (p->flags & AVRPART_HAS_TPI) != 0; + + if (!use_tpi) { + if (p->nvm_base == 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_program_enable(): no nvm_base parameter for PDI device\n", + progname); + return -1; + } + if ((mem = avr_locate_mem(p, "eeprom")) != NULL) { + if (mem->page_size == 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_program_enable(): no EEPROM page_size parameter for PDI device\n", + progname); + return -1; + } + eepagesize = mem->page_size; + } + } + + buf[0] = CMD_XPROG_SETMODE; + buf[1] = use_tpi? XPRG_MODE_TPI: XPRG_MODE_PDI; + if (stk500v2_command(pgm, buf, 2, sizeof(buf)) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_program_enable(): CMD_XPROG_SETMODE(XPRG_MODE_%s) failed\n", + progname, use_tpi? "TPI": "PDI"); + return -1; + } + + buf[0] = XPRG_CMD_ENTER_PROGMODE; + if (stk600_xprog_command(pgm, buf, 1, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_program_enable(): XPRG_CMD_ENTER_PROGMODE failed\n", + progname); + return -1; + } + + if (use_tpi) { + /* + * Whatever all that might mean, it matches what AVR Studio + * does. + */ + if (stk500v2_setparm_real(pgm, PARAM_DISCHARGEDELAY, 232) < 0) + return -1; + + buf[0] = XPRG_CMD_SET_PARAM; + buf[1] = XPRG_PARAM_TPI_3; + buf[2] = 51; + if (stk600_xprog_command(pgm, buf, 3, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_program_enable(): XPRG_CMD_SET_PARAM(XPRG_PARAM_TPI_3) failed\n", + progname); + return -1; + } + + buf[0] = XPRG_CMD_SET_PARAM; + buf[1] = XPRG_PARAM_TPI_4; + buf[2] = 50; + if (stk600_xprog_command(pgm, buf, 3, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_program_enable(): XPRG_CMD_SET_PARAM(XPRG_PARAM_TPI_4) failed\n", + progname); + return -1; + } + } else { + buf[0] = XPRG_CMD_SET_PARAM; + buf[1] = XPRG_PARAM_NVMBASE; + nvm_base = p->nvm_base; + /* + * The 0x01000000 appears to be an indication to the programmer + * that the respective address is located in IO (i.e., SRAM) + * memory address space rather than flash. This is not documented + * anywhere in AVR079 but matches what AVR Studio does. + */ + nvm_base |= 0x01000000; + buf[2] = nvm_base >> 24; + buf[3] = nvm_base >> 16; + buf[4] = nvm_base >> 8; + buf[5] = nvm_base; + if (stk600_xprog_command(pgm, buf, 6, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_program_enable(): XPRG_CMD_SET_PARAM(XPRG_PARAM_NVMBASE) failed\n", + progname); + return -1; + } + + if (mem != NULL) { + buf[0] = XPRG_CMD_SET_PARAM; + buf[1] = XPRG_PARAM_EEPPAGESIZE; + buf[2] = eepagesize >> 8; + buf[3] = eepagesize; + if (stk600_xprog_command(pgm, buf, 4, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_program_enable(): XPRG_CMD_SET_PARAM(XPRG_PARAM_EEPPAGESIZE) failed\n", + progname); + return -1; + } + } + } + + return 0; +} + +static unsigned char stk600_xprog_memtype(PROGRAMMER * pgm, unsigned long addr) +{ + if (addr >= PDATA(pgm)->boot_start) + return XPRG_MEM_TYPE_BOOT; + else + return XPRG_MEM_TYPE_APPL; +} + + +static void stk600_xprog_disable(PROGRAMMER * pgm) +{ + unsigned char buf[2]; + + buf[0] = XPRG_CMD_LEAVE_PROGMODE; + if (stk600_xprog_command(pgm, buf, 1, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_program_disable(): XPRG_CMD_LEAVE_PROGMODE failed\n", + progname); + } +} + +static int stk600_xprog_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char data) +{ + unsigned char b[9 + 256]; + int need_erase = 0; + unsigned char write_size = 1; + unsigned char memcode; + + memset(b, 0, sizeof(b)); + + if (strcmp(mem->desc, "flash") == 0) { + memcode = stk600_xprog_memtype(pgm, addr); + } else if (strcmp(mem->desc, "application") == 0 || + strcmp(mem->desc, "apptable") == 0) { + memcode = XPRG_MEM_TYPE_APPL; + } else if (strcmp(mem->desc, "boot") == 0) { + memcode = XPRG_MEM_TYPE_BOOT; + } else if (strcmp(mem->desc, "eeprom") == 0) { + memcode = XPRG_MEM_TYPE_EEPROM; + } else if (strncmp(mem->desc, "lock", strlen("lock")) == 0) { + memcode = XPRG_MEM_TYPE_LOCKBITS; + } else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) { + memcode = XPRG_MEM_TYPE_FUSE; + if (p->flags & AVRPART_HAS_TPI) + /* + * TPI devices need a mystic erase prior to writing their + * fuses. + */ + need_erase = 1; + } else if (strcmp(mem->desc, "usersig") == 0) { + memcode = XPRG_MEM_TYPE_USERSIG; + } else { + avrdude_message(MSG_INFO, "%s: stk600_xprog_write_byte(): unknown memory \"%s\"\n", + progname, mem->desc); + return -1; + } + addr += mem->offset; + + if (need_erase) { + b[0] = XPRG_CMD_ERASE; + b[1] = XPRG_ERASE_CONFIG; + b[2] = mem->offset >> 24; + b[3] = mem->offset >> 16; + b[4] = mem->offset >> 8; + b[5] = mem->offset + 1; + if (stk600_xprog_command(pgm, b, 6, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_chip_erase(): XPRG_CMD_ERASE(XPRG_ERASE_CONFIG) failed\n", + progname); + return -1; + } + } + + if (p->flags & AVRPART_HAS_TPI) { + /* + * Some TPI memories (configuration aka. fuse) require a + * larger write block size. We record that as a blocksize in + * avrdude.conf. + */ + if (mem->blocksize != 0) + write_size = mem->blocksize; + } + + b[0] = XPRG_CMD_WRITE_MEM; + b[1] = memcode; + b[2] = 0; /* pagemode: non-paged write */ + b[3] = addr >> 24; + b[4] = addr >> 16; + b[5] = addr >> 8; + b[6] = addr; + b[7] = 0; + b[8] = write_size; + b[9] = data; + if (stk600_xprog_command(pgm, b, 9 + write_size, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_write_byte(): XPRG_CMD_WRITE_MEM failed\n", + progname); + return -1; + } + return 0; +} + + +static int stk600_xprog_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned long addr, unsigned char * value) +{ + unsigned char b[8]; + + if (strcmp(mem->desc, "flash") == 0) { + b[1] = stk600_xprog_memtype(pgm, addr); + } else if (strcmp(mem->desc, "application") == 0 || + strcmp(mem->desc, "apptable") == 0) { + b[1] = XPRG_MEM_TYPE_APPL; + } else if (strcmp(mem->desc, "boot") == 0) { + b[1] = XPRG_MEM_TYPE_BOOT; + } else if (strcmp(mem->desc, "eeprom") == 0) { + b[1] = XPRG_MEM_TYPE_EEPROM; + } else if (strcmp(mem->desc, "signature") == 0) { + b[1] = XPRG_MEM_TYPE_APPL; + } else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) { + b[1] = XPRG_MEM_TYPE_FUSE; + } else if (strncmp(mem->desc, "lock", strlen("lock")) == 0) { + b[1] = XPRG_MEM_TYPE_LOCKBITS; + } else if (strcmp(mem->desc, "calibration") == 0) { + b[1] = XPRG_MEM_TYPE_FACTORY_CALIBRATION; + } else if (strcmp(mem->desc, "usersig") == 0) { + b[1] = XPRG_MEM_TYPE_USERSIG; + } else { + avrdude_message(MSG_INFO, "%s: stk600_xprog_read_byte(): unknown memory \"%s\"\n", + progname, mem->desc); + return -1; + } + addr += mem->offset; + + b[0] = XPRG_CMD_READ_MEM; + b[2] = addr >> 24; + b[3] = addr >> 16; + b[4] = addr >> 8; + b[5] = addr; + b[6] = 0; + b[7] = 1; + if (stk600_xprog_command(pgm, b, 8, 3) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_read_byte(): XPRG_CMD_READ_MEM failed\n", + progname); + return -1; + } + *value = b[2]; + return 0; +} + + +static int stk600_xprog_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned char *b; + unsigned int offset; + unsigned char memtype; + int n_bytes_orig = n_bytes, dynamic_memtype = 0; + unsigned long use_ext_addr = 0; + + /* + * The XPROG read command supports at most 256 bytes in one + * transfer. + */ + if (page_size > 256) + page_size = 256; /* not really a page size anymore */ + + /* + * Fancy offsets everywhere. + * This is probably what AVR079 means when writing about the + * "TIF address space". + */ + if (strcmp(mem->desc, "flash") == 0) { + memtype = 0; + dynamic_memtype = 1; + if (mem->size > 64 * 1024) + use_ext_addr = (1UL << 31); + } else if (strcmp(mem->desc, "application") == 0 || + strcmp(mem->desc, "apptable") == 0) { + memtype = XPRG_MEM_TYPE_APPL; + if (mem->size > 64 * 1024) + use_ext_addr = (1UL << 31); + } else if (strcmp(mem->desc, "boot") == 0) { + memtype = XPRG_MEM_TYPE_BOOT; + // Do we have to consider the total amount of flash + // instead to decide whether to use extended addressing? + if (mem->size > 64 * 1024) + use_ext_addr = (1UL << 31); + } else if (strcmp(mem->desc, "eeprom") == 0) { + memtype = XPRG_MEM_TYPE_EEPROM; + } else if (strcmp(mem->desc, "signature") == 0) { + memtype = XPRG_MEM_TYPE_APPL; + } else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) { + memtype = XPRG_MEM_TYPE_FUSE; + } else if (strncmp(mem->desc, "lock", strlen("lock")) == 0) { + memtype = XPRG_MEM_TYPE_LOCKBITS; + } else if (strcmp(mem->desc, "calibration") == 0) { + memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION; + } else if (strcmp(mem->desc, "usersig") == 0) { + memtype = XPRG_MEM_TYPE_USERSIG; + } else { + avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_load(): unknown paged memory \"%s\"\n", + progname, mem->desc); + return -1; + } + offset = addr; + addr += mem->offset; + + if ((b = malloc(page_size + 2)) == NULL) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_load(): out of memory\n", + progname); + return -1; + } + + if (stk500v2_loadaddr(pgm, use_ext_addr) < 0) { + free(b); + return -1; + } + + while (n_bytes != 0) { + if (dynamic_memtype) + memtype = stk600_xprog_memtype(pgm, addr - mem->offset); + + b[0] = XPRG_CMD_READ_MEM; + b[1] = memtype; + b[2] = addr >> 24; + b[3] = addr >> 16; + b[4] = addr >> 8; + b[5] = addr; + b[6] = page_size >> 8; + b[7] = page_size; + if (stk600_xprog_command(pgm, b, 8, page_size + 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_load(): XPRG_CMD_READ_MEM failed\n", + progname); + free(b); + return -1; + } + memcpy(mem->buf + offset, b + 2, page_size); + if (n_bytes < page_size) { + n_bytes = page_size; + } + offset += page_size; + addr += page_size; + n_bytes -= page_size; + } + free(b); + + return n_bytes_orig; +} + +static int stk600_xprog_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned char *b; + unsigned int offset; + unsigned char memtype; + int n_bytes_orig = n_bytes, dynamic_memtype = 0; + size_t writesize; + unsigned long use_ext_addr = 0; + unsigned char writemode; + + /* + * The XPROG read command supports at most 256 bytes in one + * transfer. + */ + if (page_size > 512) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_write(): cannot handle page size > 512\n", + progname); + return -1; + } + + /* + * Fancy offsets everywhere. + * This is probably what AVR079 means when writing about the + * "TIF address space". + */ + if (strcmp(mem->desc, "flash") == 0) { + memtype = 0; + dynamic_memtype = 1; + writemode = (1 << XPRG_MEM_WRITE_WRITE); + if (mem->size > 64 * 1024) + use_ext_addr = (1UL << 31); + } else if (strcmp(mem->desc, "application") == 0 || + strcmp(mem->desc, "apptable") == 0) { + memtype = XPRG_MEM_TYPE_APPL; + writemode = (1 << XPRG_MEM_WRITE_WRITE); + if (mem->size > 64 * 1024) + use_ext_addr = (1UL << 31); + } else if (strcmp(mem->desc, "boot") == 0) { + memtype = XPRG_MEM_TYPE_BOOT; + writemode = (1 << XPRG_MEM_WRITE_WRITE); + // Do we have to consider the total amount of flash + // instead to decide whether to use extended addressing? + if (mem->size > 64 * 1024) + use_ext_addr = (1UL << 31); + } else if (strcmp(mem->desc, "eeprom") == 0) { + memtype = XPRG_MEM_TYPE_EEPROM; + writemode = (1 << XPRG_MEM_WRITE_WRITE) | (1 << XPRG_MEM_WRITE_ERASE); + } else if (strcmp(mem->desc, "signature") == 0) { + memtype = XPRG_MEM_TYPE_APPL; + writemode = (1 << XPRG_MEM_WRITE_WRITE); + } else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) { + memtype = XPRG_MEM_TYPE_FUSE; + writemode = (1 << XPRG_MEM_WRITE_WRITE); + } else if (strncmp(mem->desc, "lock", strlen("lock")) == 0) { + memtype = XPRG_MEM_TYPE_LOCKBITS; + writemode = (1 << XPRG_MEM_WRITE_WRITE); + } else if (strcmp(mem->desc, "calibration") == 0) { + memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION; + writemode = (1 << XPRG_MEM_WRITE_WRITE); + } else if (strcmp(mem->desc, "usersig") == 0) { + memtype = XPRG_MEM_TYPE_USERSIG; + writemode = (1 << XPRG_MEM_WRITE_WRITE); + } else { + avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_write(): unknown paged memory \"%s\"\n", + progname, mem->desc); + return -1; + } + offset = addr; + addr += mem->offset; + + if ((b = malloc(page_size + 9)) == NULL) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_write(): out of memory\n", + progname); + return -1; + } + + if (stk500v2_loadaddr(pgm, use_ext_addr) < 0) { + free(b); + return -1; + } + + while (n_bytes != 0) { + + if (dynamic_memtype) + memtype = stk600_xprog_memtype(pgm, addr - mem->offset); + + if (page_size > 256) { + /* + * AVR079 is not quite clear. While it suggests that + * downloading up to 512 bytes (256 words) were OK, it + * obviously isn't -- 512-byte pages on the ATxmega128A1 + * are getting corrupted when written as a single piece. + * It writes random junk somewhere beyond byte 256. + * Splitting it into 256 byte chunks, and only setting the + * erase page / write page bits in the final chunk helps. + */ + if (page_size % 256 != 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_write(): page size not multiple of 256\n", + progname); + free(b); + return -1; + } + unsigned int chunk; + for (chunk = 0; chunk < page_size; chunk += 256) { + if (n_bytes < 256) { + memset(b + 9 + n_bytes, 0xff, 256 - n_bytes); + writesize = n_bytes; + } else { + writesize = 256; + } + b[0] = XPRG_CMD_WRITE_MEM; + b[1] = memtype; + b[2] = writemode; + b[3] = addr >> 24; + b[4] = addr >> 16; + b[5] = addr >> 8; + b[6] = addr; + b[7] = 1; + b[8] = 0; + memcpy(b + 9, mem->buf + offset, writesize); + if (stk600_xprog_command(pgm, b, 256 + 9, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_write(): XPRG_CMD_WRITE_MEM failed\n", + progname); + free(b); + return -1; + } + if (n_bytes < 256) + n_bytes = 256; + + offset += 256; + addr += 256; + n_bytes -= 256; + } + } else { + if (n_bytes < page_size) { + /* + * This can easily happen if the input file was not a + * multiple of the page size. + */ + memset(b + 9 + n_bytes, 0xff, page_size - n_bytes); + writesize = n_bytes; + } else { + writesize = page_size; + } + b[0] = XPRG_CMD_WRITE_MEM; + b[1] = memtype; + b[2] = writemode; + b[3] = addr >> 24; + b[4] = addr >> 16; + b[5] = addr >> 8; + b[6] = addr; + b[7] = page_size >> 8; + b[8] = page_size; + memcpy(b + 9, mem->buf + offset, writesize); + if (stk600_xprog_command(pgm, b, page_size + 9, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_write(): XPRG_CMD_WRITE_MEM failed\n", + progname); + free(b); + return -1; + } + if (n_bytes < page_size) + n_bytes = page_size; + + offset += page_size; + addr += page_size; + n_bytes -= page_size; + } + } + free(b); + + return n_bytes_orig; +} + +static int stk600_xprog_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char b[6]; + AVRMEM *mem; + unsigned int addr = 0; + + if (p->flags & AVRPART_HAS_TPI) { + if ((mem = avr_locate_mem(p, "flash")) == NULL) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_chip_erase(): no FLASH definition found for TPI device\n", + progname); + return -1; + } + addr = mem->offset + 1; + } + + b[0] = XPRG_CMD_ERASE; + b[1] = XPRG_ERASE_CHIP; + b[2] = addr >> 24; + b[3] = addr >> 16; + b[4] = addr >> 8; + b[5] = addr; + if (stk600_xprog_command(pgm, b, 6, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_chip_erase(): XPRG_CMD_ERASE(XPRG_ERASE_CHIP) failed\n", + progname); + return -1; + } + return 0; +} + +static int stk600_xprog_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int addr) +{ + unsigned char b[6]; + + if (strcmp(m->desc, "flash") == 0) { + b[1] = stk600_xprog_memtype(pgm, addr) == XPRG_MEM_TYPE_APPL? + XPRG_ERASE_APP_PAGE: XPRG_ERASE_BOOT_PAGE; + } else if (strcmp(m->desc, "application") == 0 || + strcmp(m->desc, "apptable") == 0) { + b[1] = XPRG_ERASE_APP_PAGE; + } else if (strcmp(m->desc, "boot") == 0) { + b[1] = XPRG_ERASE_BOOT_PAGE; + } else if (strcmp(m->desc, "eeprom") == 0) { + b[1] = XPRG_ERASE_EEPROM_PAGE; + } else if (strcmp(m->desc, "usersig") == 0) { + b[1] = XPRG_ERASE_USERSIG; + } else { + avrdude_message(MSG_INFO, "%s: stk600_xprog_page_erase(): unknown paged memory \"%s\"\n", + progname, m->desc); + return -1; + } + addr += m->offset; + b[0] = XPRG_CMD_ERASE; + b[2] = addr >> 24; + b[3] = addr >> 16; + b[4] = addr >> 8; + b[5] = addr; + if (stk600_xprog_command(pgm, b, 6, 2) < 0) { + avrdude_message(MSG_INFO, "%s: stk600_xprog_page_erase(): XPRG_CMD_ERASE(%d) failed\n", + progname, b[1]); + return -1; + } + return 0; +} + +/* + * Modify pgm's methods for XPROG operation. + */ +static void stk600_setup_xprog(PROGRAMMER * pgm) +{ + pgm->program_enable = stk600_xprog_program_enable; + pgm->disable = stk600_xprog_disable; + pgm->read_byte = stk600_xprog_read_byte; + pgm->write_byte = stk600_xprog_write_byte; + pgm->paged_load = stk600_xprog_paged_load; + pgm->paged_write = stk600_xprog_paged_write; + pgm->page_erase = stk600_xprog_page_erase; + pgm->chip_erase = stk600_xprog_chip_erase; +} + + +/* + * Modify pgm's methods for ISP operation. + */ +static void stk600_setup_isp(PROGRAMMER * pgm) +{ + pgm->program_enable = stk500v2_program_enable; + pgm->disable = stk500v2_disable; + pgm->read_byte = stk500isp_read_byte; + pgm->write_byte = stk500isp_write_byte; + pgm->paged_load = stk500v2_paged_load; + pgm->paged_write = stk500v2_paged_write; + pgm->page_erase = stk500v2_page_erase; + pgm->chip_erase = stk500v2_chip_erase; +} + +const char stk500v2_desc[] = "Atmel STK500 Version 2.x firmware"; + +void stk500v2_initpgm(PROGRAMMER * pgm) +{ + + strcpy(pgm->type, "STK500V2"); + + /* + * mandatory functions + */ + pgm->initialize = stk500v2_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500v2_disable; + pgm->program_enable = stk500v2_program_enable; + pgm->chip_erase = stk500v2_chip_erase; + pgm->cmd = stk500v2_cmd; + pgm->open = stk500v2_open; + pgm->close = stk500v2_close; + pgm->read_byte = stk500isp_read_byte; + pgm->write_byte = stk500isp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500v2_paged_write; + pgm->paged_load = stk500v2_paged_load; + pgm->page_erase = stk500v2_page_erase; + pgm->print_parms = stk500v2_print_parms; + pgm->set_vtarget = stk500v2_set_vtarget; + pgm->set_varef = stk500v2_set_varef; + pgm->set_fosc = stk500v2_set_fosc; + pgm->set_sck_period = stk500v2_set_sck_period; + pgm->perform_osccal = stk500v2_perform_osccal; + pgm->setup = stk500v2_setup; + pgm->teardown = stk500v2_teardown; + pgm->page_size = 256; + pgm->set_upload_size= stk500v2_set_upload_size; +} + +const char stk500pp_desc[] = "Atmel STK500 V2 in parallel programming mode"; + +void stk500pp_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "STK500PP"); + + /* + * mandatory functions + */ + pgm->initialize = stk500pp_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500pp_disable; + pgm->program_enable = stk500pp_program_enable; + pgm->chip_erase = stk500pp_chip_erase; + pgm->open = stk500v2_open; + pgm->close = stk500v2_close; + pgm->read_byte = stk500pp_read_byte; + pgm->write_byte = stk500pp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500pp_paged_write; + pgm->paged_load = stk500pp_paged_load; + pgm->print_parms = stk500v2_print_parms; + pgm->set_vtarget = stk500v2_set_vtarget; + pgm->set_varef = stk500v2_set_varef; + pgm->set_fosc = stk500v2_set_fosc; + pgm->set_sck_period = stk500v2_set_sck_period; + pgm->setup = stk500v2_setup; + pgm->teardown = stk500v2_teardown; + pgm->page_size = 256; +} + +const char stk500hvsp_desc[] = "Atmel STK500 V2 in high-voltage serial programming mode"; + +void stk500hvsp_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "STK500HVSP"); + + /* + * mandatory functions + */ + pgm->initialize = stk500hvsp_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500hvsp_disable; + pgm->program_enable = stk500hvsp_program_enable; + pgm->chip_erase = stk500hvsp_chip_erase; + pgm->open = stk500v2_open; + pgm->close = stk500v2_close; + pgm->read_byte = stk500hvsp_read_byte; + pgm->write_byte = stk500hvsp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500hvsp_paged_write; + pgm->paged_load = stk500hvsp_paged_load; + pgm->print_parms = stk500v2_print_parms; + pgm->set_vtarget = stk500v2_set_vtarget; + pgm->set_varef = stk500v2_set_varef; + pgm->set_fosc = stk500v2_set_fosc; + pgm->set_sck_period = stk500v2_set_sck_period; + pgm->setup = stk500v2_setup; + pgm->teardown = stk500v2_teardown; + pgm->page_size = 256; +} + +const char stk500v2_jtagmkII_desc[] = "Atmel JTAG ICE mkII in ISP mode"; + +void stk500v2_jtagmkII_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "JTAGMKII_ISP"); + + /* + * mandatory functions + */ + pgm->initialize = stk500v2_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500v2_disable; + pgm->program_enable = stk500v2_program_enable; + pgm->chip_erase = stk500v2_chip_erase; + pgm->cmd = stk500v2_cmd; + pgm->open = stk500v2_jtagmkII_open; + pgm->close = stk500v2_jtagmkII_close; + pgm->read_byte = stk500isp_read_byte; + pgm->write_byte = stk500isp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500v2_paged_write; + pgm->paged_load = stk500v2_paged_load; + pgm->page_erase = stk500v2_page_erase; + pgm->print_parms = stk500v2_print_parms; + pgm->set_sck_period = stk500v2_set_sck_period_mk2; + pgm->perform_osccal = stk500v2_perform_osccal; + pgm->setup = stk500v2_jtagmkII_setup; + pgm->teardown = stk500v2_jtagmkII_teardown; + pgm->page_size = 256; +} + +const char stk500v2_dragon_isp_desc[] = "Atmel AVR Dragon in ISP mode"; + +void stk500v2_dragon_isp_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "DRAGON_ISP"); + + /* + * mandatory functions + */ + pgm->initialize = stk500v2_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500v2_disable; + pgm->program_enable = stk500v2_program_enable; + pgm->chip_erase = stk500v2_chip_erase; + pgm->cmd = stk500v2_cmd; + pgm->open = stk500v2_dragon_isp_open; + pgm->close = stk500v2_jtagmkII_close; + pgm->read_byte = stk500isp_read_byte; + pgm->write_byte = stk500isp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500v2_paged_write; + pgm->paged_load = stk500v2_paged_load; + pgm->page_erase = stk500v2_page_erase; + pgm->print_parms = stk500v2_print_parms; + pgm->set_sck_period = stk500v2_set_sck_period_mk2; + pgm->setup = stk500v2_jtagmkII_setup; + pgm->teardown = stk500v2_jtagmkII_teardown; + pgm->page_size = 256; +} + +const char stk500v2_dragon_pp_desc[] = "Atmel AVR Dragon in PP mode"; + +void stk500v2_dragon_pp_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "DRAGON_PP"); + + /* + * mandatory functions + */ + pgm->initialize = stk500pp_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500pp_disable; + pgm->program_enable = stk500pp_program_enable; + pgm->chip_erase = stk500pp_chip_erase; + pgm->open = stk500v2_dragon_hv_open; + pgm->close = stk500v2_jtagmkII_close; + pgm->read_byte = stk500pp_read_byte; + pgm->write_byte = stk500pp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500pp_paged_write; + pgm->paged_load = stk500pp_paged_load; + pgm->print_parms = stk500v2_print_parms; + pgm->set_vtarget = stk500v2_set_vtarget; + pgm->set_varef = stk500v2_set_varef; + pgm->set_fosc = stk500v2_set_fosc; + pgm->set_sck_period = stk500v2_set_sck_period_mk2; + pgm->setup = stk500v2_jtagmkII_setup; + pgm->teardown = stk500v2_jtagmkII_teardown; + pgm->page_size = 256; +} + +const char stk500v2_dragon_hvsp_desc[] = "Atmel AVR Dragon in HVSP mode"; + +void stk500v2_dragon_hvsp_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "DRAGON_HVSP"); + + /* + * mandatory functions + */ + pgm->initialize = stk500hvsp_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500hvsp_disable; + pgm->program_enable = stk500hvsp_program_enable; + pgm->chip_erase = stk500hvsp_chip_erase; + pgm->open = stk500v2_dragon_hv_open; + pgm->close = stk500v2_jtagmkII_close; + pgm->read_byte = stk500hvsp_read_byte; + pgm->write_byte = stk500hvsp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500hvsp_paged_write; + pgm->paged_load = stk500hvsp_paged_load; + pgm->print_parms = stk500v2_print_parms; + pgm->set_vtarget = stk500v2_set_vtarget; + pgm->set_varef = stk500v2_set_varef; + pgm->set_fosc = stk500v2_set_fosc; + pgm->set_sck_period = stk500v2_set_sck_period_mk2; + pgm->setup = stk500v2_jtagmkII_setup; + pgm->teardown = stk500v2_jtagmkII_teardown; + pgm->page_size = 256; +} + +const char stk600_desc[] = "Atmel STK600"; + +void stk600_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "STK600"); + + /* + * mandatory functions + */ + pgm->initialize = stk500v2_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500v2_disable; + pgm->program_enable = stk500v2_program_enable; + pgm->chip_erase = stk500v2_chip_erase; + pgm->cmd = stk500v2_cmd; + pgm->open = stk600_open; + pgm->close = stk500v2_close; + pgm->read_byte = stk500isp_read_byte; + pgm->write_byte = stk500isp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500v2_paged_write; + pgm->paged_load = stk500v2_paged_load; + pgm->page_erase = stk500v2_page_erase; + pgm->print_parms = stk500v2_print_parms; + pgm->set_vtarget = stk600_set_vtarget; + pgm->set_varef = stk600_set_varef; + pgm->set_fosc = stk600_set_fosc; + pgm->set_sck_period = stk600_set_sck_period; + pgm->perform_osccal = stk500v2_perform_osccal; + pgm->setup = stk500v2_setup; + pgm->teardown = stk500v2_teardown; + pgm->page_size = 256; +} + +const char stk600pp_desc[] = "Atmel STK600 in parallel programming mode"; + +void stk600pp_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "STK600PP"); + + /* + * mandatory functions + */ + pgm->initialize = stk500pp_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500pp_disable; + pgm->program_enable = stk500pp_program_enable; + pgm->chip_erase = stk500pp_chip_erase; + pgm->open = stk600_open; + pgm->close = stk500v2_close; + pgm->read_byte = stk500pp_read_byte; + pgm->write_byte = stk500pp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500pp_paged_write; + pgm->paged_load = stk500pp_paged_load; + pgm->print_parms = stk500v2_print_parms; + pgm->set_vtarget = stk600_set_vtarget; + pgm->set_varef = stk600_set_varef; + pgm->set_fosc = stk600_set_fosc; + pgm->set_sck_period = stk600_set_sck_period; + pgm->setup = stk500v2_setup; + pgm->teardown = stk500v2_teardown; + pgm->page_size = 256; +} + +const char stk600hvsp_desc[] = "Atmel STK600 in high-voltage serial programming mode"; + +void stk600hvsp_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "STK600HVSP"); + + /* + * mandatory functions + */ + pgm->initialize = stk500hvsp_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500hvsp_disable; + pgm->program_enable = stk500hvsp_program_enable; + pgm->chip_erase = stk500hvsp_chip_erase; + pgm->open = stk600_open; + pgm->close = stk500v2_close; + pgm->read_byte = stk500hvsp_read_byte; + pgm->write_byte = stk500hvsp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500hvsp_paged_write; + pgm->paged_load = stk500hvsp_paged_load; + pgm->print_parms = stk500v2_print_parms; + pgm->set_vtarget = stk600_set_vtarget; + pgm->set_varef = stk600_set_varef; + pgm->set_fosc = stk600_set_fosc; + pgm->set_sck_period = stk600_set_sck_period; + pgm->setup = stk500v2_setup; + pgm->teardown = stk500v2_teardown; + pgm->page_size = 256; +} + +const char stk500v2_jtag3_desc[] = "Atmel JTAGICE3 in ISP mode"; + +void stk500v2_jtag3_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "JTAG3_ISP"); + + /* + * mandatory functions + */ + pgm->initialize = stk500v2_jtag3_initialize; + pgm->display = stk500v2_display; + pgm->enable = stk500v2_enable; + pgm->disable = stk500v2_jtag3_disable; + pgm->program_enable = stk500v2_program_enable; + pgm->chip_erase = stk500v2_chip_erase; + pgm->cmd = stk500v2_jtag3_cmd; + pgm->open = stk500v2_jtag3_open; + pgm->close = stk500v2_jtag3_close; + pgm->read_byte = stk500isp_read_byte; + pgm->write_byte = stk500isp_write_byte; + + /* + * optional functions + */ + pgm->paged_write = stk500v2_paged_write; + pgm->paged_load = stk500v2_paged_load; + pgm->page_erase = stk500v2_page_erase; + pgm->print_parms = stk500v2_print_parms; + pgm->set_sck_period = stk500v2_jtag3_set_sck_period; + pgm->perform_osccal = stk500v2_perform_osccal; + pgm->setup = stk500v2_jtag3_setup; + pgm->teardown = stk500v2_jtag3_teardown; + pgm->page_size = 256; +} + +void stk500v2_set_upload_size(PROGRAMMER * pgm, int size) +{ + unsigned char buf[16]; + buf[0] = CMD_SET_UPLOAD_SIZE_PRUSA3D; + buf[1] = size & 0xff; + buf[2] = size >> 8; + buf[3] = size >> 16; + stk500v2_command(pgm, buf, 4, sizeof(buf)); +} + diff --git a/xs/src/avrdude/stk500v2.h b/xs/src/avrdude/stk500v2.h new file mode 100644 index 000000000..5c182c59c --- /dev/null +++ b/xs/src/avrdude/stk500v2.h @@ -0,0 +1,65 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2002-2005 Brian S. Dean + * 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 + * 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 stk500v2_h +#define stk500v2_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char stk500v2_desc[]; +extern const char stk500hvsp_desc[]; +extern const char stk500pp_desc[]; +extern const char stk500v2_jtagmkII_desc[]; +extern const char stk500v2_dragon_hvsp_desc[]; +extern const char stk500v2_dragon_isp_desc[]; +extern const char stk500v2_dragon_pp_desc[]; +extern const char stk500v2_jtag3_desc[]; +extern const char stk600_desc[]; +extern const char stk600hvsp_desc[]; +extern const char stk600pp_desc[]; +void stk500v2_initpgm (PROGRAMMER * pgm); +void stk500hvsp_initpgm (PROGRAMMER * pgm); +void stk500pp_initpgm (PROGRAMMER * pgm); +void stk500v2_jtagmkII_initpgm(PROGRAMMER * pgm); +void stk500v2_jtag3_initpgm(PROGRAMMER * pgm); +void stk500v2_dragon_hvsp_initpgm(PROGRAMMER * pgm); +void stk500v2_dragon_isp_initpgm(PROGRAMMER * pgm); +void stk500v2_dragon_pp_initpgm(PROGRAMMER * pgm); +void stk600_initpgm (PROGRAMMER * pgm); +void stk600hvsp_initpgm (PROGRAMMER * pgm); +void stk600pp_initpgm (PROGRAMMER * pgm); + +void stk500v2_setup(PROGRAMMER * pgm); +void stk500v2_teardown(PROGRAMMER * pgm); +int stk500v2_drain(PROGRAMMER * pgm, int display); +int stk500v2_getsync(PROGRAMMER * pgm); + +void stk500v2_set_upload_size(PROGRAMMER * pgm, int size); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/xs/src/avrdude/stk500v2_private.h b/xs/src/avrdude/stk500v2_private.h new file mode 100644 index 000000000..31c1bb23d --- /dev/null +++ b/xs/src/avrdude/stk500v2_private.h @@ -0,0 +1,331 @@ +//**** ATMEL AVR - A P P L I C A T I O N N O T E ************************ +//* +//* Title: AVR068 - STK500 Communication Protocol +//* Filename: command.h +//* Version: 1.0 +//* Last updated: 10.01.2005 +//* +//* Support E-mail: avr@atmel.com +//* +//************************************************************************** + +// *****************[ STK message constants ]*************************** + +#define MESSAGE_START 0x1B //= ESC = 27 decimal +#define TOKEN 0x0E + +// *****************[ STK general command constants ]************************** + +#define CMD_SIGN_ON 0x01 +#define CMD_SET_PARAMETER 0x02 +#define CMD_GET_PARAMETER 0x03 +#define CMD_SET_DEVICE_PARAMETERS 0x04 +#define CMD_OSCCAL 0x05 +#define CMD_LOAD_ADDRESS 0x06 +#define CMD_FIRMWARE_UPGRADE 0x07 +#define CMD_CHECK_TARGET_CONNECTION 0x0D +#define CMD_LOAD_RC_ID_TABLE 0x0E +#define CMD_LOAD_EC_ID_TABLE 0x0F + +// *****************[ STK ISP command constants ]****************************** + +#define CMD_ENTER_PROGMODE_ISP 0x10 +#define CMD_LEAVE_PROGMODE_ISP 0x11 +#define CMD_CHIP_ERASE_ISP 0x12 +#define CMD_PROGRAM_FLASH_ISP 0x13 +#define CMD_READ_FLASH_ISP 0x14 +#define CMD_PROGRAM_EEPROM_ISP 0x15 +#define CMD_READ_EEPROM_ISP 0x16 +#define CMD_PROGRAM_FUSE_ISP 0x17 +#define CMD_READ_FUSE_ISP 0x18 +#define CMD_PROGRAM_LOCK_ISP 0x19 +#define CMD_READ_LOCK_ISP 0x1A +#define CMD_READ_SIGNATURE_ISP 0x1B +#define CMD_READ_OSCCAL_ISP 0x1C +#define CMD_SPI_MULTI 0x1D /* STK500v2, AVRISPmkII, + * JTAGICEmkII */ +#define CMD_SET_SCK 0x1D /* JTAGICE3 */ +#define CMD_GET_SCK 0x1E /* JTAGICE3 */ + +// *****************[ STK PP command constants ]******************************* + +#define CMD_ENTER_PROGMODE_PP 0x20 +#define CMD_LEAVE_PROGMODE_PP 0x21 +#define CMD_CHIP_ERASE_PP 0x22 +#define CMD_PROGRAM_FLASH_PP 0x23 +#define CMD_READ_FLASH_PP 0x24 +#define CMD_PROGRAM_EEPROM_PP 0x25 +#define CMD_READ_EEPROM_PP 0x26 +#define CMD_PROGRAM_FUSE_PP 0x27 +#define CMD_READ_FUSE_PP 0x28 +#define CMD_PROGRAM_LOCK_PP 0x29 +#define CMD_READ_LOCK_PP 0x2A +#define CMD_READ_SIGNATURE_PP 0x2B +#define CMD_READ_OSCCAL_PP 0x2C + +#define CMD_SET_CONTROL_STACK 0x2D + +// *****************[ STK HVSP command constants ]***************************** + +#define CMD_ENTER_PROGMODE_HVSP 0x30 +#define CMD_LEAVE_PROGMODE_HVSP 0x31 +#define CMD_CHIP_ERASE_HVSP 0x32 +#define CMD_PROGRAM_FLASH_HVSP 0x33 +#define CMD_READ_FLASH_HVSP 0x34 +#define CMD_PROGRAM_EEPROM_HVSP 0x35 +#define CMD_READ_EEPROM_HVSP 0x36 +#define CMD_PROGRAM_FUSE_HVSP 0x37 +#define CMD_READ_FUSE_HVSP 0x38 +#define CMD_PROGRAM_LOCK_HVSP 0x39 +#define CMD_READ_LOCK_HVSP 0x3A +#define CMD_READ_SIGNATURE_HVSP 0x3B +#define CMD_READ_OSCCAL_HVSP 0x3C +// These two are redefined since 0x30/0x31 collide +// with the STK600 bootloader. +#define CMD_ENTER_PROGMODE_HVSP_STK600 0x3D +#define CMD_LEAVE_PROGMODE_HVSP_STK600 0x3E + +// *** XPROG command constants *** + +#define CMD_XPROG 0x50 +#define CMD_XPROG_SETMODE 0x51 + + +// *****************[ STK Prusa3D specific command constants ]***************** + +#define CMD_SET_UPLOAD_SIZE_PRUSA3D 0x71 + + +// *** AVR32 JTAG Programming command *** + +#define CMD_JTAG_AVR32 0x80 +#define CMD_ENTER_PROGMODE_JTAG_AVR32 0x81 +#define CMD_LEAVE_PROGMODE_JTAG_AVR32 0x82 + + +// *** AVR JTAG Programming command *** + +#define CMD_JTAG_AVR 0x90 + +// *****************[ STK test command constants ]*************************** + +#define CMD_ENTER_TESTMODE 0x60 +#define CMD_LEAVE_TESTMODE 0x61 +#define CMD_CHIP_WRITE 0x62 +#define CMD_PROGRAM_FLASH_PARTIAL 0x63 +#define CMD_PROGRAM_EEPROM_PARTIAL 0x64 +#define CMD_PROGRAM_SIGNATURE_ROW 0x65 +#define CMD_READ_FLASH_MARGIN 0x66 +#define CMD_READ_EEPROM_MARGIN 0x67 +#define CMD_READ_SIGNATURE_ROW_MARGIN 0x68 +#define CMD_PROGRAM_TEST_FUSE 0x69 +#define CMD_READ_TEST_FUSE 0x6A +#define CMD_PROGRAM_HIDDEN_FUSE_LOW 0x6B +#define CMD_READ_HIDDEN_FUSE_LOW 0x6C +#define CMD_PROGRAM_HIDDEN_FUSE_HIGH 0x6D +#define CMD_READ_HIDDEN_FUSE_HIGH 0x6E +#define CMD_PROGRAM_HIDDEN_FUSE_EXT 0x6F +#define CMD_READ_HIDDEN_FUSE_EXT 0x70 + +// *****************[ STK status constants ]*************************** + +// Success +#define STATUS_CMD_OK 0x00 + +// Warnings +#define STATUS_CMD_TOUT 0x80 +#define STATUS_RDY_BSY_TOUT 0x81 +#define STATUS_SET_PARAM_MISSING 0x82 + +// Errors +#define STATUS_CMD_FAILED 0xC0 +#define STATUS_CKSUM_ERROR 0xC1 +#define STATUS_CMD_UNKNOWN 0xC9 +#define STATUS_CMD_ILLEGAL_PARAMETER 0xCA + +// Status +#define STATUS_ISP_READY 0x00 +#define STATUS_CONN_FAIL_MOSI 0x01 +#define STATUS_CONN_FAIL_RST 0x02 +#define STATUS_CONN_FAIL_SCK 0x04 +#define STATUS_TGT_NOT_DETECTED 0x10 +#define STATUS_TGT_REVERSE_INSERTED 0x20 + +// hw_status +// Bits in status variable +// Bit 0-3: Slave MCU +// Bit 4-7: Master MCU + +#define STATUS_AREF_ERROR 0 +// Set to '1' if AREF is short circuited + +#define STATUS_VTG_ERROR 4 +// Set to '1' if VTG is short circuited + +#define STATUS_RC_CARD_ERROR 5 +// Set to '1' if board id changes when board is powered + +#define STATUS_PROGMODE 6 +// Set to '1' if board is in programming mode + +#define STATUS_POWER_SURGE 7 +// Set to '1' if board draws excessive current + +// *****************[ STK parameter constants ]*************************** +#define PARAM_BUILD_NUMBER_LOW 0x80 /* ??? */ +#define PARAM_BUILD_NUMBER_HIGH 0x81 /* ??? */ +#define PARAM_HW_VER 0x90 +#define PARAM_SW_MAJOR 0x91 +#define PARAM_SW_MINOR 0x92 +#define PARAM_VTARGET 0x94 +#define PARAM_VADJUST 0x95 /* STK500 only */ +#define PARAM_OSC_PSCALE 0x96 /* STK500 only */ +#define PARAM_OSC_CMATCH 0x97 /* STK500 only */ +#define PARAM_SCK_DURATION 0x98 /* STK500 only */ +#define PARAM_TOPCARD_DETECT 0x9A /* STK500 only */ +#define PARAM_STATUS 0x9C /* STK500 only */ +#define PARAM_DATA 0x9D /* STK500 only */ +#define PARAM_RESET_POLARITY 0x9E /* STK500 only, and STK600 FW + * version <= 2.0.3 */ +#define PARAM_CONTROLLER_INIT 0x9F + +/* STK600 parameters */ +#define PARAM_STATUS_TGT_CONN 0xA1 +#define PARAM_DISCHARGEDELAY 0xA4 +#define PARAM_SOCKETCARD_ID 0xA5 +#define PARAM_ROUTINGCARD_ID 0xA6 +#define PARAM_EXPCARD_ID 0xA7 +#define PARAM_SW_MAJOR_SLAVE1 0xA8 +#define PARAM_SW_MINOR_SLAVE1 0xA9 +#define PARAM_SW_MAJOR_SLAVE2 0xAA +#define PARAM_SW_MINOR_SLAVE2 0xAB +#define PARAM_BOARD_ID_STATUS 0xAD +#define PARAM_RESET 0xB4 + +#define PARAM_JTAG_ALLOW_FULL_PAGE_STREAM 0x50 +#define PARAM_JTAG_EEPROM_PAGE_SIZE 0x52 +#define PARAM_JTAG_DAISY_BITS_BEFORE 0x53 +#define PARAM_JTAG_DAISY_BITS_AFTER 0x54 +#define PARAM_JTAG_DAISY_UNITS_BEFORE 0x55 +#define PARAM_JTAG_DAISY_UNITS_AFTER 0x56 + +// *** Parameter constants for 2 byte values *** +#define PARAM2_SCK_DURATION 0xC0 +#define PARAM2_CLOCK_CONF 0xC1 +#define PARAM2_AREF0 0xC2 +#define PARAM2_AREF1 0xC3 + +#define PARAM2_JTAG_FLASH_SIZE_H 0xC5 +#define PARAM2_JTAG_FLASH_SIZE_L 0xC6 +#define PARAM2_JTAG_FLASH_PAGE_SIZE 0xC7 +#define PARAM2_RC_ID_TABLE_REV 0xC8 +#define PARAM2_EC_ID_TABLE_REV 0xC9 + +/* STK600 XPROG section */ +// XPROG modes +#define XPRG_MODE_PDI 0 +#define XPRG_MODE_JTAG 1 +#define XPRG_MODE_TPI 2 + +// XPROG commands +#define XPRG_CMD_ENTER_PROGMODE 0x01 +#define XPRG_CMD_LEAVE_PROGMODE 0x02 +#define XPRG_CMD_ERASE 0x03 +#define XPRG_CMD_WRITE_MEM 0x04 +#define XPRG_CMD_READ_MEM 0x05 +#define XPRG_CMD_CRC 0x06 +#define XPRG_CMD_SET_PARAM 0x07 + +// Memory types +#define XPRG_MEM_TYPE_APPL 1 +#define XPRG_MEM_TYPE_BOOT 2 +#define XPRG_MEM_TYPE_EEPROM 3 +#define XPRG_MEM_TYPE_FUSE 4 +#define XPRG_MEM_TYPE_LOCKBITS 5 +#define XPRG_MEM_TYPE_USERSIG 6 +#define XPRG_MEM_TYPE_FACTORY_CALIBRATION 7 + +// Erase types +#define XPRG_ERASE_CHIP 1 +#define XPRG_ERASE_APP 2 +#define XPRG_ERASE_BOOT 3 +#define XPRG_ERASE_EEPROM 4 +#define XPRG_ERASE_APP_PAGE 5 +#define XPRG_ERASE_BOOT_PAGE 6 +#define XPRG_ERASE_EEPROM_PAGE 7 +#define XPRG_ERASE_USERSIG 8 +#define XPRG_ERASE_CONFIG 9 // TPI only, prepare fuse write + +// Write mode flags +#define XPRG_MEM_WRITE_ERASE 0 +#define XPRG_MEM_WRITE_WRITE 1 + +// CRC types +#define XPRG_CRC_APP 1 +#define XPRG_CRC_BOOT 2 +#define XPRG_CRC_FLASH 3 + +// Error codes +#define XPRG_ERR_OK 0 +#define XPRG_ERR_FAILED 1 +#define XPRG_ERR_COLLISION 2 +#define XPRG_ERR_TIMEOUT 3 + +// XPROG parameters of different sizes +// 4-byte address +#define XPRG_PARAM_NVMBASE 0x01 +// 2-byte page size +#define XPRG_PARAM_EEPPAGESIZE 0x02 +// 1-byte, undocumented TPI param +#define XPRG_PARAM_TPI_3 0x03 +// 1-byte, undocumented TPI param +#define XPRG_PARAM_TPI_4 0x04 + +// *****************[ STK answer constants ]*************************** + +#define ANSWER_CKSUM_ERROR 0xB0 + +/* + * Private data for this programmer. + */ +struct pdata +{ + /* + * See stk500pp_read_byte() for an explanation of the flash and + * EEPROM page caches. + */ + unsigned char *flash_pagecache; + unsigned long flash_pageaddr; + unsigned int flash_pagesize; + + unsigned char *eeprom_pagecache; + unsigned long eeprom_pageaddr; + unsigned int eeprom_pagesize; + + unsigned char command_sequence; + + enum + { + PGMTYPE_UNKNOWN, + PGMTYPE_STK500, + PGMTYPE_AVRISP, + PGMTYPE_AVRISP_MKII, + PGMTYPE_JTAGICE_MKII, + PGMTYPE_STK600, + PGMTYPE_JTAGICE3 + } + pgmtype; + + AVRPART *lastpart; + + /* Start address of Xmega boot area */ + unsigned long boot_start; + + /* + * Chained pdata for the JTAG ICE mkII backend. This is used when + * calling the backend functions for ISP/HVSP/PP programming + * functionality of the JTAG ICE mkII and AVR Dragon. + */ + void *chained_pdata; +}; + diff --git a/xs/src/avrdude/term.c b/xs/src/avrdude/term.c new file mode 100644 index 000000000..012f6f1a5 --- /dev/null +++ b/xs/src/avrdude/term.c @@ -0,0 +1,957 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 "ac_cfg.h" + +#include +#include +#include +#include +#include + +#if defined(HAVE_LIBREADLINE) +#if !defined(WIN32NATIVE) +# include +# include +#endif +#endif + +#include "avrdude.h" +#include "term.h" + +struct command { + char * name; + int (*func)(PROGRAMMER * pgm, struct avrpart * p, int argc, char *argv[]); + char * desc; +}; + + +static int cmd_dump (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_write (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_erase (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_sig (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_part (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_help (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_quit (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_send (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_parms (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_vtarg (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_varef (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_fosc (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_sck (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_spi (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_pgm (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +static int cmd_verbose (PROGRAMMER * pgm, struct avrpart * p, + int argc, char *argv[]); + +struct command cmd[] = { + { "dump", cmd_dump, "dump memory : %s " }, + { "read", cmd_dump, "alias for dump" }, + { "write", cmd_write, "write memory : %s ... " }, + { "erase", cmd_erase, "perform a chip erase" }, + { "sig", cmd_sig, "display device signature bytes" }, + { "part", cmd_part, "display the current part information" }, + { "send", cmd_send, "send a raw command : %s " }, + { "parms", cmd_parms, "display adjustable parameters (STK500 only)" }, + { "vtarg", cmd_vtarg, "set (STK500 only)" }, + { "varef", cmd_varef, "set (STK500 only)" }, + { "fosc", cmd_fosc, "set (STK500 only)" }, + { "sck", cmd_sck, "set (STK500 only)" }, + { "spi", cmd_spi, "enter direct SPI mode" }, + { "pgm", cmd_pgm, "return to programming mode" }, + { "verbose", cmd_verbose, "change verbosity" }, + { "help", cmd_help, "help" }, + { "?", cmd_help, "help" }, + { "quit", cmd_quit, "quit" } +}; + +#define NCMDS (sizeof(cmd)/sizeof(struct command)) + + + +static int spi_mode = 0; + +static int nexttok(char * buf, char ** tok, char ** next) +{ + char * q, * n; + + q = buf; + while (isspace((int)*q)) + q++; + + /* isolate first token */ + n = q+1; + while (*n && !isspace((int)*n)) + n++; + + if (*n) { + *n = 0; + n++; + } + + /* find start of next token */ + while (isspace((int)*n)) + n++; + + *tok = q; + *next = n; + + return 0; +} + + +static int hexdump_line(char * buffer, unsigned char * p, int n, int pad) +{ + char * hexdata = "0123456789abcdef"; + char * b; + int i, j; + + b = buffer; + + j = 0; + for (i=0; i> 4]; + b[j++] = hexdata[(p[i] & 0x0f)]; + if (i < 15) + b[j++] = ' '; + } + + for (i=j; i len) + n = len; + hexdump_line(dst1, p, n, 48); + chardump_line(dst2, p, n, 16); + fprintf(stdout, "%04x %s |%s|\n", addr, dst1, dst2); + len -= n; + addr += n; + p += n; + } + + return 0; +} + + +static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + static char prevmem[128] = {0}; + char * e; + unsigned char * buf; + int maxsize; + unsigned long i; + static unsigned long addr=0; + static int len=64; + AVRMEM * mem; + char * memtype = NULL; + int rc; + + if (!((argc == 2) || (argc == 4))) { + avrdude_message(MSG_INFO, "Usage: dump [ ]\n"); + return -1; + } + + memtype = argv[1]; + + if (strncmp(prevmem, memtype, strlen(memtype)) != 0) { + addr = 0; + len = 64; + strncpy(prevmem, memtype, sizeof(prevmem)-1); + prevmem[sizeof(prevmem)-1] = 0; + } + + mem = avr_locate_mem(p, memtype); + if (mem == NULL) { + avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n", + memtype, p->desc); + return -1; + } + + if (argc == 4) { + addr = strtoul(argv[2], &e, 0); + if (*e || (e == argv[2])) { + avrdude_message(MSG_INFO, "%s (dump): can't parse address \"%s\"\n", + progname, argv[2]); + return -1; + } + + len = strtol(argv[3], &e, 0); + if (*e || (e == argv[3])) { + avrdude_message(MSG_INFO, "%s (dump): can't parse length \"%s\"\n", + progname, argv[3]); + return -1; + } + } + + maxsize = mem->size; + + if (addr >= maxsize) { + if (argc == 2) { + /* wrap around */ + addr = 0; + } + else { + avrdude_message(MSG_INFO, "%s (dump): address 0x%05lx is out of range for %s memory\n", + progname, addr, mem->desc); + return -1; + } + } + + /* trim len if nessary to not read past the end of memory */ + if ((addr + len) > maxsize) + len = maxsize - addr; + + buf = malloc(len); + if (buf == NULL) { + avrdude_message(MSG_INFO, "%s (dump): out of memory\n", progname); + return -1; + } + + for (i=0; iread_byte(pgm, p, mem, addr+i, &buf[i]); + if (rc != 0) { + avrdude_message(MSG_INFO, "error reading %s address 0x%05lx of part %s\n", + mem->desc, addr+i, p->desc); + if (rc == -1) + avrdude_message(MSG_INFO, "read operation not supported on memory type \"%s\"\n", + mem->desc); + return -1; + } + } + + hexdump_buf(stdout, addr, buf, len); + + fprintf(stdout, "\n"); + + free(buf); + + addr = addr + len; + + return 0; +} + + +static int cmd_write(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + char * e; + int len, maxsize; + char * memtype; + unsigned long addr, i; + unsigned char * buf; + unsigned char b; + int rc; + int werror; + AVRMEM * mem; + + if (argc < 4) { + avrdude_message(MSG_INFO, "Usage: write " + " ... byteN>\n"); + return -1; + } + + memtype = argv[1]; + + mem = avr_locate_mem(p, memtype); + if (mem == NULL) { + avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n", + memtype, p->desc); + return -1; + } + + maxsize = mem->size; + + addr = strtoul(argv[2], &e, 0); + if (*e || (e == argv[2])) { + avrdude_message(MSG_INFO, "%s (write): can't parse address \"%s\"\n", + progname, argv[2]); + return -1; + } + + if (addr > maxsize) { + avrdude_message(MSG_INFO, "%s (write): address 0x%05lx is out of range for %s memory\n", + progname, addr, memtype); + return -1; + } + + /* number of bytes to write at the specified address */ + len = argc - 3; + + if ((addr + len) > maxsize) { + avrdude_message(MSG_INFO, "%s (write): selected address and # bytes exceed " + "range for %s memory\n", + progname, memtype); + return -1; + } + + buf = malloc(len); + if (buf == NULL) { + avrdude_message(MSG_INFO, "%s (write): out of memory\n", progname); + return -1; + } + + for (i=3; ierr_led(pgm, OFF); + for (werror=0, i=0; idesc); + werror = 1; + } + + rc = pgm->read_byte(pgm, p, mem, addr+i, &b); + if (b != buf[i]) { + avrdude_message(MSG_INFO, "%s (write): error writing 0x%02x at 0x%05lx cell=0x%02x\n", + progname, buf[i], addr+i, b); + werror = 1; + } + + if (werror) { + pgm->err_led(pgm, ON); + } + } + + free(buf); + + fprintf(stdout, "\n"); + + return 0; +} + + +static int cmd_send(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + unsigned char cmd[4], res[4]; + char * e; + int i; + int len; + + if (pgm->cmd == NULL) { + avrdude_message(MSG_INFO, "The %s programmer does not support direct ISP commands.\n", + pgm->type); + return -1; + } + + if (spi_mode && (pgm->spi == NULL)) { + avrdude_message(MSG_INFO, "The %s programmer does not support direct SPI transfers.\n", + pgm->type); + return -1; + } + + + if ((argc > 5) || ((argc < 5) && (!spi_mode))) { + avrdude_message(MSG_INFO, spi_mode? + "Usage: send [ [ []]]\n": + "Usage: send \n"); + return -1; + } + + /* number of bytes to write at the specified address */ + len = argc - 1; + + /* load command bytes */ + for (i=1; ierr_led(pgm, OFF); + + if (spi_mode) + pgm->spi(pgm, cmd, res, argc-1); + else + pgm->cmd(pgm, cmd, res); + + /* + * display results + */ + avrdude_message(MSG_INFO, "results:"); + for (i=0; ichip_erase(pgm, p); + return 0; +} + + +static int cmd_part(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + fprintf(stdout, "\n"); + avr_display(stdout, p, "", 0); + fprintf(stdout, "\n"); + + return 0; +} + + +static int cmd_sig(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + int i; + int rc; + AVRMEM * m; + + rc = avr_signature(pgm, p); + if (rc != 0) { + avrdude_message(MSG_INFO, "error reading signature data, rc=%d\n", + rc); + } + + m = avr_locate_mem(p, "signature"); + if (m == NULL) { + avrdude_message(MSG_INFO, "signature data not defined for device \"%s\"\n", + p->desc); + } + else { + fprintf(stdout, "Device signature = 0x"); + for (i=0; isize; i++) + fprintf(stdout, "%02x", m->buf[i]); + fprintf(stdout, "\n\n"); + } + + return 0; +} + + +static int cmd_quit(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + return 1; +} + + +static int cmd_parms(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + if (pgm->print_parms == NULL) { + avrdude_message(MSG_INFO, "%s (parms): the %s programmer does not support " + "adjustable parameters\n", + progname, pgm->type); + return -1; + } + pgm->print_parms(pgm); + + return 0; +} + + +static int cmd_vtarg(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + int rc; + double v; + char *endp; + + if (argc != 2) { + avrdude_message(MSG_INFO, "Usage: vtarg \n"); + return -1; + } + v = strtod(argv[1], &endp); + if (endp == argv[1]) { + avrdude_message(MSG_INFO, "%s (vtarg): can't parse voltage \"%s\"\n", + progname, argv[1]); + return -1; + } + if (pgm->set_vtarget == NULL) { + avrdude_message(MSG_INFO, "%s (vtarg): the %s programmer cannot set V[target]\n", + progname, pgm->type); + return -2; + } + if ((rc = pgm->set_vtarget(pgm, v)) != 0) { + avrdude_message(MSG_INFO, "%s (vtarg): failed to set V[target] (rc = %d)\n", + progname, rc); + return -3; + } + return 0; +} + + +static int cmd_fosc(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + int rc; + double v; + char *endp; + + if (argc != 2) { + avrdude_message(MSG_INFO, "Usage: fosc [M|k] | off\n"); + return -1; + } + v = strtod(argv[1], &endp); + if (endp == argv[1]) { + if (strcmp(argv[1], "off") == 0) + v = 0.0; + else { + avrdude_message(MSG_INFO, "%s (fosc): can't parse frequency \"%s\"\n", + progname, argv[1]); + return -1; + } + } + if (*endp == 'm' || *endp == 'M') + v *= 1e6; + else if (*endp == 'k' || *endp == 'K') + v *= 1e3; + if (pgm->set_fosc == NULL) { + avrdude_message(MSG_INFO, "%s (fosc): the %s programmer cannot set oscillator frequency\n", + progname, pgm->type); + return -2; + } + if ((rc = pgm->set_fosc(pgm, v)) != 0) { + avrdude_message(MSG_INFO, "%s (fosc): failed to set oscillator_frequency (rc = %d)\n", + progname, rc); + return -3; + } + return 0; +} + + +static int cmd_sck(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + int rc; + double v; + char *endp; + + if (argc != 2) { + avrdude_message(MSG_INFO, "Usage: sck \n"); + return -1; + } + v = strtod(argv[1], &endp); + if (endp == argv[1]) { + avrdude_message(MSG_INFO, "%s (sck): can't parse period \"%s\"\n", + progname, argv[1]); + return -1; + } + v *= 1e-6; /* Convert from microseconds to seconds. */ + if (pgm->set_sck_period == NULL) { + avrdude_message(MSG_INFO, "%s (sck): the %s programmer cannot set SCK period\n", + progname, pgm->type); + return -2; + } + if ((rc = pgm->set_sck_period(pgm, v)) != 0) { + avrdude_message(MSG_INFO, "%s (sck): failed to set SCK period (rc = %d)\n", + progname, rc); + return -3; + } + return 0; +} + + +static int cmd_varef(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + int rc; + unsigned int chan; + double v; + char *endp; + + if (argc != 2 && argc != 3) { + avrdude_message(MSG_INFO, "Usage: varef [channel] \n"); + return -1; + } + if (argc == 2) { + chan = 0; + v = strtod(argv[1], &endp); + if (endp == argv[1]) { + avrdude_message(MSG_INFO, "%s (varef): can't parse voltage \"%s\"\n", + progname, argv[1]); + return -1; + } + } else { + chan = strtoul(argv[1], &endp, 10); + if (endp == argv[1]) { + avrdude_message(MSG_INFO, "%s (varef): can't parse channel \"%s\"\n", + progname, argv[1]); + return -1; + } + v = strtod(argv[2], &endp); + if (endp == argv[2]) { + avrdude_message(MSG_INFO, "%s (varef): can't parse voltage \"%s\"\n", + progname, argv[2]); + return -1; + } + } + if (pgm->set_varef == NULL) { + avrdude_message(MSG_INFO, "%s (varef): the %s programmer cannot set V[aref]\n", + progname, pgm->type); + return -2; + } + if ((rc = pgm->set_varef(pgm, chan, v)) != 0) { + avrdude_message(MSG_INFO, "%s (varef): failed to set V[aref] (rc = %d)\n", + progname, rc); + return -3; + } + return 0; +} + + +static int cmd_help(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + int i; + + fprintf(stdout, "Valid commands:\n\n"); + for (i=0; isetpin(pgm, PIN_AVR_RESET, 1); + spi_mode = 1; + return 0; +} + +static int cmd_pgm(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + pgm->setpin(pgm, PIN_AVR_RESET, 0); + spi_mode = 0; + pgm->initialize(pgm, p); + return 0; +} + +static int cmd_verbose(PROGRAMMER * pgm, struct avrpart * p, + int argc, char * argv[]) +{ + int nverb; + char *endp; + + if (argc != 1 && argc != 2) { + avrdude_message(MSG_INFO, "Usage: verbose []\n"); + return -1; + } + if (argc == 1) { + avrdude_message(MSG_INFO, "Verbosity level: %d\n", verbose); + return 0; + } + nverb = strtol(argv[1], &endp, 0); + if (endp == argv[2]) { + avrdude_message(MSG_INFO, "%s: can't parse verbosity level \"%s\"\n", + progname, argv[2]); + return -1; + } + if (nverb < 0) { + avrdude_message(MSG_INFO, "%s: verbosity level must be positive: %d\n", + progname, nverb); + return -1; + } + verbose = nverb; + avrdude_message(MSG_INFO, "New verbosity level: %d\n", verbose); + + return 0; +} + +static int tokenize(char * s, char *** argv) +{ + int i, n, l, nargs, offset; + int len, slen; + char * buf; + int bufsize; + char ** bufv; + char * q, * r; + char * nbuf; + char ** av; + + slen = strlen(s); + + /* + * initialize allow for 20 arguments, use realloc to grow this if + * necessary + */ + nargs = 20; + bufsize = slen + 20; + buf = malloc(bufsize); + bufv = (char **) malloc(nargs*sizeof(char *)); + for (i=0; i= 1)) + add_history(input); + + return input; +#else + char input[256]; + printf("%s", prompt); + if (fgets(input, sizeof(input), stdin)) + { + /* FIXME: readline strips the '\n', should this too? */ + return strdup(input); + } + else + return NULL; +#endif +} + + +int terminal_mode(PROGRAMMER * pgm, struct avrpart * p) +{ + char * cmdbuf; + int i; + char * q; + int rc; + int argc; + char ** argv; + + rc = 0; + while ((cmdbuf = terminal_get_input("avrdude> ")) != NULL) { + /* + * find the start of the command, skipping any white space + */ + q = cmdbuf; + while (*q && isspace((int)*q)) + q++; + + /* skip blank lines and comments */ + if (!*q || (*q == '#')) + continue; + + /* tokenize command line */ + argc = tokenize(q, &argv); + + fprintf(stdout, ">>> "); + for (i=0; i 0) { + rc = 0; + break; + } + free(cmdbuf); + } + + return rc; +} + + diff --git a/xs/src/avrdude/term.h b/xs/src/avrdude/term.h new file mode 100644 index 000000000..fca3aac84 --- /dev/null +++ b/xs/src/avrdude/term.h @@ -0,0 +1,37 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 term_h +#define term_h + +#include "libavrdude.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int terminal_mode(PROGRAMMER * pgm, struct avrpart * p); +char * terminal_get_input(const char *prompt); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/xs/src/avrdude/tools/build-mingw32.sh b/xs/src/avrdude/tools/build-mingw32.sh new file mode 100755 index 000000000..2d9e11261 --- /dev/null +++ b/xs/src/avrdude/tools/build-mingw32.sh @@ -0,0 +1,54 @@ +#! /bin/sh + +# ---------------------------------------------------------------------------- +# "THE BEER-WARE LICENSE" (Revision 42): +# Joerg Wunsch wrote this file. As long as you retain this notice you +# can do whatever you want with this stuff. If we meet some day, and you think +# this stuff is worth it, you can buy me a beer in return. +# ---------------------------------------------------------------------------- + +# Script to cross-compile a MinGW32 executable under unixish host. +# Run this script from within the tools/ subdirectory. +# Override MINGW32_PREFIX and LIBUSB_PREFIX from the commandline +# when invoking the script, like +# +# env LIBUSB_PREFIX="$HOME/dos/ProgramFiles/LibUSB-Win32" ./build-mingw32.sh +# +# The LibUSB-Win32 package is shipped as a self-installing +# executable; it can be unpacked using Wine, and typically +# extracts into the Wine environment. +# +# libelf can be cross-compiled, and installed into the MinGW32 +# target environment if desired. + +MINGW32_PREFIX=${MINGW32_PREFIX:-/usr/local/mingw32} +LIBUSB_PREFIX=${LIBUSB_PREFIX:-/WINDOWS/ProgramFiles/LibUSB-Win32} + +for CC in mingw32-gcc i686-w64-mingw32-gcc i586-mingw32msvc-gcc +do + touch foo.c + if ${CC} -c foo.c 2> /dev/null + then + rm -f foo.* + break + fi +done +tgt=$(expr "$CC" : "\(.*\)-gcc") + +BUILDDIR=build-mingw32 +mkdir -p ${BUILDDIR} || { echo "Cannot create build dir $BUILDDIR"; exit 1; } + +cd ${BUILDDIR} || { echo "Cannot chdir to $BUILDDIR"; exit 1; } + +LDFLAGS="-L${MINGW32_PREFIX}/lib -L${LIBUSB_PREFIX}/lib/gcc" +CPPFLAGS="-I${MINGW32_PREFIX}/include -I${LIBUSB_PREFIX}/include" + +env \ + CC="${CC}" \ + CPPFLAGS="${CPPFLAGS}" \ + LDFLAGS="${LDFLAGS}" \ + ../../configure \ + --host=$(../../config.guess) \ + --target=${tgt} + +make all diff --git a/xs/src/avrdude/tools/get-dw-params.xsl b/xs/src/avrdude/tools/get-dw-params.xsl new file mode 100644 index 000000000..a3f083e96 --- /dev/null +++ b/xs/src/avrdude/tools/get-dw-params.xsl @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + #------------------------------------------------------------ + # + + + #------------------------------------------------------------ + part desc = " + + "; has_debugwire = yes; + + flash_instr = + + + + + ; + + eeprom_instr = + + + + + ; + + + + + + + + + + + + + 0 + + + + + + + + + + + 0 + + + 0x + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + , + + + + + + + + + + + + + + + + + + + + + + diff --git a/xs/src/avrdude/tools/get-hv-params.xsl b/xs/src/avrdude/tools/get-hv-params.xsl new file mode 100644 index 000000000..b4a595f13 --- /dev/null +++ b/xs/src/avrdude/tools/get-hv-params.xsl @@ -0,0 +1,254 @@ + + + + + + + + + + + + pp_controlstack = + + + + ; + + + + + hventerstabdelay = ; + + progmodedelay = ; + + latchcycles = ; + + togglevtg = ; + + poweroffdelay = ; + + resetdelayms = ; + + resetdelayus = ; + + + + + + + hvleavestabdelay = ; + + + + + + + chiperasepulsewidth = ; + + chiperasepolltimeout = ; + + + + + + + programfusepulsewidth = ; + + programfusepolltimeout = ; + + + + + + + programlockpulsewidth = ; + + programlockpolltimeout = ; + + + + + + + + + + hvsp_controlstack = + + + + ; + + + + + hventerstabdelay = ; + + hvspcmdexedelay = ; + + synchcycles = ; + + latchcycles = ; + + togglevtg = ; + + poweroffdelay = ; + + resetdelayms = ; + + resetdelayus = ; + + + + + + + hvleavestabdelay = ; + + resetdelay = ; + + + + + + + chiperasepolltimeout = ; + + chiperasetime = ; + + + + + + + programfusepolltimeout = ; + + + + + + + programlockpolltimeout = ; + + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + , + + + + + + + + + + diff --git a/xs/src/avrdude/tools/get-stk600-cards.xsl b/xs/src/avrdude/tools/get-stk600-cards.xsl new file mode 100644 index 000000000..6165b526e --- /dev/null +++ b/xs/src/avrdude/tools/get-stk600-cards.xsl @@ -0,0 +1,62 @@ + + + + + + + + + + { + + , " + + " }, + + + + + + + + { + + , " + + " }, + + + + + + diff --git a/xs/src/avrdude/tools/get-stk600-devices.xsl b/xs/src/avrdude/tools/get-stk600-devices.xsl new file mode 100644 index 000000000..efba1628a --- /dev/null +++ b/xs/src/avrdude/tools/get-stk600-devices.xsl @@ -0,0 +1,51 @@ + + + + + + + @multitable @columnfractions .15 .15 .6 + Routing card @tab Socket card @tab Devices + + @item @code{ + + } @tab @code{ + + } @tab + + + + + + + @end multitable + + + diff --git a/xs/src/avrdude/tpi.h b/xs/src/avrdude/tpi.h new file mode 100644 index 000000000..89d438d8b --- /dev/null +++ b/xs/src/avrdude/tpi.h @@ -0,0 +1,76 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 tpi_h +#define tpi_h + +#ifdef __cplusplus +extern "C" { +#endif + +static const unsigned char tpi_skey[] = { 0x12, 0x89, 0xAB, 0x45, 0xCD, 0xD8, 0x88, 0xFF }; + +/* registers */ +#define TPI_REG_TPIIR 0x0F + +#define TPI_IDENT_CODE 0x80 + +#define TPI_REG_TPIPCR 0x02 +#define TPI_REG_TPISR 0x00 + +#define TPI_REG_TPISR_NVMEN (1 << 1) + +/* TPI commands */ +#define TPI_CMD_SLD 0x20 +#define TPI_CMD_SLD_PI 0x24 +#define TPI_CMD_SIN 0x10 +#define TPI_CMD_SOUT 0x90 +#define TPI_CMD_SSTCS 0xC0 +#define TPI_CMD_SST 0x60 +#define TPI_CMD_SST_PI 0x64 + +#define TPI_CMD_SLDCS 0x80 +#define TPI_CMD_SSTPR 0x68 +#define TPI_CMD_SKEY 0xE0 + +/* for TPI_CMD_SIN & TPI_CMD_SOUT */ +#define TPI_SIO_ADDR(x) ((x & 0x30) << 1 | (x & 0x0F)) + +/* ATtiny4/5/9/10 I/O registers */ +#define TPI_IOREG_NVMCSR 0x32 +#define TPI_IOREG_NVMCMD 0x33 + +/* bit for NVMCSR */ +#define TPI_IOREG_NVMCSR_NVMBSY (1 << 7) + +/* NVM commands */ +#define TPI_NVMCMD_NO_OPERATION 0x00 +#define TPI_NVMCMD_CHIP_ERASE 0x10 +#define TPI_NVMCMD_SECTION_ERASE 0x14 +#define TPI_NVMCMD_WORD_WRITE 0x1D + +static const unsigned char tpi_skey_cmd[] = { TPI_CMD_SKEY, 0xff, 0x88, 0xd8, 0xcd, 0x45, 0xab, 0x89, 0x12 }; + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/xs/src/avrdude/update.c b/xs/src/avrdude/update.c new file mode 100644 index 000000000..a73461dfa --- /dev/null +++ b/xs/src/avrdude/update.c @@ -0,0 +1,388 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2000-2005 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 + * 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" + +UPDATE * parse_op(char * s) +{ + char buf[1024]; + char * p, * cp, c; + UPDATE * upd; + int i; + size_t fnlen; + + upd = (UPDATE *)malloc(sizeof(UPDATE)); + if (upd == NULL) { + avrdude_message(MSG_INFO, "%s: out of memory\n", progname); + exit(1); + } + + i = 0; + p = s; + while ((i < (sizeof(buf)-1) && *p && (*p != ':'))) + buf[i++] = *p++; + buf[i] = 0; + + if (*p != ':') { + upd->memtype = NULL; /* default memtype, "flash", or "application" */ + upd->op = DEVICE_WRITE; + upd->filename = (char *)malloc(strlen(buf) + 1); + if (upd->filename == NULL) { + avrdude_message(MSG_INFO, "%s: out of memory\n", progname); + exit(1); + } + strcpy(upd->filename, buf); + upd->format = FMT_AUTO; + return upd; + } + + upd->memtype = (char *)malloc(strlen(buf)+1); + if (upd->memtype == NULL) { + avrdude_message(MSG_INFO, "%s: out of memory\n", progname); + exit(1); + } + strcpy(upd->memtype, buf); + + p++; + if (*p == 'r') { + upd->op = DEVICE_READ; + } + else if (*p == 'w') { + upd->op = DEVICE_WRITE; + } + else if (*p == 'v') { + upd->op = DEVICE_VERIFY; + } + else { + avrdude_message(MSG_INFO, "%s: invalid I/O mode '%c' in update specification\n", + progname, *p); + avrdude_message(MSG_INFO, " allowed values are:\n" + " r = read device\n" + " w = write device\n" + " v = verify device\n"); + free(upd->memtype); + free(upd); + return NULL; + } + + p++; + + if (*p != ':') { + avrdude_message(MSG_INFO, "%s: invalid update specification\n", progname); + free(upd->memtype); + free(upd); + return NULL; + } + + p++; + + /* + * Now, parse the filename component. Instead of looking for the + * leftmost possible colon delimiter, we look for the rightmost one. + * If we found one, we do have a trailing :format specifier, and + * process it. Otherwise, the remainder of the string is our file + * name component. That way, the file name itself is allowed to + * contain a colon itself (e. g. C:/some/file.hex), except the + * optional format specifier becomes mandatory then. + */ + cp = p; + p = strrchr(cp, ':'); + if (p == NULL) { + upd->format = FMT_AUTO; + fnlen = strlen(cp); + upd->filename = (char *)malloc(fnlen + 1); + } else { + fnlen = p - cp; + upd->filename = (char *)malloc(fnlen +1); + c = *++p; + if (c && p[1]) + /* More than one char - force failure below. */ + c = '?'; + switch (c) { + case 'a': upd->format = FMT_AUTO; break; + case 's': upd->format = FMT_SREC; break; + case 'i': upd->format = FMT_IHEX; break; + case 'r': upd->format = FMT_RBIN; break; + case 'e': upd->format = FMT_ELF; break; + case 'm': upd->format = FMT_IMM; break; + case 'b': upd->format = FMT_BIN; break; + case 'd': upd->format = FMT_DEC; break; + case 'h': upd->format = FMT_HEX; break; + case 'o': upd->format = FMT_OCT; break; + default: + avrdude_message(MSG_INFO, "%s: invalid file format '%s' in update specifier\n", + progname, p); + free(upd->memtype); + free(upd); + return NULL; + } + } + + if (upd->filename == NULL) { + avrdude_message(MSG_INFO, "%s: out of memory\n", progname); + free(upd->memtype); + free(upd); + return NULL; + } + memcpy(upd->filename, cp, fnlen); + upd->filename[fnlen] = 0; + + return upd; +} + +UPDATE * dup_update(UPDATE * upd) +{ + UPDATE * u; + + u = (UPDATE *)malloc(sizeof(UPDATE)); + if (u == NULL) { + avrdude_message(MSG_INFO, "%s: out of memory\n", progname); + exit(1); + } + + memcpy(u, upd, sizeof(UPDATE)); + + if (upd->memtype != NULL) + u->memtype = strdup(upd->memtype); + else + u->memtype = NULL; + u->filename = strdup(upd->filename); + + return u; +} + +UPDATE * new_update(int op, char * memtype, int filefmt, char * filename) +{ + UPDATE * u; + + u = (UPDATE *)malloc(sizeof(UPDATE)); + if (u == NULL) { + avrdude_message(MSG_INFO, "%s: out of memory\n", progname); + exit(1); + } + + u->memtype = strdup(memtype); + u->filename = strdup(filename); + u->op = op; + u->format = filefmt; + + return u; +} + +void free_update(UPDATE * u) +{ + if (u != NULL) { + if(u->memtype != NULL) { + free(u->memtype); + u->memtype = NULL; + } + if(u->filename != NULL) { + free(u->filename); + u->filename = NULL; + } + free(u); + } +} + + +int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags flags) +{ + struct avrpart * v; + AVRMEM * mem; + int size, vsize; + int rc; + + mem = avr_locate_mem(p, upd->memtype); + if (mem == NULL) { + avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n", + upd->memtype, p->desc); + return -1; + } + + if (upd->op == DEVICE_READ) { + /* + * read out the specified device memory and write it to a file + */ + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: reading %s memory:\n", + progname, mem->desc); + } + report_progress(0,1,"Reading"); + rc = avr_read(pgm, p, upd->memtype, 0); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: failed to read all of %s memory, rc=%d\n", + progname, mem->desc, rc); + return -1; + } + report_progress(1,1,NULL); + size = rc; + + if (quell_progress < 2) { + if (rc == 0) + avrdude_message(MSG_INFO, "%s: Flash is empty, resulting file has no contents.\n", + progname); + avrdude_message(MSG_INFO, "%s: writing output file \"%s\"\n", + progname, + strcmp(upd->filename, "-")==0 ? "" : upd->filename); + } + rc = fileio(FIO_WRITE, upd->filename, upd->format, p, upd->memtype, size); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: write to file '%s' failed\n", + progname, upd->filename); + return -1; + } + } + else if (upd->op == DEVICE_WRITE) { + /* + * write the selected device memory using data from a file; first + * read the data from the specified file + */ + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: reading input file \"%s\"\n", + progname, + strcmp(upd->filename, "-")==0 ? "" : upd->filename); + } + rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: read from file '%s' failed\n", + progname, upd->filename); + return -1; + } + size = rc; + + /* + * write the buffer contents to the selected memory type + */ + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: writing %s (%d bytes):\n", + progname, mem->desc, size); + } + + //Prusa3D bootloader progress on lcd + if (strcmp(pgm->type, "Wiring") == 0) + { + if (pgm->set_upload_size != 0) + pgm->set_upload_size(pgm, size); + } + + if (!(flags & UF_NOWRITE)) { + report_progress(0,1,"Writing"); + rc = avr_write(pgm, p, upd->memtype, size, (flags & UF_AUTO_ERASE) != 0); + report_progress(1,1,NULL); + } + else { + /* + * test mode, don't actually write to the chip, output the buffer + * to stdout in intel hex instead + */ + rc = fileio(FIO_WRITE, "-", FMT_IHEX, p, upd->memtype, size); + } + + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: failed to write %s memory, rc=%d\n", + progname, mem->desc, rc); + return -1; + } + + vsize = rc; + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: %d bytes of %s written\n", progname, + vsize, mem->desc); + } + + } + else if (upd->op == DEVICE_VERIFY) { + /* + * verify that the in memory file (p->mem[AVR_M_FLASH|AVR_M_EEPROM]) + * is the same as what is on the chip + */ + pgm->vfy_led(pgm, ON); + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: verifying %s memory against %s:\n", + progname, mem->desc, upd->filename); + + avrdude_message(MSG_INFO, "%s: load data %s data from input file %s:\n", + progname, mem->desc, upd->filename); + } + + rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: read from file '%s' failed\n", + progname, upd->filename); + return -1; + } + v = avr_dup_part(p); + size = rc; + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: input file %s contains %d bytes\n", + progname, upd->filename, size); + avrdude_message(MSG_INFO, "%s: reading on-chip %s data:\n", + progname, mem->desc); + } + + report_progress (0,1,"Reading"); + rc = avr_read(pgm, p, upd->memtype, v); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: failed to read all of %s memory, rc=%d\n", + progname, mem->desc, rc); + pgm->err_led(pgm, ON); + return -1; + } + report_progress (1,1,NULL); + + + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: verifying ...\n", progname); + } + rc = avr_verify(p, v, upd->memtype, size); + if (rc < 0) { + avrdude_message(MSG_INFO, "%s: verification error; content mismatch\n", + progname); + pgm->err_led(pgm, ON); + return -1; + } + + if (quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: %d bytes of %s verified\n", + progname, rc, mem->desc); + } + + pgm->vfy_led(pgm, OFF); + } + else { + avrdude_message(MSG_INFO, "%s: invalid update operation (%d) requested\n", + progname, upd->op); + return -1; + } + + return 0; +} + diff --git a/xs/src/avrdude/usb_hidapi.c b/xs/src/avrdude/usb_hidapi.c new file mode 100644 index 000000000..81e9c4abe --- /dev/null +++ b/xs/src/avrdude/usb_hidapi.c @@ -0,0 +1,357 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2016 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 + * 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$ */ + +/* + * USB interface via libhidapi for avrdude. + */ + +#include "ac_cfg.h" +#if defined(HAVE_LIBHIDAPI) + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "usbdevs.h" + +#if defined(WIN32NATIVE) +/* someone has defined "interface" to "struct" in Cygwin */ +# undef interface +#endif + +/* + * The "baud" parameter is meaningless for USB devices, so we reuse it + * to pass the desired USB device ID. + */ +static int usbhid_open(char * port, union pinfo pinfo, union filedescriptor *fd) +{ + hid_device *dev; + char *serno, *cp2; + size_t x; + unsigned char usbbuf[USBDEV_MAX_XFER_3 + 1]; + + if (fd->usb.max_xfer == 0) + fd->usb.max_xfer = USBDEV_MAX_XFER_3; + + /* + * The syntax for usb devices is defined as: + * + * -P usb[:serialnumber] + * + * See if we've got a serial number passed here. The serial number + * might contain colons which we remove below, and we compare it + * right-to-left, so only the least significant nibbles need to be + * specified. + */ + if ((serno = strchr(port, ':')) != NULL) + { + /* first, drop all colons there if any */ + cp2 = ++serno; + + while ((cp2 = strchr(cp2, ':')) != NULL) + { + x = strlen(cp2) - 1; + memmove(cp2, cp2 + 1, x); + cp2[x] = '\0'; + } + + if (strlen(serno) > 12) + { + avrdude_message(MSG_INFO, "%s: usbhid_open(): invalid serial number \"%s\"\n", + progname, serno); + return -1; + } + + wchar_t wserno[15]; + mbstowcs(wserno, serno, 15); + size_t serlen = strlen(serno); + + /* + * Now, try finding all devices matching VID:PID, and compare + * their serial numbers against the requested one. + */ + struct hid_device_info *list, *walk; + list = hid_enumerate(pinfo.usbinfo.vid, pinfo.usbinfo.pid); + if (list == NULL) + return -1; + + walk = list; + while (walk) + { + avrdude_message(MSG_NOTICE, "%s: usbhid_open(): Found %ls, serno: %ls\n", + progname, 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; + } + avrdude_message(MSG_DEBUG, "%s: usbhid_open(): serial number doesn't match\n", + progname); + walk = walk->next; + } + if (walk == NULL) + { + avrdude_message(MSG_INFO, "%s: usbhid_open(): No matching device found\n", + progname); + hid_free_enumeration(list); + return -1; + } + avrdude_message(MSG_DEBUG, "%s: usbhid_open(): Opening path %s\n", + progname, walk->path); + dev = hid_open_path(walk->path); + hid_free_enumeration(list); + if (dev == NULL) + { + avrdude_message(MSG_INFO, + "%s: usbhid_open(): Found device, but hid_open_path() failed\n", + progname); + return -1; + } + } + else + { + /* + * No serial number requested, pass straight to hid_open() + */ + dev = hid_open(pinfo.usbinfo.vid, pinfo.usbinfo.pid, NULL); + if (dev == NULL) + { + avrdude_message(MSG_INFO, "%s: usbhid_open(): No device found\n", + progname); + return -1; + } + } + + fd->usb.handle = dev; + + /* + * Try finding out the endpoint size. Alas, libhidapi doesn't + * 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 + * 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 + * USB 1.1 connections, or mEDBG devices). + * + * In order to find out, we send a CMSIS-DAP DAP_Info command + * (0x00), with an ID of 0xFF (get maximum packet size). In theory, + * this gets us the desired information, but this suffers from a + * chicken-and-egg problem: the request must be sent with a + * full-sized packet lest the ICE won't answer. Thus, we send a + * 64-byte packet first, and if we don't get a timely reply, + * complete that request by sending another 448 bytes, and hope it + * will eventually reply. + * + * Note that libhidapi always requires a report ID as the first + * byte. If the target doesn't use report IDs (Atmel targets + * don't), this first byte must be 0x00. However, the length must + * be incremented by one, as the report ID will be omitted by the + * hidapi library. + */ + if (pinfo.usbinfo.vid == USB_VENDOR_ATMEL) + { + avrdude_message(MSG_DEBUG, "%s: usbhid_open(): Probing for max. packet size\n", + progname); + memset(usbbuf, 0, sizeof usbbuf); + usbbuf[0] = 0; /* no HID reports used */ + usbbuf[1] = 0; /* DAP_Info */ + usbbuf[2] = 0xFF; /* get max. packet size */ + + hid_write(dev, usbbuf, 65); + fd->usb.max_xfer = 64; /* first guess */ + + memset(usbbuf, 0, sizeof usbbuf); + int res = hid_read_timeout(dev, usbbuf, 10 /* bytes */, 50 /* milliseconds */); + if (res == 0) { + /* no timely response, assume 512 byte size */ + hid_write(dev, usbbuf, (512 - 64) + 1); + fd->usb.max_xfer = 512; + res = hid_read_timeout(dev, usbbuf, 10, 50); + } + if (res <= 0) { + avrdude_message(MSG_INFO, "%s: usbhid_open(): No response from device\n", + progname); + hid_close(dev); + return -1; + } + if (usbbuf[0] != 0 || usbbuf[1] != 2) { + avrdude_message(MSG_INFO, + "%s: usbhid_open(): Unexpected reply to DAP_Info: 0x%02x 0x%02x\n", + progname, usbbuf[0], usbbuf[1]); + } else { + fd->usb.max_xfer = usbbuf[2] + (usbbuf[3] << 8); + avrdude_message(MSG_DEBUG, + "%s: usbhid_open(): Setting max_xfer from DAP_Info response to %d\n", + progname, fd->usb.max_xfer); + } + } + if (fd->usb.max_xfer > USBDEV_MAX_XFER_3) { + avrdude_message(MSG_INFO, + "%s: usbhid_open(): Unexpected max size %d, reducing to %d\n", + progname, fd->usb.max_xfer, USBDEV_MAX_XFER_3); + fd->usb.max_xfer = USBDEV_MAX_XFER_3; + } + + return 0; +} + +static void usbhid_close(union filedescriptor *fd) +{ + hid_device *udev = (hid_device *)fd->usb.handle; + + if (udev == NULL) + return; + + hid_close(udev); +} + + +static int usbhid_send(union filedescriptor *fd, const unsigned char *bp, size_t mlen) +{ + hid_device *udev = (hid_device *)fd->usb.handle; + int rv; + int i = mlen; + const unsigned char * p = bp; + unsigned char usbbuf[USBDEV_MAX_XFER_3 + 1]; + + + int tx_size; + + if (udev == NULL) + return -1; + + tx_size = (mlen < USBDEV_MAX_XFER_3)? mlen: USBDEV_MAX_XFER_3; + usbbuf[0] = 0; /* no report ID used */ + memcpy(usbbuf + 1, bp, tx_size); + rv = hid_write(udev, usbbuf, tx_size + 1); + if (rv < 0) { + avrdude_message(MSG_INFO, "%s: Failed to write %d bytes to USB\n", + progname, tx_size); + return -1; + } + if (rv != tx_size + 1) + avrdude_message(MSG_INFO, "%s: Short write to USB: %d bytes out of %d written\n", + progname, rv, tx_size + 1); + + if (verbose > 4) + { + avrdude_message(MSG_TRACE2, "%s: Sent: ", progname); + + while (i) { + unsigned char c = *p; + if (isprint(c)) { + avrdude_message(MSG_TRACE2, "%c ", c); + } + else { + avrdude_message(MSG_TRACE2, ". "); + } + avrdude_message(MSG_TRACE2, "[%02x] ", c); + + p++; + i--; + } + avrdude_message(MSG_TRACE2, "\n"); + } + return 0; +} + +static int usbhid_recv(union filedescriptor *fd, unsigned char *buf, size_t nbytes) +{ + hid_device *udev = (hid_device *)fd->usb.handle; + int i, rv; + unsigned char * p = buf; + + if (udev == NULL) + return -1; + + rv = i = hid_read_timeout(udev, buf, nbytes, 300); + if (i != nbytes) + avrdude_message(MSG_INFO, + "%s: Short read, read only %d out of %u bytes\n", + progname, i, nbytes); + + if (verbose > 4) + { + avrdude_message(MSG_TRACE2, "%s: Recv: ", progname); + + while (i) { + unsigned char c = *p; + if (isprint(c)) { + avrdude_message(MSG_TRACE2, "%c ", c); + } + else { + avrdude_message(MSG_TRACE2, ". "); + } + avrdude_message(MSG_TRACE2, "[%02x] ", c); + + p++; + i--; + } + avrdude_message(MSG_TRACE2, "\n"); + } + + return rv; +} + +static int usbhid_drain(union filedescriptor *fd, int display) +{ + /* + * There is not much point in trying to flush any data + * on an USB endpoint, as the endpoint is supposed to + * start afresh after being configured from the host. + * + * As trying to flush the data here caused strange effects + * in some situations (see + * https://savannah.nongnu.org/bugs/index.php?43268 ) + * better avoid it. + */ + + return 0; +} + +/* + * Device descriptor. + */ +struct serial_device usbhid_serdev = +{ + .open = usbhid_open, + .close = usbhid_close, + .send = usbhid_send, + .recv = usbhid_recv, + .drain = usbhid_drain, + .flags = SERDEV_FL_NONE, +}; + +#endif /* HAVE_LIBHIDAPI */ diff --git a/xs/src/avrdude/usb_libusb.c b/xs/src/avrdude/usb_libusb.c new file mode 100644 index 000000000..235e330a8 --- /dev/null +++ b/xs/src/avrdude/usb_libusb.c @@ -0,0 +1,615 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2005,2006 Joerg Wunsch + * Copyright (C) 2006 David Moore + * + * 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$ */ + +/* + * USB interface via libusb for avrdude. + */ + +#include "ac_cfg.h" +#if defined(HAVE_LIBUSB) + + +#include +#include +#include +#include +#include +#include +#include + +#if defined(HAVE_USB_H) +# include +#elif defined(HAVE_LUSB0_USB_H) +# include +#else +# error "libusb needs either or " +#endif + +#include "avrdude.h" +#include "libavrdude.h" + +#include "usbdevs.h" + +#if defined(WIN32NATIVE) +/* someone has defined "interface" to "struct" in Cygwin */ +# undef interface +#endif + +static char usbbuf[USBDEV_MAX_XFER_3]; +static int buflen = -1, bufptr; + +static int usb_interface; + +/* + * The "baud" parameter is meaningless for USB devices, so we reuse it + * to pass the desired USB device ID. + */ +static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd) +{ + char string[256]; + char product[256]; + struct usb_bus *bus; + struct usb_device *dev; + usb_dev_handle *udev; + char *serno, *cp2; + int i; + int iface; + size_t x; + + /* + * The syntax for usb devices is defined as: + * + * -P usb[:serialnumber] + * + * See if we've got a serial number passed here. The serial number + * might contain colons which we remove below, and we compare it + * right-to-left, so only the least significant nibbles need to be + * specified. + */ + if ((serno = strchr(port, ':')) != NULL) + { + /* first, drop all colons there if any */ + cp2 = ++serno; + + while ((cp2 = strchr(cp2, ':')) != NULL) + { + x = strlen(cp2) - 1; + memmove(cp2, cp2 + 1, x); + cp2[x] = '\0'; + } + + if (strlen(serno) > 12) + { + avrdude_message(MSG_INFO, "%s: usbdev_open(): invalid serial number \"%s\"\n", + progname, serno); + return -1; + } + } + + if (fd->usb.max_xfer == 0) + fd->usb.max_xfer = USBDEV_MAX_XFER_MKII; + + usb_init(); + + usb_find_busses(); + usb_find_devices(); + + for (bus = usb_get_busses(); bus; bus = bus->next) + { + for (dev = bus->devices; dev; dev = dev->next) + { + if (dev->descriptor.idVendor == pinfo.usbinfo.vid && + dev->descriptor.idProduct == pinfo.usbinfo.pid) + { + udev = usb_open(dev); + if (udev) + { + /* yeah, we found something */ + if (usb_get_string_simple(udev, + dev->descriptor.iSerialNumber, + string, sizeof(string)) < 0) + { + avrdude_message(MSG_INFO, "%s: usb_open(): cannot read serial number \"%s\"\n", + progname, usb_strerror()); + /* + * On some systems, libusb appears to have + * problems sending control messages. Catch the + * benign case where the user did not request a + * particular serial number, so we could + * continue anyway. + */ + if (serno != NULL) + return -1; /* no chance */ + else + strcpy(string, "[unknown]"); + } + + if (usb_get_string_simple(udev, + dev->descriptor.iProduct, + product, sizeof(product)) < 0) + { + avrdude_message(MSG_INFO, "%s: usb_open(): cannot read product name \"%s\"\n", + progname, usb_strerror()); + strcpy(product, "[unnamed product]"); + } + /* + * The CMSIS-DAP specification mandates the string + * "CMSIS-DAP" must be present somewhere in the + * product name string for a device compliant to + * that protocol. Use this for the decisision + * whether we have to search for a HID interface + * below. + */ + if(strstr(product, "CMSIS-DAP") != NULL) + { + pinfo.usbinfo.flags |= PINFO_FL_USEHID; + /* The JTAGICE3 running the CMSIS-DAP firmware doesn't + * use a separate endpoint for event reception. */ + fd->usb.eep = 0; + } + + if(strstr(product, "mEDBG") != NULL) + { + /* The AVR Xplained Mini uses different endpoints. */ + fd->usb.rep = 0x81; + fd->usb.wep = 0x02; + } + + avrdude_message(MSG_NOTICE, "%s: usbdev_open(): Found %s, serno: %s\n", + progname, product, string); + if (serno != NULL) + { + /* + * See if the serial number requested by the + * user matches what we found, matching + * right-to-left. + */ + x = strlen(string) - strlen(serno); + if (strcasecmp(string + x, serno) != 0) + { + avrdude_message(MSG_DEBUG, "%s: usbdev_open(): serial number doesn't match\n", + progname); + usb_close(udev); + continue; + } + } + + if (dev->config == NULL) + { + avrdude_message(MSG_INFO, "%s: usbdev_open(): USB device has no configuration\n", + progname); + goto trynext; + } + + if (usb_set_configuration(udev, dev->config[0].bConfigurationValue)) + { + avrdude_message(MSG_INFO, "%s: usbdev_open(): WARNING: failed to set configuration %d: %s\n", + progname, dev->config[0].bConfigurationValue, + usb_strerror()); + /* let's hope it has already been configured */ + // goto trynext; + } + + for (iface = 0; iface < dev->config[0].bNumInterfaces; iface++) + { + usb_interface = dev->config[0].interface[iface].altsetting[0].bInterfaceNumber; +#ifdef LIBUSB_HAS_GET_DRIVER_NP + /* + * Many Linux systems attach the usbhid driver + * by default to any HID-class device. On + * those, the driver needs to be detached before + * we can claim the interface. + */ + (void)usb_detach_kernel_driver_np(udev, usb_interface); +#endif + if (usb_claim_interface(udev, usb_interface)) + { + avrdude_message(MSG_INFO, "%s: usbdev_open(): error claiming interface %d: %s\n", + progname, usb_interface, usb_strerror()); + } + else + { + if (pinfo.usbinfo.flags & PINFO_FL_USEHID) + { + /* only consider an interface that is of class HID */ + if (dev->config[0].interface[iface].altsetting[0].bInterfaceClass != + USB_CLASS_HID) + continue; + fd->usb.use_interrupt_xfer = 1; + } + break; + } + } + if (iface == dev->config[0].bNumInterfaces) + { + avrdude_message(MSG_INFO, "%s: usbdev_open(): no usable interface found\n", + progname); + goto trynext; + } + + fd->usb.handle = udev; + if (fd->usb.rep == 0) + { + /* Try finding out what our read endpoint is. */ + for (i = 0; i < dev->config[0].interface[iface].altsetting[0].bNumEndpoints; i++) + { + int possible_ep = dev->config[0].interface[iface].altsetting[0]. + endpoint[i].bEndpointAddress; + + if ((possible_ep & USB_ENDPOINT_DIR_MASK) != 0) + { + avrdude_message(MSG_NOTICE2, "%s: usbdev_open(): using read endpoint 0x%02x\n", + progname, possible_ep); + fd->usb.rep = possible_ep; + break; + } + } + if (fd->usb.rep == 0) + { + avrdude_message(MSG_INFO, "%s: usbdev_open(): cannot find a read endpoint, using 0x%02x\n", + progname, USBDEV_BULK_EP_READ_MKII); + fd->usb.rep = USBDEV_BULK_EP_READ_MKII; + } + } + for (i = 0; i < dev->config[0].interface[iface].altsetting[0].bNumEndpoints; i++) + { + if ((dev->config[0].interface[iface].altsetting[0].endpoint[i].bEndpointAddress == fd->usb.rep || + dev->config[0].interface[iface].altsetting[0].endpoint[i].bEndpointAddress == fd->usb.wep) && + dev->config[0].interface[iface].altsetting[0].endpoint[i].wMaxPacketSize < fd->usb.max_xfer) + { + avrdude_message(MSG_NOTICE, "%s: max packet size expected %d, but found %d due to EP 0x%02x's wMaxPacketSize\n", + progname, + fd->usb.max_xfer, + dev->config[0].interface[iface].altsetting[0].endpoint[i].wMaxPacketSize, + dev->config[0].interface[iface].altsetting[0].endpoint[i].bEndpointAddress); + fd->usb.max_xfer = dev->config[0].interface[iface].altsetting[0].endpoint[i].wMaxPacketSize; + } + } + if (pinfo.usbinfo.flags & PINFO_FL_USEHID) + { + if (usb_control_msg(udev, 0x21, 0x0a /* SET_IDLE */, 0, 0, NULL, 0, 100) < 0) + avrdude_message(MSG_INFO, "%s: usbdev_open(): SET_IDLE failed\n", progname); + } + return 0; + trynext: + usb_close(udev); + } + else + avrdude_message(MSG_INFO, "%s: usbdev_open(): cannot open device: %s\n", + progname, usb_strerror()); + } + } + } + + if ((pinfo.usbinfo.flags & PINFO_FL_SILENT) == 0) + avrdude_message(MSG_NOTICE, "%s: usbdev_open(): did not find any%s USB device \"%s\" (0x%04x:0x%04x)\n", + progname, serno? " (matching)": "", port, + (unsigned)pinfo.usbinfo.vid, (unsigned)pinfo.usbinfo.pid); + return -1; +} + +static void usbdev_close(union filedescriptor *fd) +{ + usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle; + + if (udev == NULL) + return; + + (void)usb_release_interface(udev, usb_interface); + +#if defined(__linux__) + /* + * Without this reset, the AVRISP mkII seems to stall the second + * time we try to connect to it. This is not necessary on + * FreeBSD. + */ + usb_reset(udev); +#endif + + usb_close(udev); +} + + +static int usbdev_send(union filedescriptor *fd, const unsigned char *bp, size_t mlen) +{ + usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle; + int rv; + int i = mlen; + const unsigned char * p = bp; + int tx_size; + + if (udev == NULL) + return -1; + + /* + * Split the frame into multiple packets. It's important to make + * sure we finish with a short packet, or else the device won't know + * the frame is finished. For example, if we need to send 64 bytes, + * we must send a packet of length 64 followed by a packet of length + * 0. + */ + do { + tx_size = (mlen < fd->usb.max_xfer)? mlen: fd->usb.max_xfer; + if (fd->usb.use_interrupt_xfer) + rv = usb_interrupt_write(udev, fd->usb.wep, (char *)bp, tx_size, 10000); + else + rv = usb_bulk_write(udev, fd->usb.wep, (char *)bp, tx_size, 10000); + if (rv != tx_size) + { + avrdude_message(MSG_INFO, "%s: usbdev_send(): wrote %d out of %d bytes, err = %s\n", + progname, rv, tx_size, usb_strerror()); + return -1; + } + bp += tx_size; + mlen -= tx_size; + } while (mlen > 0); + + if (verbose > 3) + { + avrdude_message(MSG_TRACE, "%s: Sent: ", progname); + + while (i) { + unsigned char c = *p; + if (isprint(c)) { + avrdude_message(MSG_TRACE, "%c ", c); + } + else { + avrdude_message(MSG_TRACE, ". "); + } + avrdude_message(MSG_TRACE, "[%02x] ", c); + + p++; + i--; + } + avrdude_message(MSG_TRACE, "\n"); + } + return 0; +} + +/* + * As calls to usb_bulk_read() result in exactly one USB request, we + * have to buffer the read results ourselves, so the single-char read + * requests performed by the upper layers will be handled. In order + * to do this, we maintain a private buffer of what we've got so far, + * 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) +{ + int rv; + + if (use_interrupt_xfer) + rv = usb_interrupt_read(udev, ep, usbbuf, maxsize, 10000); + else + rv = usb_bulk_read(udev, ep, usbbuf, maxsize, 10000); + if (rv < 0) + { + avrdude_message(MSG_NOTICE2, "%s: usb_fill_buf(): usb_%s_read() error %s\n", + progname, (use_interrupt_xfer? "interrupt": "bulk"), + usb_strerror()); + return -1; + } + + buflen = rv; + bufptr = 0; + + return 0; +} + +static int usbdev_recv(union filedescriptor *fd, unsigned char *buf, size_t nbytes) +{ + usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle; + int i, amnt; + unsigned char * p = buf; + + if (udev == NULL) + return -1; + + for (i = 0; nbytes > 0;) + { + if (buflen <= bufptr) + { + if (usb_fill_buf(udev, fd->usb.max_xfer, fd->usb.rep, fd->usb.use_interrupt_xfer) < 0) + return -1; + } + amnt = buflen - bufptr > nbytes? nbytes: buflen - bufptr; + memcpy(buf + i, usbbuf + bufptr, amnt); + bufptr += amnt; + nbytes -= amnt; + i += amnt; + } + + if (verbose > 4) + { + avrdude_message(MSG_TRACE2, "%s: Recv: ", progname); + + while (i) { + unsigned char c = *p; + if (isprint(c)) { + avrdude_message(MSG_TRACE2, "%c ", c); + } + else { + avrdude_message(MSG_TRACE2, ". "); + } + avrdude_message(MSG_TRACE2, "[%02x] ", c); + + p++; + i--; + } + avrdude_message(MSG_TRACE2, "\n"); + } + + return 0; +} + +/* + * This version of recv keeps reading packets until we receive a short + * packet. Then, the entire frame is assembled and returned to the + * user. The length will be unknown in advance, so we return the + * length as the return value of this function, or -1 in case of an + * error. + * + * This is used for the AVRISP mkII device. + */ +static int usbdev_recv_frame(union filedescriptor *fd, unsigned char *buf, size_t nbytes) +{ + usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle; + int rv, n; + int i; + unsigned char * p = buf; + + if (udev == NULL) + return -1; + + /* 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, + fd->usb.max_xfer, 1); + if (rv > 4) + { + memcpy(buf, usbbuf, rv); + n = rv; + n |= USB_RECV_FLAG_EVENT; + goto printout; + } + else if (rv > 0) + { + avrdude_message(MSG_INFO, "Short event len = %d, ignored.\n", rv); + /* fallthrough */ + } + } + + n = 0; + do + { + if (fd->usb.use_interrupt_xfer) + rv = usb_interrupt_read(udev, fd->usb.rep, usbbuf, + fd->usb.max_xfer, 10000); + else + rv = usb_bulk_read(udev, fd->usb.rep, usbbuf, + fd->usb.max_xfer, 10000); + if (rv < 0) + { + avrdude_message(MSG_NOTICE2, "%s: usbdev_recv_frame(): usb_%s_read(): %s\n", + progname, (fd->usb.use_interrupt_xfer? "interrupt": "bulk"), + usb_strerror()); + return -1; + } + + if (rv <= nbytes) + { + memcpy (buf, usbbuf, rv); + buf += rv; + } + else + { + return -1; // buffer overflow + } + + n += rv; + nbytes -= rv; + } + while (nbytes > 0 && rv == fd->usb.max_xfer); + +/* + this ends when the buffer is completly filled (nbytes=0) or was too small (nbytes< 0) + or a short packet is found. + however we cannot say for nbytes=0 that there was really a packet completed, + we had to check the last rv value than for a short packet, + but what happens if the packet does not end with a short packet? + and what if the buffer is filled without the packet was completed? + + preconditions: + expected packet is not a multiple of usb.max_xfer. (prevents further waiting) + + expected packet is shorter than the provided buffer (so it cannot filled completely) + or buffer size is not a multiple of usb.max_xfer. (so it can clearly detected if the buffer was overflown.) +*/ + + printout: + if (verbose > 3) + { + i = n & USB_RECV_LENGTH_MASK; + avrdude_message(MSG_TRACE, "%s: Recv: ", progname); + + while (i) { + unsigned char c = *p; + if (isprint(c)) { + avrdude_message(MSG_TRACE, "%c ", c); + } + else { + avrdude_message(MSG_TRACE, ". "); + } + avrdude_message(MSG_TRACE, "[%02x] ", c); + + p++; + i--; + } + avrdude_message(MSG_TRACE, "\n"); + } + return n; +} + +static int usbdev_drain(union filedescriptor *fd, int display) +{ + /* + * There is not much point in trying to flush any data + * on an USB endpoint, as the endpoint is supposed to + * start afresh after being configured from the host. + * + * As trying to flush the data here caused strange effects + * in some situations (see + * https://savannah.nongnu.org/bugs/index.php?43268 ) + * better avoid it. + */ + + return 0; +} + +/* + * Device descriptor for the JTAG ICE mkII. + */ +struct serial_device usb_serdev = +{ + .open = usbdev_open, + .close = usbdev_close, + .send = usbdev_send, + .recv = usbdev_recv, + .drain = usbdev_drain, + .flags = SERDEV_FL_NONE, +}; + +/* + * Device descriptor for the AVRISP mkII. + */ +struct serial_device usb_serdev_frame = +{ + .open = usbdev_open, + .close = usbdev_close, + .send = usbdev_send, + .recv = usbdev_recv_frame, + .drain = usbdev_drain, + .flags = SERDEV_FL_NONE, +}; + +#endif /* HAVE_LIBUSB */ diff --git a/xs/src/avrdude/usbasp.c b/xs/src/avrdude/usbasp.c new file mode 100644 index 000000000..e75eed1d7 --- /dev/null +++ b/xs/src/avrdude/usbasp.c @@ -0,0 +1,1221 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2006 Thomas Fischl + * Copyright 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 + * 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$ */ + +/* + * Interface to the USBasp programmer. + * + * See http://www.fischl.de/usbasp/ + */ +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "usbasp.h" +#include "usbdevs.h" + +#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0) + +#ifdef HAVE_LIBUSB_1_0 +# define USE_LIBUSB_1_0 +#endif + +#if defined(USE_LIBUSB_1_0) +# if defined(HAVE_LIBUSB_1_0_LIBUSB_H) +# include +# else +# include +# endif +#else +# if defined(HAVE_USB_H) +# include +# elif defined(HAVE_LUSB0_USB_H) +# include +# else +# error "libusb needs either or " +# endif +#endif + +#ifdef USE_LIBUSB_1_0 + +static libusb_context *ctx = NULL; + +static int libusb_to_errno(int result) +{ + switch (result) { + case LIBUSB_SUCCESS: + return 0; + case LIBUSB_ERROR_IO: + return EIO; + case LIBUSB_ERROR_INVALID_PARAM: + return EINVAL; + case LIBUSB_ERROR_ACCESS: + return EACCES; + case LIBUSB_ERROR_NO_DEVICE: + return ENXIO; + case LIBUSB_ERROR_NOT_FOUND: + return ENOENT; + case LIBUSB_ERROR_BUSY: + return EBUSY; +#ifdef ETIMEDOUT + case LIBUSB_ERROR_TIMEOUT: + return ETIMEDOUT; +#endif +#ifdef EOVERFLOW + case LIBUSB_ERROR_OVERFLOW: + return EOVERFLOW; +#endif + case LIBUSB_ERROR_PIPE: + return EPIPE; + case LIBUSB_ERROR_INTERRUPTED: + return EINTR; + case LIBUSB_ERROR_NO_MEM: + return ENOMEM; + case LIBUSB_ERROR_NOT_SUPPORTED: + return ENOSYS; + default: + return ERANGE; + } +} + +#endif + + +/* + * Private data for this programmer. + */ +struct pdata +{ +#ifdef USE_LIBUSB_1_0 + libusb_device_handle *usbhandle; +#else + usb_dev_handle *usbhandle; +#endif + int sckfreq_hz; + unsigned int capabilities; + int use_tpi; +}; + +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) +#define IMPORT_PDATA(pgm) struct pdata *pdata = PDATA(pgm) + + + +/* Prototypes */ +// interface - management +static void usbasp_setup(PROGRAMMER * pgm); +static void usbasp_teardown(PROGRAMMER * pgm); +// internal functions +static int usbasp_transmit(PROGRAMMER * pgm, unsigned char receive, + unsigned char functionid, const unsigned char *send, + unsigned char *buffer, int buffersize); +#ifdef USE_LIBUSB_1_0 +static int usbOpenDevice(libusb_device_handle **device, int vendor, char *vendorName, int product, char *productName); +#else +static int usbOpenDevice(usb_dev_handle **device, int vendor, char *vendorName, int product, char *productName); +#endif +// interface - prog. +static int usbasp_open(PROGRAMMER * pgm, char * port); +static void usbasp_close(PROGRAMMER * pgm); +// dummy functions +static void usbasp_disable(PROGRAMMER * pgm); +static void usbasp_enable(PROGRAMMER * pgm); +static void usbasp_display(PROGRAMMER * pgm, const char * p); +// universal functions +static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p); +// SPI specific functions +static int usbasp_spi_cmd(PROGRAMMER * pgm, const unsigned char *cmd, unsigned char *res); +static int usbasp_spi_program_enable(PROGRAMMER * pgm, AVRPART * p); +static int usbasp_spi_chip_erase(PROGRAMMER * pgm, AVRPART * p); +static int usbasp_spi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes); +static int usbasp_spi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes); +static int usbasp_spi_set_sck_period(PROGRAMMER *pgm, double sckperiod); +// TPI specific functions +static void usbasp_tpi_send_byte(PROGRAMMER * pgm, uint8_t b); +static int usbasp_tpi_cmd(PROGRAMMER * pgm, const unsigned char *cmd, unsigned char *res); +static int usbasp_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p); +static int usbasp_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p); +static int usbasp_tpi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes); +static int usbasp_tpi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes); +static int usbasp_tpi_set_sck_period(PROGRAMMER *pgm, double sckperiod); +static int usbasp_tpi_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr, unsigned char * value); +static int usbasp_tpi_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr, unsigned char data); + + +/* Interface - management */ +static void usbasp_setup(PROGRAMMER * pgm) +{ + if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + avrdude_message(MSG_INFO, "%s: usbasp_setup(): Out of memory allocating private data\n", + progname); + exit(1); + } + memset(pgm->cookie, 0, sizeof(struct pdata)); +} + +static void usbasp_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); +} + +/* Internal functions */ + +static const char *usbasp_get_funcname(unsigned char functionid) +{ + switch (functionid) { + case USBASP_FUNC_CONNECT: return "USBASP_FUNC_CONNECT"; break; + case USBASP_FUNC_DISCONNECT: return "USBASP_FUNC_DISCONNECT"; break; + case USBASP_FUNC_TRANSMIT: return "USBASP_FUNC_TRANSMIT"; break; + case USBASP_FUNC_READFLASH: return "USBASP_FUNC_READFLASH"; break; + case USBASP_FUNC_ENABLEPROG: return "USBASP_FUNC_ENABLEPROG"; break; + case USBASP_FUNC_WRITEFLASH: return "USBASP_FUNC_WRITEFLASH"; break; + case USBASP_FUNC_READEEPROM: return "USBASP_FUNC_READEEPROM"; break; + case USBASP_FUNC_WRITEEEPROM: return "USBASP_FUNC_WRITEEEPROM"; break; + case USBASP_FUNC_SETLONGADDRESS: return "USBASP_FUNC_SETLONGADDRESS"; break; + case USBASP_FUNC_SETISPSCK: return "USBASP_FUNC_SETISPSCK"; break; + case USBASP_FUNC_TPI_CONNECT: return "USBASP_FUNC_TPI_CONNECT"; break; + case USBASP_FUNC_TPI_DISCONNECT: return "USBASP_FUNC_TPI_DISCONNECT"; break; + case USBASP_FUNC_TPI_RAWREAD: return "USBASP_FUNC_TPI_RAWREAD"; break; + case USBASP_FUNC_TPI_RAWWRITE: return "USBASP_FUNC_TPI_RAWWRITE"; break; + case USBASP_FUNC_TPI_READBLOCK: return "USBASP_FUNC_TPI_READBLOCK"; break; + case USBASP_FUNC_TPI_WRITEBLOCK: return "USBASP_FUNC_TPI_WRITEBLOCK"; break; + case USBASP_FUNC_GETCAPABILITIES: return "USBASP_FUNC_GETCAPABILITIES"; break; + default: return "Unknown USBASP function"; break; + } +} + +/* + * wrapper for usb_control_msg call + */ +static int usbasp_transmit(PROGRAMMER * pgm, + unsigned char receive, unsigned char functionid, + const unsigned char *send, + unsigned char *buffer, int buffersize) +{ + int nbytes; + + if (verbose > 3) { + avrdude_message(MSG_TRACE, "%s: usbasp_transmit(\"%s\", 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n", + progname, + usbasp_get_funcname(functionid), send[0], send[1], send[2], send[3]); + if (!receive && buffersize > 0) { + int i; + avrdude_message(MSG_TRACE, "%s => ", progbuf); + for (i = 0; i < buffersize; i++) + avrdude_message(MSG_TRACE, "[%02x] ", buffer[i]); + avrdude_message(MSG_TRACE, "\n"); + } + } + +#ifdef USE_LIBUSB_1_0 + nbytes = libusb_control_transfer(PDATA(pgm)->usbhandle, + (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | (receive << 7)) & 0xff, + functionid & 0xff, + ((send[1] << 8) | send[0]) & 0xffff, + ((send[3] << 8) | send[2]) & 0xffff, + buffer, + buffersize & 0xffff, + 5000); + if(nbytes < 0){ + avrdude_message(MSG_INFO, "%s: error: usbasp_transmit: %s\n", progname, strerror(libusb_to_errno(nbytes))); + return -1; + } +#else + nbytes = usb_control_msg(PDATA(pgm)->usbhandle, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | (receive << 7), + functionid, + (send[1] << 8) | send[0], + (send[3] << 8) | send[2], + (char *)buffer, buffersize, + 5000); + if(nbytes < 0){ + avrdude_message(MSG_INFO, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror()); + return -1; + } +#endif + + if (verbose > 3 && receive && nbytes > 0) { + int i; + avrdude_message(MSG_TRACE, "%s<= ", progbuf); + for (i = 0; i < nbytes; i++) + avrdude_message(MSG_TRACE, "[%02x] ", buffer[i]); + avrdude_message(MSG_TRACE, "\n"); + } + + return nbytes; +} + + +/* + * Try to open USB device with given VID, PID, vendor and product name + * Parts of this function were taken from an example code by OBJECTIVE + * DEVELOPMENT Software GmbH (www.obdev.at) to meet conditions for + * shared VID/PID + */ +#ifdef USE_LIBUSB_1_0 +static int usbOpenDevice(libusb_device_handle **device, int vendor, + char *vendorName, int product, char *productName) +{ + libusb_device_handle *handle = NULL; + int errorCode = USB_ERROR_NOTFOUND; + static int didUsbInit = 0; + int j; + int r; + + if(!didUsbInit){ + didUsbInit = 1; + libusb_init(&ctx); + } + + libusb_device **dev_list; + int dev_list_len = libusb_get_device_list(ctx, &dev_list); + + for (j=0; j%s<-\n", + progname, string); + if ((vendorName != NULL) && (vendorName[0] != 0) && (strcmp(string, vendorName) != 0)) + errorCode = USB_ERROR_NOTFOUND; + } + /* if productName not given ignore it (any product matches) */ + r = libusb_get_string_descriptor_ascii(handle, descriptor.iProduct & 0xff, (unsigned char*)string, sizeof(string)); + if (r < 0) { + if ((productName != NULL) && (productName[0] != 0)) { + errorCode = USB_ERROR_IO; + avrdude_message(MSG_INFO, "%s: Warning: cannot query product for device: %s\n", + progname, strerror(libusb_to_errno(r))); + } + } else { + avrdude_message(MSG_NOTICE2, "%s: seen product ->%s<-\n", + progname, string); + if((productName != NULL) && (productName[0] != 0) && (strcmp(string, productName) != 0)) + errorCode = USB_ERROR_NOTFOUND; + } + if (errorCode == 0) + break; + libusb_close(handle); + handle = NULL; + } + } + libusb_free_device_list(dev_list,1); + if (handle != NULL){ + errorCode = 0; + *device = handle; + } + return errorCode; +} +#else +static int usbOpenDevice(usb_dev_handle **device, int vendor, + char *vendorName, int product, char *productName) +{ +struct usb_bus *bus; +struct usb_device *dev; +usb_dev_handle *handle = NULL; +int errorCode = USB_ERROR_NOTFOUND; +static int didUsbInit = 0; + + if(!didUsbInit){ + didUsbInit = 1; + usb_init(); + } + usb_find_busses(); + usb_find_devices(); + for(bus=usb_get_busses(); bus; bus=bus->next){ + for(dev=bus->devices; dev; dev=dev->next){ + if(dev->descriptor.idVendor == vendor && + dev->descriptor.idProduct == product){ + char string[256]; + int len; + /* we need to open the device in order to query strings */ + handle = usb_open(dev); + if(!handle){ + errorCode = USB_ERROR_ACCESS; + avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n", + progname, usb_strerror()); + continue; + } + errorCode = 0; + /* now check whether the names match: */ + /* if vendorName not given ignore it (any vendor matches) */ + len = usb_get_string_simple(handle, dev->descriptor.iManufacturer, + string, sizeof(string)); + if(len < 0){ + if ((vendorName != NULL) && (vendorName[0] != 0)) { + errorCode = USB_ERROR_IO; + avrdude_message(MSG_INFO, "%s: Warning: cannot query manufacturer for device: %s\n", + progname, usb_strerror()); + } + } else { + avrdude_message(MSG_NOTICE2, "%s: seen device from vendor ->%s<-\n", + progname, string); + if((vendorName != NULL) && (vendorName[0] != 0) && (strcmp(string, vendorName) != 0)) + errorCode = USB_ERROR_NOTFOUND; + } + /* if productName not given ignore it (any product matches) */ + len = usb_get_string_simple(handle, dev->descriptor.iProduct, + string, sizeof(string)); + if(len < 0){ + if ((productName != NULL) && (productName[0] != 0)) { + errorCode = USB_ERROR_IO; + avrdude_message(MSG_INFO, "%s: Warning: cannot query product for device: %s\n", + progname, usb_strerror()); + } + } else { + avrdude_message(MSG_NOTICE2, "%s: seen product ->%s<-\n", + progname, string); + if((productName != NULL) && (productName[0] != 0) && (strcmp(string, productName) != 0)) + errorCode = USB_ERROR_NOTFOUND; + } + if (errorCode == 0) + break; + usb_close(handle); + handle = NULL; + } + } + if(handle) + break; + } + if(handle != NULL){ + errorCode = 0; + *device = handle; + } + return errorCode; +} +#endif + + +/* Interface - prog. */ +static int usbasp_open(PROGRAMMER * pgm, char * port) +{ + avrdude_message(MSG_DEBUG, "%s: usbasp_open(\"%s\")\n", + progname, port); + + /* usb_init will be done in usbOpenDevice */ + LNODEID usbpid = lfirst(pgm->usbpid); + int pid, vid; + if (usbpid) { + pid = *(int *)(ldata(usbpid)); + if (lnext(usbpid)) + avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n", + progname, pid); + } else { + pid = USBASP_SHARED_PID; + } + vid = pgm->usbvid? pgm->usbvid: USBASP_SHARED_VID; + if (usbOpenDevice(&PDATA(pgm)->usbhandle, vid, pgm->usbvendor, pid, pgm->usbproduct) != 0) { + /* try alternatives */ + if(strcasecmp(ldata(lfirst(pgm->id)), "usbasp") == 0) { + /* for id usbasp autodetect some variants */ + if(strcasecmp(port, "nibobee") == 0) { + avrdude_message(MSG_INFO, "%s: warning: Using \"-C usbasp -P nibobee\" is deprecated," + "use \"-C nibobee\" instead.\n", + progname); + if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_NIBOBEE_VID, "www.nicai-systems.com", + USBASP_NIBOBEE_PID, "NIBObee") != 0) { + avrdude_message(MSG_INFO, "%s: error: could not find USB device " + "\"NIBObee\" with vid=0x%x pid=0x%x\n", + progname, USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID); + return -1; + } + return 0; + } + /* check if device with old VID/PID is available */ + if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_OLD_VID, "www.fischl.de", + USBASP_OLD_PID, "USBasp") == 0) { + /* found USBasp with old IDs */ + avrdude_message(MSG_INFO, "%s: Warning: Found USB device \"USBasp\" with " + "old VID/PID! Please update firmware of USBasp!\n", + progname); + return 0; + } + /* original USBasp is specified in config file, so no need to check it again here */ + /* no alternative found => fall through to generic error message */ + } + + avrdude_message(MSG_INFO, "%s: error: could not find USB device with vid=0x%x pid=0x%x", + progname, vid, pid); + if (pgm->usbvendor[0] != 0) { + avrdude_message(MSG_INFO, " vendor='%s'", pgm->usbvendor); + } + if (pgm->usbproduct[0] != 0) { + avrdude_message(MSG_INFO, " product='%s'", pgm->usbproduct); + } + avrdude_message(MSG_INFO, "\n"); + return -1; + } + + return 0; +} + +static void usbasp_close(PROGRAMMER * pgm) +{ + avrdude_message(MSG_DEBUG, "%s: usbasp_close()\n", progname); + + if (PDATA(pgm)->usbhandle!=NULL) { + unsigned char temp[4]; + memset(temp, 0, sizeof(temp)); + + if (PDATA(pgm)->use_tpi) { + usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_DISCONNECT, temp, temp, sizeof(temp)); + } else { + usbasp_transmit(pgm, 1, USBASP_FUNC_DISCONNECT, temp, temp, sizeof(temp)); + } + +#ifdef USE_LIBUSB_1_0 + libusb_close(PDATA(pgm)->usbhandle); +#else + usb_close(PDATA(pgm)->usbhandle); +#endif + } +#ifdef USE_LIBUSB_1_0 + libusb_exit(ctx); +#else + /* nothing for usb 0.1 ? */ +#endif +} + + +/* Dummy functions */ +static void usbasp_disable(PROGRAMMER * pgm) +{ + /* Do nothing. */ + + return; +} + +static void usbasp_enable(PROGRAMMER * pgm) +{ + /* Do nothing. */ + + return; +} + +static void usbasp_display(PROGRAMMER * pgm, const char * p) +{ + return; +} + + +/* Universal functions: for both SPI and TPI */ +static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char temp[4]; + unsigned char res[4]; + IMPORT_PDATA(pgm); + + avrdude_message(MSG_DEBUG, "%s: usbasp_initialize()\n", progname); + + /* get capabilities */ + memset(temp, 0, sizeof(temp)); + if(usbasp_transmit(pgm, 1, USBASP_FUNC_GETCAPABILITIES, temp, res, sizeof(res)) == 4) + pdata->capabilities = res[0] | ((unsigned int)res[1] << 8) | ((unsigned int)res[2] << 16) | ((unsigned int)res[3] << 24); + else + pdata->capabilities = 0; + + pdata->use_tpi = ((pdata->capabilities & USBASP_CAP_TPI) != 0 && (p->flags & AVRPART_HAS_TPI) != 0) ? 1 : 0; + + if(pdata->use_tpi) + { + /* calc tpiclk delay */ + int dly = 1500000.0 * pgm->bitclock; + if(dly < 1) + dly = 1; + else if(dly > 2047) + dly = 2047; + temp[0] = dly; + temp[1] = dly >> 8; + + /* connect */ + usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_CONNECT, temp, res, sizeof(res)); + + /* change interface */ + pgm->program_enable = usbasp_tpi_program_enable; + pgm->chip_erase = usbasp_tpi_chip_erase; + pgm->cmd = usbasp_tpi_cmd; + pgm->read_byte = usbasp_tpi_read_byte; + pgm->write_byte = usbasp_tpi_write_byte; + pgm->paged_write = usbasp_tpi_paged_write; + pgm->paged_load = usbasp_tpi_paged_load; + pgm->set_sck_period = usbasp_tpi_set_sck_period; + } + else + { + /* set sck period */ + pgm->set_sck_period(pgm, pgm->bitclock); + + /* connect to target device */ + usbasp_transmit(pgm, 1, USBASP_FUNC_CONNECT, temp, res, sizeof(res)); + + /* change interface */ + pgm->program_enable = usbasp_spi_program_enable; + pgm->chip_erase = usbasp_spi_chip_erase; + pgm->cmd = usbasp_spi_cmd; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; + pgm->paged_write = usbasp_spi_paged_write; + pgm->paged_load = usbasp_spi_paged_load; + pgm->set_sck_period = usbasp_spi_set_sck_period; + } + + /* wait, so device is ready to receive commands */ + usleep(100000); + + return pgm->program_enable(pgm, p); +} + +/* SPI specific functions */ +static int usbasp_spi_cmd(PROGRAMMER * pgm, const unsigned char *cmd, + unsigned char *res) +{ + avrdude_message(MSG_DEBUG, "%s: usbasp_spi_cmd(0x%02x, 0x%02x, 0x%02x, 0x%02x)%s", + progname, cmd[0], cmd[1], cmd[2], cmd[3], + verbose > 3? "...\n": ""); + + int nbytes = + usbasp_transmit(pgm, 1, USBASP_FUNC_TRANSMIT, cmd, res, 4); + + if(nbytes != 4){ + if (verbose == 3) + putc('\n', stderr); + + avrdude_message(MSG_INFO, "%s: error: wrong responds size\n", + progname); + return -1; + } + avrdude_message(MSG_TRACE, "%s: usbasp_spi_cmd()", progname); + avrdude_message(MSG_DEBUG, " => 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", + res[0], res[1], res[2], res[3]); + + return 0; +} + +static int usbasp_spi_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char res[4]; + unsigned char cmd[4]; + memset(cmd, 0, sizeof(cmd)); + memset(res, 0, sizeof(res)); + + cmd[0] = 0; + + avrdude_message(MSG_DEBUG, "%s: usbasp_program_enable()\n", + progname); + + int nbytes = + usbasp_transmit(pgm, 1, USBASP_FUNC_ENABLEPROG, cmd, res, sizeof(res)); + + if ((nbytes != 1) | (res[0] != 0)) { + avrdude_message(MSG_INFO, "%s: error: program enable: target doesn't answer. %x \n", + progname, res[0]); + return -1; + } + + return 0; +} + +static int usbasp_spi_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char cmd[4]; + unsigned char res[4]; + + avrdude_message(MSG_DEBUG, "%s: usbasp_chip_erase()\n", + progname); + + if (p->op[AVR_OP_CHIP_ERASE] == NULL) { + avrdude_message(MSG_INFO, "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 int usbasp_spi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int address, unsigned int n_bytes) +{ + int n; + unsigned char cmd[4]; + int wbytes = n_bytes; + int blocksize; + unsigned char *buffer = m->buf + address; + int function; + + avrdude_message(MSG_DEBUG, "%s: usbasp_program_paged_load(\"%s\", 0x%x, %d)\n", + progname, m->desc, address, n_bytes); + + if (strcmp(m->desc, "flash") == 0) { + function = USBASP_FUNC_READFLASH; + } else if (strcmp(m->desc, "eeprom") == 0) { + function = USBASP_FUNC_READEEPROM; + } else { + return -2; + } + + /* set blocksize depending on sck frequency */ + if ((PDATA(pgm)->sckfreq_hz > 0) && (PDATA(pgm)->sckfreq_hz < 10000)) { + blocksize = USBASP_READBLOCKSIZE / 10; + } else { + blocksize = USBASP_READBLOCKSIZE; + } + + while (wbytes) { + if (wbytes <= blocksize) { + blocksize = wbytes; + } + wbytes -= blocksize; + + /* set address (new mode) - if firmware on usbasp support newmode, then they use address from this command */ + unsigned char temp[4]; + memset(temp, 0, sizeof(temp)); + cmd[0] = address & 0xFF; + cmd[1] = address >> 8; + cmd[2] = address >> 16; + cmd[3] = address >> 24; + usbasp_transmit(pgm, 1, USBASP_FUNC_SETLONGADDRESS, cmd, temp, sizeof(temp)); + + /* send command with address (compatibility mode) - if firmware on + usbasp doesn't support newmode, then they use address from this */ + cmd[0] = address & 0xFF; + cmd[1] = address >> 8; + // for compatibility - previous version of usbasp.c doesn't initialize this fields (firmware ignore it) + cmd[2] = 0; + cmd[3] = 0; + + n = usbasp_transmit(pgm, 1, function, cmd, buffer, blocksize); + + if (n != blocksize) { + avrdude_message(MSG_INFO, "%s: error: wrong reading bytes %x\n", + progname, n); + return -3; + } + + buffer += blocksize; + address += blocksize; + } + + return n_bytes; +} + +static int usbasp_spi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int address, unsigned int n_bytes) +{ + int n; + unsigned char cmd[4]; + int wbytes = n_bytes; + int blocksize; + unsigned char *buffer = m->buf + address; + unsigned char blockflags = USBASP_BLOCKFLAG_FIRST; + int function; + + avrdude_message(MSG_DEBUG, "%s: usbasp_program_paged_write(\"%s\", 0x%x, %d)\n", + progname, m->desc, address, n_bytes); + + if (strcmp(m->desc, "flash") == 0) { + function = USBASP_FUNC_WRITEFLASH; + } else if (strcmp(m->desc, "eeprom") == 0) { + function = USBASP_FUNC_WRITEEEPROM; + } else { + return -2; + } + + /* set blocksize depending on sck frequency */ + if ((PDATA(pgm)->sckfreq_hz > 0) && (PDATA(pgm)->sckfreq_hz < 10000)) { + blocksize = USBASP_WRITEBLOCKSIZE / 10; + } else { + blocksize = USBASP_WRITEBLOCKSIZE; + } + + while (wbytes) { + + if (wbytes <= blocksize) { + blocksize = wbytes; + } + wbytes -= blocksize; + + + /* set address (new mode) - if firmware on usbasp support newmode, then + they use address from this command */ + unsigned char temp[4]; + memset(temp, 0, sizeof(temp)); + cmd[0] = address & 0xFF; + cmd[1] = address >> 8; + cmd[2] = address >> 16; + cmd[3] = address >> 24; + usbasp_transmit(pgm, 1, USBASP_FUNC_SETLONGADDRESS, cmd, temp, sizeof(temp)); + + /* normal command - firmware what support newmode - use address from previous command, + firmware what doesn't support newmode - ignore previous command and use address from this command */ + + cmd[0] = address & 0xFF; + cmd[1] = address >> 8; + cmd[2] = page_size & 0xFF; + cmd[3] = (blockflags & 0x0F) + ((page_size & 0xF00) >> 4); //TP: Mega128 fix + blockflags = 0; + + n = usbasp_transmit(pgm, 0, function, cmd, buffer, blocksize); + + if (n != blocksize) { + avrdude_message(MSG_INFO, "%s: error: wrong count at writing %x\n", + progname, n); + return -3; + } + + + buffer += blocksize; + address += blocksize; + } + + return n_bytes; +} + +/* The list of SCK frequencies in Hz supported by USBasp */ +static struct sckoptions_t usbaspSCKoptions[] = { + { USBASP_ISP_SCK_1500, 1500000 }, + { USBASP_ISP_SCK_750, 750000 }, + { USBASP_ISP_SCK_375, 375000 }, + { USBASP_ISP_SCK_187_5, 187500 }, + { USBASP_ISP_SCK_93_75, 93750 }, + { USBASP_ISP_SCK_32, 32000 }, + { USBASP_ISP_SCK_16, 16000 }, + { USBASP_ISP_SCK_8, 8000 }, + { USBASP_ISP_SCK_4, 4000 }, + { USBASP_ISP_SCK_2, 2000 }, + { USBASP_ISP_SCK_1, 1000 }, + { USBASP_ISP_SCK_0_5, 500 } +}; + +/* + * Set sck period (in seconds) + * Find next possible sck period and write it to the programmer. + */ +static int usbasp_spi_set_sck_period(PROGRAMMER *pgm, double sckperiod) +{ + char clockoption = USBASP_ISP_SCK_AUTO; + unsigned char res[4]; + unsigned char cmd[4]; + + avrdude_message(MSG_DEBUG, "%s: usbasp_spi_set_sck_period(%g)\n", + progname, sckperiod); + + memset(cmd, 0, sizeof(cmd)); + memset(res, 0, sizeof(res)); + + /* reset global sck frequency to auto */ + PDATA(pgm)->sckfreq_hz = 0; + + if (sckperiod == 0) { + /* auto sck set */ + + avrdude_message(MSG_NOTICE, "%s: auto set sck period (because given equals null)\n", progname); + + } else { + + int sckfreq = 1 / sckperiod; /* sck in Hz */ + int usefreq = 0; + + avrdude_message(MSG_NOTICE2, "%s: try to set SCK period to %g s (= %i Hz)\n", progname, sckperiod, sckfreq); + + if (sckfreq >= usbaspSCKoptions[0].frequency) { + clockoption = usbaspSCKoptions[0].id; + usefreq = usbaspSCKoptions[0].frequency; + } else { + + /* find clock option next to given clock */ + int i; + for (i = 0; i < sizeof(usbaspSCKoptions) / sizeof(usbaspSCKoptions[0]); i++) { + if (sckfreq >= usbaspSCKoptions[i].frequency - 1) { /* subtract 1 to compensate round errors */ + clockoption = usbaspSCKoptions[i].id; + usefreq = usbaspSCKoptions[i].frequency; + break; + } + } + } + + /* save used sck frequency */ + PDATA(pgm)->sckfreq_hz = usefreq; + + avrdude_message(MSG_INFO, "%s: set SCK frequency to %i Hz\n", progname, usefreq); + } + + cmd[0] = clockoption; + + int nbytes = + usbasp_transmit(pgm, 1, USBASP_FUNC_SETISPSCK, cmd, res, sizeof(res)); + + if ((nbytes != 1) | (res[0] != 0)) { + avrdude_message(MSG_INFO, "%s: warning: cannot set sck period. please check for usbasp firmware update.\n", + progname); + return -1; + } + + return 0; +} + +/* TPI specific functions */ +static void usbasp_tpi_send_byte(PROGRAMMER * pgm, uint8_t b) +{ + unsigned char temp[4]; + memset(temp, 0, sizeof(temp)); + + temp[0] = b; + + usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_RAWWRITE, temp, temp, sizeof(temp)); +} + + +static int usbasp_tpi_recv_byte(PROGRAMMER * pgm) +{ + unsigned char temp[4]; + memset(temp, 0, sizeof(temp)); + + if(usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_RAWREAD, temp, temp, sizeof(temp)) != 1) + { + avrdude_message(MSG_INFO, "%s: error: wrong responds size\n", progname); + return -1; + } + + return temp[0]; +} + + +static int usbasp_tpi_nvm_waitbusy(PROGRAMMER * pgm) +{ + int retry; + + avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_nvm_waitbusy() ...", progname); + + for(retry=50; retry>0; retry--) + { + usbasp_tpi_send_byte(pgm, TPI_OP_SIN(NVMCSR)); + if(usbasp_tpi_recv_byte(pgm) & NVMCSR_BSY) + continue; + + avrdude_message(MSG_DEBUG, " ready\n"); + + return 0; + } + + avrdude_message(MSG_DEBUG, " failure\n"); + + return -1; +} + +static int usbasp_tpi_cmd(PROGRAMMER * pgm, const unsigned char *cmd, unsigned char *res) +{ + avrdude_message(MSG_INFO, "%s: error: spi_cmd used in TPI mode: not allowed\n", progname); + return -1; +} + +static int usbasp_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p) +{ + int retry; + + avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_program_enable()\n", progname); + + /* change guard time */ + usbasp_tpi_send_byte(pgm, TPI_OP_SSTCS(TPIPCR)); + usbasp_tpi_send_byte(pgm, TPIPCR_GT_2b); + + /* send SKEY */ + usbasp_tpi_send_byte(pgm, 0xE0); + usbasp_tpi_send_byte(pgm, 0xFF); + usbasp_tpi_send_byte(pgm, 0x88); + usbasp_tpi_send_byte(pgm, 0xD8); + usbasp_tpi_send_byte(pgm, 0xCD); + usbasp_tpi_send_byte(pgm, 0x45); + usbasp_tpi_send_byte(pgm, 0xAB); + usbasp_tpi_send_byte(pgm, 0x89); + usbasp_tpi_send_byte(pgm, 0x12); + + /* check if device is ready */ + for(retry=0; retry<10; retry++) + { + usbasp_tpi_send_byte(pgm, TPI_OP_SLDCS(TPIIR)); + if(usbasp_tpi_recv_byte(pgm) != 0x80) + continue; + usbasp_tpi_send_byte(pgm, TPI_OP_SLDCS(TPISR)); + if((usbasp_tpi_recv_byte(pgm) & TPISR_NVMEN) == 0) + continue; + break; + } + if(retry >= 10) + { + avrdude_message(MSG_INFO, "%s: error: program enable: target doesn't answer.\n", progname); + return -1; + } + + return 0; +} + +static int usbasp_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_chip_erase()\n", progname); + + /* Set PR to flash */ + usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(0)); + usbasp_tpi_send_byte(pgm, 0x01); + usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(1)); + usbasp_tpi_send_byte(pgm, 0x40); + /* select ERASE */ + usbasp_tpi_send_byte(pgm, TPI_OP_SOUT(NVMCMD)); + usbasp_tpi_send_byte(pgm, NVMCMD_CHIP_ERASE); + /* dummy write */ + usbasp_tpi_send_byte(pgm, TPI_OP_SST_INC); + usbasp_tpi_send_byte(pgm, 0x00); + usbasp_tpi_nvm_waitbusy(pgm); + + usleep(p->chip_erase_delay); + pgm->initialize(pgm, p); + + return 0; +} + +static int usbasp_tpi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned char cmd[4]; + unsigned char* dptr; + int readed, clen, n; + uint16_t pr; + + + avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_paged_load(\"%s\", 0x%0x, %d)\n", + progname, m->desc, addr, n_bytes); + + dptr = addr + m->buf; + pr = addr + m->offset; + readed = 0; + + while(readed < n_bytes) + { + clen = n_bytes - readed; + if(clen > 32) + clen = 32; + + /* prepare READBLOCK cmd */ + cmd[0] = pr & 0xFF; + cmd[1] = pr >> 8; + cmd[2] = 0; + cmd[3] = 0; + n = usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_READBLOCK, cmd, dptr, clen); + if(n != clen) + { + avrdude_message(MSG_INFO, "%s: error: wrong reading bytes %x\n", progname, n); + return -3; + } + + readed += clen; + pr += clen; + dptr += clen; + } + + return n_bytes; +} + +static int usbasp_tpi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned char cmd[4]; + unsigned char* sptr; + int writed, clen, n; + uint16_t pr; + + + avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_paged_write(\"%s\", 0x%0x, %d)\n", + progname, m->desc, addr, n_bytes); + + sptr = addr + m->buf; + pr = addr + m->offset; + writed = 0; + + /* Set PR to flash */ + usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(0)); + usbasp_tpi_send_byte(pgm, (pr & 0xFF) | 1 ); + usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(1)); + usbasp_tpi_send_byte(pgm, (pr >> 8) ); + + while(writed < n_bytes) + { + clen = n_bytes - writed; + if(clen > 32) + clen = 32; + + /* prepare WRITEBLOCK cmd */ + cmd[0] = pr & 0xFF; + cmd[1] = pr >> 8; + cmd[2] = 0; + cmd[3] = 0; + n = usbasp_transmit(pgm, 0, USBASP_FUNC_TPI_WRITEBLOCK, cmd, sptr, clen); + if(n != clen) + { + avrdude_message(MSG_INFO, "%s: error: wrong count at writing %x\n", progname, n); + return -3; + } + + writed += clen; + pr += clen; + sptr += clen; + } + + return n_bytes; +} + +static int usbasp_tpi_set_sck_period(PROGRAMMER *pgm, double sckperiod) +{ + return 0; +} +static int usbasp_tpi_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr, unsigned char * value) +{ + unsigned char cmd[4]; + int n; + uint16_t pr; + + + avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_read_byte(\"%s\", 0x%0lx)\n", + progname, m->desc, addr); + + pr = m->offset + addr; + + /* READBLOCK */ + cmd[0] = pr & 0xFF; + cmd[1] = pr >> 8; + cmd[2] = 0; + cmd[3] = 0; + n = usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_READBLOCK, cmd, value, 1); + if(n != 1) + { + avrdude_message(MSG_INFO, "%s: error: wrong reading bytes %x\n", progname, n); + return -3; + } + return 0; +} + +static int usbasp_tpi_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr, unsigned char data) +{ + avrdude_message(MSG_INFO, "%s: error: usbasp_write_byte in TPI mode: all writes have to be done at page level\n", progname); + return -1; +} + + +void usbasp_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "usbasp"); + + /* + * mandatory functions + */ + + pgm->initialize = usbasp_initialize; + pgm->display = usbasp_display; + pgm->enable = usbasp_enable; + pgm->disable = usbasp_disable; + pgm->program_enable = usbasp_spi_program_enable; + pgm->chip_erase = usbasp_spi_chip_erase; + pgm->cmd = usbasp_spi_cmd; + pgm->open = usbasp_open; + pgm->close = usbasp_close; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; + + /* + * optional functions + */ + + pgm->paged_write = usbasp_spi_paged_write; + pgm->paged_load = usbasp_spi_paged_load; + pgm->setup = usbasp_setup; + pgm->teardown = usbasp_teardown; + pgm->set_sck_period = usbasp_spi_set_sck_period; + +} + + +#else /* HAVE_LIBUSB */ + +static int usbasp_nousb_open (struct programmer_t *pgm, char * name) +{ + avrdude_message(MSG_INFO, "%s: error: no usb support. please compile again with libusb installed.\n", + progname); + + return -1; +} + +void usbasp_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "usbasp"); + + pgm->open = usbasp_nousb_open; +} + +#endif /* HAVE_LIBUSB */ + +const char usbasp_desc[] = "USBasp programmer, see http://www.fischl.de/usbasp/"; + diff --git a/xs/src/avrdude/usbasp.h b/xs/src/avrdude/usbasp.h new file mode 100644 index 000000000..573d2b853 --- /dev/null +++ b/xs/src/avrdude/usbasp.h @@ -0,0 +1,137 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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 usbasp_h +#define usbasp_h + +/* USB function call identifiers */ +#define USBASP_FUNC_CONNECT 1 +#define USBASP_FUNC_DISCONNECT 2 +#define USBASP_FUNC_TRANSMIT 3 +#define USBASP_FUNC_READFLASH 4 +#define USBASP_FUNC_ENABLEPROG 5 +#define USBASP_FUNC_WRITEFLASH 6 +#define USBASP_FUNC_READEEPROM 7 +#define USBASP_FUNC_WRITEEEPROM 8 +#define USBASP_FUNC_SETLONGADDRESS 9 +#define USBASP_FUNC_SETISPSCK 10 +#define USBASP_FUNC_TPI_CONNECT 11 +#define USBASP_FUNC_TPI_DISCONNECT 12 +#define USBASP_FUNC_TPI_RAWREAD 13 +#define USBASP_FUNC_TPI_RAWWRITE 14 +#define USBASP_FUNC_TPI_READBLOCK 15 +#define USBASP_FUNC_TPI_WRITEBLOCK 16 +#define USBASP_FUNC_GETCAPABILITIES 127 + +/* USBASP capabilities */ +#define USBASP_CAP_TPI 0x01 + +/* Block mode flags */ +#define USBASP_BLOCKFLAG_FIRST 1 +#define USBASP_BLOCKFLAG_LAST 2 + +/* Block mode data size */ +#define USBASP_READBLOCKSIZE 200 +#define USBASP_WRITEBLOCKSIZE 200 + +/* ISP SCK speed identifiers */ +#define USBASP_ISP_SCK_AUTO 0 +#define USBASP_ISP_SCK_0_5 1 /* 500 Hz */ +#define USBASP_ISP_SCK_1 2 /* 1 kHz */ +#define USBASP_ISP_SCK_2 3 /* 2 kHz */ +#define USBASP_ISP_SCK_4 4 /* 4 kHz */ +#define USBASP_ISP_SCK_8 5 /* 8 kHz */ +#define USBASP_ISP_SCK_16 6 /* 16 kHz */ +#define USBASP_ISP_SCK_32 7 /* 32 kHz */ +#define USBASP_ISP_SCK_93_75 8 /* 93.75 kHz */ +#define USBASP_ISP_SCK_187_5 9 /* 187.5 kHz */ +#define USBASP_ISP_SCK_375 10 /* 375 kHz */ +#define USBASP_ISP_SCK_750 11 /* 750 kHz */ +#define USBASP_ISP_SCK_1500 12 /* 1.5 MHz */ + +/* TPI instructions */ +#define TPI_OP_SLD 0x20 +#define TPI_OP_SLD_INC 0x24 +#define TPI_OP_SST 0x60 +#define TPI_OP_SST_INC 0x64 +#define TPI_OP_SSTPR(a) (0x68 | (a)) +#define TPI_OP_SIN(a) (0x10 | (((a)<<1)&0x60) | ((a)&0x0F) ) +#define TPI_OP_SOUT(a) (0x90 | (((a)<<1)&0x60) | ((a)&0x0F) ) +#define TPI_OP_SLDCS(a) (0x80 | ((a)&0x0F) ) +#define TPI_OP_SSTCS(a) (0xC0 | ((a)&0x0F) ) +#define TPI_OP_SKEY 0xE0 + +/* TPI control/status registers */ +#define TPIIR 0xF +#define TPIPCR 0x2 +#define TPISR 0x0 + +// TPIPCR bits +#define TPIPCR_GT_2 0x04 +#define TPIPCR_GT_1 0x02 +#define TPIPCR_GT_0 0x01 +#define TPIPCR_GT_128b 0x00 +#define TPIPCR_GT_64b 0x01 +#define TPIPCR_GT_32b 0x02 +#define TPIPCR_GT_16b 0x03 +#define TPIPCR_GT_8b 0x04 +#define TPIPCR_GT_4b 0x05 +#define TPIPCR_GT_2b 0x06 +#define TPIPCR_GT_0b 0x07 + +// TPISR bits +#define TPISR_NVMEN 0x02 + +/* NVM registers */ +#define NVMCSR 0x32 +#define NVMCMD 0x33 + +// NVMCSR bits +#define NVMCSR_BSY 0x80 + +// NVMCMD values +#define NVMCMD_NOP 0x00 +#define NVMCMD_CHIP_ERASE 0x10 +#define NVMCMD_SECTION_ERASE 0x14 +#define NVMCMD_WORD_WRITE 0x1D + + +typedef struct sckoptions_t { + int id; + double frequency; +} CLOCKOPTIONS; + +/* USB error identifiers */ +#define USB_ERROR_NOTFOUND 1 +#define USB_ERROR_ACCESS 2 +#define USB_ERROR_IO 3 + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char usbasp_desc[]; +void usbasp_initpgm (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif /* usbasp_h */ diff --git a/xs/src/avrdude/usbdevs.h b/xs/src/avrdude/usbdevs.h new file mode 100644 index 000000000..a3bc413ca --- /dev/null +++ b/xs/src/avrdude/usbdevs.h @@ -0,0 +1,83 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * 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 + * 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$ */ + +/* + * defines for the USB interface + */ + +#ifndef usbdevs_h +#define usbdevs_h + +#define USB_VENDOR_ATMEL 1003 +#define USB_DEVICE_JTAGICEMKII 0x2103 +#define USB_DEVICE_AVRISPMKII 0x2104 +#define USB_DEVICE_STK600 0x2106 +#define USB_DEVICE_AVRDRAGON 0x2107 +#define USB_DEVICE_JTAGICE3 0x2110 +#define USB_DEVICE_XPLAINEDPRO 0x2111 +#define USB_DEVICE_JTAG3_EDBG 0x2140 +#define USB_DEVICE_ATMEL_ICE 0x2141 + +#define USB_VENDOR_FTDI 0x0403 +#define USB_DEVICE_FT2232 0x6010 +#define USB_DEVICE_FT245 0x6001 + +#define USBASP_SHARED_VID 0x16C0 /* VOTI */ +#define USBASP_SHARED_PID 0x05DC /* Obdev's free shared PID */ + +#define USBASP_OLD_VID 0x03EB /* ATMEL */ +#define USBASP_OLD_PID 0xC7B4 /* (unoffical) USBasp */ + +#define USBASP_NIBOBEE_VID 0x16C0 /* VOTI */ +#define USBASP_NIBOBEE_PID 0x092F /* NIBObee PID */ + +// these are specifically assigned to USBtiny, +// if you need your own VID and PIDs you can get them for cheap from +// www.mecanique.co.uk so please don't reuse these. Thanks! +#define USBTINY_VENDOR_DEFAULT 0x1781 +#define USBTINY_PRODUCT_DEFAULT 0x0C9F + + + +/* JTAGICEmkII, AVRISPmkII */ +#define USBDEV_BULK_EP_WRITE_MKII 0x02 +#define USBDEV_BULK_EP_READ_MKII 0x82 +#define USBDEV_MAX_XFER_MKII 64 + +/* STK600 */ +#define USBDEV_BULK_EP_WRITE_STK600 0x02 +#define USBDEV_BULK_EP_READ_STK600 0x83 + +/* JTAGICE3 */ +#define USBDEV_BULK_EP_WRITE_3 0x01 +#define USBDEV_BULK_EP_READ_3 0x82 +#define USBDEV_EVT_EP_READ_3 0x83 +#define USBDEV_MAX_XFER_3 512 + +/* + * When operating on the JTAGICE3, usbdev_recv_frame() returns an + * indication in the upper bits of the return value whether the + * message has been received from the event endpoint rather than the + * normal conversation endpoint. + */ +#define USB_RECV_LENGTH_MASK 0x0fff /* up to 4 KiB */ +#define USB_RECV_FLAG_EVENT 0x1000 + +#endif /* usbdevs_h */ diff --git a/xs/src/avrdude/usbtiny.c b/xs/src/avrdude/usbtiny.c new file mode 100644 index 000000000..b6bc7cc07 --- /dev/null +++ b/xs/src/avrdude/usbtiny.c @@ -0,0 +1,589 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2007 Dick Streefland, adapted for 5.4 by Limor Fried + * + * 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 . + */ + +/* + * Driver for "usbtiny"-type programmers + * Please see http://www.xs4all.nl/~dicks/avr/usbtiny/ + * and http://www.ladyada.net/make/usbtinyisp/ + * For example schematics and detailed documentation + */ + +#include "ac_cfg.h" + +#include +#include +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "usbtiny.h" +#include "usbdevs.h" + +#if defined(HAVE_LIBUSB) // we use LIBUSB to talk to the board +#if defined(HAVE_USB_H) +# include +#elif defined(HAVE_LUSB0_USB_H) +# include +#else +# error "libusb needs either or " +#endif + +#ifndef HAVE_UINT_T +typedef unsigned int uint_t; +#endif +#ifndef HAVE_ULONG_T +typedef unsigned long ulong_t; +#endif + +extern int avr_write_byte_default ( PROGRAMMER* pgm, AVRPART* p, + AVRMEM* mem, ulong_t addr, + unsigned char data ); +/* + * Private data for this programmer. + */ +struct pdata +{ + usb_dev_handle *usb_handle; + int sck_period; + int chunk_size; + int retries; +}; + +#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) + +// ---------------------------------------------------------------------- + +static void usbtiny_setup(PROGRAMMER * pgm) +{ + if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { + avrdude_message(MSG_INFO, "%s: usbtiny_setup(): Out of memory allocating private data\n", + progname); + exit(1); + } + memset(pgm->cookie, 0, sizeof(struct pdata)); +} + +static void usbtiny_teardown(PROGRAMMER * pgm) +{ + free(pgm->cookie); +} + +// Wrapper for simple usb_control_msg messages +static int usb_control (PROGRAMMER * pgm, + unsigned int requestid, unsigned int val, unsigned int index ) +{ + int nbytes; + nbytes = usb_control_msg( PDATA(pgm)->usb_handle, + USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + requestid, + val, index, // 2 bytes each of data + NULL, 0, // no data buffer in control messge + USB_TIMEOUT ); // default timeout + if(nbytes < 0){ + avrdude_message(MSG_INFO, "\n%s: error: usbtiny_transmit: %s\n", progname, usb_strerror()); + return -1; + } + + return nbytes; +} + +// Wrapper for simple usb_control_msg messages to receive data from programmer +static int usb_in (PROGRAMMER * pgm, + unsigned int requestid, unsigned int val, unsigned int index, + unsigned char* buffer, int buflen, int bitclk ) +{ + int nbytes; + int timeout; + int i; + + // calculate the amout of time we expect the process to take by + // figuring the bit-clock time and buffer size and adding to the standard USB timeout. + timeout = USB_TIMEOUT + (buflen * bitclk) / 1000; + + for (i = 0; i < 10; i++) { + nbytes = usb_control_msg( PDATA(pgm)->usb_handle, + USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + requestid, + val, index, + (char *)buffer, buflen, + timeout); + if (nbytes == buflen) { + return nbytes; + } + PDATA(pgm)->retries++; + } + avrdude_message(MSG_INFO, "\n%s: error: usbtiny_receive: %s (expected %d, got %d)\n", + progname, usb_strerror(), buflen, nbytes); + return -1; +} + +// Report the number of retries, and reset the counter. +static void check_retries (PROGRAMMER * pgm, const char* operation) +{ + if (PDATA(pgm)->retries > 0 && quell_progress < 2) { + avrdude_message(MSG_INFO, "%s: %d retries during %s\n", progname, + PDATA(pgm)->retries, operation); + } + PDATA(pgm)->retries = 0; +} + +// Wrapper for simple usb_control_msg messages to send data to programmer +static int usb_out (PROGRAMMER * pgm, + unsigned int requestid, unsigned int val, unsigned int index, + unsigned char* buffer, int buflen, int bitclk ) +{ + int nbytes; + int timeout; + + // calculate the amout of time we expect the process to take by + // figuring the bit-clock time and buffer size and adding to the standard USB timeout. + timeout = USB_TIMEOUT + (buflen * bitclk) / 1000; + + nbytes = usb_control_msg( PDATA(pgm)->usb_handle, + USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + requestid, + val, index, + (char *)buffer, buflen, + timeout); + if (nbytes != buflen) { + avrdude_message(MSG_INFO, "\n%s: error: usbtiny_send: %s (expected %d, got %d)\n", + progname, usb_strerror(), buflen, nbytes); + return -1; + } + + return nbytes; +} + +// Sometimes we just need to know the SPI command for the part to perform +// a function. Here we wrap this request for an operation so that we +// can just specify the part and operation and it'll do the right stuff +// to get the information from AvrDude and send to the USBtiny +static int usbtiny_avr_op (PROGRAMMER * pgm, AVRPART * p, + int op, + unsigned char *res) +{ + unsigned char cmd[4]; + + if (p->op[op] == NULL) { + avrdude_message(MSG_INFO, "Operation %d not defined for this chip!\n", op ); + return -1; + } + memset(cmd, 0, sizeof(cmd)); + avr_set_bits(p->op[op], cmd); + + return pgm->cmd(pgm, cmd, res); +} + +// ---------------------------------------------------------------------- + +/* Find a device with the correct VID/PID match for USBtiny */ + +static int usbtiny_open(PROGRAMMER* pgm, char* name) +{ + struct usb_bus *bus; + struct usb_device *dev = 0; + char *bus_name = NULL; + char *dev_name = NULL; + int vid, pid; + + // if no -P was given or '-P usb' was given + if(strcmp(name, "usb") == 0) + name = NULL; + else { + // calculate bus and device names from -P option + const size_t usb_len = strlen("usb"); + if(strncmp(name, "usb", usb_len) == 0 && ':' == name[usb_len]) { + bus_name = name + usb_len + 1; + dev_name = strchr(bus_name, ':'); + if(NULL != dev_name) + *dev_name++ = '\0'; + } + } + + usb_init(); // initialize the libusb system + usb_find_busses(); // have libusb scan all the usb busses available + usb_find_devices(); // have libusb scan all the usb devices available + + PDATA(pgm)->usb_handle = NULL; + + if (pgm->usbvid) + vid = pgm->usbvid; + else + vid = USBTINY_VENDOR_DEFAULT; + + LNODEID usbpid = lfirst(pgm->usbpid); + if (usbpid) { + pid = *(int *)(ldata(usbpid)); + if (lnext(usbpid)) + avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n", + progname, pid); + } else { + pid = USBTINY_PRODUCT_DEFAULT; + } + + + // now we iterate through all the busses and devices + for ( bus = usb_busses; bus; bus = bus->next ) { + for ( dev = bus->devices; dev; dev = dev->next ) { + if (dev->descriptor.idVendor == vid + && dev->descriptor.idProduct == pid ) { // found match? + avrdude_message(MSG_NOTICE, "%s: usbdev_open(): Found USBtinyISP, bus:device: %s:%s\n", + progname, bus->dirname, dev->filename); + // if -P was given, match device by device name and bus name + if(name != NULL && + (NULL == dev_name || + strcmp(bus->dirname, bus_name) || + strcmp(dev->filename, dev_name))) + continue; + PDATA(pgm)->usb_handle = usb_open(dev); // attempt to connect to device + + // wrong permissions or something? + if (!PDATA(pgm)->usb_handle) { + avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n", + progname, usb_strerror()); + continue; + } + } + } + } + + if(NULL != name && NULL == dev_name) { + avrdude_message(MSG_INFO, "%s: Error: Invalid -P value: '%s'\n", progname, name); + avrdude_message(MSG_INFO, "%sUse -P usb:bus:device\n", progbuf); + return -1; + } + if (!PDATA(pgm)->usb_handle) { + avrdude_message(MSG_INFO, "%s: Error: Could not find USBtiny device (0x%x/0x%x)\n", + progname, vid, pid ); + return -1; + } + + return 0; // If we got here, we must have found a good USB device +} + +/* Clean up the handle for the usbtiny */ +static void usbtiny_close ( PROGRAMMER* pgm ) +{ + if (! PDATA(pgm)->usb_handle) { + return; // not a valid handle, bail! + } + usb_close(PDATA(pgm)->usb_handle); // ask libusb to clean up + PDATA(pgm)->usb_handle = NULL; +} + +/* A simple calculator function determines the maximum size of data we can + shove through a USB connection without getting errors */ +static void usbtiny_set_chunk_size (PROGRAMMER * pgm, int period) +{ + PDATA(pgm)->chunk_size = CHUNK_SIZE; // start with the maximum (default) + while (PDATA(pgm)->chunk_size > 8 && period > 16) { + // Reduce the chunk size for a slow SCK to reduce + // the maximum time of a single USB transfer. + PDATA(pgm)->chunk_size >>= 1; + period >>= 1; + } +} + +/* Given a SCK bit-clock speed (in useconds) we verify its an OK speed and tell the + USBtiny to update itself to the new frequency */ +static int usbtiny_set_sck_period (PROGRAMMER *pgm, double v) +{ + PDATA(pgm)->sck_period = (int)(v * 1e6 + 0.5); // convert from us to 'int', the 0.5 is for rounding up + + // Make sure its not 0, as that will confuse the usbtiny + if (PDATA(pgm)->sck_period < SCK_MIN) + PDATA(pgm)->sck_period = SCK_MIN; + + // We can't go slower, due to the byte-size of the clock variable + if (PDATA(pgm)->sck_period > SCK_MAX) + PDATA(pgm)->sck_period = SCK_MAX; + + avrdude_message(MSG_NOTICE, "%s: Setting SCK period to %d usec\n", progname, + PDATA(pgm)->sck_period ); + + // send the command to the usbtiny device. + // MEME: for at90's fix resetstate? + if (usb_control(pgm, USBTINY_POWERUP, PDATA(pgm)->sck_period, RESET_LOW) < 0) + return -1; + + // with the new speed, we'll have to update how much data we send per usb transfer + usbtiny_set_chunk_size(pgm, PDATA(pgm)->sck_period); + return 0; +} + + +static int usbtiny_initialize (PROGRAMMER *pgm, AVRPART *p ) +{ + unsigned char res[4]; // store the response from usbtinyisp + + // Check for bit-clock and tell the usbtiny to adjust itself + if (pgm->bitclock > 0.0) { + // -B option specified: convert to valid range for sck_period + usbtiny_set_sck_period(pgm, pgm->bitclock); + } else { + // -B option not specified: use default + PDATA(pgm)->sck_period = SCK_DEFAULT; + avrdude_message(MSG_NOTICE, "%s: Using SCK period of %d usec\n", + progname, PDATA(pgm)->sck_period ); + if (usb_control(pgm, USBTINY_POWERUP, + PDATA(pgm)->sck_period, RESET_LOW ) < 0) + return -1; + usbtiny_set_chunk_size(pgm, PDATA(pgm)->sck_period); + } + + // Let the device wake up. + usleep(50000); + + // Attempt to use the underlying avrdude methods to connect (MEME: is this kosher?) + if (! usbtiny_avr_op(pgm, p, AVR_OP_PGM_ENABLE, res)) { + // no response, RESET and try again + if (usb_control(pgm, USBTINY_POWERUP, + PDATA(pgm)->sck_period, RESET_HIGH) < 0 || + usb_control(pgm, USBTINY_POWERUP, + PDATA(pgm)->sck_period, RESET_LOW) < 0) + return -1; + usleep(50000); + if ( ! usbtiny_avr_op( pgm, p, AVR_OP_PGM_ENABLE, res)) { + // give up + return -1; + } + } + return 0; +} + +/* Tell the USBtiny to release the output pins, etc */ +static void usbtiny_powerdown(PROGRAMMER * pgm) +{ + if (!PDATA(pgm)->usb_handle) { + return; // wasn't connected in the first place + } + usb_control(pgm, USBTINY_POWERDOWN, 0, 0); // Send USB control command to device +} + +/* Send a 4-byte SPI command to the USBtinyISP for execution + This procedure is used by higher-level Avrdude procedures */ +static int usbtiny_cmd(PROGRAMMER * pgm, const unsigned char *cmd, unsigned char *res) +{ + int nbytes; + + // Make sure its empty so we don't read previous calls if it fails + memset(res, '\0', 4 ); + + nbytes = usb_in( pgm, USBTINY_SPI, + (cmd[1] << 8) | cmd[0], // convert to 16-bit words + (cmd[3] << 8) | cmd[2], // " + res, 4, 8 * PDATA(pgm)->sck_period ); + if (nbytes < 0) + return -1; + check_retries(pgm, "SPI command"); + // print out the data we sent and received + avrdude_message(MSG_NOTICE2, "CMD: [%02x %02x %02x %02x] [%02x %02x %02x %02x]\n", + cmd[0], cmd[1], cmd[2], cmd[3], + res[0], res[1], res[2], res[3] ); + return ((nbytes == 4) && // should have read 4 bytes + res[2] == cmd[1]); // AVR's do a delayed-echo thing +} + +/* Send the chip-erase command */ +static int usbtiny_chip_erase(PROGRAMMER * pgm, AVRPART * p) +{ + unsigned char res[4]; + + if (p->op[AVR_OP_CHIP_ERASE] == NULL) { + avrdude_message(MSG_INFO, "Chip erase instruction not defined for part \"%s\"\n", + p->desc); + return -1; + } + + // get the command for erasing this chip and transmit to avrdude + if (! usbtiny_avr_op( pgm, p, AVR_OP_CHIP_ERASE, res )) { + return -1; + } + usleep( p->chip_erase_delay ); + + // prepare for further instruction + pgm->initialize(pgm, p); + + return 0; +} + +// These are required functions but don't actually do anything +static void usbtiny_enable ( PROGRAMMER* pgm ) {} + +static void usbtiny_disable ( PROGRAMMER* pgm ) {} + + +/* To speed up programming and reading, we do a 'chunked' read. + * We request just the data itself and the USBtiny uses the SPI function + * given to read in the data. Much faster than sending a 4-byte SPI request + * per byte +*/ +static int usbtiny_paged_load (PROGRAMMER * pgm, AVRPART * p, AVRMEM* m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int maxaddr = addr + n_bytes; + int chunk; + int function; + + + // First determine what we're doing + if (strcmp( m->desc, "flash" ) == 0) { + function = USBTINY_FLASH_READ; + } else { + function = USBTINY_EEPROM_READ; + } + + for (; addr < maxaddr; addr += chunk) { + chunk = PDATA(pgm)->chunk_size; // start with the maximum chunk size possible + + // Send the chunk of data to the USBtiny with the function we want + // to perform + if (usb_in(pgm, + function, // EEPROM or flash + 0, // delay between SPI commands + addr, // address in memory + m->buf + addr, // pointer to where we store data + chunk, // number of bytes + 32 * PDATA(pgm)->sck_period) // each byte gets turned into a 4-byte SPI cmd + < 0) { + // usb_in() multiplies this per byte. + return -1; + } + } + + check_retries(pgm, "read"); + return n_bytes; +} + +/* To speed up programming and reading, we do a 'chunked' write. + * We send just the data itself and the USBtiny uses the SPI function + * given to write the data. Much faster than sending a 4-byte SPI request + * per byte. +*/ +static int usbtiny_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, + unsigned int page_size, + unsigned int addr, unsigned int n_bytes) +{ + unsigned int maxaddr = addr + n_bytes; + int chunk; // Size of data to write at once + int next; + int function; // which SPI command to use + int delay; // delay required between SPI commands + + // First determine what we're doing + if (strcmp( m->desc, "flash" ) == 0) { + function = USBTINY_FLASH_WRITE; + } else { + function = USBTINY_EEPROM_WRITE; + } + + delay = 0; + if (! m->paged) { + unsigned int poll_value; + // Does this chip not support paged writes? + poll_value = (m->readback[1] << 8) | m->readback[0]; + if (usb_control(pgm, USBTINY_POLL_BYTES, poll_value, 0 ) < 0) + return -1; + delay = m->max_write_delay; + } + + for (; addr < maxaddr; addr += chunk) { + // start with the max chunk size + chunk = PDATA(pgm)->chunk_size; + + // we can only write a page at a time anyways + if (m->paged && chunk > page_size) + chunk = page_size; + + if (usb_out(pgm, + function, // Flash or EEPROM + delay, // How much to wait between each byte + addr, // Address in memory + m->buf + addr, // Pointer to data + chunk, // Number of bytes to write + 32 * PDATA(pgm)->sck_period + delay // each byte gets turned into a + // 4-byte SPI cmd usb_out() multiplies + // this per byte. Then add the cmd-delay + ) < 0) { + return -1; + } + + next = addr + chunk; // Calculate what address we're at now + if (m->paged + && ((next % page_size) == 0 || next == maxaddr) ) { + // If we're at a page boundary, send the SPI command to flush it. + avr_write_page(pgm, p, m, (unsigned long) addr); + } + } + return n_bytes; +} + +void usbtiny_initpgm ( PROGRAMMER* pgm ) +{ + strcpy(pgm->type, "USBtiny"); + + /* Mandatory Functions */ + pgm->initialize = usbtiny_initialize; + pgm->enable = usbtiny_enable; + pgm->disable = usbtiny_disable; + pgm->program_enable = NULL; + pgm->chip_erase = usbtiny_chip_erase; + pgm->cmd = usbtiny_cmd; + pgm->open = usbtiny_open; + pgm->close = usbtiny_close; + pgm->read_byte = avr_read_byte_default; + pgm->write_byte = avr_write_byte_default; + + /* Optional Functions */ + pgm->powerup = NULL; + pgm->powerdown = usbtiny_powerdown; + pgm->paged_load = usbtiny_paged_load; + pgm->paged_write = usbtiny_paged_write; + pgm->set_sck_period = usbtiny_set_sck_period; + pgm->setup = usbtiny_setup; + pgm->teardown = usbtiny_teardown; +} + +#else /* !HAVE_LIBUSB */ + +// Give a proper error if we were not compiled with libusb + +static int usbtiny_nousb_open(struct programmer_t *pgm, char * name) +{ + avrdude_message(MSG_INFO, "%s: error: no usb support. Please compile again with libusb installed.\n", + progname); + + return -1; +} + +void usbtiny_initpgm(PROGRAMMER * pgm) +{ + strcpy(pgm->type, "usbtiny"); + + pgm->open = usbtiny_nousb_open; +} + +#endif /* HAVE_LIBUSB */ + +const char usbtiny_desc[] = "Driver for \"usbtiny\"-type programmers"; + diff --git a/xs/src/avrdude/usbtiny.h b/xs/src/avrdude/usbtiny.h new file mode 100644 index 000000000..3a258b9f1 --- /dev/null +++ b/xs/src/avrdude/usbtiny.h @@ -0,0 +1,68 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2007 Limor Fried + * + * 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 . + */ + + +#ifndef usbtiny_h +#define usbtiny_h + +// Generic requests to the USBtiny +#define USBTINY_ECHO 0 // echo test +#define USBTINY_READ 1 // read byte (wIndex:address) +#define USBTINY_WRITE 2 // write byte (wIndex:address, wValue:value) +#define USBTINY_CLR 3 // clear bit (wIndex:address, wValue:bitno) +#define USBTINY_SET 4 // set bit (wIndex:address, wValue:bitno) + +// Programming requests +#define USBTINY_POWERUP 5 // apply power (wValue:SCK-period, wIndex:RESET) +#define USBTINY_POWERDOWN 6 // remove power from chip +#define USBTINY_SPI 7 // issue SPI command (wValue:c1c0, wIndex:c3c2) +#define USBTINY_POLL_BYTES 8 // set poll bytes for write (wValue:p1p2) +#define USBTINY_FLASH_READ 9 // read flash (wIndex:address) +#define USBTINY_FLASH_WRITE 10 // write flash (wIndex:address, wValue:timeout) +#define USBTINY_EEPROM_READ 11 // read eeprom (wIndex:address) +#define USBTINY_EEPROM_WRITE 12 // write eeprom (wIndex:address, wValue:timeout) + + + +// Flags to indicate how to set RESET on power up +#define RESET_LOW 0 +#define RESET_HIGH 1 + +// The SCK speed can be set by avrdude, to allow programming of slow-clocked parts +#define SCK_MIN 1 // usec delay (target clock >= 4 MHz) +#define SCK_MAX 250 // usec (target clock >= 16 KHz) +#define SCK_DEFAULT 10 // usec (target clock >= 0.4 MHz) + +// How much data, max, do we want to send in one USB packet? +#define CHUNK_SIZE 128 // must be power of 2 less than 256 + +// The default USB Timeout +#define USB_TIMEOUT 500 // msec + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char usbtiny_desc[]; +void usbtiny_initpgm (PROGRAMMER * pgm); + +#ifdef __cplusplus +} +#endif + +#endif /* usbtiny_h */ diff --git a/xs/src/avrdude/windows/.cvsignore b/xs/src/avrdude/windows/.cvsignore new file mode 100644 index 000000000..601c4fbff --- /dev/null +++ b/xs/src/avrdude/windows/.cvsignore @@ -0,0 +1,4 @@ +.cvsignore +.deps +Makefile +Makefile.in diff --git a/xs/src/avrdude/windows/Makefile.am b/xs/src/avrdude/windows/Makefile.am new file mode 100644 index 000000000..9890fd05f --- /dev/null +++ b/xs/src/avrdude/windows/Makefile.am @@ -0,0 +1,57 @@ +# +# avrdude - A Downloader/Uploader for AVR device programmers +# 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 +# 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$ +# + +# +# This Makefile will only be used on windows based systems. +# + +local_install_list = \ + giveio.sys \ + install_giveio.bat \ + remove_giveio.bat \ + status_giveio.bat + +EXTRA_DIST = \ + giveio.c \ + $(local_install_list) + +bin_PROGRAMS = loaddrv + +loaddrv_SOURCES = \ + loaddrv.c \ + loaddrv.h + +install-exec-local: + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(local_install_list)'; for file in $$list; do \ + echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) \ + $(srcdir)/$$file $(DESTDIR)$(bindir)/$$file"; \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $(srcdir)/$$file \ + $(DESTDIR)$(bindir)/$$file; \ + done + +uninstall-local: + @for file in $(local_install_list); do \ + echo " rm -f $(DESTDIR)$(bindir)/$$file"; \ + rm -f $(DESTDIR)$(bindir)/$$file; \ + done + diff --git a/xs/src/avrdude/windows/getopt.c b/xs/src/avrdude/windows/getopt.c new file mode 100644 index 000000000..cfa302335 --- /dev/null +++ b/xs/src/avrdude/windows/getopt.c @@ -0,0 +1,1258 @@ +/* Getopt for GNU. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to drepper@gnu.org + before changing it! + Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This tells Alpha OSF/1 not to define a getopt prototype in . + Ditto for AIX 3.2 and . */ +#ifndef _NO_PROTO +# define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +# include +#endif + +#if !defined __STDC__ || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +# ifndef const +# define const +# endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +# include +# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +# define ELIDE_CODE +# endif +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +# include +# include +#endif /* GNU C library. */ + +#ifdef VMS +# include +# if HAVE_STRING_H - 0 +# include +# endif +#endif + +#ifndef _ +/* This is for other GNU distributions with internationalized messages. */ +# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC +# include +# ifndef _ +# define _(msgid) gettext (msgid) +# endif +# else +# define _(msgid) (msgid) +# endif +# if defined _LIBC && defined USE_IN_LIBIO +# include +# endif +#endif + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* 1003.2 says this must be 1 before any call. */ +int optind = 1; + +/* Formerly, initialization of getopt depended on optind==0, which + causes problems with re-calling getopt as programs generally don't + know that. */ + +int __getopt_initialized; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int optopt = '?'; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return -1 with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; + +#ifdef __GNU_LIBRARY__ +/* We want to avoid inclusion of string.h with non-GNU libraries + because there are many ways it can cause trouble. + On some systems, it contains special magic macros that don't work + in GCC. */ +# include +# define my_index strchr +#else + +# if HAVE_STRING_H || WIN32 /* Pete Wilson mod 7/28/02 */ +# include +# else +# include +# endif + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +#ifndef getenv +extern char *getenv (); +#endif + +static char * +my_index (str, chr) + const char *str; + int chr; +{ + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; +} + +/* If using GCC, we can safely declare strlen this way. + If not using GCC, it is ok not to declare it. */ +#ifdef __GNUC__ +/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. + That was relevant to code that was here before. */ +# if (!defined __STDC__ || !__STDC__) && !defined strlen +/* gcc with -traditional declares the built-in strlen to return int, + and has done so at least since version 2.4.5. -- rms. */ +extern int strlen (const char *); +# endif /* not __STDC__ */ +#endif /* __GNUC__ */ + +#endif /* not __GNU_LIBRARY__ */ + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +#ifdef _LIBC +/* Stored original parameters. + XXX This is no good solution. We should rather copy the args so + that we can compare them later. But we must not use malloc(3). */ +extern int __libc_argc; +extern char **__libc_argv; + +/* Bash 2.0 gives us an environment variable containing flags + indicating ARGV elements that should not be considered arguments. */ + +# ifdef USE_NONOPTION_FLAGS +/* Defined in getopt_init.c */ +extern char *__getopt_nonoption_flags; + +static int nonoption_flags_max_len; +static int nonoption_flags_len; +# endif + +# ifdef USE_NONOPTION_FLAGS +# define SWAP_FLAGS(ch1, ch2) \ + if (nonoption_flags_len > 0) \ + { \ + char __tmp = __getopt_nonoption_flags[ch1]; \ + __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ + __getopt_nonoption_flags[ch2] = __tmp; \ + } +# else +# define SWAP_FLAGS(ch1, ch2) +# endif +#else /* !_LIBC */ +# define SWAP_FLAGS(ch1, ch2) +#endif /* _LIBC */ + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +#if defined __STDC__ && __STDC__ +static void exchange (char **); +#endif + +static void +exchange (argv) + char **argv; +{ + int bottom = first_nonopt; + int middle = last_nonopt; + int top = optind; + char *tem; + + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ + +#if defined _LIBC && defined USE_NONOPTION_FLAGS + /* First make sure the handling of the `__getopt_nonoption_flags' + string can work normally. Our top argument must be in the range + of the string. */ + if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) + { + /* We must extend the array. The user plays games with us and + presents new arguments. */ + char *new_str = malloc (top + 1); + if (new_str == NULL) + nonoption_flags_len = nonoption_flags_max_len = 0; + else + { + memset (__mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', top + 1 - nonoption_flags_max_len); + nonoption_flags_max_len = top + 1; + __getopt_nonoption_flags = new_str; + } + } +#endif + + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } + else + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + SWAP_FLAGS (bottom + i, middle + i); + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Initialize the internal data when the first call is made. */ + +#if defined __STDC__ && __STDC__ +static const char *_getopt_initialize (int, char *const *, const char *); +#endif +static const char * +_getopt_initialize (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + first_nonopt = last_nonopt = optind; + + nextchar = NULL; + + posixly_correct = getenv ("POSIXLY_CORRECT"); + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (posixly_correct != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + +#if defined _LIBC && defined USE_NONOPTION_FLAGS + if (posixly_correct == NULL + && argc == __libc_argc && argv == __libc_argv) + { + if (nonoption_flags_max_len == 0) + { + if (__getopt_nonoption_flags == NULL + || __getopt_nonoption_flags[0] == '\0') + nonoption_flags_max_len = -1; + else + { + const char *orig_str = __getopt_nonoption_flags; + int len = nonoption_flags_max_len = strlen (orig_str); + if (nonoption_flags_max_len < argc) + nonoption_flags_max_len = argc; + __getopt_nonoption_flags = + (char *) malloc (nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + nonoption_flags_max_len = -1; + else + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', nonoption_flags_max_len - len); + } + } + nonoption_flags_len = nonoption_flags_max_len; + } + else + nonoption_flags_len = 0; +#endif + + return optstring; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns -1. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) + int argc; + char *const *argv; + const char *optstring; + const struct option *longopts; + int *longind; + int long_only; +{ + int print_errors = opterr; + if (optstring[0] == ':') + print_errors = 0; + + if (argc < 1) + return -1; + + optarg = NULL; + + if (optind == 0 || !__getopt_initialized) + { + if (optind == 0) + optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize (argc, argv, optstring); + __getopt_initialized = 1; + } + + /* Test whether ARGV[optind] points to a non-option argument. + Either it does not have option syntax, or there is an environment flag + from the shell indicating it is not an option. The later information + is only used when the used in the GNU libc. */ +#if defined _LIBC && defined USE_NONOPTION_FLAGS +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ + || (optind < nonoption_flags_len \ + && __getopt_nonoption_flags[optind] == '1')) +#else +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +#endif + + if (nextchar == NULL || *nextchar == '\0') + { + /* Advance to the next ARGV-element. */ + + /* Give FIRST_NONOPT and LAST_NONOPT rational values if OPTIND has been + moved back by the user (who may also have changed the arguments). */ + if (last_nonopt > optind) + last_nonopt = optind; + if (first_nonopt > optind) + first_nonopt = optind; + + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc && NONOPTION_P) + optind++; + last_nonopt = optind; + } + + /* The special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return -1; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if (NONOPTION_P) + { + if (ordering == REQUIRE_ORDER) + return -1; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + + if (longopts != NULL + && (argv[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = -1; + int option_index; + + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) + == (unsigned int) strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else if (long_only + || pfound->has_arg != p->has_arg + || pfound->flag != p->flag + || pfound->val != p->val) + /* Second or later nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (print_errors) + { +#if defined _LIBC && defined USE_IN_LIBIO + char *buf; + + __asprintf (&buf, _("%s: option `%s' is ambiguous\n"), + argv[0], argv[optind]); + + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); + + free (buf); +#else + fprintf (stderr, _("%s: option `%s' is ambiguous\n"), + argv[0], argv[optind]); +#endif + } + nextchar += strlen (nextchar); + optind++; + optopt = 0; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (print_errors) + { +#if defined _LIBC && defined USE_IN_LIBIO + char *buf; +#endif + + if (argv[optind - 1][1] == '-') + { + /* --option */ +#if defined _LIBC && defined USE_IN_LIBIO + __asprintf (&buf, _("\ +%s: option `--%s' doesn't allow an argument\n"), + argv[0], pfound->name); +#else + fprintf (stderr, _("\ +%s: option `--%s' doesn't allow an argument\n"), + argv[0], pfound->name); +#endif + } + else + { + /* +option or -option */ +#if defined _LIBC && defined USE_IN_LIBIO + __asprintf (&buf, _("\ +%s: option `%c%s' doesn't allow an argument\n"), + argv[0], argv[optind - 1][0], + pfound->name); +#else + fprintf (stderr, _("\ +%s: option `%c%s' doesn't allow an argument\n"), + argv[0], argv[optind - 1][0], pfound->name); +#endif + } + +#if defined _LIBC && defined USE_IN_LIBIO + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); + + free (buf); +#endif + } + + nextchar += strlen (nextchar); + + optopt = pfound->val; + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (print_errors) + { +#if defined _LIBC && defined USE_IN_LIBIO + char *buf; + + __asprintf (&buf, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); + + free (buf); +#else + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); +#endif + } + nextchar += strlen (nextchar); + optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' + || my_index (optstring, *nextchar) == NULL) + { + if (print_errors) + { +#if defined _LIBC && defined USE_IN_LIBIO + char *buf; +#endif + + if (argv[optind][1] == '-') + { + /* --option */ +#if defined _LIBC && defined USE_IN_LIBIO + __asprintf (&buf, _("%s: unrecognized option `--%s'\n"), + argv[0], nextchar); +#else + fprintf (stderr, _("%s: unrecognized option `--%s'\n"), + argv[0], nextchar); +#endif + } + else + { + /* +option or -option */ +#if defined _LIBC && defined USE_IN_LIBIO + __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"), + argv[0], argv[optind][0], nextchar); +#else + fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), + argv[0], argv[optind][0], nextchar); +#endif + } + +#if defined _LIBC && defined USE_IN_LIBIO + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); + + free (buf); +#endif + } + nextchar = (char *) ""; + optind++; + optopt = 0; + return '?'; + } + } + + /* Look at and handle the next short option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (print_errors) + { +#if defined _LIBC && defined USE_IN_LIBIO + char *buf; +#endif + + if (posixly_correct) + { + /* 1003.2 specifies the format of this message. */ +#if defined _LIBC && defined USE_IN_LIBIO + __asprintf (&buf, _("%s: illegal option -- %c\n"), + argv[0], c); +#else + fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); +#endif + } + else + { +#if defined _LIBC && defined USE_IN_LIBIO + __asprintf (&buf, _("%s: invalid option -- %c\n"), + argv[0], c); +#else + fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); +#endif + } + +#if defined _LIBC && defined USE_IN_LIBIO + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); + + free (buf); +#endif + } + optopt = c; + return '?'; + } + /* Convenience. Treat POSIX -W foo same as long option --foo */ + if (temp[0] == 'W' && temp[1] == ';') + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (print_errors) + { + /* 1003.2 specifies the format of this message. */ +#if defined _LIBC && defined USE_IN_LIBIO + char *buf; + + __asprintf (&buf, _("%s: option requires an argument -- %c\n"), + argv[0], c); + + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); + + free (buf); +#else + fprintf (stderr, _("%s: option requires an argument -- %c\n"), + argv[0], c); +#endif + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + + /* optarg is now the argument, see if it's in the + table of longopts. */ + + for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) + { + if (print_errors) + { +#if defined _LIBC && defined USE_IN_LIBIO + char *buf; + + __asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"), + argv[0], argv[optind]); + + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); + + free (buf); +#else + fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), + argv[0], argv[optind]); +#endif + } + nextchar += strlen (nextchar); + optind++; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (print_errors) + { +#if defined _LIBC && defined USE_IN_LIBIO + char *buf; + + __asprintf (&buf, _("\ +%s: option `-W %s' doesn't allow an argument\n"), + argv[0], pfound->name); + + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); + + free (buf); +#else + fprintf (stderr, _("\ +%s: option `-W %s' doesn't allow an argument\n"), + argv[0], pfound->name); +#endif + } + + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (print_errors) + { +#if defined _LIBC && defined USE_IN_LIBIO + char *buf; + + __asprintf (&buf, _("\ +%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); + + free (buf); +#else + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); +#endif + } + nextchar += strlen (nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + nextchar = NULL; + return 'W'; /* Let the application handle it. */ + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = NULL; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (print_errors) + { + /* 1003.2 specifies the format of this message. */ +#if defined _LIBC && defined USE_IN_LIBIO + char *buf; + + __asprintf (&buf, + _("%s: option requires an argument -- %c\n"), + argv[0], c); + + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); + + free (buf); +#else + fprintf (stderr, + _("%s: option requires an argument -- %c\n"), + argv[0], c); +#endif + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +#endif /* Not ELIDE_CODE. */ + + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +/* #define TEST */ /* Pete Wilson mod 7/28/02 */ +#ifdef TEST + +#ifndef exit /* Pete Wilson mod 7/28/02 */ + int exit(int); /* Pete Wilson mod 7/28/02 */ +#endif /* Pete Wilson mod 7/28/02 */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == -1) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/xs/src/avrdude/windows/getopt.h b/xs/src/avrdude/windows/getopt.h new file mode 100644 index 000000000..8a45c8b13 --- /dev/null +++ b/xs/src/avrdude/windows/getopt.h @@ -0,0 +1,188 @@ + +/* getopt.h */ +/* Declarations for getopt. + Copyright (C) 1989-1994, 1996-1999, 2001 Free Software + Foundation, Inc. This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute + it and/or modify it under the terms of the GNU Lesser + General Public License as published by the Free Software + Foundation; either version 2.1 of the License, or + (at your option) any later version. + + The GNU C Library 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 Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with the GNU C Library; if not, write + to the Free Software Foundation, Inc., 59 Temple Place, + Suite 330, Boston, MA 02111-1307 USA. */ + + + + +#ifndef _GETOPT_H + +#ifndef __need_getopt +# define _GETOPT_H 1 +#endif + +/* If __GNU_LIBRARY__ is not already defined, either we are being used + standalone, or this is the first header included in the source file. + If we are being used with glibc, we need to include , but + that does not exist if we are standalone. So: if __GNU_LIBRARY__ is + not defined, include , which will pull in for us + if it's from glibc. (Why ctype.h? It's guaranteed to exist and it + doesn't flood the namespace with stuff the way some other headers do.) */ +#if !defined __GNU_LIBRARY__ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +#ifndef __need_getopt +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +# if (defined __STDC__ && __STDC__) || defined __cplusplus + const char *name; +# else + char *name; +# endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 +#endif /* need getopt */ + + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, `optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in `optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU `getopt'. + + The argument `--' causes premature termination of argument + scanning, explicitly telling `getopt' that there are no more + options. + + If OPTS begins with `--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + `getopt'. */ + +#if (defined __STDC__ && __STDC__) || defined __cplusplus +# ifdef __GNU_LIBRARY__ +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int ___argc, char *const *___argv, const char *__shortopts); +# else /* not __GNU_LIBRARY__ */ +extern int getopt (); +# endif /* __GNU_LIBRARY__ */ + +# ifndef __need_getopt +extern int getopt_long (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); +extern int getopt_long_only (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only); +# endif +#else /* not __STDC__ */ +extern int getopt (); +# ifndef __need_getopt +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +# endif +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + +#endif /* getopt.h */ diff --git a/xs/src/avrdude/windows/giveio.c b/xs/src/avrdude/windows/giveio.c new file mode 100644 index 000000000..f752a2937 --- /dev/null +++ b/xs/src/avrdude/windows/giveio.c @@ -0,0 +1,168 @@ +/********************************************************************* + +Author: Dale Roberts +Date: 8/30/95 +Program: GIVEIO.SYS +Compile: Use DDK BUILD facility + +Purpose: Give direct port I/O access to a user mode process. + +*********************************************************************/ +#include + +/* + * The name of our device driver. + */ +#define DEVICE_NAME_STRING L"giveio" + +/* + * This is the "structure" of the IOPM. It is just a simple + * character array of length 0x2000. + * + * This holds 8K * 8 bits -> 64K bits of the IOPM, which maps the + * entire 64K I/O space of the x86 processor. Any 0 bits will give + * access to the corresponding port for user mode processes. Any 1 + * bits will disallow I/O access to the corresponding port. + */ +#define IOPM_SIZE 0x2000 +typedef UCHAR IOPM[IOPM_SIZE]; + +/* + * This will hold simply an array of 0's which will be copied + * into our actual IOPM in the TSS by Ke386SetIoAccessMap(). + * The memory is allocated at driver load time. + */ +IOPM *IOPM_local = 0; + +/* + * These are the two undocumented calls that we will use to give + * the calling process I/O access. + * + * Ke386IoSetAccessMap() copies the passed map to the TSS. + * + * Ke386IoSetAccessProcess() adjusts the IOPM offset pointer so that + * the newly copied map is actually used. Otherwise, the IOPM offset + * points beyond the end of the TSS segment limit, causing any I/O + * access by the user mode process to generate an exception. + */ +void Ke386SetIoAccessMap(int, IOPM *); +void Ke386QueryIoAccessMap(int, IOPM *); +void Ke386IoSetAccessProcess(PEPROCESS, int); + +/********************************************************************* + Release any allocated objects. +*********************************************************************/ +VOID GiveioUnload(IN PDRIVER_OBJECT DriverObject) +{ + WCHAR DOSNameBuffer[] = L"\\DosDevices\\" DEVICE_NAME_STRING; + UNICODE_STRING uniDOSString; + + if(IOPM_local) + MmFreeNonCachedMemory(IOPM_local, sizeof(IOPM)); + + RtlInitUnicodeString(&uniDOSString, DOSNameBuffer); + IoDeleteSymbolicLink (&uniDOSString); + IoDeleteDevice(DriverObject->DeviceObject); +} + +/********************************************************************* + Set the IOPM (I/O permission map) of the calling process so that it +is given full I/O access. Our IOPM_local[] array is all zeros, so +the IOPM will be all zeros. If OnFlag is 1, the process is given I/O +access. If it is 0, access is removed. +*********************************************************************/ +VOID SetIOPermissionMap(int OnFlag) +{ + Ke386IoSetAccessProcess(PsGetCurrentProcess(), OnFlag); + Ke386SetIoAccessMap(1, IOPM_local); +} + +void GiveIO(void) +{ + SetIOPermissionMap(1); +} + +/********************************************************************* + Service handler for a CreateFile() user mode call. + + This routine is entered in the driver object function call table by +the DriverEntry() routine. When the user mode application calls +CreateFile(), this routine gets called while still in the context of +the user mode application, but with the CPL (the processor's Current +Privelege Level) set to 0. This allows us to do kernel mode +operations. GiveIO() is called to give the calling process I/O +access. All the user mode application needs do to obtain I/O access +is open this device with CreateFile(). No other operations are +required. +*********************************************************************/ +NTSTATUS GiveioCreateDispatch( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp + ) +{ + GiveIO(); // give the calling process I/O access + + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_SUCCESS; +} + +/********************************************************************* + Driver Entry routine. + + This routine is called only once after the driver is initially +loaded into memory. It allocates everything necessary for the +driver's operation. In our case, it allocates memory for our IOPM +array, and creates a device which user mode applications can open. +It also creates a symbolic link to the device driver. This allows +a user mode application to access our driver using the \\.\giveio +notation. +*********************************************************************/ +NTSTATUS DriverEntry( + IN PDRIVER_OBJECT DriverObject, + IN PUNICODE_STRING RegistryPath + ) +{ + PDEVICE_OBJECT deviceObject; + NTSTATUS status; + WCHAR NameBuffer[] = L"\\Device\\" DEVICE_NAME_STRING; + WCHAR DOSNameBuffer[] = L"\\DosDevices\\" DEVICE_NAME_STRING; + UNICODE_STRING uniNameString, uniDOSString; + + // + // Allocate a buffer for the local IOPM and zero it. + // + IOPM_local = MmAllocateNonCachedMemory(sizeof(IOPM)); + if(IOPM_local == 0) + return STATUS_INSUFFICIENT_RESOURCES; + RtlZeroMemory(IOPM_local, sizeof(IOPM)); + + // + // Set up device driver name and device object. + // + RtlInitUnicodeString(&uniNameString, NameBuffer); + RtlInitUnicodeString(&uniDOSString, DOSNameBuffer); + + status = IoCreateDevice(DriverObject, 0, + &uniNameString, + FILE_DEVICE_UNKNOWN, + 0, FALSE, &deviceObject); + + if(!NT_SUCCESS(status)) + return status; + + status = IoCreateSymbolicLink (&uniDOSString, &uniNameString); + + if (!NT_SUCCESS(status)) + return status; + + // + // Initialize the Driver Object with driver's entry points. + // All we require are the Create and Unload operations. + // + DriverObject->MajorFunction[IRP_MJ_CREATE] = GiveioCreateDispatch; + DriverObject->DriverUnload = GiveioUnload; + return STATUS_SUCCESS; +} + diff --git a/xs/src/avrdude/windows/giveio.sys b/xs/src/avrdude/windows/giveio.sys new file mode 100644 index 000000000..62a0cb66f Binary files /dev/null and b/xs/src/avrdude/windows/giveio.sys differ diff --git a/xs/src/avrdude/windows/install_giveio.bat b/xs/src/avrdude/windows/install_giveio.bat new file mode 100755 index 000000000..4a02b093b --- /dev/null +++ b/xs/src/avrdude/windows/install_giveio.bat @@ -0,0 +1,34 @@ +@set DIRVERNAME=giveio +@set DIRVERFILE=%DIRVERNAME%.sys + +@echo Copying the driver to the windows directory +@echo target file: %WINDIR%\%DIRVERFILE% +@copy %DIRVERFILE% %WINDIR%\%DIRVERFILE% + +@echo Remove a running service if needed... +@loaddrv stop %DIRVERNAME% >NUL +@if errorlevel 2 goto install + +@loaddrv remove %DIRVERNAME% >NUL +@if errorlevel 1 goto install + +:install +@echo Installing Windows NT/2k/XP driver: %DIRVERNAME% + +@loaddrv install %DIRVERNAME% %WINDIR%\%DIRVERFILE% +@if errorlevel 3 goto error + +@loaddrv start %DIRVERNAME% +@if errorlevel 1 goto error + +@loaddrv starttype %DIRVERNAME% auto +@if errorlevel 1 goto error + +@echo Success +@goto exit + +:error +@echo ERROR: Installation of %DIRVERNAME% failed + +:exit + diff --git a/xs/src/avrdude/windows/loaddrv.c b/xs/src/avrdude/windows/loaddrv.c new file mode 100644 index 000000000..ca92a2a1a --- /dev/null +++ b/xs/src/avrdude/windows/loaddrv.c @@ -0,0 +1,460 @@ +// loaddrv.c - Dynamic driver install/start/stop/remove +// based on Paula Tomlinson's LOADDRV program. +// She describes it in her May 1995 article in Windows/DOS Developer's +// Journal (now Windows Developer's Journal). +// Modified by Chris Liechti +// I removed the old/ugly dialog, it now accepts command line options and +// prints error messages with textual description from the OS. + +#include +#include +#include +#include +#include +#include "loaddrv.h" + +// globals +SC_HANDLE hSCMan = NULL; + +//get ext messages for windows error codes: +void DisplayErrorText(DWORD dwLastError) { + LPSTR MessageBuffer; + DWORD dwBufferLength; + + DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM; + + dwBufferLength = FormatMessageA( + dwFormatFlags, + NULL, // module to get message from (NULL == system) + dwLastError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language + (LPSTR) &MessageBuffer, + 0, + NULL + ); + if (dwBufferLength) { + // Output message + puts(MessageBuffer); + // Free the buffer allocated by the system. + LocalFree(MessageBuffer); + } +} + +int exists(char *filename) { + FILE * pFile; + pFile = fopen(filename, "r"); + return pFile != NULL; +} + +void usage(void) { + printf("USGAE: loaddrv command drivername [args...]\n\n" + "NT/2k/XP Driver and Service modification tool.\n" + "(C)2002 Chris Liechti \n\n" + "Suported commands:\n\n" + " install [fullpathforinstall]\n" + " Install new service. Loaded from given path. If path is not present,\n" + " the local directory is searched for a .sys file. If the service\n" + " already exists, it must be removed first.\n" + " start\n" + " Start service. It must be installed in advance.\n" + " stop\n" + " Stop service.\n" + " remove\n" + " Remove service. It must be stopped in advance.\n" + " status\n" + " Show status information about service.\n" + " starttype auto|manual|system|disable\n" + " Change startup type to the given type.\n" + ); +} + +int main(int argc, char *argv[]) { + DWORD status = 0; + int level = 0; + if (argc < 3) { + usage(); + exit(1); + } + LoadDriverInit(); + if (strcmp(argv[1], "start") == 0) { + printf("starting %s... ", argv[2]); + status = DriverStart(argv[2]); + if ( status != OKAY) { + printf("start failed (status %ld):\n", status); + level = 1; + } else { + printf("ok.\n"); + } + } else if (strcmp(argv[1], "stop") == 0) { + printf("stoping %s... ", argv[2]); + status = DriverStop(argv[2]); + if ( status != OKAY) { + printf("stop failed (status %ld):\n", status); + level = 1; + } else { + printf("ok.\n"); + } + } else if (strcmp(argv[1], "install") == 0) { + char path[MAX_PATH*2]; + if (argc<4) { + char cwd[MAX_PATH]; + getcwd(cwd, sizeof cwd); + sprintf(path, "%s\\%s.sys", cwd, argv[2]); + } else { + strncpy(path, argv[3], MAX_PATH); + } + if (exists(path)) { + printf("installing %s from %s... ", argv[2], path); + status = DriverInstall(path, argv[2]); + if ( status != OKAY) { + printf("install failed (status %ld):\n", status); + level = 2; + } else { + printf("ok.\n"); + } + } else { + printf("install failed, file not found: %s\n", path); + level = 1; + } + } else if (strcmp(argv[1], "remove") == 0) { + printf("removing %s... ", argv[2]); + status = DriverRemove(argv[2]); + if ( status != OKAY) { + printf("remove failed (status %ld):\n", status); + level = 1; + } else { + printf("ok.\n"); + } + } else if (strcmp(argv[1], "status") == 0) { + printf("status of %s:\n", argv[2]); + status = DriverStatus(argv[2]); + if ( status != OKAY) { + printf("stat failed (status %ld):\n", status); + level = 1; + } else { + printf("ok.\n"); + } + } else if (strcmp(argv[1], "starttype") == 0) { + if (argc < 4) { + printf("Error: need start type (string) as argument.\n"); + level = 2; + } else { + DWORD type = 0; + printf("set start type of %s to %s... ", argv[2], argv[3]); + if (strcmp(argv[1], "boot") == 0) { + type = SERVICE_BOOT_START; + } else if (strcmp(argv[3], "system") == 0) { + type = SERVICE_SYSTEM_START; + } else if (strcmp(argv[3], "auto") == 0) { + type = SERVICE_AUTO_START; + } else if (strcmp(argv[3], "manual") == 0) { + type = SERVICE_DEMAND_START; + } else if (strcmp(argv[3], "disabled") == 0) { + type = SERVICE_DISABLED; + } else { + printf("unknown type\n"); + level = 1; + } + if (level == 0) { + status = DriverStartType(argv[2], type); + if ( status != OKAY) { + printf("set start type failed (status %ld):\n", status); + level = 1; + } else { + printf("ok.\n"); + } + } + } + } else { + usage(); + level = 1; + } + if (status) DisplayErrorText(status); + LoadDriverCleanup(); + exit(level); + return 0; +} + + +DWORD LoadDriverInit(void) { + // connect to local service control manager + if ((hSCMan = OpenSCManager(NULL, NULL, + SC_MANAGER_ALL_ACCESS)) == NULL) { + return -1; + } + return OKAY; +} + +void LoadDriverCleanup(void) { + if (hSCMan != NULL) CloseServiceHandle(hSCMan); +} + +/**-----------------------------------------------------**/ +DWORD DriverInstall(LPSTR lpPath, LPSTR lpDriver) { + BOOL dwStatus = OKAY; + SC_HANDLE hService = NULL; + + // add to service control manager's database + if ((hService = CreateService(hSCMan, lpDriver, + lpDriver, SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, + SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, lpPath, + NULL, NULL, NULL, NULL, NULL)) == NULL) + dwStatus = GetLastError(); + else CloseServiceHandle(hService); + + return dwStatus; +} // DriverInstall + +/**-----------------------------------------------------**/ +DWORD DriverStart(LPSTR lpDriver) { + BOOL dwStatus = OKAY; + SC_HANDLE hService = NULL; + + // get a handle to the service + if ((hService = OpenService(hSCMan, lpDriver, + SERVICE_ALL_ACCESS)) != NULL) + { + // start the driver + if (!StartService(hService, 0, NULL)) + dwStatus = GetLastError(); + } else dwStatus = GetLastError(); + + if (hService != NULL) CloseServiceHandle(hService); + return dwStatus; +} // DriverStart + +/**-----------------------------------------------------**/ +DWORD DriverStop(LPSTR lpDriver) +{ + BOOL dwStatus = OKAY; + SC_HANDLE hService = NULL; + SERVICE_STATUS serviceStatus; + + // get a handle to the service + if ((hService = OpenService(hSCMan, lpDriver, + SERVICE_ALL_ACCESS)) != NULL) + { + // stop the driver + if (!ControlService(hService, SERVICE_CONTROL_STOP, + &serviceStatus)) + dwStatus = GetLastError(); + } else dwStatus = GetLastError(); + + if (hService != NULL) CloseServiceHandle(hService); + return dwStatus; +} // DriverStop + +/**-----------------------------------------------------**/ +DWORD DriverRemove(LPSTR lpDriver) +{ + BOOL dwStatus = OKAY; + SC_HANDLE hService = NULL; + + // get a handle to the service + if ((hService = OpenService(hSCMan, lpDriver, + SERVICE_ALL_ACCESS)) != NULL) + { // remove the driver + if (!DeleteService(hService)) + dwStatus = GetLastError(); + } else dwStatus = GetLastError(); + + if (hService != NULL) CloseServiceHandle(hService); + return dwStatus; +} // DriverRemove + +/**-----------------------------------------------------**/ +////extensions by Lch +/**-----------------------------------------------------**/ +DWORD DriverStatus(LPSTR lpDriver) { + BOOL dwStatus = OKAY; + SC_HANDLE hService = NULL; + DWORD dwBytesNeeded; + + // get a handle to the service + if ((hService = OpenService(hSCMan, lpDriver, + SERVICE_ALL_ACCESS)) != NULL) + { + LPQUERY_SERVICE_CONFIG lpqscBuf; + //~ LPSERVICE_DESCRIPTION lpqscBuf2; + // Allocate a buffer for the configuration information. + if ((lpqscBuf = (LPQUERY_SERVICE_CONFIG) LocalAlloc( + LPTR, 4096)) != NULL) + { + //~ if ((lpqscBuf2 = (LPSERVICE_DESCRIPTION) LocalAlloc( + //~ LPTR, 4096)) != NULL) + { + // Get the configuration information. + if (QueryServiceConfig( + hService, + lpqscBuf, + 4096, + &dwBytesNeeded) //&& + //~ QueryServiceConfig2( + //~ hService, + //~ SERVICE_CONFIG_DESCRIPTION, + //~ lpqscBuf2, + //~ 4096, + //~ &dwBytesNeeded + ) + { + // Print the configuration information. + printf("Type: [0x%02lx] ", lpqscBuf->dwServiceType); + switch (lpqscBuf->dwServiceType) { + case SERVICE_WIN32_OWN_PROCESS: + printf("The service runs in its own process."); + break; + case SERVICE_WIN32_SHARE_PROCESS: + printf("The service shares a process with other services."); + break; + case SERVICE_KERNEL_DRIVER: + printf("Kernel driver."); + break; + case SERVICE_FILE_SYSTEM_DRIVER: + printf("File system driver."); + break; + case SERVICE_INTERACTIVE_PROCESS: + printf("The service can interact with the desktop."); + break; + default: + printf("Unknown type."); + } + printf("\nStart Type: [0x%02lx] ", lpqscBuf->dwStartType); + switch (lpqscBuf->dwStartType) { + case SERVICE_BOOT_START: + printf("Boot"); + break; + case SERVICE_SYSTEM_START: + printf("System"); + break; + case SERVICE_AUTO_START: + printf("Automatic"); + break; + case SERVICE_DEMAND_START: + printf("Manual"); + break; + case SERVICE_DISABLED: + printf("Disabled"); + break; + default: + printf("Unknown."); + } + printf("\nError Control: [0x%02lx] ", lpqscBuf->dwErrorControl); + switch (lpqscBuf->dwErrorControl) { + case SERVICE_ERROR_IGNORE: + printf("IGNORE: Ignore."); + break; + case SERVICE_ERROR_NORMAL: + printf("NORMAL: Display a message box."); + break; + case SERVICE_ERROR_SEVERE: + printf("SEVERE: Restart with last-known-good config."); + break; + case SERVICE_ERROR_CRITICAL: + printf("CRITICAL: Restart w/ last-known-good config."); + break; + default: + printf("Unknown."); + } + printf("\nBinary path: %s\n", lpqscBuf->lpBinaryPathName); + + if (lpqscBuf->lpLoadOrderGroup != NULL) + printf("Load order grp: %s\n", lpqscBuf->lpLoadOrderGroup); + if (lpqscBuf->dwTagId != 0) + printf("Tag ID: %ld\n", lpqscBuf->dwTagId); + if (lpqscBuf->lpDependencies != NULL) + printf("Dependencies: %s\n", lpqscBuf->lpDependencies); + if (lpqscBuf->lpServiceStartName != NULL) + printf("Start Name: %s\n", lpqscBuf->lpServiceStartName); + //~ if (lpqscBuf2->lpDescription != NULL) + //~ printf("Description: %s\n", lpqscBuf2->lpDescription); + } + //~ LocalFree(lpqscBuf2); + } + LocalFree(lpqscBuf); + } else { + dwStatus = GetLastError(); + } + } else { + dwStatus = GetLastError(); + } + + if (hService != NULL) CloseServiceHandle(hService); + return dwStatus; +} // DriverStatus + +/**-----------------------------------------------------**/ +DWORD DriverStartType(LPSTR lpDriver, DWORD dwStartType) { + BOOL dwStatus = OKAY; + SC_HANDLE hService = NULL; + + SC_LOCK sclLock; + LPQUERY_SERVICE_LOCK_STATUS lpqslsBuf; + DWORD dwBytesNeeded; + + // Need to acquire database lock before reconfiguring. + sclLock = LockServiceDatabase(hSCMan); + + // If the database cannot be locked, report the details. + if (sclLock == NULL) { + // Exit if the database is not locked by another process. + if (GetLastError() == ERROR_SERVICE_DATABASE_LOCKED) { + + // Allocate a buffer to get details about the lock. + lpqslsBuf = (LPQUERY_SERVICE_LOCK_STATUS) LocalAlloc( + LPTR, sizeof(QUERY_SERVICE_LOCK_STATUS)+256); + if (lpqslsBuf != NULL) { + // Get and print the lock status information. + if (QueryServiceLockStatus( + hSCMan, + lpqslsBuf, + sizeof(QUERY_SERVICE_LOCK_STATUS)+256, + &dwBytesNeeded) ) + { + if (lpqslsBuf->fIsLocked) { + printf("Locked by: %s, duration: %ld seconds\n", + lpqslsBuf->lpLockOwner, + lpqslsBuf->dwLockDuration + ); + } else { + printf("No longer locked\n"); + } + } + LocalFree(lpqslsBuf); + } + } + dwStatus = GetLastError(); + } else { + // The database is locked, so it is safe to make changes. + // Open a handle to the service. + hService = OpenService( + hSCMan, // SCManager database + lpDriver, // name of service + SERVICE_CHANGE_CONFIG + ); // need CHANGE access + if (hService != NULL) { + // Make the changes. + if (!ChangeServiceConfig( + hService, // handle of service + SERVICE_NO_CHANGE, // service type: no change + dwStartType, // change service start type + SERVICE_NO_CHANGE, // error control: no change + NULL, // binary path: no change + NULL, // load order group: no change + NULL, // tag ID: no change + NULL, // dependencies: no change + NULL, // account name: no change + NULL, // password: no change + NULL) ) // display name: no change + { + dwStatus = GetLastError(); + } + } + // Release the database lock. + UnlockServiceDatabase(sclLock); + } + + if (hService != NULL) CloseServiceHandle(hService); + return dwStatus; +} // DriverStartType diff --git a/xs/src/avrdude/windows/loaddrv.h b/xs/src/avrdude/windows/loaddrv.h new file mode 100644 index 000000000..d7d102b97 --- /dev/null +++ b/xs/src/avrdude/windows/loaddrv.h @@ -0,0 +1,20 @@ +#ifndef LOADDRV_H +#define LOADDRV_H + +#include + +#define OKAY 0 +#define UNEXPECTED_ERROR 9999 + +//prototypes +DWORD LoadDriverInit(void); +void LoadDriverCleanup(void); +DWORD DriverInstall(LPSTR, LPSTR); +DWORD DriverStart(LPSTR); +DWORD DriverStop(LPSTR); +DWORD DriverRemove(LPSTR); +DWORD DriverStatus(LPSTR); +DWORD DriverStartType(LPSTR, DWORD); +#endif //LOADDRV_H + + diff --git a/xs/src/avrdude/windows/remove_giveio.bat b/xs/src/avrdude/windows/remove_giveio.bat new file mode 100755 index 000000000..024427db8 --- /dev/null +++ b/xs/src/avrdude/windows/remove_giveio.bat @@ -0,0 +1,14 @@ +@set DIRVERNAME=giveio + +@loaddrv stop %DIRVERNAME% +@if errorlevel 2 goto error + +@loaddrv remove %DIRVERNAME% +@if errorlevel 1 goto error + +@goto exit + +:error +@echo ERROR: Deinstallation of %DIRVERNAME% failed + +:exit diff --git a/xs/src/avrdude/windows/status_giveio.bat b/xs/src/avrdude/windows/status_giveio.bat new file mode 100755 index 000000000..bc8214749 --- /dev/null +++ b/xs/src/avrdude/windows/status_giveio.bat @@ -0,0 +1,12 @@ +@set DIRVERNAME=giveio + +@loaddrv status %DIRVERNAME% +@if errorlevel 1 goto error + +@goto exit + +:error +@echo ERROR: Status querry for %DIRVERNAME% failed + +:exit + diff --git a/xs/src/avrdude/windows/unistd.cpp b/xs/src/avrdude/windows/unistd.cpp new file mode 100644 index 000000000..e47c0b659 --- /dev/null +++ b/xs/src/avrdude/windows/unistd.cpp @@ -0,0 +1,44 @@ +#include "unistd.h" + +#include +#include +#include + +#include + + +extern "C" { + + +int usleep(unsigned usec) +{ + std::this_thread::sleep_for(std::chrono::microseconds(usec)); + return 0; +} + + +// SO: https://stackoverflow.com/questions/10905892/equivalent-of-gettimeday-for-windows +int gettimeofday(struct timeval *tp, struct timezone *tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) + // until 00:00:00 January 1, 1970 + static const std::uint64_t EPOCH = ((std::uint64_t) 116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + std::uint64_t time; + + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + time = ((std::uint64_t)file_time.dwLowDateTime); + time += ((std::uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long)((time - EPOCH) / 10000000L); + tp->tv_usec = (long)(system_time.wMilliseconds * 1000); + return 0; +} + + + +} diff --git a/xs/src/avrdude/windows/unistd.h b/xs/src/avrdude/windows/unistd.h new file mode 100644 index 000000000..b1bc6bf7f --- /dev/null +++ b/xs/src/avrdude/windows/unistd.h @@ -0,0 +1,85 @@ +#ifndef SLIC3R_AVRDUDE_UNISTD_H +#define SLIC3R_AVRDUDE_UNISTD_H 1 + +/* This is intended as a drop-in replacement for unistd.h on Windows. + * Please add functionality as neeeded. + * https://stackoverflow.com/a/826027/1202830 + */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include +#include +#include /* getopt at: https://gist.github.com/ashelly/7776712 */ +#include /* for getpid() and the exec..() family */ +#include /* for _getcwd() and _chdir() */ +#include +#include /* both for stat() */ + +#ifndef __cplusplus +#define inline __inline +#endif + +#define __func__ __FUNCTION__ + +#define srandom srand +#define random rand + +/* Values for the second argument to access. + These may be OR'd together. */ +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +//#define X_OK 1 /* execute permission - unsupported in windows*/ +#define F_OK 0 /* Test for existence. */ + +#define access _access +#define dup2 _dup2 +#define execve _execve +#define ftruncate _chsize +#define unlink _unlink +#define fileno _fileno +#define getcwd _getcwd +#define chdir _chdir +#define isatty _isatty +#define lseek _lseek +#define snprintf _snprintf +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#define stat _stat +/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ + +#ifdef _WIN64 +#define ssize_t __int64 +#else +#define ssize_t long +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +#ifndef __cplusplus +/* should be in some equivalent to */ +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +#endif + + +int usleep(unsigned usec); +int gettimeofday(struct timeval *tp, struct timezone *tzp); + + +#ifdef __cplusplus +} +#endif + +#endif /* unistd.h */ diff --git a/xs/src/avrdude/wiring.c b/xs/src/avrdude/wiring.c new file mode 100644 index 000000000..395459762 --- /dev/null +++ b/xs/src/avrdude/wiring.c @@ -0,0 +1,223 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2011 Brett Hagman + * + * 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$ */ + +/* + * avrdude interface for Wiring bootloaders + * + * http://wiring.org.co/ + * + * The Wiring bootloader uses a near-complete STK500v2 protocol. + * (Only ISP specific programming commands are not implemented + * e.g. chip erase). + * DTR and RTS signals are diddled to set the board into programming mode. + * + * Also includes an extended parameter to introduce a delay after opening + * to accommodate multi-layered programmers/bootloaders. If the extended + * parameter 'snooze' > 0, then no DTR/RTS toggle takes place, and + * AVRDUDE will wait that amount of time in milliseconds before syncing. + * + * Unfortunately, there is no way to easily chain private programmer data + * when we "inherit" programmer types as we have (stk500v2). Sooooo, a + * *cringe* global variable is used to store the snooze time. + */ + +#include "ac_cfg.h" + +#include +#include +#include +#include + +#include "avrdude.h" +#include "libavrdude.h" + +#include "stk500v2_private.h" +#include "stk500v2.h" +#include "wiring.h" + +/* + * Private data for this programmer. + */ +struct wiringpdata +{ + /* + * We just have the single snooze integer to carry around for now. + */ + int snoozetime; +}; + + +/* wiringpdata is our private data */ +/* pdata is stk500v2's private data (inherited) */ + +#define WIRINGPDATA(x) ((struct wiringpdata *)(x)) + +#define STK500V2PDATA(pgm) ((struct pdata *)(pgm->cookie)) + + +static void wiring_setup(PROGRAMMER * pgm) +{ + void *mycookie; + + /* + * First, have STK500v2 backend allocate its own private data. + */ + stk500v2_setup(pgm); + + /* + * Now prepare our data + */ + if ((mycookie = malloc(sizeof(struct wiringpdata))) == 0) { + avrdude_message(MSG_INFO, "%s: wiring_setup(): Out of memory allocating private data\n", + progname); + exit(1); + } + memset(mycookie, 0, sizeof(struct wiringpdata)); + WIRINGPDATA(mycookie)->snoozetime = 0; + + /* + * Store our own cookie in a safe place for the time being. + */ + STK500V2PDATA(pgm)->chained_pdata = mycookie; +} + +static void wiring_teardown(PROGRAMMER * pgm) +{ + void *mycookie; + + mycookie = STK500V2PDATA(pgm)->chained_pdata; + + free(mycookie); + + stk500v2_teardown(pgm); +} + +static int wiring_parseextparms(PROGRAMMER * pgm, LISTID extparms) +{ + LNODEID ln; + const char *extended_param; + int rv = 0; + void *mycookie = STK500V2PDATA(pgm)->chained_pdata; + + for (ln = lfirst(extparms); ln; ln = lnext(ln)) { + extended_param = ldata(ln); + + if (strncmp(extended_param, "snooze=", strlen("snooze=")) == 0) { + int newsnooze; + if (sscanf(extended_param, "snooze=%i", &newsnooze) != 1 || + newsnooze < 0) { + avrdude_message(MSG_INFO, "%s: wiring_parseextparms(): invalid snooze time '%s'\n", + progname, extended_param); + rv = -1; + continue; + } + avrdude_message(MSG_NOTICE2, "%s: wiring_parseextparms(): snooze time set to %d ms\n", + progname, newsnooze); + WIRINGPDATA(mycookie)->snoozetime = newsnooze; + + continue; + } + + avrdude_message(MSG_INFO, "%s: wiring_parseextparms(): invalid extended parameter '%s'\n", + progname, extended_param); + rv = -1; + } + + return rv; +} + +static int wiring_open(PROGRAMMER * pgm, char * port) +{ + int timetosnooze; + void *mycookie = STK500V2PDATA(pgm)->chained_pdata; + union pinfo pinfo; + + strcpy(pgm->port, port); + pinfo.baud = pgm->baudrate ? pgm->baudrate: 115200; + if (serial_open(port, pinfo, &pgm->fd) < 0) { + return -1; + } + + /* If we have a snoozetime, then we wait and do NOT toggle DTR/RTS */ + + if (WIRINGPDATA(mycookie)->snoozetime > 0) { + timetosnooze = WIRINGPDATA(mycookie)->snoozetime; + + avrdude_message(MSG_NOTICE2, "%s: wiring_open(): snoozing for %d ms\n", + progname, timetosnooze); + while (timetosnooze--) + usleep(1000); + avrdude_message(MSG_NOTICE2, "%s: wiring_open(): done snoozing\n", + progname); + } else { + /* Perform Wiring programming mode RESET. */ + /* This effectively *releases* both DTR and RTS. */ + /* i.e. both DTR and RTS rise to a HIGH logic level */ + /* since they are active LOW signals. */ + + avrdude_message(MSG_NOTICE2, "%s: wiring_open(): releasing DTR/RTS\n", + progname); + + serial_set_dtr_rts(&pgm->fd, 0); + usleep(50*1000); + + /* After releasing for 50 milliseconds, DTR and RTS */ + /* are asserted (i.e. logic LOW) again. */ + + avrdude_message(MSG_NOTICE2, "%s: wiring_open(): asserting DTR/RTS\n", + progname); + + serial_set_dtr_rts(&pgm->fd, 1); + usleep(50*1000); + } + + /* drain any extraneous input */ + stk500v2_drain(pgm, 0); + + if (stk500v2_getsync(pgm) < 0) + return -1; + + return 0; +} + +static void wiring_close(PROGRAMMER * pgm) +{ + serial_set_dtr_rts(&pgm->fd, 0); + serial_close(&pgm->fd); + pgm->fd.ifd = -1; +} + +const char wiring_desc[] = "http://wiring.org.co/, Basically STK500v2 protocol, with some glue to trigger the bootloader."; + +void wiring_initpgm(PROGRAMMER * pgm) +{ + /* The Wiring bootloader uses a near-complete STK500v2 protocol. */ + + stk500v2_initpgm(pgm); + + strcpy(pgm->type, "Wiring"); + pgm->open = wiring_open; + pgm->close = wiring_close; + + pgm->setup = wiring_setup; + pgm->teardown = wiring_teardown; + pgm->parseextparams = wiring_parseextparms; +} + diff --git a/xs/src/avrdude/wiring.h b/xs/src/avrdude/wiring.h new file mode 100644 index 000000000..ed1362de7 --- /dev/null +++ b/xs/src/avrdude/wiring.h @@ -0,0 +1,29 @@ +/* + * avrdude - A Downloader/Uploader for AVR device programmers + * Copyright (C) 2011 Brett Hagman + * + * 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 wiring_h__ +#define wiring_h__ + +extern const char wiring_desc[]; +void wiring_initpgm(PROGRAMMER * pgm); + +#endif + + diff --git a/xs/src/slic3r/GUI/FirmwareDialog.cpp b/xs/src/slic3r/GUI/FirmwareDialog.cpp new file mode 100644 index 000000000..8ea9d2d6e --- /dev/null +++ b/xs/src/slic3r/GUI/FirmwareDialog.cpp @@ -0,0 +1,402 @@ +#include "FirmwareDialog.hpp" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libslic3r/Utils.hpp" +#include "avrdude/avrdude-slic3r.hpp" +#include "GUI.hpp" +#include "../Utils/Serial.hpp" + +namespace fs = boost::filesystem; + + +namespace Slic3r { + + +// This enum discriminates the kind of information in EVT_AVRDUDE, +// it's stored in the ExtraLong field of wxCommandEvent. +enum AvrdudeEvent +{ + AE_MESSAGE, + AE_PRORGESS, + AE_EXIT, +}; + +wxDECLARE_EVENT(EVT_AVRDUDE, wxCommandEvent); +wxDEFINE_EVENT(EVT_AVRDUDE, wxCommandEvent); + + +// Private + +struct FirmwareDialog::priv +{ + enum AvrDudeComplete + { + AC_NONE, + AC_SUCCESS, + AC_FAILURE, + AC_CANCEL, + }; + + FirmwareDialog *q; // PIMPL back pointer ("Q-Pointer") + + wxComboBox *port_picker; + std::vector ports; + wxFilePickerCtrl *hex_picker; + wxStaticText *txt_status; + wxStaticText *txt_progress; + wxGauge *progressbar; + wxCollapsiblePane *spoiler; + wxTextCtrl *txt_stdout; + wxButton *btn_rescan; + wxButton *btn_close; + wxButton *btn_flash; + wxString btn_flash_label_ready; + wxString btn_flash_label_flashing; + + // This is a shared pointer holding the background AvrDude task + // also serves as a status indication (it is set _iff_ the background task is running, otherwise it is reset). + AvrDude::Ptr avrdude; + std::string avrdude_config; + unsigned progress_tasks_done; + bool cancelled; + + priv(FirmwareDialog *q) : + q(q), + btn_flash_label_ready(_(L("Flash!"))), + btn_flash_label_flashing(_(L("Cancel"))), + avrdude_config((fs::path(::Slic3r::resources_dir()) / "avrdude" / "avrdude.conf").string()), + progress_tasks_done(0), + cancelled(false) + {} + + void find_serial_ports(); + void flashing_status(bool flashing, AvrDudeComplete complete = AC_NONE); + void perform_upload(); + void cancel(); + void on_avrdude(const wxCommandEvent &evt); +}; + +void FirmwareDialog::priv::find_serial_ports() +{ + auto new_ports = Utils::scan_serial_ports_extended(); + if (new_ports != this->ports) { + this->ports = new_ports; + port_picker->Clear(); + for (const auto &port : this->ports) + port_picker->Append(port.friendly_name); + if (ports.size() > 0) { + int idx = port_picker->GetValue().IsEmpty() ? 0 : -1; + for (int i = 0; i < (int)this->ports.size(); ++ i) + if (this->ports[i].is_printer) { + idx = i; + break; + } + if (idx != -1) + port_picker->SetSelection(idx); + } + } +} + +void FirmwareDialog::priv::flashing_status(bool value, AvrDudeComplete complete) +{ + if (value) { + txt_stdout->Clear(); + txt_status->SetLabel(_(L("Flashing in progress. Please do not disconnect the printer!"))); + txt_status->SetForegroundColour(GUI::get_label_clr_modified()); + port_picker->Disable(); + btn_rescan->Disable(); + hex_picker->Disable(); + btn_close->Disable(); + btn_flash->SetLabel(btn_flash_label_flashing); + progressbar->SetRange(200); // See progress callback below + progressbar->SetValue(0); + progress_tasks_done = 0; + cancelled = false; + } else { + auto text_color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + port_picker->Enable(); + btn_rescan->Enable(); + hex_picker->Enable(); + btn_close->Enable(); + btn_flash->SetLabel(btn_flash_label_ready); + txt_status->SetForegroundColour(text_color); + progressbar->SetValue(200); + + switch (complete) { + case AC_SUCCESS: txt_status->SetLabel(_(L("Flashing succeeded!"))); break; + case AC_FAILURE: txt_status->SetLabel(_(L("Flashing failed. Please see the avrdude log below."))); break; + case AC_CANCEL: txt_status->SetLabel(_(L("Flashing cancelled."))); break; + } + } +} + +void FirmwareDialog::priv::perform_upload() +{ + auto filename = hex_picker->GetPath(); + std::string port = port_picker->GetValue().ToStdString(); + int selection = port_picker->GetSelection(); + if (selection != -1) { + // Verify whether the combo box list selection equals to the combo box edit value. + if (this->ports[selection].friendly_name == port) + port = this->ports[selection].port; + } + if (filename.IsEmpty() || port.empty()) { return; } + + flashing_status(true); + + std::vector args {{ + "-v", + "-p", "atmega2560", + "-c", "wiring", + "-P", port, + "-b", "115200", // XXX: is this ok to hardcode? + "-D", + "-U", (boost::format("flash:w:%1%:i") % filename.ToStdString()).str() + }}; + + BOOST_LOG_TRIVIAL(info) << "Invoking avrdude, arguments: " + << std::accumulate(std::next(args.begin()), args.end(), args[0], [](std::string a, const std::string &b) { + return a + ' ' + b; + }); + + // It is ok here to use the q-pointer to the FirmwareDialog + // because the dialog ensures it doesn't exit before the background thread is done. + auto q = this->q; + + avrdude = AvrDude() + .sys_config(avrdude_config) + .args(args) + .on_message(std::move([q](const char *msg, unsigned /* size */) { + auto evt = new wxCommandEvent(EVT_AVRDUDE, q->GetId()); + evt->SetExtraLong(AE_MESSAGE); + evt->SetString(msg); + wxQueueEvent(q, evt); + })) + .on_progress(std::move([q](const char * /* task */, unsigned progress) { + auto evt = new wxCommandEvent(EVT_AVRDUDE, q->GetId()); + evt->SetExtraLong(AE_PRORGESS); + evt->SetInt(progress); + wxQueueEvent(q, evt); + })) + .on_complete(std::move([q](int status) { + auto evt = new wxCommandEvent(EVT_AVRDUDE, q->GetId()); + evt->SetExtraLong(AE_EXIT); + evt->SetInt(status); + wxQueueEvent(q, evt); + })) + .run(); +} + +void FirmwareDialog::priv::cancel() +{ + if (avrdude) { + cancelled = true; + txt_status->SetLabel(_(L("Cancelling..."))); + avrdude->cancel(); + } +} + +void FirmwareDialog::priv::on_avrdude(const wxCommandEvent &evt) +{ + AvrDudeComplete complete_kind; + + switch (evt.GetExtraLong()) { + case AE_MESSAGE: + txt_stdout->AppendText(evt.GetString()); + break; + + case AE_PRORGESS: + // We try to track overall progress here. + // When uploading the firmware, avrdude first reads a littlebit of status data, + // then performs write, then reading (verification). + // We Pulse() during the first read and combine progress of the latter two tasks. + + if (progress_tasks_done == 0) { + progressbar->Pulse(); + } else { + progressbar->SetValue(progress_tasks_done - 100 + evt.GetInt()); + } + + if (evt.GetInt() == 100) { + progress_tasks_done += 100; + } + + break; + + case AE_EXIT: + BOOST_LOG_TRIVIAL(info) << "avrdude exit code: " << evt.GetInt(); + + complete_kind = cancelled ? AC_CANCEL : (evt.GetInt() == 0 ? AC_SUCCESS : AC_FAILURE); + flashing_status(false, complete_kind); + + // Make sure the background thread is collected and the AvrDude object reset + if (avrdude) { avrdude->join(); } + avrdude.reset(); + + break; + + default: + break; + } +} + + +// Public + +FirmwareDialog::FirmwareDialog(wxWindow *parent) : + wxDialog(parent, wxID_ANY, _(L("Firmware flasher")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), + p(new priv(this)) +{ + enum { + DIALOG_MARGIN = 15, + SPACING = 10, + MIN_WIDTH = 600, + MIN_HEIGHT = 200, + MIN_HEIGHT_EXPANDED = 500, + }; + + wxFont status_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + status_font.MakeBold(); + wxFont mono_font(wxFontInfo().Family(wxFONTFAMILY_TELETYPE)); + mono_font.MakeSmaller(); + + auto *panel = new wxPanel(this); + wxBoxSizer *vsizer = new wxBoxSizer(wxVERTICAL); + panel->SetSizer(vsizer); + + auto *label_port_picker = new wxStaticText(panel, wxID_ANY, _(L("Serial port:"))); + p->port_picker = new wxComboBox(panel, wxID_ANY); + p->btn_rescan = new wxButton(panel, wxID_ANY, _(L("Rescan"))); + auto *port_sizer = new wxBoxSizer(wxHORIZONTAL); + port_sizer->Add(p->port_picker, 1, wxEXPAND | wxRIGHT, SPACING); + port_sizer->Add(p->btn_rescan, 0); + + auto *label_hex_picker = new wxStaticText(panel, wxID_ANY, _(L("Firmware image:"))); + p->hex_picker = new wxFilePickerCtrl(panel, wxID_ANY); + + auto *label_status = new wxStaticText(panel, wxID_ANY, _(L("Status:"))); + p->txt_status = new wxStaticText(panel, wxID_ANY, _(L("Ready"))); + p->txt_status->SetFont(status_font); + + auto *label_progress = new wxStaticText(panel, wxID_ANY, _(L("Progress:"))); + p->progressbar = new wxGauge(panel, wxID_ANY, 1, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_SMOOTH); + + auto *grid = new wxFlexGridSizer(2, SPACING, SPACING); + grid->AddGrowableCol(1); + grid->Add(label_port_picker, 0, wxALIGN_CENTER_VERTICAL); + grid->Add(port_sizer, 0, wxEXPAND); + + grid->Add(label_hex_picker, 0, wxALIGN_CENTER_VERTICAL); + grid->Add(p->hex_picker, 0, wxEXPAND); + + grid->Add(label_status, 0, wxALIGN_CENTER_VERTICAL); + grid->Add(p->txt_status, 0, wxEXPAND); + + grid->Add(label_progress, 0, wxALIGN_CENTER_VERTICAL); + grid->Add(p->progressbar, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL); + + vsizer->Add(grid, 0, wxEXPAND | wxTOP | wxBOTTOM, SPACING); + + p->spoiler = new wxCollapsiblePane(panel, wxID_ANY, _(L("Advanced: avrdude output log"))); + auto *spoiler_pane = p->spoiler->GetPane(); + auto *spoiler_sizer = new wxBoxSizer(wxVERTICAL); + p->txt_stdout = new wxTextCtrl(spoiler_pane, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY); + p->txt_stdout->SetFont(mono_font); + spoiler_sizer->Add(p->txt_stdout, 1, wxEXPAND); + spoiler_pane->SetSizer(spoiler_sizer); + // The doc says proportion need to be 0 for wxCollapsiblePane. + // Experience says it needs to be 1, otherwise things won't get sized properly. + vsizer->Add(p->spoiler, 1, wxEXPAND | wxBOTTOM, SPACING); + + p->btn_close = new wxButton(panel, wxID_CLOSE); + p->btn_flash = new wxButton(panel, wxID_ANY, p->btn_flash_label_ready); + auto *bsizer = new wxBoxSizer(wxHORIZONTAL); + bsizer->Add(p->btn_close); + bsizer->AddStretchSpacer(); + bsizer->Add(p->btn_flash); + vsizer->Add(bsizer, 0, wxEXPAND); + + auto *topsizer = new wxBoxSizer(wxVERTICAL); + topsizer->Add(panel, 1, wxEXPAND | wxALL, DIALOG_MARGIN); + SetMinSize(wxSize(MIN_WIDTH, MIN_HEIGHT)); + SetSizerAndFit(topsizer); + const auto size = GetSize(); + SetSize(std::max(size.GetWidth(), static_cast(MIN_WIDTH)), std::max(size.GetHeight(), static_cast(MIN_HEIGHT))); + Layout(); + + p->spoiler->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, [this](wxCollapsiblePaneEvent &evt) { + // Dialog size gets screwed up by wxCollapsiblePane, we need to fix it here + if (evt.GetCollapsed()) { + this->SetMinSize(wxSize(MIN_WIDTH, MIN_HEIGHT)); + } else { + this->SetMinSize(wxSize(MIN_WIDTH, MIN_HEIGHT_EXPANDED)); + } + + this->Fit(); + this->Layout(); + }); + + p->btn_close->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { this->Close(); }); + p->btn_rescan->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { this->p->find_serial_ports(); }); + + p->btn_flash->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { + if (this->p->avrdude) { + // Flashing is in progress, ask the user if they're really sure about canceling it + wxMessageDialog dlg(this, + _(L("Are you sure you want to cancel firmware flashing?\nThis could leave your printer in an unusable state!")), + _(L("Confirmation")), + wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION); + if (dlg.ShowModal() == wxID_YES) { + this->p->cancel(); + } + } else { + // Start a flashing task + this->p->perform_upload(); + } + }); + + Bind(EVT_AVRDUDE, [this](wxCommandEvent &evt) { this->p->on_avrdude(evt); }); + + Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent &evt) { + if (this->p->avrdude) { + evt.Veto(); + } else { + evt.Skip(); + } + }); + + p->find_serial_ports(); +} + +FirmwareDialog::~FirmwareDialog() +{ + // Needed bacuse of forward defs +} + +void FirmwareDialog::run(wxWindow *parent) +{ + FirmwareDialog dialog(parent); + dialog.ShowModal(); +} + + +} diff --git a/xs/src/slic3r/GUI/FirmwareDialog.hpp b/xs/src/slic3r/GUI/FirmwareDialog.hpp new file mode 100644 index 000000000..ad048bf5d --- /dev/null +++ b/xs/src/slic3r/GUI/FirmwareDialog.hpp @@ -0,0 +1,31 @@ +#ifndef slic3r_FirmwareDialog_hpp_ +#define slic3r_FirmwareDialog_hpp_ + +#include + +#include + + +namespace Slic3r { + + +class FirmwareDialog: public wxDialog +{ +public: + FirmwareDialog(wxWindow *parent); + FirmwareDialog(FirmwareDialog &&) = delete; + FirmwareDialog(const FirmwareDialog &) = delete; + FirmwareDialog &operator=(FirmwareDialog &&) = delete; + FirmwareDialog &operator=(const FirmwareDialog &) = delete; + ~FirmwareDialog(); + + static void run(wxWindow *parent); +private: + struct priv; + std::unique_ptr p; +}; + + +} + +#endif diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index a744bb09d..aad970236 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -4,11 +4,8 @@ #include #include -#include -#include #include -#include -#include +#include #include #if __APPLE__ @@ -25,7 +22,6 @@ #undef max #endif #include "boost/nowide/convert.hpp" -#pragma comment(lib, "user32.lib") #endif #include @@ -55,10 +51,12 @@ #include "Preferences.hpp" #include "PresetBundle.hpp" #include "UpdateDialogs.hpp" +#include "FirmwareDialog.hpp" #include "../Utils/PresetUpdater.hpp" #include "../Config/Snapshot.hpp" + namespace Slic3r { namespace GUI { #if __APPLE__ @@ -86,83 +84,6 @@ void enable_screensaver() #endif } -std::vector scan_serial_ports() -{ - std::vector out; -#ifdef _WIN32 - // 1) Open the registry key SERIALCOM. - HKEY hKey; - LONG lRes = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_READ, &hKey); - assert(lRes == ERROR_SUCCESS); - if (lRes == ERROR_SUCCESS) { - // 2) Get number of values of SERIALCOM key. - DWORD cValues; // number of values for key - { - TCHAR achKey[255]; // buffer for subkey name - DWORD cbName; // size of name string - TCHAR achClass[MAX_PATH] = TEXT(""); // buffer for class name - DWORD cchClassName = MAX_PATH; // size of class string - DWORD cSubKeys=0; // number of subkeys - DWORD cbMaxSubKey; // longest subkey size - DWORD cchMaxClass; // longest class string - DWORD cchMaxValue; // longest value name - DWORD cbMaxValueData; // longest value data - DWORD cbSecurityDescriptor; // size of security descriptor - FILETIME ftLastWriteTime; // last write time - // Get the class name and the value count. - lRes = RegQueryInfoKey( - hKey, // key handle - achClass, // buffer for class name - &cchClassName, // size of class string - NULL, // reserved - &cSubKeys, // number of subkeys - &cbMaxSubKey, // longest subkey size - &cchMaxClass, // longest class string - &cValues, // number of values for this key - &cchMaxValue, // longest value name - &cbMaxValueData, // longest value data - &cbSecurityDescriptor, // security descriptor - &ftLastWriteTime); // last write time - assert(lRes == ERROR_SUCCESS); - } - // 3) Read the SERIALCOM values. - { - DWORD dwIndex = 0; - for (int i = 0; i < cValues; ++ i, ++ dwIndex) { - wchar_t valueName[2048]; - DWORD valNameLen = 2048; - DWORD dataType; - wchar_t data[2048]; - DWORD dataSize = 4096; - lRes = ::RegEnumValueW(hKey, dwIndex, valueName, &valNameLen, nullptr, &dataType, (BYTE*)&data, &dataSize); - if (lRes == ERROR_SUCCESS && dataType == REG_SZ && valueName[0] != 0) - out.emplace_back(boost::nowide::narrow(data)); - } - } - ::RegCloseKey(hKey); - } -#else - // UNIX and OS X - std::initializer_list prefixes { "ttyUSB" , "ttyACM", "tty.", "cu.", "rfcomm" }; - for (auto &dir_entry : boost::filesystem::directory_iterator(boost::filesystem::path("/dev"))) { - std::string name = dir_entry.path().filename().string(); - for (const char *prefix : prefixes) { - if (boost::starts_with(name, prefix)) { - out.emplace_back(dir_entry.path().string()); - break; - } - } - } -#endif - - out.erase(std::remove_if(out.begin(), out.end(), - [](const std::string &key){ - return boost::starts_with(key, "Bluetooth") || boost::starts_with(key, "FireFly"); - }), - out.end()); - return out; -} - bool debugged() { #ifdef _WIN32 @@ -383,6 +304,7 @@ enum ConfigMenuIDs { ConfigMenuUpdate, ConfigMenuPreferences, ConfigMenuLanguage, + ConfigMenuFlashFirmware, ConfigMenuCnt, }; @@ -396,11 +318,15 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l local_menu->Append(config_id_base + ConfigMenuWizard, ConfigWizard::name() + "\u2026", config_wizard_tooltip); local_menu->Append(config_id_base + ConfigMenuSnapshots, _(L("Configuration Snapshots"))+"\u2026", _(L("Inspect / activate configuration snapshots"))); local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _(L("Take Configuration Snapshot")), _(L("Capture a configuration snapshot"))); - local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); +// local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); local_menu->AppendSeparator(); local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("Preferences"))+"\u2026\tCtrl+,", _(L("Application preferences"))); - local_menu->AppendSeparator(); local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); + local_menu->AppendSeparator(); + local_menu->Append(config_id_base + ConfigMenuFlashFirmware, _(L("Flash printer firmware")), _(L("Upload a firmware image into an Arduino based printer"))); + // TODO: for when we're able to flash dictionaries + // local_menu->Append(config_id_base + FirmwareMenuDict, _(L("Flash language file")), _(L("Upload a language dictionary file into a Prusa printer"))); + local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ switch (event.GetId() - config_id_base) { case ConfigMenuWizard: @@ -455,12 +381,22 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l } } break; - } + } + case ConfigMenuFlashFirmware: + FirmwareDialog::run(g_wxMainFrame); + break; + default: + break; } }); menu->Append(local_menu, _(L("&Configuration"))); } +void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_language_change) +{ + add_config_menu(menu, event_language_change, event_language_change); +} + // This is called when closing the application, when loading a config file or when starting the config wizard // to notify the user whether he is aware that some preset changes will be lost. bool check_unsaved_changes() @@ -992,4 +928,35 @@ void about() dlg.Destroy(); } +void desktop_open_datadir_folder() +{ + // Execute command to open a file explorer, platform dependent. + std::string cmd = +#ifdef _WIN32 + "explorer " +#elif __APPLE__ + "open " +#else + "xdg-open " +#endif + ; + // Escape the path, platform dependent. + std::string path = data_dir(); +#ifdef _WIN32 + // Enclose the path into double quotes on Windows. A quote character is forbidden in file names, + // therefore it does not need to be escaped. + cmd += '"'; + cmd += path; + cmd += '"'; +#else + // Enclose the path into single quotes on Unix / OSX. All single quote characters need to be escaped + // inside a file name. + cmd += '\''; + boost::replace_all(path, "'", "\\'"); + cmd += path; + cmd += '\''; +#endif + ::wxExecute(wxString::FromUTF8(cmd.c_str()), wxEXEC_ASYNC, nullptr); +} + } } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 3752b5a7a..4deee1910 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -68,7 +68,6 @@ inline t_file_wild_card& get_file_wild_card() { void disable_screensaver(); void enable_screensaver(); -std::vector scan_serial_ports(); bool debugged(); void break_to_debugger(); @@ -91,7 +90,7 @@ unsigned get_colour_approx_luma(const wxColour &colour); void set_label_clr_modified(const wxColour& clr); void set_label_clr_sys(const wxColour& clr); -extern void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_language_change); +extern void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_language_change); // This is called when closing the application, when loading a config file or when starting the config wizard // to notify the user whether he is aware that some preset changes will be lost. @@ -159,7 +158,9 @@ void add_export_option(wxFileDialog* dlg, const std::string& format); int get_export_option(wxFileDialog* dlg); // Display an About dialog -void about(); +extern void about(); +// Ask the destop to open the datadir using the default file explorer. +extern void desktop_open_datadir_folder(); } // namespace GUI } // namespace Slic3r diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 5a47dd1e7..ab5aa2bb0 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -6,6 +6,7 @@ #include "slic3r/Utils/Http.hpp" #include "slic3r/Utils/OctoPrint.hpp" +#include "slic3r/Utils/Serial.hpp" #include "BonjourDialog.hpp" #include "WipeTowerDialog.hpp" #include "ButtonsDescription.hpp" @@ -1693,7 +1694,7 @@ void TabPrinter::build() void TabPrinter::update_serial_ports(){ Field *field = get_field("serial_port"); Choice *choice = static_cast(field); - choice->set_values(scan_serial_ports()); + choice->set_values(Utils::scan_serial_ports()); } void TabPrinter::extruders_count_changed(size_t extruders_count){ @@ -1709,7 +1710,8 @@ void TabPrinter::build_extruder_pages(){ size_t n_before_extruders = 2; // Count of pages before Extruder pages size_t n_after_single_extruder_MM = 2; // Count of pages after single_extruder_multi_material page - if (m_extruders_count_old == m_extruders_count || m_extruders_count <= 2) + if (m_extruders_count_old == m_extruders_count || + (m_has_single_extruder_MM_page && m_extruders_count == 1)) { // if we have a single extruder MM setup, add a page with configuration options: for (int i = 0; i < m_pages.size(); ++i) // first make sure it's not there already @@ -1717,16 +1719,19 @@ void TabPrinter::build_extruder_pages(){ m_pages.erase(m_pages.begin() + i); break; } - if (m_extruders_count > 1 && m_config->opt_bool("single_extruder_multi_material")) { - // create a page, but pretend it's an extruder page, so we can add it to m_pages ourselves - auto page = add_options_page(_(L("Single extruder MM setup")), "printer_empty.png", true); - auto optgroup = page->new_optgroup(_(L("Single extruder multimaterial parameters"))); - optgroup->append_single_option_line("cooling_tube_retraction"); - optgroup->append_single_option_line("cooling_tube_length"); - optgroup->append_single_option_line("parking_pos_retraction"); - m_pages.insert(m_pages.end() - n_after_single_extruder_MM, page); - } + m_has_single_extruder_MM_page = false; } + if (m_extruders_count > 1 && m_config->opt_bool("single_extruder_multi_material") && !m_has_single_extruder_MM_page) { + // create a page, but pretend it's an extruder page, so we can add it to m_pages ourselves + auto page = add_options_page(_(L("Single extruder MM setup")), "printer_empty.png", true); + auto optgroup = page->new_optgroup(_(L("Single extruder multimaterial parameters"))); + optgroup->append_single_option_line("cooling_tube_retraction"); + optgroup->append_single_option_line("cooling_tube_length"); + optgroup->append_single_option_line("parking_pos_retraction"); + m_pages.insert(m_pages.end() - n_after_single_extruder_MM, page); + m_has_single_extruder_MM_page = true; + } + for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx){ //# build page diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 62030bce3..d6bf2cf43 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -312,6 +312,7 @@ public: //Slic3r::GUI::Tab::Printer; class TabPrinter : public Tab { + bool m_has_single_extruder_MM_page = false; public: wxButton* m_serial_test_btn; wxButton* m_octoprint_host_test_btn; diff --git a/xs/src/slic3r/Utils/Serial.cpp b/xs/src/slic3r/Utils/Serial.cpp new file mode 100644 index 000000000..32b6bb160 --- /dev/null +++ b/xs/src/slic3r/Utils/Serial.cpp @@ -0,0 +1,193 @@ +#include "Serial.hpp" + +#include +#include +#include +#include + +#include +#include +#include + +#if _WIN32 + #include + #include + #include + #include + // Undefine min/max macros incompatible with the standard library + // For example, std::numeric_limits::max() + // produces some weird errors + #ifdef min + #undef min + #endif + #ifdef max + #undef max + #endif + #include "boost/nowide/convert.hpp" + #pragma comment(lib, "user32.lib") +#elif __APPLE__ + #include + #include + #include + #include + #include + #include +#endif + +namespace Slic3r { +namespace Utils { + +static bool looks_like_printer(const std::string &friendly_name) +{ + return friendly_name.find("Original Prusa") != std::string::npos; +} + +#ifdef __linux__ +static std::string get_tty_friendly_name(const std::string &path, const std::string &name) +{ + const auto sysfs_product = (boost::format("/sys/class/tty/%1%/device/../product") % name).str(); + std::ifstream file(sysfs_product); + std::string product; + + std::getline(file, product); + return file.good() ? (boost::format("%1% (%2%)") % product % path).str() : path; +} +#endif + +std::vector scan_serial_ports_extended() +{ + std::vector output; + +#ifdef _WIN32 + SP_DEVINFO_DATA devInfoData = { 0 }; + devInfoData.cbSize = sizeof(devInfoData); + // Get the tree containing the info for the ports. + HDEVINFO hDeviceInfo = SetupDiGetClassDevs(&GUID_DEVCLASS_PORTS, 0, nullptr, DIGCF_PRESENT); + if (hDeviceInfo != INVALID_HANDLE_VALUE) { + // Iterate over all the devices in the tree. + for (int nDevice = 0; SetupDiEnumDeviceInfo(hDeviceInfo, nDevice, &devInfoData); ++ nDevice) { + SerialPortInfo port_info; + // Get the registry key which stores the ports settings. + HKEY hDeviceKey = SetupDiOpenDevRegKey(hDeviceInfo, &devInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_QUERY_VALUE); + if (hDeviceKey) { + // Read in the name of the port. + wchar_t pszPortName[4096]; + DWORD dwSize = sizeof(pszPortName); + DWORD dwType = 0; + if (RegQueryValueEx(hDeviceKey, L"PortName", NULL, &dwType, (LPBYTE)pszPortName, &dwSize) == ERROR_SUCCESS) + port_info.port = boost::nowide::narrow(pszPortName); + RegCloseKey(hDeviceKey); + if (port_info.port.empty()) + continue; + } + // Find the size required to hold the device info. + DWORD regDataType; + DWORD reqSize = 0; + SetupDiGetDeviceRegistryProperty(hDeviceInfo, &devInfoData, SPDRP_HARDWAREID, nullptr, nullptr, 0, &reqSize); + std::vector hardware_id(reqSize > 1 ? reqSize : 1); + // Now store it in a buffer. + if (! SetupDiGetDeviceRegistryProperty(hDeviceInfo, &devInfoData, SPDRP_HARDWAREID, ®DataType, (BYTE*)hardware_id.data(), reqSize, nullptr)) + continue; + port_info.hardware_id = boost::nowide::narrow(hardware_id.data()); + // Find the size required to hold the friendly name. + reqSize = 0; + SetupDiGetDeviceRegistryProperty(hDeviceInfo, &devInfoData, SPDRP_FRIENDLYNAME, nullptr, nullptr, 0, &reqSize); + std::vector friendly_name; + friendly_name.reserve(reqSize > 1 ? reqSize : 1); + // Now store it in a buffer. + if (! SetupDiGetDeviceRegistryProperty(hDeviceInfo, &devInfoData, SPDRP_FRIENDLYNAME, nullptr, (BYTE*)friendly_name.data(), reqSize, nullptr)) { + port_info.friendly_name = port_info.port; + } else { + port_info.friendly_name = boost::nowide::narrow(friendly_name.data()); + port_info.is_printer = looks_like_printer(port_info.friendly_name); + } + output.emplace_back(std::move(port_info)); + } + } +#elif __APPLE__ + // inspired by https://sigrok.org/wiki/Libserialport + CFMutableDictionaryRef classes = IOServiceMatching(kIOSerialBSDServiceValue); + if (classes != 0) { + io_iterator_t iter; + if (IOServiceGetMatchingServices(kIOMasterPortDefault, classes, &iter) == KERN_SUCCESS) { + io_object_t port; + while ((port = IOIteratorNext(iter)) != 0) { + CFTypeRef cf_property = IORegistryEntryCreateCFProperty(port, CFSTR(kIOCalloutDeviceKey), kCFAllocatorDefault, 0); + if (cf_property) { + char path[PATH_MAX]; + Boolean result = CFStringGetCString((CFStringRef)cf_property, path, sizeof(path), kCFStringEncodingUTF8); + CFRelease(cf_property); + if (result) { + SerialPortInfo port_info; + port_info.port = path; + if ((cf_property = IORegistryEntrySearchCFProperty(port, kIOServicePlane, + CFSTR("USB Interface Name"), kCFAllocatorDefault, + kIORegistryIterateRecursively | kIORegistryIterateParents)) || + (cf_property = IORegistryEntrySearchCFProperty(port, kIOServicePlane, + CFSTR("USB Product Name"), kCFAllocatorDefault, + kIORegistryIterateRecursively | kIORegistryIterateParents)) || + (cf_property = IORegistryEntrySearchCFProperty(port, kIOServicePlane, + CFSTR("Product Name"), kCFAllocatorDefault, + kIORegistryIterateRecursively | kIORegistryIterateParents)) || + (cf_property = IORegistryEntryCreateCFProperty(port, + CFSTR(kIOTTYDeviceKey), kCFAllocatorDefault, 0))) { + // Description limited to 127 char, anything longer would not be user friendly anyway. + char description[128]; + if (CFStringGetCString((CFStringRef)cf_property, description, sizeof(description), kCFStringEncodingUTF8)) { + port_info.friendly_name = std::string(description) + " (" + port_info.port + ")"; + port_info.is_printer = looks_like_printer(port_info.friendly_name); + } + CFRelease(cf_property); + } + if (port_info.friendly_name.empty()) + port_info.friendly_name = port_info.port; + output.emplace_back(std::move(port_info)); + } + } + IOObjectRelease(port); + } + } + } +#else + // UNIX / Linux + std::initializer_list prefixes { "ttyUSB" , "ttyACM", "tty.", "cu.", "rfcomm" }; + for (auto &dir_entry : boost::filesystem::directory_iterator(boost::filesystem::path("/dev"))) { + std::string name = dir_entry.path().filename().string(); + for (const char *prefix : prefixes) { + if (boost::starts_with(name, prefix)) { + const auto path = dir_entry.path().string(); + SerialPortInfo spi; + spi.port = path; + spi.hardware_id = path; +#ifdef __linux__ + spi.friendly_name = get_tty_friendly_name(path, name); +#else + spi.friendly_name = path; +#endif + output.emplace_back(std::move(spi)); + break; + } + } + } +#endif + + output.erase(std::remove_if(output.begin(), output.end(), + [](const SerialPortInfo &info) { + return boost::starts_with(info.port, "Bluetooth") || boost::starts_with(info.port, "FireFly"); + }), + output.end()); + return output; +} + +std::vector scan_serial_ports() +{ + std::vector ports = scan_serial_ports_extended(); + std::vector output; + output.reserve(ports.size()); + for (const SerialPortInfo &spi : ports) + output.emplace_back(std::move(spi.port)); + return output; +} + +} // namespace Utils +} // namespace Slic3r diff --git a/xs/src/slic3r/Utils/Serial.hpp b/xs/src/slic3r/Utils/Serial.hpp new file mode 100644 index 000000000..9381ab398 --- /dev/null +++ b/xs/src/slic3r/Utils/Serial.hpp @@ -0,0 +1,32 @@ +#ifndef slic3r_GUI_Utils_Serial_hpp_ +#define slic3r_GUI_Utils_Serial_hpp_ + +#include +#include +#include +#include + +namespace Slic3r { +namespace Utils { + +struct SerialPortInfo { + std::string port; + std::string hardware_id; + std::string friendly_name; + bool is_printer = false; +}; + +inline bool operator==(const SerialPortInfo &sp1, const SerialPortInfo &sp2) +{ + return sp1.port == sp2.port && + sp1.hardware_id == sp2.hardware_id && + sp1.is_printer == sp2.is_printer; +} + +extern std::vector scan_serial_ports(); +extern std::vector scan_serial_ports_extended(); + +} // Utils +} // Slic3r + +#endif /* slic3r_GUI_Utils_Serial_hpp_ */ diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index aa95bd647..897e63693 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -4,6 +4,7 @@ #include #include "slic3r/GUI/GUI.hpp" #include "slic3r/Utils/ASCIIFolding.hpp" +#include "slic3r/Utils/Serial.hpp" %} @@ -19,7 +20,7 @@ void enable_screensaver() %code{% Slic3r::GUI::enable_screensaver(); %}; std::vector scan_serial_ports() - %code{% RETVAL=Slic3r::GUI::scan_serial_ports(); %}; + %code{% RETVAL=Slic3r::Utils::scan_serial_ports(); %}; bool debugged() %code{% RETVAL=Slic3r::GUI::debugged(); %}; @@ -36,8 +37,8 @@ void set_main_frame(SV *ui) void set_tab_panel(SV *ui) %code%{ Slic3r::GUI::set_tab_panel((wxNotebook*)wxPli_sv_2_object(aTHX_ ui, "Wx::Notebook")); %}; -void add_config_menu(SV *ui, int event_preferences_changed, int event_language_change) - %code%{ Slic3r::GUI::add_config_menu((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar"), event_preferences_changed, event_language_change); %}; +void add_menus(SV *ui, int event_preferences_changed, int event_language_change) + %code%{ Slic3r::GUI::add_menus((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar"), event_preferences_changed, event_language_change); %}; void create_preset_tabs(bool no_controller, int event_value_change, int event_presets_changed) %code%{ Slic3r::GUI::create_preset_tabs(no_controller, event_value_change, event_presets_changed); %}; @@ -94,4 +95,6 @@ void add_export_option(SV *ui, std::string format) int get_export_option(SV *ui) %code%{ RETVAL = Slic3r::GUI::get_export_option((wxFileDialog*)wxPli_sv_2_object(aTHX_ ui, "Wx::FileDialog")); %}; - \ No newline at end of file + +void desktop_open_datadir_folder() + %code%{ Slic3r::GUI::desktop_open_datadir_folder(); %};