avrdude-6.0.1/000755 000153 000000 00000000000 12216243567 012536 5ustar00jwheel000000 000000 avrdude-6.0.1/INSTALL000444 000153 000000 00000036605 12216240532 013564 0ustar00jwheel000000 000000 Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX `make' updates targets which have the same time stamps as their prerequisites, which makes it generally unusable when shipped generated files such as `configure' are involved. Use GNU `make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf limitation. Until the limitation is lifted, you can use this workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. avrdude-6.0.1/NEWS000644 000153 000000 00000061140 12216240452 013225 0ustar00jwheel000000 000000 $Id: NEWS 1243 2013-09-18 05:58:44Z joerg_wunsch $ Approximate change log for AVRDUDE by version. (For more detailed changes, see the ChangeLog file.) ---------------------------------------------------------------------- Version 6.0.1: * 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 - bug #40055: AVRDUDE segfaults when writing eeprom * 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 Weier * 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. avrdude-6.0.1/README000644 000153 000000 00000003214 12216240452 013404 0ustar00jwheel000000 000000 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.) avrdude-6.0.1/AUTHORS000644 000153 000000 00000001346 12216240452 013600 0ustar00jwheel000000 000000 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. avrdude-6.0.1/ChangeLog000644 000153 000000 00000052643 12216240505 014307 0ustar00jwheel000000 000000 2013-09-17 Joerg Wunsch * configure.ac (AC_INIT): Bump version to 6.0.1. 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 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 avrdude-6.0.1/Makefile.in000644 000153 000000 00000373026 12216243010 014575 0ustar00jwheel000000 000000 # Makefile.in generated by automake 1.14 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # # 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: Makefile.am 1175 2013-05-15 18:55:19Z rliebscher $ # VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = avrdude$(EXEEXT) subdir = . DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/ac_cfg.h.in $(srcdir)/avrdude.spec.in \ $(srcdir)/avrdude.conf.in config_gram.h config_gram.c lexer.c \ depcomp ylwrap COPYING compile config.guess config.sub \ install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = ac_cfg.h CONFIG_CLEAN_FILES = avrdude.spec avrdude.conf.tmp CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru AM_V_AR = $(am__v_AR_@AM_V@) am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) am__v_AR_0 = @echo " AR " $@; am__v_AR_1 = libavrdude_a_AR = $(AR) $(ARFLAGS) libavrdude_a_LIBADD = am_libavrdude_a_OBJECTS = libavrdude_a-config_gram.$(OBJEXT) \ libavrdude_a-lexer.$(OBJEXT) libavrdude_a-arduino.$(OBJEXT) \ libavrdude_a-avr.$(OBJEXT) libavrdude_a-avr910.$(OBJEXT) \ libavrdude_a-avrftdi.$(OBJEXT) \ libavrdude_a-avrftdi_tpi.$(OBJEXT) \ libavrdude_a-avrpart.$(OBJEXT) libavrdude_a-bitbang.$(OBJEXT) \ libavrdude_a-buspirate.$(OBJEXT) \ libavrdude_a-butterfly.$(OBJEXT) libavrdude_a-config.$(OBJEXT) \ libavrdude_a-confwin.$(OBJEXT) libavrdude_a-crc16.$(OBJEXT) \ libavrdude_a-fileio.$(OBJEXT) libavrdude_a-ft245r.$(OBJEXT) \ libavrdude_a-jtagmkI.$(OBJEXT) libavrdude_a-jtagmkII.$(OBJEXT) \ libavrdude_a-jtag3.$(OBJEXT) libavrdude_a-linuxgpio.$(OBJEXT) \ libavrdude_a-lists.$(OBJEXT) libavrdude_a-par.$(OBJEXT) \ libavrdude_a-pgm.$(OBJEXT) libavrdude_a-pgm_type.$(OBJEXT) \ libavrdude_a-pickit2.$(OBJEXT) libavrdude_a-pindefs.$(OBJEXT) \ libavrdude_a-ppi.$(OBJEXT) libavrdude_a-ppiwin.$(OBJEXT) \ libavrdude_a-safemode.$(OBJEXT) \ libavrdude_a-serbb_posix.$(OBJEXT) \ libavrdude_a-serbb_win32.$(OBJEXT) \ libavrdude_a-ser_avrdoper.$(OBJEXT) \ libavrdude_a-ser_posix.$(OBJEXT) \ libavrdude_a-ser_win32.$(OBJEXT) libavrdude_a-stk500.$(OBJEXT) \ libavrdude_a-stk500v2.$(OBJEXT) \ libavrdude_a-stk500generic.$(OBJEXT) \ libavrdude_a-usbasp.$(OBJEXT) \ libavrdude_a-usb_libusb.$(OBJEXT) \ libavrdude_a-usbtiny.$(OBJEXT) libavrdude_a-update.$(OBJEXT) \ libavrdude_a-wiring.$(OBJEXT) libavrdude_a_OBJECTS = $(am_libavrdude_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \ "$(DESTDIR)$(sysconfdir)" PROGRAMS = $(bin_PROGRAMS) am_avrdude_OBJECTS = avrdude-main.$(OBJEXT) avrdude-term.$(OBJEXT) avrdude_OBJECTS = $(am_avrdude_OBJECTS) avrdude_DEPENDENCIES = $(top_builddir)/$(noinst_LIBRARIES) avrdude_LINK = $(CCLD) $(avrdude_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = LEXCOMPILE = $(LEX) $(AM_LFLAGS) $(LFLAGS) AM_V_LEX = $(am__v_LEX_@AM_V@) am__v_LEX_ = $(am__v_LEX_@AM_DEFAULT_V@) am__v_LEX_0 = @echo " LEX " $@; am__v_LEX_1 = YLWRAP = $(top_srcdir)/ylwrap am__yacc_c2h = sed -e s/cc$$/hh/ -e s/cpp$$/hpp/ -e s/cxx$$/hxx/ \ -e s/c++$$/h++/ -e s/c$$/h/ YACCCOMPILE = $(YACC) $(AM_YFLAGS) $(YFLAGS) AM_V_YACC = $(am__v_YACC_@AM_V@) am__v_YACC_ = $(am__v_YACC_@AM_DEFAULT_V@) am__v_YACC_0 = @echo " YACC " $@; am__v_YACC_1 = SOURCES = $(libavrdude_a_SOURCES) $(avrdude_SOURCES) DIST_SOURCES = $(libavrdude_a_SOURCES) $(avrdude_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man1dir = $(mandir)/man1 NROFF = nroff MANS = $(man_MANS) DATA = $(sysconf_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)ac_cfg.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_PAR_PORT = @DEFAULT_PAR_PORT@ DEFAULT_SER_PORT = @DEFAULT_SER_PORT@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DIST_SUBDIRS_AC = @DIST_SUBDIRS_AC@ DOC_INST_DIR = @DOC_INST_DIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_WARNINGS = @ENABLE_WARNINGS@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBELF = @LIBELF@ LIBFTDI = @LIBFTDI@ LIBFTDI1 = @LIBFTDI1@ LIBHID = @LIBHID@ LIBOBJS = @LIBOBJS@ LIBPTHREAD = @LIBPTHREAD@ LIBS = @LIBS@ LIBUSB = @LIBUSB@ LIBUSB_1_0 = @LIBUSB_1_0@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBDIRS_AC = @SUBDIRS_AC@ VERSION = @VERSION@ WINDOWS_DIRS = @WINDOWS_DIRS@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = \ ChangeLog \ ChangeLog-2001 \ ChangeLog-2002 \ ChangeLog-2003 \ ChangeLog-2004-2006 \ ChangeLog-2007 \ ChangeLog-2008 \ ChangeLog-2009 \ ChangeLog-2010 \ ChangeLog-2011 \ ChangeLog-2012 \ 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 # doc comes here, and we want to use the built avrdude to generate the parts list SUBDIRS = . @SUBDIRS_AC@ @WINDOWS_DIRS@ DIST_SUBDIRS = @DIST_SUBDIRS_AC@ AM_YFLAGS = -d avrdude_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" libavrdude_a_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" avrdude_CFLAGS = @ENABLE_WARNINGS@ libavrdude_a_CFLAGS = @ENABLE_WARNINGS@ avrdude_LDADD = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB_1_0@ @LIBUSB@ @LIBFTDI1@ @LIBFTDI@ @LIBHID@ @LIBELF@ @LIBPTHREAD@ -lm noinst_LIBRARIES = libavrdude.a libavrdude_a_SOURCES = \ config_gram.y \ lexer.l \ arduino.h \ arduino.c \ avr.c \ avr.h \ avr910.c \ avr910.h \ avrdude.h \ avrftdi.c \ avrftdi.h \ avrftdi_private.h \ avrftdi_tpi.c \ avrftdi_tpi.h \ avrpart.c \ avrpart.h \ bitbang.c \ bitbang.h \ buspirate.c \ buspirate.h \ butterfly.c \ butterfly.h \ config.c \ config.h \ confwin.c \ confwin.h \ crc16.c \ crc16.h \ fileio.c \ fileio.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 \ linuxgpio.c \ linuxgpio.h \ linux_ppdev.h \ lists.c \ lists.h \ my_ddk_hidsdi.h \ par.c \ par.h \ pgm.c \ pgm.h \ pgm_type.c \ pgm_type.h \ pickit2.c \ pickit2.h \ pindefs.c \ pindefs.h \ ppi.c \ ppi.h \ ppiwin.c \ safemode.c \ safemode.h \ serial.h \ 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_libusb.c \ usbtiny.h \ usbtiny.c \ update.h \ update.c \ wiring.h \ wiring.c avrdude_SOURCES = \ main.c \ term.c \ term.h man_MANS = avrdude.1 sysconf_DATA = avrdude.conf all: $(BUILT_SOURCES) ac_cfg.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .l .o .obj .y am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): ac_cfg.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/ac_cfg.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status ac_cfg.h $(srcdir)/ac_cfg.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f ac_cfg.h stamp-h1 avrdude.spec: $(top_builddir)/config.status $(srcdir)/avrdude.spec.in cd $(top_builddir) && $(SHELL) ./config.status $@ avrdude.conf.tmp: $(top_builddir)/config.status $(srcdir)/avrdude.conf.in cd $(top_builddir) && $(SHELL) ./config.status $@ clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) config_gram.h: config_gram.c @if test ! -f $@; then rm -f config_gram.c; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) config_gram.c; else :; fi libavrdude.a: $(libavrdude_a_OBJECTS) $(libavrdude_a_DEPENDENCIES) $(EXTRA_libavrdude_a_DEPENDENCIES) $(AM_V_at)-rm -f libavrdude.a $(AM_V_AR)$(libavrdude_a_AR) libavrdude.a $(libavrdude_a_OBJECTS) $(libavrdude_a_LIBADD) $(AM_V_at)$(RANLIB) libavrdude.a install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) avrdude$(EXEEXT): $(avrdude_OBJECTS) $(avrdude_DEPENDENCIES) $(EXTRA_avrdude_DEPENDENCIES) @rm -f avrdude$(EXEEXT) $(AM_V_CCLD)$(avrdude_LINK) $(avrdude_OBJECTS) $(avrdude_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avrdude-main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avrdude-term.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-arduino.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-avr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-avr910.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-avrftdi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-avrftdi_tpi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-avrpart.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-bitbang.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-buspirate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-butterfly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-config.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-config_gram.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-confwin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-crc16.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-fileio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-ft245r.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-jtag3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-jtagmkI.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-jtagmkII.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-lexer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-linuxgpio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-lists.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-par.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-pgm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-pgm_type.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-pickit2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-pindefs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-ppi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-ppiwin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-safemode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-ser_avrdoper.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-ser_posix.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-ser_win32.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-serbb_posix.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-serbb_win32.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-stk500.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-stk500generic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-stk500v2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-update.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-usb_libusb.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-usbasp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-usbtiny.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-wiring.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` libavrdude_a-config_gram.o: config_gram.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-config_gram.o -MD -MP -MF $(DEPDIR)/libavrdude_a-config_gram.Tpo -c -o libavrdude_a-config_gram.o `test -f 'config_gram.c' || echo '$(srcdir)/'`config_gram.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-config_gram.Tpo $(DEPDIR)/libavrdude_a-config_gram.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='config_gram.c' object='libavrdude_a-config_gram.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-config_gram.o `test -f 'config_gram.c' || echo '$(srcdir)/'`config_gram.c libavrdude_a-config_gram.obj: config_gram.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-config_gram.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-config_gram.Tpo -c -o libavrdude_a-config_gram.obj `if test -f 'config_gram.c'; then $(CYGPATH_W) 'config_gram.c'; else $(CYGPATH_W) '$(srcdir)/config_gram.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-config_gram.Tpo $(DEPDIR)/libavrdude_a-config_gram.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='config_gram.c' object='libavrdude_a-config_gram.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-config_gram.obj `if test -f 'config_gram.c'; then $(CYGPATH_W) 'config_gram.c'; else $(CYGPATH_W) '$(srcdir)/config_gram.c'; fi` libavrdude_a-lexer.o: lexer.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-lexer.o -MD -MP -MF $(DEPDIR)/libavrdude_a-lexer.Tpo -c -o libavrdude_a-lexer.o `test -f 'lexer.c' || echo '$(srcdir)/'`lexer.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-lexer.Tpo $(DEPDIR)/libavrdude_a-lexer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lexer.c' object='libavrdude_a-lexer.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-lexer.o `test -f 'lexer.c' || echo '$(srcdir)/'`lexer.c libavrdude_a-lexer.obj: lexer.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-lexer.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-lexer.Tpo -c -o libavrdude_a-lexer.obj `if test -f 'lexer.c'; then $(CYGPATH_W) 'lexer.c'; else $(CYGPATH_W) '$(srcdir)/lexer.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-lexer.Tpo $(DEPDIR)/libavrdude_a-lexer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lexer.c' object='libavrdude_a-lexer.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-lexer.obj `if test -f 'lexer.c'; then $(CYGPATH_W) 'lexer.c'; else $(CYGPATH_W) '$(srcdir)/lexer.c'; fi` libavrdude_a-arduino.o: arduino.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-arduino.o -MD -MP -MF $(DEPDIR)/libavrdude_a-arduino.Tpo -c -o libavrdude_a-arduino.o `test -f 'arduino.c' || echo '$(srcdir)/'`arduino.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-arduino.Tpo $(DEPDIR)/libavrdude_a-arduino.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='arduino.c' object='libavrdude_a-arduino.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-arduino.o `test -f 'arduino.c' || echo '$(srcdir)/'`arduino.c libavrdude_a-arduino.obj: arduino.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-arduino.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-arduino.Tpo -c -o libavrdude_a-arduino.obj `if test -f 'arduino.c'; then $(CYGPATH_W) 'arduino.c'; else $(CYGPATH_W) '$(srcdir)/arduino.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-arduino.Tpo $(DEPDIR)/libavrdude_a-arduino.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='arduino.c' object='libavrdude_a-arduino.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-arduino.obj `if test -f 'arduino.c'; then $(CYGPATH_W) 'arduino.c'; else $(CYGPATH_W) '$(srcdir)/arduino.c'; fi` libavrdude_a-avr.o: avr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-avr.o -MD -MP -MF $(DEPDIR)/libavrdude_a-avr.Tpo -c -o libavrdude_a-avr.o `test -f 'avr.c' || echo '$(srcdir)/'`avr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-avr.Tpo $(DEPDIR)/libavrdude_a-avr.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='avr.c' object='libavrdude_a-avr.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-avr.o `test -f 'avr.c' || echo '$(srcdir)/'`avr.c libavrdude_a-avr.obj: avr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-avr.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-avr.Tpo -c -o libavrdude_a-avr.obj `if test -f 'avr.c'; then $(CYGPATH_W) 'avr.c'; else $(CYGPATH_W) '$(srcdir)/avr.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-avr.Tpo $(DEPDIR)/libavrdude_a-avr.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='avr.c' object='libavrdude_a-avr.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-avr.obj `if test -f 'avr.c'; then $(CYGPATH_W) 'avr.c'; else $(CYGPATH_W) '$(srcdir)/avr.c'; fi` libavrdude_a-avr910.o: avr910.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-avr910.o -MD -MP -MF $(DEPDIR)/libavrdude_a-avr910.Tpo -c -o libavrdude_a-avr910.o `test -f 'avr910.c' || echo '$(srcdir)/'`avr910.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-avr910.Tpo $(DEPDIR)/libavrdude_a-avr910.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='avr910.c' object='libavrdude_a-avr910.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-avr910.o `test -f 'avr910.c' || echo '$(srcdir)/'`avr910.c libavrdude_a-avr910.obj: avr910.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-avr910.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-avr910.Tpo -c -o libavrdude_a-avr910.obj `if test -f 'avr910.c'; then $(CYGPATH_W) 'avr910.c'; else $(CYGPATH_W) '$(srcdir)/avr910.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-avr910.Tpo $(DEPDIR)/libavrdude_a-avr910.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='avr910.c' object='libavrdude_a-avr910.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-avr910.obj `if test -f 'avr910.c'; then $(CYGPATH_W) 'avr910.c'; else $(CYGPATH_W) '$(srcdir)/avr910.c'; fi` libavrdude_a-avrftdi.o: avrftdi.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-avrftdi.o -MD -MP -MF $(DEPDIR)/libavrdude_a-avrftdi.Tpo -c -o libavrdude_a-avrftdi.o `test -f 'avrftdi.c' || echo '$(srcdir)/'`avrftdi.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-avrftdi.Tpo $(DEPDIR)/libavrdude_a-avrftdi.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='avrftdi.c' object='libavrdude_a-avrftdi.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-avrftdi.o `test -f 'avrftdi.c' || echo '$(srcdir)/'`avrftdi.c libavrdude_a-avrftdi.obj: avrftdi.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-avrftdi.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-avrftdi.Tpo -c -o libavrdude_a-avrftdi.obj `if test -f 'avrftdi.c'; then $(CYGPATH_W) 'avrftdi.c'; else $(CYGPATH_W) '$(srcdir)/avrftdi.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-avrftdi.Tpo $(DEPDIR)/libavrdude_a-avrftdi.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='avrftdi.c' object='libavrdude_a-avrftdi.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-avrftdi.obj `if test -f 'avrftdi.c'; then $(CYGPATH_W) 'avrftdi.c'; else $(CYGPATH_W) '$(srcdir)/avrftdi.c'; fi` libavrdude_a-avrftdi_tpi.o: avrftdi_tpi.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-avrftdi_tpi.o -MD -MP -MF $(DEPDIR)/libavrdude_a-avrftdi_tpi.Tpo -c -o libavrdude_a-avrftdi_tpi.o `test -f 'avrftdi_tpi.c' || echo '$(srcdir)/'`avrftdi_tpi.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-avrftdi_tpi.Tpo $(DEPDIR)/libavrdude_a-avrftdi_tpi.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='avrftdi_tpi.c' object='libavrdude_a-avrftdi_tpi.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-avrftdi_tpi.o `test -f 'avrftdi_tpi.c' || echo '$(srcdir)/'`avrftdi_tpi.c libavrdude_a-avrftdi_tpi.obj: avrftdi_tpi.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-avrftdi_tpi.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-avrftdi_tpi.Tpo -c -o libavrdude_a-avrftdi_tpi.obj `if test -f 'avrftdi_tpi.c'; then $(CYGPATH_W) 'avrftdi_tpi.c'; else $(CYGPATH_W) '$(srcdir)/avrftdi_tpi.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-avrftdi_tpi.Tpo $(DEPDIR)/libavrdude_a-avrftdi_tpi.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='avrftdi_tpi.c' object='libavrdude_a-avrftdi_tpi.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-avrftdi_tpi.obj `if test -f 'avrftdi_tpi.c'; then $(CYGPATH_W) 'avrftdi_tpi.c'; else $(CYGPATH_W) '$(srcdir)/avrftdi_tpi.c'; fi` libavrdude_a-avrpart.o: avrpart.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-avrpart.o -MD -MP -MF $(DEPDIR)/libavrdude_a-avrpart.Tpo -c -o libavrdude_a-avrpart.o `test -f 'avrpart.c' || echo '$(srcdir)/'`avrpart.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-avrpart.Tpo $(DEPDIR)/libavrdude_a-avrpart.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='avrpart.c' object='libavrdude_a-avrpart.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-avrpart.o `test -f 'avrpart.c' || echo '$(srcdir)/'`avrpart.c libavrdude_a-avrpart.obj: avrpart.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-avrpart.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-avrpart.Tpo -c -o libavrdude_a-avrpart.obj `if test -f 'avrpart.c'; then $(CYGPATH_W) 'avrpart.c'; else $(CYGPATH_W) '$(srcdir)/avrpart.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-avrpart.Tpo $(DEPDIR)/libavrdude_a-avrpart.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='avrpart.c' object='libavrdude_a-avrpart.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-avrpart.obj `if test -f 'avrpart.c'; then $(CYGPATH_W) 'avrpart.c'; else $(CYGPATH_W) '$(srcdir)/avrpart.c'; fi` libavrdude_a-bitbang.o: bitbang.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-bitbang.o -MD -MP -MF $(DEPDIR)/libavrdude_a-bitbang.Tpo -c -o libavrdude_a-bitbang.o `test -f 'bitbang.c' || echo '$(srcdir)/'`bitbang.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-bitbang.Tpo $(DEPDIR)/libavrdude_a-bitbang.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bitbang.c' object='libavrdude_a-bitbang.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-bitbang.o `test -f 'bitbang.c' || echo '$(srcdir)/'`bitbang.c libavrdude_a-bitbang.obj: bitbang.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-bitbang.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-bitbang.Tpo -c -o libavrdude_a-bitbang.obj `if test -f 'bitbang.c'; then $(CYGPATH_W) 'bitbang.c'; else $(CYGPATH_W) '$(srcdir)/bitbang.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-bitbang.Tpo $(DEPDIR)/libavrdude_a-bitbang.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bitbang.c' object='libavrdude_a-bitbang.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-bitbang.obj `if test -f 'bitbang.c'; then $(CYGPATH_W) 'bitbang.c'; else $(CYGPATH_W) '$(srcdir)/bitbang.c'; fi` libavrdude_a-buspirate.o: buspirate.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-buspirate.o -MD -MP -MF $(DEPDIR)/libavrdude_a-buspirate.Tpo -c -o libavrdude_a-buspirate.o `test -f 'buspirate.c' || echo '$(srcdir)/'`buspirate.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-buspirate.Tpo $(DEPDIR)/libavrdude_a-buspirate.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='buspirate.c' object='libavrdude_a-buspirate.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-buspirate.o `test -f 'buspirate.c' || echo '$(srcdir)/'`buspirate.c libavrdude_a-buspirate.obj: buspirate.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-buspirate.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-buspirate.Tpo -c -o libavrdude_a-buspirate.obj `if test -f 'buspirate.c'; then $(CYGPATH_W) 'buspirate.c'; else $(CYGPATH_W) '$(srcdir)/buspirate.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-buspirate.Tpo $(DEPDIR)/libavrdude_a-buspirate.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='buspirate.c' object='libavrdude_a-buspirate.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-buspirate.obj `if test -f 'buspirate.c'; then $(CYGPATH_W) 'buspirate.c'; else $(CYGPATH_W) '$(srcdir)/buspirate.c'; fi` libavrdude_a-butterfly.o: butterfly.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-butterfly.o -MD -MP -MF $(DEPDIR)/libavrdude_a-butterfly.Tpo -c -o libavrdude_a-butterfly.o `test -f 'butterfly.c' || echo '$(srcdir)/'`butterfly.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-butterfly.Tpo $(DEPDIR)/libavrdude_a-butterfly.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='butterfly.c' object='libavrdude_a-butterfly.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-butterfly.o `test -f 'butterfly.c' || echo '$(srcdir)/'`butterfly.c libavrdude_a-butterfly.obj: butterfly.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-butterfly.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-butterfly.Tpo -c -o libavrdude_a-butterfly.obj `if test -f 'butterfly.c'; then $(CYGPATH_W) 'butterfly.c'; else $(CYGPATH_W) '$(srcdir)/butterfly.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-butterfly.Tpo $(DEPDIR)/libavrdude_a-butterfly.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='butterfly.c' object='libavrdude_a-butterfly.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-butterfly.obj `if test -f 'butterfly.c'; then $(CYGPATH_W) 'butterfly.c'; else $(CYGPATH_W) '$(srcdir)/butterfly.c'; fi` libavrdude_a-config.o: config.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-config.o -MD -MP -MF $(DEPDIR)/libavrdude_a-config.Tpo -c -o libavrdude_a-config.o `test -f 'config.c' || echo '$(srcdir)/'`config.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-config.Tpo $(DEPDIR)/libavrdude_a-config.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='config.c' object='libavrdude_a-config.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-config.o `test -f 'config.c' || echo '$(srcdir)/'`config.c libavrdude_a-config.obj: config.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-config.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-config.Tpo -c -o libavrdude_a-config.obj `if test -f 'config.c'; then $(CYGPATH_W) 'config.c'; else $(CYGPATH_W) '$(srcdir)/config.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-config.Tpo $(DEPDIR)/libavrdude_a-config.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='config.c' object='libavrdude_a-config.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-config.obj `if test -f 'config.c'; then $(CYGPATH_W) 'config.c'; else $(CYGPATH_W) '$(srcdir)/config.c'; fi` libavrdude_a-confwin.o: confwin.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-confwin.o -MD -MP -MF $(DEPDIR)/libavrdude_a-confwin.Tpo -c -o libavrdude_a-confwin.o `test -f 'confwin.c' || echo '$(srcdir)/'`confwin.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-confwin.Tpo $(DEPDIR)/libavrdude_a-confwin.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='confwin.c' object='libavrdude_a-confwin.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-confwin.o `test -f 'confwin.c' || echo '$(srcdir)/'`confwin.c libavrdude_a-confwin.obj: confwin.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-confwin.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-confwin.Tpo -c -o libavrdude_a-confwin.obj `if test -f 'confwin.c'; then $(CYGPATH_W) 'confwin.c'; else $(CYGPATH_W) '$(srcdir)/confwin.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-confwin.Tpo $(DEPDIR)/libavrdude_a-confwin.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='confwin.c' object='libavrdude_a-confwin.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-confwin.obj `if test -f 'confwin.c'; then $(CYGPATH_W) 'confwin.c'; else $(CYGPATH_W) '$(srcdir)/confwin.c'; fi` libavrdude_a-crc16.o: crc16.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-crc16.o -MD -MP -MF $(DEPDIR)/libavrdude_a-crc16.Tpo -c -o libavrdude_a-crc16.o `test -f 'crc16.c' || echo '$(srcdir)/'`crc16.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-crc16.Tpo $(DEPDIR)/libavrdude_a-crc16.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crc16.c' object='libavrdude_a-crc16.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-crc16.o `test -f 'crc16.c' || echo '$(srcdir)/'`crc16.c libavrdude_a-crc16.obj: crc16.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-crc16.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-crc16.Tpo -c -o libavrdude_a-crc16.obj `if test -f 'crc16.c'; then $(CYGPATH_W) 'crc16.c'; else $(CYGPATH_W) '$(srcdir)/crc16.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-crc16.Tpo $(DEPDIR)/libavrdude_a-crc16.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crc16.c' object='libavrdude_a-crc16.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-crc16.obj `if test -f 'crc16.c'; then $(CYGPATH_W) 'crc16.c'; else $(CYGPATH_W) '$(srcdir)/crc16.c'; fi` libavrdude_a-fileio.o: fileio.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-fileio.o -MD -MP -MF $(DEPDIR)/libavrdude_a-fileio.Tpo -c -o libavrdude_a-fileio.o `test -f 'fileio.c' || echo '$(srcdir)/'`fileio.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-fileio.Tpo $(DEPDIR)/libavrdude_a-fileio.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fileio.c' object='libavrdude_a-fileio.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-fileio.o `test -f 'fileio.c' || echo '$(srcdir)/'`fileio.c libavrdude_a-fileio.obj: fileio.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-fileio.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-fileio.Tpo -c -o libavrdude_a-fileio.obj `if test -f 'fileio.c'; then $(CYGPATH_W) 'fileio.c'; else $(CYGPATH_W) '$(srcdir)/fileio.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-fileio.Tpo $(DEPDIR)/libavrdude_a-fileio.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fileio.c' object='libavrdude_a-fileio.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-fileio.obj `if test -f 'fileio.c'; then $(CYGPATH_W) 'fileio.c'; else $(CYGPATH_W) '$(srcdir)/fileio.c'; fi` libavrdude_a-ft245r.o: ft245r.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ft245r.o -MD -MP -MF $(DEPDIR)/libavrdude_a-ft245r.Tpo -c -o libavrdude_a-ft245r.o `test -f 'ft245r.c' || echo '$(srcdir)/'`ft245r.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ft245r.Tpo $(DEPDIR)/libavrdude_a-ft245r.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ft245r.c' object='libavrdude_a-ft245r.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ft245r.o `test -f 'ft245r.c' || echo '$(srcdir)/'`ft245r.c libavrdude_a-ft245r.obj: ft245r.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ft245r.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-ft245r.Tpo -c -o libavrdude_a-ft245r.obj `if test -f 'ft245r.c'; then $(CYGPATH_W) 'ft245r.c'; else $(CYGPATH_W) '$(srcdir)/ft245r.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ft245r.Tpo $(DEPDIR)/libavrdude_a-ft245r.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ft245r.c' object='libavrdude_a-ft245r.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ft245r.obj `if test -f 'ft245r.c'; then $(CYGPATH_W) 'ft245r.c'; else $(CYGPATH_W) '$(srcdir)/ft245r.c'; fi` libavrdude_a-jtagmkI.o: jtagmkI.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-jtagmkI.o -MD -MP -MF $(DEPDIR)/libavrdude_a-jtagmkI.Tpo -c -o libavrdude_a-jtagmkI.o `test -f 'jtagmkI.c' || echo '$(srcdir)/'`jtagmkI.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-jtagmkI.Tpo $(DEPDIR)/libavrdude_a-jtagmkI.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='jtagmkI.c' object='libavrdude_a-jtagmkI.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-jtagmkI.o `test -f 'jtagmkI.c' || echo '$(srcdir)/'`jtagmkI.c libavrdude_a-jtagmkI.obj: jtagmkI.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-jtagmkI.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-jtagmkI.Tpo -c -o libavrdude_a-jtagmkI.obj `if test -f 'jtagmkI.c'; then $(CYGPATH_W) 'jtagmkI.c'; else $(CYGPATH_W) '$(srcdir)/jtagmkI.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-jtagmkI.Tpo $(DEPDIR)/libavrdude_a-jtagmkI.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='jtagmkI.c' object='libavrdude_a-jtagmkI.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-jtagmkI.obj `if test -f 'jtagmkI.c'; then $(CYGPATH_W) 'jtagmkI.c'; else $(CYGPATH_W) '$(srcdir)/jtagmkI.c'; fi` libavrdude_a-jtagmkII.o: jtagmkII.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-jtagmkII.o -MD -MP -MF $(DEPDIR)/libavrdude_a-jtagmkII.Tpo -c -o libavrdude_a-jtagmkII.o `test -f 'jtagmkII.c' || echo '$(srcdir)/'`jtagmkII.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-jtagmkII.Tpo $(DEPDIR)/libavrdude_a-jtagmkII.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='jtagmkII.c' object='libavrdude_a-jtagmkII.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-jtagmkII.o `test -f 'jtagmkII.c' || echo '$(srcdir)/'`jtagmkII.c libavrdude_a-jtagmkII.obj: jtagmkII.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-jtagmkII.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-jtagmkII.Tpo -c -o libavrdude_a-jtagmkII.obj `if test -f 'jtagmkII.c'; then $(CYGPATH_W) 'jtagmkII.c'; else $(CYGPATH_W) '$(srcdir)/jtagmkII.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-jtagmkII.Tpo $(DEPDIR)/libavrdude_a-jtagmkII.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='jtagmkII.c' object='libavrdude_a-jtagmkII.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-jtagmkII.obj `if test -f 'jtagmkII.c'; then $(CYGPATH_W) 'jtagmkII.c'; else $(CYGPATH_W) '$(srcdir)/jtagmkII.c'; fi` libavrdude_a-jtag3.o: jtag3.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-jtag3.o -MD -MP -MF $(DEPDIR)/libavrdude_a-jtag3.Tpo -c -o libavrdude_a-jtag3.o `test -f 'jtag3.c' || echo '$(srcdir)/'`jtag3.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-jtag3.Tpo $(DEPDIR)/libavrdude_a-jtag3.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='jtag3.c' object='libavrdude_a-jtag3.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-jtag3.o `test -f 'jtag3.c' || echo '$(srcdir)/'`jtag3.c libavrdude_a-jtag3.obj: jtag3.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-jtag3.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-jtag3.Tpo -c -o libavrdude_a-jtag3.obj `if test -f 'jtag3.c'; then $(CYGPATH_W) 'jtag3.c'; else $(CYGPATH_W) '$(srcdir)/jtag3.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-jtag3.Tpo $(DEPDIR)/libavrdude_a-jtag3.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='jtag3.c' object='libavrdude_a-jtag3.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-jtag3.obj `if test -f 'jtag3.c'; then $(CYGPATH_W) 'jtag3.c'; else $(CYGPATH_W) '$(srcdir)/jtag3.c'; fi` libavrdude_a-linuxgpio.o: linuxgpio.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-linuxgpio.o -MD -MP -MF $(DEPDIR)/libavrdude_a-linuxgpio.Tpo -c -o libavrdude_a-linuxgpio.o `test -f 'linuxgpio.c' || echo '$(srcdir)/'`linuxgpio.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-linuxgpio.Tpo $(DEPDIR)/libavrdude_a-linuxgpio.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='linuxgpio.c' object='libavrdude_a-linuxgpio.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-linuxgpio.o `test -f 'linuxgpio.c' || echo '$(srcdir)/'`linuxgpio.c libavrdude_a-linuxgpio.obj: linuxgpio.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-linuxgpio.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-linuxgpio.Tpo -c -o libavrdude_a-linuxgpio.obj `if test -f 'linuxgpio.c'; then $(CYGPATH_W) 'linuxgpio.c'; else $(CYGPATH_W) '$(srcdir)/linuxgpio.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-linuxgpio.Tpo $(DEPDIR)/libavrdude_a-linuxgpio.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='linuxgpio.c' object='libavrdude_a-linuxgpio.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-linuxgpio.obj `if test -f 'linuxgpio.c'; then $(CYGPATH_W) 'linuxgpio.c'; else $(CYGPATH_W) '$(srcdir)/linuxgpio.c'; fi` libavrdude_a-lists.o: lists.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-lists.o -MD -MP -MF $(DEPDIR)/libavrdude_a-lists.Tpo -c -o libavrdude_a-lists.o `test -f 'lists.c' || echo '$(srcdir)/'`lists.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-lists.Tpo $(DEPDIR)/libavrdude_a-lists.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lists.c' object='libavrdude_a-lists.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-lists.o `test -f 'lists.c' || echo '$(srcdir)/'`lists.c libavrdude_a-lists.obj: lists.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-lists.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-lists.Tpo -c -o libavrdude_a-lists.obj `if test -f 'lists.c'; then $(CYGPATH_W) 'lists.c'; else $(CYGPATH_W) '$(srcdir)/lists.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-lists.Tpo $(DEPDIR)/libavrdude_a-lists.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lists.c' object='libavrdude_a-lists.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-lists.obj `if test -f 'lists.c'; then $(CYGPATH_W) 'lists.c'; else $(CYGPATH_W) '$(srcdir)/lists.c'; fi` libavrdude_a-par.o: par.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-par.o -MD -MP -MF $(DEPDIR)/libavrdude_a-par.Tpo -c -o libavrdude_a-par.o `test -f 'par.c' || echo '$(srcdir)/'`par.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-par.Tpo $(DEPDIR)/libavrdude_a-par.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='par.c' object='libavrdude_a-par.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-par.o `test -f 'par.c' || echo '$(srcdir)/'`par.c libavrdude_a-par.obj: par.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-par.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-par.Tpo -c -o libavrdude_a-par.obj `if test -f 'par.c'; then $(CYGPATH_W) 'par.c'; else $(CYGPATH_W) '$(srcdir)/par.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-par.Tpo $(DEPDIR)/libavrdude_a-par.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='par.c' object='libavrdude_a-par.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-par.obj `if test -f 'par.c'; then $(CYGPATH_W) 'par.c'; else $(CYGPATH_W) '$(srcdir)/par.c'; fi` libavrdude_a-pgm.o: pgm.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-pgm.o -MD -MP -MF $(DEPDIR)/libavrdude_a-pgm.Tpo -c -o libavrdude_a-pgm.o `test -f 'pgm.c' || echo '$(srcdir)/'`pgm.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-pgm.Tpo $(DEPDIR)/libavrdude_a-pgm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pgm.c' object='libavrdude_a-pgm.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-pgm.o `test -f 'pgm.c' || echo '$(srcdir)/'`pgm.c libavrdude_a-pgm.obj: pgm.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-pgm.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-pgm.Tpo -c -o libavrdude_a-pgm.obj `if test -f 'pgm.c'; then $(CYGPATH_W) 'pgm.c'; else $(CYGPATH_W) '$(srcdir)/pgm.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-pgm.Tpo $(DEPDIR)/libavrdude_a-pgm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pgm.c' object='libavrdude_a-pgm.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-pgm.obj `if test -f 'pgm.c'; then $(CYGPATH_W) 'pgm.c'; else $(CYGPATH_W) '$(srcdir)/pgm.c'; fi` libavrdude_a-pgm_type.o: pgm_type.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-pgm_type.o -MD -MP -MF $(DEPDIR)/libavrdude_a-pgm_type.Tpo -c -o libavrdude_a-pgm_type.o `test -f 'pgm_type.c' || echo '$(srcdir)/'`pgm_type.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-pgm_type.Tpo $(DEPDIR)/libavrdude_a-pgm_type.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pgm_type.c' object='libavrdude_a-pgm_type.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-pgm_type.o `test -f 'pgm_type.c' || echo '$(srcdir)/'`pgm_type.c libavrdude_a-pgm_type.obj: pgm_type.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-pgm_type.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-pgm_type.Tpo -c -o libavrdude_a-pgm_type.obj `if test -f 'pgm_type.c'; then $(CYGPATH_W) 'pgm_type.c'; else $(CYGPATH_W) '$(srcdir)/pgm_type.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-pgm_type.Tpo $(DEPDIR)/libavrdude_a-pgm_type.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pgm_type.c' object='libavrdude_a-pgm_type.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-pgm_type.obj `if test -f 'pgm_type.c'; then $(CYGPATH_W) 'pgm_type.c'; else $(CYGPATH_W) '$(srcdir)/pgm_type.c'; fi` libavrdude_a-pickit2.o: pickit2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-pickit2.o -MD -MP -MF $(DEPDIR)/libavrdude_a-pickit2.Tpo -c -o libavrdude_a-pickit2.o `test -f 'pickit2.c' || echo '$(srcdir)/'`pickit2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-pickit2.Tpo $(DEPDIR)/libavrdude_a-pickit2.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pickit2.c' object='libavrdude_a-pickit2.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-pickit2.o `test -f 'pickit2.c' || echo '$(srcdir)/'`pickit2.c libavrdude_a-pickit2.obj: pickit2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-pickit2.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-pickit2.Tpo -c -o libavrdude_a-pickit2.obj `if test -f 'pickit2.c'; then $(CYGPATH_W) 'pickit2.c'; else $(CYGPATH_W) '$(srcdir)/pickit2.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-pickit2.Tpo $(DEPDIR)/libavrdude_a-pickit2.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pickit2.c' object='libavrdude_a-pickit2.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-pickit2.obj `if test -f 'pickit2.c'; then $(CYGPATH_W) 'pickit2.c'; else $(CYGPATH_W) '$(srcdir)/pickit2.c'; fi` libavrdude_a-pindefs.o: pindefs.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-pindefs.o -MD -MP -MF $(DEPDIR)/libavrdude_a-pindefs.Tpo -c -o libavrdude_a-pindefs.o `test -f 'pindefs.c' || echo '$(srcdir)/'`pindefs.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-pindefs.Tpo $(DEPDIR)/libavrdude_a-pindefs.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pindefs.c' object='libavrdude_a-pindefs.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-pindefs.o `test -f 'pindefs.c' || echo '$(srcdir)/'`pindefs.c libavrdude_a-pindefs.obj: pindefs.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-pindefs.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-pindefs.Tpo -c -o libavrdude_a-pindefs.obj `if test -f 'pindefs.c'; then $(CYGPATH_W) 'pindefs.c'; else $(CYGPATH_W) '$(srcdir)/pindefs.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-pindefs.Tpo $(DEPDIR)/libavrdude_a-pindefs.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pindefs.c' object='libavrdude_a-pindefs.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-pindefs.obj `if test -f 'pindefs.c'; then $(CYGPATH_W) 'pindefs.c'; else $(CYGPATH_W) '$(srcdir)/pindefs.c'; fi` libavrdude_a-ppi.o: ppi.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ppi.o -MD -MP -MF $(DEPDIR)/libavrdude_a-ppi.Tpo -c -o libavrdude_a-ppi.o `test -f 'ppi.c' || echo '$(srcdir)/'`ppi.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ppi.Tpo $(DEPDIR)/libavrdude_a-ppi.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ppi.c' object='libavrdude_a-ppi.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ppi.o `test -f 'ppi.c' || echo '$(srcdir)/'`ppi.c libavrdude_a-ppi.obj: ppi.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ppi.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-ppi.Tpo -c -o libavrdude_a-ppi.obj `if test -f 'ppi.c'; then $(CYGPATH_W) 'ppi.c'; else $(CYGPATH_W) '$(srcdir)/ppi.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ppi.Tpo $(DEPDIR)/libavrdude_a-ppi.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ppi.c' object='libavrdude_a-ppi.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ppi.obj `if test -f 'ppi.c'; then $(CYGPATH_W) 'ppi.c'; else $(CYGPATH_W) '$(srcdir)/ppi.c'; fi` libavrdude_a-ppiwin.o: ppiwin.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ppiwin.o -MD -MP -MF $(DEPDIR)/libavrdude_a-ppiwin.Tpo -c -o libavrdude_a-ppiwin.o `test -f 'ppiwin.c' || echo '$(srcdir)/'`ppiwin.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ppiwin.Tpo $(DEPDIR)/libavrdude_a-ppiwin.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ppiwin.c' object='libavrdude_a-ppiwin.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ppiwin.o `test -f 'ppiwin.c' || echo '$(srcdir)/'`ppiwin.c libavrdude_a-ppiwin.obj: ppiwin.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ppiwin.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-ppiwin.Tpo -c -o libavrdude_a-ppiwin.obj `if test -f 'ppiwin.c'; then $(CYGPATH_W) 'ppiwin.c'; else $(CYGPATH_W) '$(srcdir)/ppiwin.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ppiwin.Tpo $(DEPDIR)/libavrdude_a-ppiwin.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ppiwin.c' object='libavrdude_a-ppiwin.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ppiwin.obj `if test -f 'ppiwin.c'; then $(CYGPATH_W) 'ppiwin.c'; else $(CYGPATH_W) '$(srcdir)/ppiwin.c'; fi` libavrdude_a-safemode.o: safemode.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-safemode.o -MD -MP -MF $(DEPDIR)/libavrdude_a-safemode.Tpo -c -o libavrdude_a-safemode.o `test -f 'safemode.c' || echo '$(srcdir)/'`safemode.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-safemode.Tpo $(DEPDIR)/libavrdude_a-safemode.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='safemode.c' object='libavrdude_a-safemode.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-safemode.o `test -f 'safemode.c' || echo '$(srcdir)/'`safemode.c libavrdude_a-safemode.obj: safemode.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-safemode.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-safemode.Tpo -c -o libavrdude_a-safemode.obj `if test -f 'safemode.c'; then $(CYGPATH_W) 'safemode.c'; else $(CYGPATH_W) '$(srcdir)/safemode.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-safemode.Tpo $(DEPDIR)/libavrdude_a-safemode.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='safemode.c' object='libavrdude_a-safemode.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-safemode.obj `if test -f 'safemode.c'; then $(CYGPATH_W) 'safemode.c'; else $(CYGPATH_W) '$(srcdir)/safemode.c'; fi` libavrdude_a-serbb_posix.o: serbb_posix.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-serbb_posix.o -MD -MP -MF $(DEPDIR)/libavrdude_a-serbb_posix.Tpo -c -o libavrdude_a-serbb_posix.o `test -f 'serbb_posix.c' || echo '$(srcdir)/'`serbb_posix.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-serbb_posix.Tpo $(DEPDIR)/libavrdude_a-serbb_posix.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='serbb_posix.c' object='libavrdude_a-serbb_posix.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-serbb_posix.o `test -f 'serbb_posix.c' || echo '$(srcdir)/'`serbb_posix.c libavrdude_a-serbb_posix.obj: serbb_posix.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-serbb_posix.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-serbb_posix.Tpo -c -o libavrdude_a-serbb_posix.obj `if test -f 'serbb_posix.c'; then $(CYGPATH_W) 'serbb_posix.c'; else $(CYGPATH_W) '$(srcdir)/serbb_posix.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-serbb_posix.Tpo $(DEPDIR)/libavrdude_a-serbb_posix.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='serbb_posix.c' object='libavrdude_a-serbb_posix.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-serbb_posix.obj `if test -f 'serbb_posix.c'; then $(CYGPATH_W) 'serbb_posix.c'; else $(CYGPATH_W) '$(srcdir)/serbb_posix.c'; fi` libavrdude_a-serbb_win32.o: serbb_win32.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-serbb_win32.o -MD -MP -MF $(DEPDIR)/libavrdude_a-serbb_win32.Tpo -c -o libavrdude_a-serbb_win32.o `test -f 'serbb_win32.c' || echo '$(srcdir)/'`serbb_win32.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-serbb_win32.Tpo $(DEPDIR)/libavrdude_a-serbb_win32.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='serbb_win32.c' object='libavrdude_a-serbb_win32.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-serbb_win32.o `test -f 'serbb_win32.c' || echo '$(srcdir)/'`serbb_win32.c libavrdude_a-serbb_win32.obj: serbb_win32.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-serbb_win32.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-serbb_win32.Tpo -c -o libavrdude_a-serbb_win32.obj `if test -f 'serbb_win32.c'; then $(CYGPATH_W) 'serbb_win32.c'; else $(CYGPATH_W) '$(srcdir)/serbb_win32.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-serbb_win32.Tpo $(DEPDIR)/libavrdude_a-serbb_win32.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='serbb_win32.c' object='libavrdude_a-serbb_win32.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-serbb_win32.obj `if test -f 'serbb_win32.c'; then $(CYGPATH_W) 'serbb_win32.c'; else $(CYGPATH_W) '$(srcdir)/serbb_win32.c'; fi` libavrdude_a-ser_avrdoper.o: ser_avrdoper.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ser_avrdoper.o -MD -MP -MF $(DEPDIR)/libavrdude_a-ser_avrdoper.Tpo -c -o libavrdude_a-ser_avrdoper.o `test -f 'ser_avrdoper.c' || echo '$(srcdir)/'`ser_avrdoper.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ser_avrdoper.Tpo $(DEPDIR)/libavrdude_a-ser_avrdoper.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ser_avrdoper.c' object='libavrdude_a-ser_avrdoper.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ser_avrdoper.o `test -f 'ser_avrdoper.c' || echo '$(srcdir)/'`ser_avrdoper.c libavrdude_a-ser_avrdoper.obj: ser_avrdoper.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ser_avrdoper.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-ser_avrdoper.Tpo -c -o libavrdude_a-ser_avrdoper.obj `if test -f 'ser_avrdoper.c'; then $(CYGPATH_W) 'ser_avrdoper.c'; else $(CYGPATH_W) '$(srcdir)/ser_avrdoper.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ser_avrdoper.Tpo $(DEPDIR)/libavrdude_a-ser_avrdoper.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ser_avrdoper.c' object='libavrdude_a-ser_avrdoper.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ser_avrdoper.obj `if test -f 'ser_avrdoper.c'; then $(CYGPATH_W) 'ser_avrdoper.c'; else $(CYGPATH_W) '$(srcdir)/ser_avrdoper.c'; fi` libavrdude_a-ser_posix.o: ser_posix.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ser_posix.o -MD -MP -MF $(DEPDIR)/libavrdude_a-ser_posix.Tpo -c -o libavrdude_a-ser_posix.o `test -f 'ser_posix.c' || echo '$(srcdir)/'`ser_posix.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ser_posix.Tpo $(DEPDIR)/libavrdude_a-ser_posix.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ser_posix.c' object='libavrdude_a-ser_posix.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ser_posix.o `test -f 'ser_posix.c' || echo '$(srcdir)/'`ser_posix.c libavrdude_a-ser_posix.obj: ser_posix.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ser_posix.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-ser_posix.Tpo -c -o libavrdude_a-ser_posix.obj `if test -f 'ser_posix.c'; then $(CYGPATH_W) 'ser_posix.c'; else $(CYGPATH_W) '$(srcdir)/ser_posix.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ser_posix.Tpo $(DEPDIR)/libavrdude_a-ser_posix.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ser_posix.c' object='libavrdude_a-ser_posix.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ser_posix.obj `if test -f 'ser_posix.c'; then $(CYGPATH_W) 'ser_posix.c'; else $(CYGPATH_W) '$(srcdir)/ser_posix.c'; fi` libavrdude_a-ser_win32.o: ser_win32.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ser_win32.o -MD -MP -MF $(DEPDIR)/libavrdude_a-ser_win32.Tpo -c -o libavrdude_a-ser_win32.o `test -f 'ser_win32.c' || echo '$(srcdir)/'`ser_win32.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ser_win32.Tpo $(DEPDIR)/libavrdude_a-ser_win32.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ser_win32.c' object='libavrdude_a-ser_win32.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ser_win32.o `test -f 'ser_win32.c' || echo '$(srcdir)/'`ser_win32.c libavrdude_a-ser_win32.obj: ser_win32.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-ser_win32.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-ser_win32.Tpo -c -o libavrdude_a-ser_win32.obj `if test -f 'ser_win32.c'; then $(CYGPATH_W) 'ser_win32.c'; else $(CYGPATH_W) '$(srcdir)/ser_win32.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-ser_win32.Tpo $(DEPDIR)/libavrdude_a-ser_win32.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ser_win32.c' object='libavrdude_a-ser_win32.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-ser_win32.obj `if test -f 'ser_win32.c'; then $(CYGPATH_W) 'ser_win32.c'; else $(CYGPATH_W) '$(srcdir)/ser_win32.c'; fi` libavrdude_a-stk500.o: stk500.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-stk500.o -MD -MP -MF $(DEPDIR)/libavrdude_a-stk500.Tpo -c -o libavrdude_a-stk500.o `test -f 'stk500.c' || echo '$(srcdir)/'`stk500.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-stk500.Tpo $(DEPDIR)/libavrdude_a-stk500.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stk500.c' object='libavrdude_a-stk500.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-stk500.o `test -f 'stk500.c' || echo '$(srcdir)/'`stk500.c libavrdude_a-stk500.obj: stk500.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-stk500.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-stk500.Tpo -c -o libavrdude_a-stk500.obj `if test -f 'stk500.c'; then $(CYGPATH_W) 'stk500.c'; else $(CYGPATH_W) '$(srcdir)/stk500.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-stk500.Tpo $(DEPDIR)/libavrdude_a-stk500.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stk500.c' object='libavrdude_a-stk500.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-stk500.obj `if test -f 'stk500.c'; then $(CYGPATH_W) 'stk500.c'; else $(CYGPATH_W) '$(srcdir)/stk500.c'; fi` libavrdude_a-stk500v2.o: stk500v2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-stk500v2.o -MD -MP -MF $(DEPDIR)/libavrdude_a-stk500v2.Tpo -c -o libavrdude_a-stk500v2.o `test -f 'stk500v2.c' || echo '$(srcdir)/'`stk500v2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-stk500v2.Tpo $(DEPDIR)/libavrdude_a-stk500v2.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stk500v2.c' object='libavrdude_a-stk500v2.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-stk500v2.o `test -f 'stk500v2.c' || echo '$(srcdir)/'`stk500v2.c libavrdude_a-stk500v2.obj: stk500v2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-stk500v2.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-stk500v2.Tpo -c -o libavrdude_a-stk500v2.obj `if test -f 'stk500v2.c'; then $(CYGPATH_W) 'stk500v2.c'; else $(CYGPATH_W) '$(srcdir)/stk500v2.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-stk500v2.Tpo $(DEPDIR)/libavrdude_a-stk500v2.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stk500v2.c' object='libavrdude_a-stk500v2.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-stk500v2.obj `if test -f 'stk500v2.c'; then $(CYGPATH_W) 'stk500v2.c'; else $(CYGPATH_W) '$(srcdir)/stk500v2.c'; fi` libavrdude_a-stk500generic.o: stk500generic.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-stk500generic.o -MD -MP -MF $(DEPDIR)/libavrdude_a-stk500generic.Tpo -c -o libavrdude_a-stk500generic.o `test -f 'stk500generic.c' || echo '$(srcdir)/'`stk500generic.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-stk500generic.Tpo $(DEPDIR)/libavrdude_a-stk500generic.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stk500generic.c' object='libavrdude_a-stk500generic.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-stk500generic.o `test -f 'stk500generic.c' || echo '$(srcdir)/'`stk500generic.c libavrdude_a-stk500generic.obj: stk500generic.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-stk500generic.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-stk500generic.Tpo -c -o libavrdude_a-stk500generic.obj `if test -f 'stk500generic.c'; then $(CYGPATH_W) 'stk500generic.c'; else $(CYGPATH_W) '$(srcdir)/stk500generic.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-stk500generic.Tpo $(DEPDIR)/libavrdude_a-stk500generic.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stk500generic.c' object='libavrdude_a-stk500generic.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-stk500generic.obj `if test -f 'stk500generic.c'; then $(CYGPATH_W) 'stk500generic.c'; else $(CYGPATH_W) '$(srcdir)/stk500generic.c'; fi` libavrdude_a-usbasp.o: usbasp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-usbasp.o -MD -MP -MF $(DEPDIR)/libavrdude_a-usbasp.Tpo -c -o libavrdude_a-usbasp.o `test -f 'usbasp.c' || echo '$(srcdir)/'`usbasp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-usbasp.Tpo $(DEPDIR)/libavrdude_a-usbasp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='usbasp.c' object='libavrdude_a-usbasp.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-usbasp.o `test -f 'usbasp.c' || echo '$(srcdir)/'`usbasp.c libavrdude_a-usbasp.obj: usbasp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-usbasp.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-usbasp.Tpo -c -o libavrdude_a-usbasp.obj `if test -f 'usbasp.c'; then $(CYGPATH_W) 'usbasp.c'; else $(CYGPATH_W) '$(srcdir)/usbasp.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-usbasp.Tpo $(DEPDIR)/libavrdude_a-usbasp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='usbasp.c' object='libavrdude_a-usbasp.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-usbasp.obj `if test -f 'usbasp.c'; then $(CYGPATH_W) 'usbasp.c'; else $(CYGPATH_W) '$(srcdir)/usbasp.c'; fi` libavrdude_a-usb_libusb.o: usb_libusb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-usb_libusb.o -MD -MP -MF $(DEPDIR)/libavrdude_a-usb_libusb.Tpo -c -o libavrdude_a-usb_libusb.o `test -f 'usb_libusb.c' || echo '$(srcdir)/'`usb_libusb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-usb_libusb.Tpo $(DEPDIR)/libavrdude_a-usb_libusb.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='usb_libusb.c' object='libavrdude_a-usb_libusb.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-usb_libusb.o `test -f 'usb_libusb.c' || echo '$(srcdir)/'`usb_libusb.c libavrdude_a-usb_libusb.obj: usb_libusb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-usb_libusb.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-usb_libusb.Tpo -c -o libavrdude_a-usb_libusb.obj `if test -f 'usb_libusb.c'; then $(CYGPATH_W) 'usb_libusb.c'; else $(CYGPATH_W) '$(srcdir)/usb_libusb.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-usb_libusb.Tpo $(DEPDIR)/libavrdude_a-usb_libusb.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='usb_libusb.c' object='libavrdude_a-usb_libusb.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-usb_libusb.obj `if test -f 'usb_libusb.c'; then $(CYGPATH_W) 'usb_libusb.c'; else $(CYGPATH_W) '$(srcdir)/usb_libusb.c'; fi` libavrdude_a-usbtiny.o: usbtiny.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-usbtiny.o -MD -MP -MF $(DEPDIR)/libavrdude_a-usbtiny.Tpo -c -o libavrdude_a-usbtiny.o `test -f 'usbtiny.c' || echo '$(srcdir)/'`usbtiny.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-usbtiny.Tpo $(DEPDIR)/libavrdude_a-usbtiny.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='usbtiny.c' object='libavrdude_a-usbtiny.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-usbtiny.o `test -f 'usbtiny.c' || echo '$(srcdir)/'`usbtiny.c libavrdude_a-usbtiny.obj: usbtiny.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-usbtiny.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-usbtiny.Tpo -c -o libavrdude_a-usbtiny.obj `if test -f 'usbtiny.c'; then $(CYGPATH_W) 'usbtiny.c'; else $(CYGPATH_W) '$(srcdir)/usbtiny.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-usbtiny.Tpo $(DEPDIR)/libavrdude_a-usbtiny.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='usbtiny.c' object='libavrdude_a-usbtiny.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-usbtiny.obj `if test -f 'usbtiny.c'; then $(CYGPATH_W) 'usbtiny.c'; else $(CYGPATH_W) '$(srcdir)/usbtiny.c'; fi` libavrdude_a-update.o: update.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-update.o -MD -MP -MF $(DEPDIR)/libavrdude_a-update.Tpo -c -o libavrdude_a-update.o `test -f 'update.c' || echo '$(srcdir)/'`update.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-update.Tpo $(DEPDIR)/libavrdude_a-update.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='update.c' object='libavrdude_a-update.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-update.o `test -f 'update.c' || echo '$(srcdir)/'`update.c libavrdude_a-update.obj: update.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-update.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-update.Tpo -c -o libavrdude_a-update.obj `if test -f 'update.c'; then $(CYGPATH_W) 'update.c'; else $(CYGPATH_W) '$(srcdir)/update.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-update.Tpo $(DEPDIR)/libavrdude_a-update.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='update.c' object='libavrdude_a-update.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-update.obj `if test -f 'update.c'; then $(CYGPATH_W) 'update.c'; else $(CYGPATH_W) '$(srcdir)/update.c'; fi` libavrdude_a-wiring.o: wiring.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-wiring.o -MD -MP -MF $(DEPDIR)/libavrdude_a-wiring.Tpo -c -o libavrdude_a-wiring.o `test -f 'wiring.c' || echo '$(srcdir)/'`wiring.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-wiring.Tpo $(DEPDIR)/libavrdude_a-wiring.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='wiring.c' object='libavrdude_a-wiring.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-wiring.o `test -f 'wiring.c' || echo '$(srcdir)/'`wiring.c libavrdude_a-wiring.obj: wiring.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-wiring.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-wiring.Tpo -c -o libavrdude_a-wiring.obj `if test -f 'wiring.c'; then $(CYGPATH_W) 'wiring.c'; else $(CYGPATH_W) '$(srcdir)/wiring.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libavrdude_a-wiring.Tpo $(DEPDIR)/libavrdude_a-wiring.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='wiring.c' object='libavrdude_a-wiring.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-wiring.obj `if test -f 'wiring.c'; then $(CYGPATH_W) 'wiring.c'; else $(CYGPATH_W) '$(srcdir)/wiring.c'; fi` avrdude-main.o: main.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(avrdude_CPPFLAGS) $(CPPFLAGS) $(avrdude_CFLAGS) $(CFLAGS) -MT avrdude-main.o -MD -MP -MF $(DEPDIR)/avrdude-main.Tpo -c -o avrdude-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/avrdude-main.Tpo $(DEPDIR)/avrdude-main.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='avrdude-main.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(avrdude_CPPFLAGS) $(CPPFLAGS) $(avrdude_CFLAGS) $(CFLAGS) -c -o avrdude-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c avrdude-main.obj: main.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(avrdude_CPPFLAGS) $(CPPFLAGS) $(avrdude_CFLAGS) $(CFLAGS) -MT avrdude-main.obj -MD -MP -MF $(DEPDIR)/avrdude-main.Tpo -c -o avrdude-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/avrdude-main.Tpo $(DEPDIR)/avrdude-main.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='avrdude-main.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(avrdude_CPPFLAGS) $(CPPFLAGS) $(avrdude_CFLAGS) $(CFLAGS) -c -o avrdude-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi` avrdude-term.o: term.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(avrdude_CPPFLAGS) $(CPPFLAGS) $(avrdude_CFLAGS) $(CFLAGS) -MT avrdude-term.o -MD -MP -MF $(DEPDIR)/avrdude-term.Tpo -c -o avrdude-term.o `test -f 'term.c' || echo '$(srcdir)/'`term.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/avrdude-term.Tpo $(DEPDIR)/avrdude-term.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term.c' object='avrdude-term.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(avrdude_CPPFLAGS) $(CPPFLAGS) $(avrdude_CFLAGS) $(CFLAGS) -c -o avrdude-term.o `test -f 'term.c' || echo '$(srcdir)/'`term.c avrdude-term.obj: term.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(avrdude_CPPFLAGS) $(CPPFLAGS) $(avrdude_CFLAGS) $(CFLAGS) -MT avrdude-term.obj -MD -MP -MF $(DEPDIR)/avrdude-term.Tpo -c -o avrdude-term.obj `if test -f 'term.c'; then $(CYGPATH_W) 'term.c'; else $(CYGPATH_W) '$(srcdir)/term.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/avrdude-term.Tpo $(DEPDIR)/avrdude-term.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term.c' object='avrdude-term.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(avrdude_CPPFLAGS) $(CPPFLAGS) $(avrdude_CFLAGS) $(CFLAGS) -c -o avrdude-term.obj `if test -f 'term.c'; then $(CYGPATH_W) 'term.c'; else $(CYGPATH_W) '$(srcdir)/term.c'; fi` .l.c: $(AM_V_LEX)$(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) .y.c: $(AM_V_YACC)$(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h `echo $@ | $(am__yacc_c2h)` y.output $*.output -- $(YACCCOMPILE) install-man1: $(man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(man_MANS)'; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-sysconfDATA: $(sysconf_DATA) @$(NORMAL_INSTALL) @list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(sysconfdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(sysconfdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(sysconfdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(sysconfdir)" || exit $$?; \ done uninstall-sysconfDATA: @$(NORMAL_UNINSTALL) @list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(sysconfdir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(MANS) $(DATA) ac_cfg.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(sysconfdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -rm -f config_gram.c -rm -f config_gram.h -rm -f lexer.c -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-recursive clean-am: clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-local distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-man install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-binPROGRAMS install-exec-local \ install-sysconfDATA install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-man1 install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-man \ uninstall-sysconfDATA uninstall-man: uninstall-man1 .MAKE: $(am__recursive_targets) all check install install-am \ install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-binPROGRAMS \ clean-cscope clean-generic clean-noinstLIBRARIES cscope \ cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ dist-gzip dist-hook dist-lzip dist-shar dist-tarZ dist-xz \ dist-zip distcheck distclean distclean-compile \ distclean-generic distclean-hdr distclean-local distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-exec-local install-html \ install-html-am install-info install-info-am install-man \ install-man1 install-pdf install-pdf-am install-ps \ install-ps-am install-strip install-sysconfDATA installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-binPROGRAMS uninstall-man \ uninstall-man1 uninstall-sysconfDATA # 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 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 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: avrdude-6.0.1/Makefile.am000644 000153 000000 00000007626 12216240453 014574 0ustar00jwheel000000 000000 # # 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: Makefile.am 1175 2013-05-15 18:55:19Z rliebscher $ # EXTRA_DIST = \ ChangeLog \ ChangeLog-2001 \ ChangeLog-2002 \ ChangeLog-2003 \ ChangeLog-2004-2006 \ ChangeLog-2007 \ ChangeLog-2008 \ ChangeLog-2009 \ ChangeLog-2010 \ ChangeLog-2011 \ ChangeLog-2012 \ 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)\" avrdude_CFLAGS = @ENABLE_WARNINGS@ libavrdude_a_CFLAGS = @ENABLE_WARNINGS@ avrdude_LDADD = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB_1_0@ @LIBUSB@ @LIBFTDI1@ @LIBFTDI@ @LIBHID@ @LIBELF@ @LIBPTHREAD@ -lm bin_PROGRAMS = avrdude noinst_LIBRARIES = libavrdude.a # 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 \ avr.h \ avr910.c \ avr910.h \ avrdude.h \ avrftdi.c \ avrftdi.h \ avrftdi_private.h \ avrftdi_tpi.c \ avrftdi_tpi.h \ avrpart.c \ avrpart.h \ bitbang.c \ bitbang.h \ buspirate.c \ buspirate.h \ butterfly.c \ butterfly.h \ config.c \ config.h \ confwin.c \ confwin.h \ crc16.c \ crc16.h \ fileio.c \ fileio.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 \ linuxgpio.c \ linuxgpio.h \ linux_ppdev.h \ lists.c \ lists.h \ my_ddk_hidsdi.h \ par.c \ par.h \ pgm.c \ pgm.h \ pgm_type.c \ pgm_type.h \ pickit2.c \ pickit2.h \ pindefs.c \ pindefs.h \ ppi.c \ ppi.h \ ppiwin.c \ safemode.c \ safemode.h \ serial.h \ 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_libusb.c \ usbtiny.h \ usbtiny.c \ update.h \ update.c \ wiring.h \ wiring.c 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 avrdude-6.0.1/configure000755 000153 000000 00000662145 12216243006 014447 0ustar00jwheel000000 000000 #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for avrdude 6.0.1. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: avrdude-dev@nongnu.org about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='avrdude' PACKAGE_TARNAME='avrdude' PACKAGE_VERSION='6.0.1' PACKAGE_STRING='avrdude 6.0.1' PACKAGE_BUGREPORT='avrdude-dev@nongnu.org' PACKAGE_URL='' ac_unique_file="main.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS WINDOWS_DIRS ENABLE_WARNINGS DEFAULT_SER_PORT DEFAULT_PAR_PORT DIST_SUBDIRS_AC SUBDIRS_AC DOC_INST_DIR LIBHID LIBPTHREAD LIBFTDI LIBFTDI1 LIBUSB_1_0 LIBUSB LIBELF EGREP GREP CPP AR RANLIB LEXLIB LEX_OUTPUT_ROOT LEX YFLAGS YACC SED am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_os target_vendor target_cpu target host_os host_vendor host_cpu host build_os build_vendor build_cpu build target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking enable_versioned_doc enable_doc enable_parport enable_linuxgpio ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS YACC YFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures avrdude 6.0.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/avrdude] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of avrdude 6.0.1:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-versioned-doc install docs in directory with version name (default) --enable-doc Enable building documents --enable-parport Enable accessing parallel ports(default) --enable-linuxgpio Enable the Linux sysfs GPIO interface programmer type Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory YACC The `Yet Another Compiler Compiler' implementation to use. Defaults to the first program found out of: `bison -y', `byacc', `yacc'. YFLAGS The list of arguments that will be passed by default to $YACC. This script will default YFLAGS to the empty string to avoid a default value of `-d' given by some make applications. CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF avrdude configure 6.0.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------- ## ## Report this to avrdude-dev@nongnu.org ## ## ------------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by avrdude $as_me 6.0.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } if ${ac_cv_target+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; *) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' set x $ac_cv_target shift target_cpu=$1 target_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: target_os=$* IFS=$ac_save_IFS case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- am__api_version='1.14' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='avrdude' VERSION='6.0.1' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi ac_config_headers="$ac_config_headers ac_cfg.h" # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed for ac_prog in 'bison -y' byacc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_YACC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$YACC"; then ac_cv_prog_YACC="$YACC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_YACC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi YACC=$ac_cv_prog_YACC if test -n "$YACC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 $as_echo "$YACC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$YACC" && break done test -n "$YACC" || YACC="yacc" for ac_prog in flex lex do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LEX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LEX"; then ac_cv_prog_LEX="$LEX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LEX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LEX=$ac_cv_prog_LEX if test -n "$LEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5 $as_echo "$LEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$LEX" && break done test -n "$LEX" || LEX=":" if test "x$LEX" != "x:"; then cat >conftest.l <<_ACEOF %% a { ECHO; } b { REJECT; } c { yymore (); } d { yyless (1); } e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */ yyless ((input () != 0)); } f { unput (yytext[0]); } . { BEGIN INITIAL; } %% #ifdef YYTEXT_POINTER extern char *yytext; #endif int main (void) { return ! yylex () + ! yywrap (); } _ACEOF { { ac_try="$LEX conftest.l" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$LEX conftest.l") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5 $as_echo_n "checking lex output file root... " >&6; } if ${ac_cv_prog_lex_root+:} false; then : $as_echo_n "(cached) " >&6 else if test -f lex.yy.c; then ac_cv_prog_lex_root=lex.yy elif test -f lexyy.c; then ac_cv_prog_lex_root=lexyy else as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5 $as_echo "$ac_cv_prog_lex_root" >&6; } LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root if test -z "${LEXLIB+set}"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5 $as_echo_n "checking lex library... " >&6; } if ${ac_cv_lib_lex+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_LIBS=$LIBS ac_cv_lib_lex='none needed' for ac_lib in '' -lfl -ll; do LIBS="$ac_lib $ac_save_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ `cat $LEX_OUTPUT_ROOT.c` _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_lex=$ac_lib fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext test "$ac_cv_lib_lex" != 'none needed' && break done LIBS=$ac_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5 $as_echo "$ac_cv_lib_lex" >&6; } test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5 $as_echo_n "checking whether yytext is a pointer... " >&6; } if ${ac_cv_prog_lex_yytext_pointer+:} false; then : $as_echo_n "(cached) " >&6 else # POSIX says lex can declare yytext either as a pointer or an array; the # default is implementation-dependent. Figure out which it is, since # not all implementations provide the %pointer and %array declarations. ac_cv_prog_lex_yytext_pointer=no ac_save_LIBS=$LIBS LIBS="$LEXLIB $ac_save_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define YYTEXT_POINTER 1 `cat $LEX_OUTPUT_ROOT.c` _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_prog_lex_yytext_pointer=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5 $as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; } if test $ac_cv_prog_lex_yytext_pointer = yes; then $as_echo "#define YYTEXT_POINTER 1" >>confdefs.h fi rm -f conftest.l $LEX_OUTPUT_ROOT.c fi # Extract the first word of "$target_alias-ranlib", so it can be a program name with args. set dummy $target_alias-ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="$target_alias-ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$ac_cv_prog_RANLIB"; then if test "$build" = "$target"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi RANLIB=$ac_ct_RANLIB else RANLIB=":" fi else RANLIB="$ac_cv_prog_RANLIB" fi # Extract the first word of "$target_alias-ar", so it can be a program name with args. set dummy $target_alias-ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$target_alias-ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$ac_cv_prog_AR"; then if test "$build" = "$target"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR=":" fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi AR=$ac_ct_AR else AR=":" fi else AR="$ac_cv_prog_AR" fi # flex should have this if test "x$LEX" == xflex; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yylex_destroy is generated by flex" >&5 $as_echo_n "checking whether yylex_destroy is generated by flex... " >&6; } flex_version=`$LEX -V -v --version 2>/dev/null | $SED -e 's/^.* //'` case $flex_version in [0-1].*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: version $flex_version => no" >&5 $as_echo "version $flex_version => no" >&6; } ;; 2.[0-4].*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: version $flex_version => no" >&5 $as_echo "version $flex_version => no" >&6; } ;; 2.5.[0-8]) { $as_echo "$as_me:${as_lineno-$LINENO}: result: version $flex_version => no" >&5 $as_echo "version $flex_version => no" >&6; } ;; 2.5.[0-8][A-Za-z]*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: version $flex_version => no" >&5 $as_echo "version $flex_version => no" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: version $flex_version => yes" >&5 $as_echo "version $flex_version => yes" >&6; } $as_echo "#define HAVE_YYLEX_DESTROY 1" >>confdefs.h ;; esac fi # Checks for libraries. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tputs in -ltermcap" >&5 $as_echo_n "checking for tputs in -ltermcap... " >&6; } if ${ac_cv_lib_termcap_tputs+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltermcap $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char tputs (); int main () { return tputs (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_termcap_tputs=yes else ac_cv_lib_termcap_tputs=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termcap_tputs" >&5 $as_echo "$ac_cv_lib_termcap_tputs" >&6; } if test "x$ac_cv_lib_termcap_tputs" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBTERMCAP 1 _ACEOF LIBS="-ltermcap $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tputs in -lncurses" >&5 $as_echo_n "checking for tputs in -lncurses... " >&6; } if ${ac_cv_lib_ncurses_tputs+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lncurses $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char tputs (); int main () { return tputs (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ncurses_tputs=yes else ac_cv_lib_ncurses_tputs=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_tputs" >&5 $as_echo "$ac_cv_lib_ncurses_tputs" >&6; } if test "x$ac_cv_lib_ncurses_tputs" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNCURSES 1 _ACEOF LIBS="-lncurses $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5 $as_echo_n "checking for readline in -lreadline... " >&6; } if ${ac_cv_lib_readline_readline+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lreadline $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char readline (); int main () { return readline (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_readline_readline=yes else ac_cv_lib_readline_readline=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5 $as_echo "$ac_cv_lib_readline_readline" >&6; } if test "x$ac_cv_lib_readline_readline" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBREADLINE 1 _ACEOF LIBS="-lreadline $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_begin in -lelf" >&5 $as_echo_n "checking for elf_begin in -lelf... " >&6; } if ${ac_cv_lib_elf_elf_begin+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lelf $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char elf_begin (); int main () { return elf_begin (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_elf_elf_begin=yes else ac_cv_lib_elf_elf_begin=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_elf_begin" >&5 $as_echo "$ac_cv_lib_elf_elf_begin" >&6; } if test "x$ac_cv_lib_elf_elf_begin" = xyes; then : have_libelf=yes fi if test x$have_libelf = xyes; then case $target in *) LIBELF="-lelf" ;; esac $as_echo "#define HAVE_LIBELF 1" >>confdefs.h ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in libelf.h libelf/libelf.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done fi LIBELF=$LIBELF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostent" >&5 $as_echo_n "checking for library containing gethostent... " >&6; } if ${ac_cv_search_gethostent+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostent (); int main () { return gethostent (); ; return 0; } _ACEOF for ac_lib in '' nsl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_gethostent=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_gethostent+:} false; then : break fi done if ${ac_cv_search_gethostent+:} false; then : else ac_cv_search_gethostent=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostent" >&5 $as_echo "$ac_cv_search_gethostent" >&6; } ac_res=$ac_cv_search_gethostent if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing setsockopt" >&5 $as_echo_n "checking for library containing setsockopt... " >&6; } if ${ac_cv_search_setsockopt+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char setsockopt (); int main () { return setsockopt (); ; return 0; } _ACEOF for ac_lib in '' socket; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_setsockopt=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_setsockopt+:} false; then : break fi done if ${ac_cv_search_setsockopt+:} false; then : else ac_cv_search_setsockopt=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_setsockopt" >&5 $as_echo "$ac_cv_search_setsockopt" >&6; } ac_res=$ac_cv_search_setsockopt if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_get_string_simple in -lusb" >&5 $as_echo_n "checking for usb_get_string_simple in -lusb... " >&6; } if ${ac_cv_lib_usb_usb_get_string_simple+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char usb_get_string_simple (); int main () { return usb_get_string_simple (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_usb_get_string_simple=yes else ac_cv_lib_usb_usb_get_string_simple=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_usb_get_string_simple" >&5 $as_echo "$ac_cv_lib_usb_usb_get_string_simple" >&6; } if test "x$ac_cv_lib_usb_usb_get_string_simple" = xyes; then : have_libusb=yes fi if test x$have_libusb = xyes; then case $target in *-*-darwin*) LIBUSB="-lusb -framework CoreFoundation -framework IOKit" ;; *) LIBUSB="-lusb" ;; esac $as_echo "#define HAVE_LIBUSB 1" >>confdefs.h for ac_header in usb.h do : ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" if test "x$ac_cv_header_usb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_USB_H 1 _ACEOF fi done for ac_header in lusb0_usb.h do : ac_fn_c_check_header_mongrel "$LINENO" "lusb0_usb.h" "ac_cv_header_lusb0_usb_h" "$ac_includes_default" if test "x$ac_cv_header_lusb0_usb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LUSB0_USB_H 1 _ACEOF fi done fi LIBUSB=$LIBUSB { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb_init in -lusb-1.0" >&5 $as_echo_n "checking for libusb_init in -lusb-1.0... " >&6; } if ${ac_cv_lib_usb_1_0_libusb_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb-1.0 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char libusb_init (); int main () { return libusb_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_1_0_libusb_init=yes else ac_cv_lib_usb_1_0_libusb_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_1_0_libusb_init" >&5 $as_echo "$ac_cv_lib_usb_1_0_libusb_init" >&6; } if test "x$ac_cv_lib_usb_1_0_libusb_init" = xyes; then : have_libusb_1_0=yes fi 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 $as_echo "#define HAVE_LIBUSB_1_0 1" >>confdefs.h for ac_header in libusb-1.0/libusb.h do : ac_fn_c_check_header_mongrel "$LINENO" "libusb-1.0/libusb.h" "ac_cv_header_libusb_1_0_libusb_h" "$ac_includes_default" if test "x$ac_cv_header_libusb_1_0_libusb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBUSB_1_0_LIBUSB_H 1 _ACEOF fi done for ac_header in libusb.h do : ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" if test "x$ac_cv_header_libusb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBUSB_H 1 _ACEOF fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb_init in -lusb" >&5 $as_echo_n "checking for libusb_init in -lusb... " >&6; } if ${ac_cv_lib_usb_libusb_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char libusb_init (); int main () { return libusb_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_libusb_init=yes else ac_cv_lib_usb_libusb_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_libusb_init" >&5 $as_echo "$ac_cv_lib_usb_libusb_init" >&6; } if test "x$ac_cv_lib_usb_libusb_init" = xyes; then : have_libusb_1_0=yes fi 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 $as_echo "#define HAVE_LIBUSB_1_0 1" >>confdefs.h for ac_header in libusb.h do : ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" if test "x$ac_cv_header_libusb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBUSB_H 1 _ACEOF fi done fi LIBUSB_1_0=$LIBUSB_1_0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ftdi_new in -lftdi1" >&5 $as_echo_n "checking for ftdi_new in -lftdi1... " >&6; } if ${ac_cv_lib_ftdi1_ftdi_new+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lftdi1 -lusb-1.0 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ftdi_new (); int main () { return ftdi_new (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ftdi1_ftdi_new=yes else ac_cv_lib_ftdi1_ftdi_new=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ftdi1_ftdi_new" >&5 $as_echo "$ac_cv_lib_ftdi1_ftdi_new" >&6; } if test "x$ac_cv_lib_ftdi1_ftdi_new" = xyes; then : have_libftdi1=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ftdi_usb_get_strings in -lftdi" >&5 $as_echo_n "checking for ftdi_usb_get_strings in -lftdi... " >&6; } if ${ac_cv_lib_ftdi_ftdi_usb_get_strings+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lftdi -lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ftdi_usb_get_strings (); int main () { return ftdi_usb_get_strings (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ftdi_ftdi_usb_get_strings=yes else ac_cv_lib_ftdi_ftdi_usb_get_strings=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ftdi_ftdi_usb_get_strings" >&5 $as_echo "$ac_cv_lib_ftdi_ftdi_usb_get_strings" >&6; } if test "x$ac_cv_lib_ftdi_ftdi_usb_get_strings" = xyes; then : have_libftdi=yes fi if test x$have_libftdi1 = xyes; then LIBFTDI1="-lftdi1" $as_echo "#define HAVE_LIBFTDI1 1" >>confdefs.h LIBFTDI1=$LIBFTDI1 else if test x$have_libftdi = xyes; then LIBFTDI="-lftdi -lusb" $as_echo "#define HAVE_LIBFTDI 1" >>confdefs.h LIBFTDI=$LIBFTDI ac_fn_c_check_decl "$LINENO" "TYPE_232H" "ac_cv_have_decl_TYPE_232H" "#include " if test "x$ac_cv_have_decl_TYPE_232H" = xyes; then : have_libftdi_FT232H=yes fi if test x$have_libftdi_FT232H = xyes; then $as_echo "#define HAVE_LIBFTDI_TYPE_232H 1" >>confdefs.h fi fi fi for ac_header in pthread.h do : ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_H 1 _ACEOF fi done # as there exits header file only pthread implementations for Windows, check if we have a library { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_create=yes else ac_cv_lib_pthread_pthread_create=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : have_pthread=yes fi if test x$have_pthread = xyes; then LIBPTHREAD="-lpthread" fi LIBPTHREAD=$LIBPTHREAD # Checks for header files. for ac_header in limits.h stdlib.h string.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in fcntl.h sys/ioctl.h sys/time.h termios.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in ddk/hidsdi.h do : ac_fn_c_check_header_compile "$LINENO" "ddk/hidsdi.h" "ac_cv_header_ddk_hidsdi_h" "#include #include " if test "x$ac_cv_header_ddk_hidsdi_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DDK_HIDSDI_H 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi # Checks for library functions. for ac_func in memset select strcasecmp strdup strerror strncasecmp strtol strtoul gettimeofday usleep do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a Win32 HID libray" >&5 $as_echo_n "checking for a Win32 HID libray... " >&6; } 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}" if test "$cross_compiling" = yes; then : have_libhid=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include $HIDINCLUDE int main(void) { GUID hidGuid; HidD_GetHidGuid(&hidGuid); return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : have_libhid=yes else have_libhid=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_libhid" >&5 $as_echo "$have_libhid" >&6; } if test x$have_libhid = xyes; then $as_echo "#define HAVE_LIBHID 1" >>confdefs.h else LIBHID="" fi LIBS="${SAVED_LIBS}" LIBHID=$LIBHID # Check for types # Solaris has uint_t and ulong_t typedefs in , avoid # the redeclaration in usbtiny.c. ac_fn_c_check_type "$LINENO" "uint_t" "ac_cv_type_uint_t" "#include " if test "x$ac_cv_type_uint_t" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UINT_T 1 _ACEOF fi ac_fn_c_check_type "$LINENO" "ulong_t" "ac_cv_type_ulong_t" "#include " if test "x$ac_cv_type_ulong_t" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ULONG_T 1 _ACEOF fi # Checks for misc stuff. # Check whether --enable-versioned-doc was given. if test "${enable_versioned_doc+set}" = set; then : enableval=$enable_versioned_doc; case "${enableval}" in yes) versioned_doc=yes ;; no) versioned_doc=no ;; *) as_fn_error $? "bad value ${enableval} for versioned-doc option" "$LINENO" 5 ;; esac else versioned_doc=yes fi if test "$versioned_doc" = "yes"; then DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude-$(VERSION)' else DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude' fi # Check whether --enable-doc was given. if test "${enable_doc+set}" = set; then : enableval=$enable_doc; case "${enableval}" in yes) enabled_doc=yes ;; no) enabled_doc=no ;; *) as_fn_error $? "bad value ${enableval} for disable-doc option" "$LINENO" 5 ;; esac else enabled_doc=no fi # Check whether --enable-parport was given. if test "${enable_parport+set}" = set; then : enableval=$enable_parport; case "${enableval}" in yes) enabled_parport=yes ;; no) enabled_parport=no ;; *) as_fn_error $? "bad value ${enableval} for enable-parport option" "$LINENO" 5 ;; esac else enabled_parport=yes fi # Check whether --enable-linuxgpio was given. if test "${enable_linuxgpio+set}" = set; then : enableval=$enable_linuxgpio; case "${enableval}" in yes) enabled_linuxgpio=yes ;; no) enabled_linuxgpio=no ;; *) as_fn_error $? "bad value ${enableval} for enable-linuxgpio option" "$LINENO" 5 ;; esac else enabled_linuxgpio=no fi DIST_SUBDIRS_AC='doc windows' if test "$enabled_doc" = "yes"; then SUBDIRS_AC='doc' else SUBDIRS_AC='' fi DOC_INST_DIR=$DOC_INST_DIR SUBDIRS_AC=$SUBDIRS_AC 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for parallel device" >&5 $as_echo_n "checking for parallel device... " >&6; } if test "$DEFAULT_PAR_PORT" = "unknown"; then { $as_echo "$as_me:${as_lineno-$LINENO}: parallel port access disabled for this system" >&5 $as_echo "$as_me: parallel port access disabled for this system" >&6;} enabled_parport=no else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEFAULT_PAR_PORT" >&5 $as_echo "$DEFAULT_PAR_PORT" >&6; } fi DEFAULT_PAR_PORT=$DEFAULT_PAR_PORT fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for serial device" >&5 $as_echo_n "checking for serial device... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEFAULT_SER_PORT" >&5 $as_echo "$DEFAULT_SER_PORT" >&6; } DEFAULT_SER_PORT=$DEFAULT_SER_PORT if test "$enabled_parport" = "yes"; then $as_echo "#define HAVE_PARPORT 1" >>confdefs.h confsubst="-e /^@HAVE_PARPORT_/d" else confsubst="-e /^@HAVE_PARPORT_BEGIN@/,/^@HAVE_PARPORT_END@/d" fi if test "$enabled_linuxgpio" = "yes"; then $as_echo "#define HAVE_LINUXGPIO 1" >>confdefs.h 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 ? { $as_echo "$as_me:${as_lineno-$LINENO}: checking if gcc accepts -Wno-pointer-sign " >&5 $as_echo_n "checking if gcc accepts -Wno-pointer-sign ... " >&6; } safe_CFLAGS=$CFLAGS CFLAGS="$ENABLE_WARNINGS -Wno-pointer-sign" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { int main () { return 0 ; } ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : no_pointer_sign=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else no_pointer_sign=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS=$safe_CFLAGS if test x$no_pointer_sign = xyes; then ENABLE_WARNINGS="$ENABLE_WARNINGS -Wno-pointer-sign" fi fi 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? { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC accepts -mno-cygwin" >&5 $as_echo_n "checking if $CC accepts -mno-cygwin... " >&6; } safe_CFLAGS="$CFLAGS" CFLAGS="$ENABLE_WARNINGS -mno-cygwin" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { int main () { return 0 ; } ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : no_cygwin=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else no_cygwin=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$safe_CFLAGS" if test x$no_cygwin = xyes; then CFLAGS="${CFLAGS} -mno-cygwin" else { $as_echo "$as_me:${as_lineno-$LINENO}: Your compiler does not understand the -mno-cygwin option." >&5 $as_echo "$as_me: Your compiler does not understand the -mno-cygwin option." >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: You might want to select an alternative compiler, like" >&5 $as_echo "$as_me: You might want to select an alternative compiler, like" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: " >&5 $as_echo "$as_me: " >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: CC=mingw32-gcc ./configure" >&5 $as_echo "$as_me: CC=mingw32-gcc ./configure" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: " >&5 $as_echo "$as_me: " >&6;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker accepts -static" >&5 $as_echo_n "checking if linker accepts -static... " >&6; } safe_LDFLAGS="$LDFLAGS" LDFLAGS="${LDFLAGS} -static" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { int main () { return 0 ; } ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : can_link_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else can_link_static_cygwin=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$safe_LDFLAGS" if test x$can_link_static = xyes; then LDFLAGS="${LDFLAGS} -static" fi WINDOWS_DIRS="windows" CFLAGS="${CFLAGS} -DWIN32NATIVE" ;; esac WINDOWS_DIRS=$WINDOWS_DIRS ac_config_files="$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="$ac_config_files avrdude.conf.tmp:avrdude.conf.in" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by avrdude $as_me 6.0.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ avrdude config.status 6.0.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" confsubst="$confsubst" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "ac_cfg.h") CONFIG_HEADERS="$CONFIG_HEADERS ac_cfg.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "windows/Makefile") CONFIG_FILES="$CONFIG_FILES windows/Makefile" ;; "avrdude.spec") CONFIG_FILES="$CONFIG_FILES avrdude.spec" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "avrdude.conf.tmp") CONFIG_FILES="$CONFIG_FILES avrdude.conf.tmp:avrdude.conf.in" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "avrdude.conf.tmp":F) sed $confsubst avrdude.conf.tmp > avrdude.conf ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi 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_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 avrdude-6.0.1/configure.ac000644 000153 000000 00000034452 12216242776 015035 0ustar00jwheel000000 000000 # # 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: configure.ac 1244 2013-09-18 06:19:42Z joerg_wunsch $ # # Process this file with autoconf to produce a configure script. AC_PREREQ(2.60) AC_INIT(avrdude, 6.0.1, 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) # Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_SED AC_PROG_YACC AC_PROG_LEX AN_MAKEVAR([RANLIB], [AC_PROG_RANLIB]) AN_PROGRAM([ranlib], [AC_PROG_RANLIB]) AC_DEFUN([AC_PROG_RANLIB], [AC_CHECK_TARGET_TOOL(RANLIB, ranlib, :)]) AC_PROG_RANLIB 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_begin], [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_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], [], [-lusb-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 # 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_RUN([#include #include $HIDINCLUDE int main(void) { GUID hidGuid; HidD_GetHidGuid(&hidGuid); return 0; } ], [have_libhid=yes], [have_libhid=no], [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_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 avrdude-6.0.1/aclocal.m4000644 000153 000000 00000121701 12216243005 014363 0ustar00jwheel000000 000000 # generated automatically by aclocal 1.14 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.14], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.14])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR avrdude-6.0.1/ac_cfg.h.in000644 000153 000000 00000011227 12216243041 014504 0ustar00jwheel000000 000000 /* 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_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_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 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 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 /* 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 avrdude-6.0.1/avrdude.spec.in000644 000153 000000 00000005256 12216240452 015447 0ustar00jwheel000000 000000 ## -*- mode: rpm-spec; -*- ## ## $Id: avrdude.spec.in 558 2005-11-29 20:28:51Z joerg_wunsch $ ## ## @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. avrdude-6.0.1/avrdude.conf.in000644 000153 000000 00001607130 12216240452 015442 0ustar00jwheel000000 000000 # $Id: avrdude.conf.in 1236 2013-09-16 19:40:15Z 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. # # 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) # 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 = ~ ( [, ... ] ) . # ; # # 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 # 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 ; # 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; ; 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; # RTS mosi = 2; # TxD 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"; ; 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; ; programmer id = "jtag3pdi"; desc = "Atmel AVR JTAGICE3 in PDI mode"; type = "jtagice3_pdi"; connection_type = usb; ; programmer id = "jtag3dw"; desc = "Atmel AVR JTAGICE3 in debugWIRE mode"; type = "jtagice3_dw"; connection_type = usb; ; programmer id = "jtag3isp"; desc = "Atmel AVR JTAGICE3 in ISP mode"; type = "jtagice3_isp"; connection_type = usb; ; 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; ; @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; ; #------------------------------------------------------------ # 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 x x x 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 x x x x x x x 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 x x x x x x x 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 x x x x x x x 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"; ; ; #------------------------------------------------------------ # 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 x x x x x x x 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; ; #------------------------------------------------------------ # 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 x x x x x 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; ; #------------------------------------------------------------ # 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 x x x x x 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; ; #------------------------------------------------------------ # 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 x x x x x 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 x x x x x 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; ; #------------------------------------------------------------ # 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; ; ; #------------------------------------------------------------ # 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"; 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"; ; ; #------------------------------------------------------------ # 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"; 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"; ; ; #------------------------------------------------------------ # 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"; 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"; ; ; #------------------------------------------------------------ # 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 = 55000; bs2 = 0xE2; 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; ; ; #------------------------------------------------------------ # 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; 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; 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; 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; 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; 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; 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; 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; 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 = 64; 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 = 64; 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; 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; 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; 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; ; #------------------------------------------------------------ # 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; ; #------------------------------------------------------------ # ATxmega64A3 #------------------------------------------------------------ part parent "x64a1" id = "x64a3"; desc = "ATxmega64A3"; signature = 0x1e 0x96 0x42; ; #------------------------------------------------------------ # ATxmega64A3U #------------------------------------------------------------ part parent "x64a1" id = "x64a3u"; desc = "ATxmega64A3U"; signature = 0x1e 0x96 0x42; ; #------------------------------------------------------------ # ATxmega64A4 #------------------------------------------------------------ part parent "x64a1" id = "x64a4"; desc = "ATxmega64A4"; signature = 0x1e 0x96 0x46; ; #------------------------------------------------------------ # ATxmega64B1 #------------------------------------------------------------ part parent "x64a1" id = "x64b1"; desc = "ATxmega64B1"; signature = 0x1e 0x96 0x52; ; #------------------------------------------------------------ # ATxmega64B3 #------------------------------------------------------------ part parent "x64a1" id = "x64b3"; desc = "ATxmega64B3"; signature = 0x1e 0x96 0x51; ; #------------------------------------------------------------ # ATxmega128C3 #------------------------------------------------------------ part parent ".xmega" id = "x128c3"; desc = "ATxmega128C3"; signature = 0x1e 0x97 0x52; 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; ; #------------------------------------------------------------ # ATxmega128A3 #------------------------------------------------------------ part parent "x128a1" id = "x128a3"; desc = "ATxmega128A3"; signature = 0x1e 0x97 0x42; ; #------------------------------------------------------------ # ATxmega128A3U #------------------------------------------------------------ part parent "x128a1" id = "x128a3u"; desc = "ATxmega128A3U"; signature = 0x1e 0x97 0x42; ; #------------------------------------------------------------ # 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; 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; 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; ; #------------------------------------------------------------ # ATxmega192C3 #------------------------------------------------------------ part parent ".xmega" id = "x192c3"; desc = "ATxmega192C3"; signature = 0x1e 0x97 0x51; 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; ; #------------------------------------------------------------ # ATxmega256C3 #------------------------------------------------------------ part parent ".xmega" id = "x256c3"; desc = "ATxmega256C3"; signature = 0x1e 0x98 0x46; 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; ; #------------------------------------------------------------ # ATxmega256A3B #------------------------------------------------------------ part parent "x256a1" id = "x256a3b"; desc = "ATxmega256A3B"; signature = 0x1e 0x98 0x43; ; #------------------------------------------------------------ # ATxmega256A3BU #------------------------------------------------------------ part parent "x256a1" id = "x256a3bu"; desc = "ATxmega256A3BU"; signature = 0x1e 0x98 0x43; ; #------------------------------------------------------------ # ATxmega384C3 #------------------------------------------------------------ part parent ".xmega" id = "x384c3"; desc = "ATxmega384C3"; signature = 0x1e 0x98 0x45; 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 = 0x00804000; 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 = 0x00804000; 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 x x x 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; ; ; avrdude-6.0.1/depcomp000555 000153 000000 00000056016 12216240532 014106 0ustar00jwheel000000 000000 #! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2013-05-30.07; # UTC # Copyright (C) 1999-2013 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 2, 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 to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: avrdude-6.0.1/ylwrap000555 000153 000000 00000015312 12216240532 013767 0ustar00jwheel000000 000000 #! /bin/sh # ylwrap - wrapper for lex/yacc invocations. scriptversion=2013-01-12.17; # UTC # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # Written by Tom Tromey . # # 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, 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 to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . get_dirname () { case $1 in */*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';; # Otherwise, we want the empty string (not "."). esac } # guard FILE # ---------- # The CPP macro used to guard inclusion of FILE. guard () { printf '%s\n' "$1" \ | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g' \ -e 's/__*/_/g' } # quote_for_sed [STRING] # ---------------------- # Return STRING (or stdin) quoted to be used as a sed pattern. quote_for_sed () { case $# in 0) cat;; 1) printf '%s\n' "$1";; esac \ | sed -e 's|[][\\.*]|\\&|g' } case "$1" in '') echo "$0: No files given. Try '$0 --help' for more information." 1>&2 exit 1 ;; --basedir) basedir=$2 shift 2 ;; -h|--h*) cat <<\EOF Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... Wrapper for lex/yacc invocations, renaming files as desired. INPUT is the input file OUTPUT is one file PROG generates DESIRED is the file we actually want instead of OUTPUT PROGRAM is program to run ARGS are passed to PROG Any number of OUTPUT,DESIRED pairs may be used. Report bugs to . EOF exit $? ;; -v|--v*) echo "ylwrap $scriptversion" exit $? ;; esac # The input. input=$1 shift # We'll later need for a correct munging of "#line" directives. input_sub_rx=`get_dirname "$input" | quote_for_sed` case $input in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input=`pwd`/$input ;; esac input_rx=`get_dirname "$input" | quote_for_sed` # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot=false if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot=true fi # The parser itself, the first file, is the destination of the .y.c # rule in the Makefile. parser=$1 # A sed program to s/FROM/TO/g for all the FROM/TO so that, for # instance, we rename #include "y.tab.h" into #include "parse.h" # during the conversion from y.tab.c to parse.c. sed_fix_filenames= # Also rename header guards, as Bison 2.7 for instance uses its header # guard in its implementation file. sed_fix_header_guards= while test $# -ne 0; do if test x"$1" = x"--"; then shift break fi from=$1 # Handle y_tab.c and y_tab.h output by DOS if $y_tab_nodot; then case $from in "y.tab.c") from=y_tab.c;; "y.tab.h") from=y_tab.h;; esac fi shift to=$1 shift sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;" sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;" done # The program to run. prog=$1 shift # Make any relative path in $prog absolute. case $prog in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog=`pwd`/$prog ;; esac dirname=ylwrap$$ do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 mkdir $dirname || exit 1 cd $dirname case $# in 0) "$prog" "$input" ;; *) "$prog" "$@" "$input" ;; esac ret=$? if test $ret -eq 0; then for from in * do to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"` if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend '../'. case $to in [\\/]* | ?:[\\/]*) target=$to;; *) target=../$to;; esac # Do not overwrite unchanged header files to avoid useless # recompilations. Always update the parser itself: it is the # destination of the .y.c rule in the Makefile. Divert the # output of all other files to a temporary file so we can # compare them to existing versions. if test $from != $parser; then realtarget=$target target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'` fi # Munge "#line" or "#" directives. Don't let the resulting # debug information point at an absolute srcdir. Use the real # output file name, not yy.lex.c for instance. Adjust the # include guards too. sed -e "/^#/!b" \ -e "s|$input_rx|$input_sub_rx|" \ -e "$sed_fix_filenames" \ -e "$sed_fix_header_guards" \ "$from" >"$target" || ret=$? # Check whether files must be updated. if test "$from" != "$parser"; then if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then echo "$to is unchanged" rm -f "$target" else echo "updating $to" mv -f "$target" "$realtarget" fi fi else # A missing file is only an error for the parser. This is a # blatant hack to let us support using "yacc -d". If -d is not # specified, don't fail when the header file is "missing". if test "$from" = "$parser"; then ret=1 fi fi done fi # Remove the directory. cd .. rm -rf $dirname exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: avrdude-6.0.1/COPYING000644 000153 000000 00000043003 12216240452 013557 0ustar00jwheel000000 000000 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. avrdude-6.0.1/compile000555 000153 000000 00000016245 12216240532 014107 0ustar00jwheel000000 000000 #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2013 Free Software Foundation, Inc. # Written by Tom Tromey . # # 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, 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 to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: avrdude-6.0.1/config.guess000555 000153 000000 00000127737 12216240532 015062 0ustar00jwheel000000 000000 #! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2013 Free Software Foundation, Inc. timestamp='2013-05-16' # This file 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 to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches with a ChangeLog entry to config-patches@gnu.org. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; or1k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: avrdude-6.0.1/config.sub000555 000153 000000 00000105124 12216240532 014507 0ustar00jwheel000000 000000 #! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2013 Free Software Foundation, Inc. timestamp='2013-04-24' # This file 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 to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches with a ChangeLog entry to config-patches@gnu.org. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 \ | or1k | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | amd64-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or1k-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: avrdude-6.0.1/install-sh000555 000153 000000 00000033255 12216240532 014535 0ustar00jwheel000000 000000 #!/bin/sh # install - install a program, script, or datafile scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: avrdude-6.0.1/missing000555 000153 000000 00000015331 12216240532 014123 0ustar00jwheel000000 000000 #! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2012-06-26.16; # UTC # Copyright (C) 1996-2013 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # 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, 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 to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'automa4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: avrdude-6.0.1/config_gram.y000644 000153 000000 00000106005 12216240452 015173 0ustar00jwheel000000 000000 /* * 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: config_gram.y 1226 2013-09-13 17:22:38Z joerg_wunsch $ */ %{ #include "ac_cfg.h" #include #include #include #include "avrdude.h" #include "config.h" #include "lists.h" #include "par.h" #include "serbb.h" #include "pindefs.h" #include "ppi.h" #include "pgm.h" #include "pgm_type.h" #include "avr.h" #if defined(WIN32NATIVE) #define strtok_r( _s, _sep, _lasts ) \ ( *(_lasts) = strtok( (_s), (_sep) ) ) #endif int yylex(void); int yyerror(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) { fprintf(stderr, "%s: error at %s:%d: required parameter id not specified\n", progname, infile, lineno); exit(1); } if (current_prog->initpgm == NULL) { fprintf(stderr, "%s: error at %s:%d: programmer type not specified\n", progname, infile, lineno); exit(1); } id = ldata(lfirst(current_prog->id)); existing_prog = locate_programmer(programmers, id); if (existing_prog) { fprintf(stderr, "%s: warning at %s:%d: programmer %s overwrites " "previous definition %s:%d.\n", progname, infile, current_prog->lineno, id, existing_prog->config_file, existing_prog->lineno); 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(); 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) { fprintf(stderr, "%s: error at %s:%d: parent programmer %s not found\n", progname, infile, lineno, $3->value.string); exit(1); } current_prog = pgm_dup(pgm); 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) { fprintf(stderr, "%s: error at %s:%d: required parameter id not specified\n", progname, infile, lineno); exit(1); } /* * 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) { fprintf(stderr, "%s: error at %s:%d: must specify page_size for paged " "memory\n", progname, infile, lineno); exit(1); } if (m->num_pages == 0) { fprintf(stderr, "%s: error at %s:%d: must specify num_pages for paged " "memory\n", progname, infile, lineno); exit(1); } if (m->size != m->page_size * m->num_pages) { fprintf(stderr, "%s: error at %s:%d: page size (%u) * num_pages (%u) = " "%u does not match memory size (%u)\n", progname, infile, lineno, m->page_size, m->num_pages, m->page_size * m->num_pages, m->size); exit(1); } } } existing_part = locate_part(part_list, current_part->id); if (existing_part) { fprintf(stderr, "%s: warning at %s:%d: part %s overwrites " "previous definition %s:%d.\n", progname, infile, current_part->lineno, current_part->id, existing_part->config_file, existing_part->lineno); 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(); 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) { fprintf(stderr, "%s: error at %s:%d: can't find parent part", progname, infile, lineno); exit(1); } current_part = avr_dup_part(parent_part); 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; while (lsize(string_list)) { t = lrmv_n(string_list, 1); ladd(current_prog->id, dup_string(t->value.string)); free_token(t); } } } | 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) { fprintf(stderr, "%s: error at %s:%d: programmer type %s not found\n", progname, infile, lineno, $1->value.string); exit(1); } current_prog->initpgm = pgm_type->initpgm; free_token($1); } | error { fprintf(stderr, "%s: error at %s:%d: programmer type must be written as \"id_type\"\n", progname, infile, lineno); exit(1); } ; 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 TKN_NUMBER { { current_prog->usbpid = $3->value.number; free_token($3); } } | 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); } } ; pin_number_non_empty: TKN_NUMBER { assign_pin(pin_name, $1, 0); } | TKN_TILDE TKN_NUMBER { assign_pin(pin_name, $2, 1); } ; 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 { assign_pin_list(1); } ; 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 { { fprintf(stderr, "%s: error at %s:%d: devicecode is deprecated, use " "stk500_devcode instead\n", progname, infile, lineno); exit(1); } } | 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_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) { fprintf(stderr, "%s: Warning: line %d of %s: " "too many bytes in control stack\n", progname, lineno, infile); } } } | 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) { fprintf(stderr, "%s: Warning: line %d of %s: " "too many bytes in control stack\n", progname, lineno, infile); } } } | 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) { fprintf(stderr, "%s: Warning: line %d of %s: " "too many bytes in flash instructions\n", progname, lineno, infile); } } } | 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) { fprintf(stderr, "%s: Warning: line %d of %s: " "too many bytes in EEPROM instructions\n", progname, lineno, infile); } } } | 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(); 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); op = avr_new_opcode(); parse_cmdbits(op); if (current_part->op[opnum] != NULL) { /*fprintf(stderr, "%s: warning at %s:%d: operation redefined\n", progname, infile, lineno);*/ 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); op = avr_new_opcode(); parse_cmdbits(op); if (current_mem->op[opnum] != NULL) { /*fprintf(stderr, "%s: warning at %s:%d: operation redefined\n", progname, infile, lineno);*/ 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)) { fprintf(stderr, "%s: error at line %d of %s: pin must be in the " "range %d-%d\n", progname, lineno, infile, PIN_MIN, PIN_MAX); exit(1); } pin_set_value(&(current_prog->pin[pinno]), value, invert); return 0; } static int assign_pin_list(int invert) { TOKEN * t; int pin; current_prog->pinno[pin_name] = 0; while (lsize(number_list)) { t = lrmv_n(number_list, 1); pin = t->value.number; if ((pin < PIN_MIN) || (pin > PIN_MAX)) { fprintf(stderr, "%s: error at line %d of %s: pin must be in the " "range %d-%d\n", progname, lineno, infile, PIN_MIN, PIN_MAX); exit(1); /* TODO clear list and free tokens if no exit is done */ } pin_set_value(&(current_prog->pin[pin_name]), pin, invert); free_token(t); } return 0; } 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 : fprintf(stderr, "%s: error at %s:%d: invalid opcode\n", progname, infile, lineno); exit(1); break; } } static int parse_cmdbits(OPCODE * op) { TOKEN * t; int bitno; char ch; char * e; char * q; int len; char * s, *brkt = NULL; bitno = 32; while (lsize(string_list)) { t = lrmv_n(string_list, 1); s = strtok_r(t->value.string, " ", &brkt); while (s != NULL) { bitno--; if (bitno < 0) { fprintf(stderr, "%s: error at %s:%d: too many opcode bits for instruction\n", progname, infile, lineno); exit(1); } len = strlen(s); if (len == 0) { fprintf(stderr, "%s: error at %s:%d: invalid bit specifier \"\"\n", progname, infile, lineno); exit(1); } 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 : fprintf(stderr, "%s: error at %s:%d: invalid bit specifier '%c'\n", progname, infile, lineno, ch); exit(1); break; } } else { if (ch == 'a') { q = &s[1]; op->bit[bitno].bitno = strtol(q, &e, 0); if ((e == q)||(*e != 0)) { fprintf(stderr, "%s: error at %s:%d: can't parse bit number from \"%s\"\n", progname, infile, lineno, q); exit(1); } op->bit[bitno].type = AVR_CMDBIT_ADDRESS; op->bit[bitno].value = 0; } else { fprintf(stderr, "%s: error at %s:%d: invalid bit specifier \"%s\"\n", progname, infile, lineno, s); exit(1); } } s = strtok_r(NULL, " ", &brkt); } free_token(t); } /* while */ return 0; } avrdude-6.0.1/lexer.l000644 000153 000000 00000026236 12216240453 014032 0ustar00jwheel000000 000000 /* * 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: lexer.l 1226 2013-09-13 17:22:38Z joerg_wunsch $ */ %{ /* need this for the call to atof() below */ #include #include #include #include #include #include #include "avrdude.h" #include "config.h" #include "config_gram.h" #include "lists.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) { fprintf(stderr, "error at %s:%d: EOF in comment\n", infile, lineno); fprintf(stderr, " comment started on line %d\n", comment_start); exit(1); break; } } } \" { *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 { fprintf(stderr, "error at line %d: unterminated character constant\n", lineno); exit(1); } 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: { fprintf(stderr, "error at %s:%d: possible old-style config file entry\n", infile, lineno); fprintf(stderr, " Update your config file (see %s%s for a sample)\n", CONFIG_DIR, "/avrdude.conf.sample"); return YYERRCODE; } . { return YYERRCODE; } %% avrdude-6.0.1/arduino.h000644 000153 000000 00000001656 12216240452 014346 0ustar00jwheel000000 000000 /* * 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: arduino.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #ifndef arduino_h__ #define arduino_h__ extern const char arduino_desc[]; void arduino_initpgm (PROGRAMMER * pgm); #endif avrdude-6.0.1/arduino.c000644 000153 000000 00000006472 12216240452 014342 0ustar00jwheel000000 000000 /* * 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: arduino.c 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ /* * 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 "pgm.h" #include "stk500_private.h" #include "stk500.h" #include "serial.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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500_cmd(): programmer is out of sync\n", progname); return -1; } else if (buf[0] != Resp_STK_INSYNC) { fprintf(stderr, "\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) { fprintf(stderr, "\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) { strcpy(pgm->port, port); if (serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &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; } avrdude-6.0.1/avr.c000644 000153 000000 00000077616 12216240452 013501 0ustar00jwheel000000 000000 /* * 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: avr.c 1221 2013-09-13 12:48:13Z joerg_wunsch $ */ #include "ac_cfg.h" #include #include #include #include #include #include #include "avrdude.h" #include "avr.h" #include "lists.h" #include "pindefs.h" #include "ppi.h" #include "safemode.h" #include "update.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) { fprintf(stderr, "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 { fprintf(stderr, "%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) { fprintf(stderr, "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; } fprintf(stderr, "Error enabling TPI external programming mode:"); fprintf(stderr, "Target does not reply\n"); return -1; } else { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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 fprintf(stderr, "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) { fprintf(stderr, "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++) { 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) { fprintf(stderr, "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) { /* 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 if (verbose >= 3) { fprintf(stderr, "%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++) { if (vmem == NULL || (vmem->tags[i] & TAG_ALLOCATED) != 0) { rc = pgm->read_byte(pgm, p, mem, i, mem->buf + i); if (rc != 0) { fprintf(stderr, "avr_read(): error reading address 0x%04lx\n", i); if (rc == -1) fprintf(stderr, " 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) { fprintf(stderr, "%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) { fprintf(stderr, "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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: Error: %s programmer does not support TPI\n", progname, pgm->type); return -1; } if (strcmp(mem->desc, "flash") == 0) { fprintf(stderr, "Writing a byte to flash is not supported for %s\n", p->desc); return -1; } else if ((mem->offset + addr) & 1) { fprintf(stderr, "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 fprintf(stderr, "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); fprintf(stderr, "%s: this device must be powered off and back on to continue\n", progname); if (pgm->pinno[PPI_AVR_VCC]) { fprintf(stderr, "%s: attempting to do this now ...\n", progname); pgm->powerdown(pgm); usleep(250000); rc = pgm->initialize(pgm, p); if (rc < 0) { fprintf(stderr, "%s: initialization failed, rc=%d\n", progname, rc); fprintf(stderr, "%s: can't re-initialize device after programming the " "%s bits\n", progname, mem->desc); fprintf(stderr, "%s: you must manually power-down the device and restart\n" "%s: %s to continue.\n", progname, progname, progname); return -3; } fprintf(stderr, "%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) { fprintf(stderr, "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) { fprintf(stderr, "%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) { 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) { /* 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 if (verbose >= 3) { fprintf(stderr, "%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) { fprintf(stderr, " ***failed; "); fprintf(stderr, "\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) { fprintf(stderr, " *** page %d (addresses 0x%04x - 0x%04x) failed " "to write\n", i % m->page_size, i - m->page_size + 1, i); fprintf(stderr, "\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 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) { fprintf(stderr, "%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) { fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "%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]) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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 = (completed * 100) / total; 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. */ } avrdude-6.0.1/avr.h000644 000153 000000 00000004532 12216240452 013471 0ustar00jwheel000000 000000 /* * 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: avr.h 1167 2013-05-06 12:49:26Z hweisbach $ */ #ifndef __avr_h__ #define __avr_h__ #include #include "avrpart.h" #include "pgm.h" typedef void (*FP_UpdateProgress)(int percent, double etime, char *hdr); extern struct avrpart parts[]; extern FP_UpdateProgress update_progress; #ifdef __cplusplus extern "C" { #endif int avr_tpi_poll_nvmbsy(PROGRAMMER *pgm); int avr_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p); int avr_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p, unsigned char guard_time); int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, unsigned long addr, unsigned char * value); int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, AVRPART * v); int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, unsigned long addr); int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, unsigned long addr, unsigned char data); int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, unsigned long addr, unsigned char data); int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size, int auto_erase); int avr_signature(PROGRAMMER * pgm, AVRPART * p); int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size); int avr_get_cycle_count(PROGRAMMER * pgm, AVRPART * p, int * cycles); int avr_put_cycle_count(PROGRAMMER * pgm, AVRPART * p, int cycles); int avr_mem_hiaddr(AVRMEM * mem); int avr_chip_erase(PROGRAMMER * pgm, AVRPART * p); void report_progress (int completed, int total, char *hdr); #ifdef __cplusplus } #endif #endif avrdude-6.0.1/avr910.c000644 000153 000000 00000044037 12216240452 013722 0ustar00jwheel000000 000000 /* * 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: avr910.c 1206 2013-09-03 21:43:24Z joerg_wunsch $ */ /* * 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 #include #include "avrdude.h" #include "avr.h" #include "config.h" #include "pgm.h" #include "avr910.h" #include "serial.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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: avr910_recv(): programmer is not responding\n", progname); exit(1); } return 0; } static int avr910_drain(PROGRAMMER * pgm, int display) { return serial_drain(&pgm->fd, display); } static void avr910_vfy_cmd_sent(PROGRAMMER * pgm, char * errmsg) { char c; avr910_recv(pgm, &c, 1); if (c != '\r') { fprintf(stderr, "%s: error: programmer did not respond to command: %s\n", progname, errmsg); exit(1); } } /* * issue the 'chip erase' command to the AVR device */ static int avr910_chip_erase(PROGRAMMER * pgm, AVRPART * p) { avr910_send(pgm, "e", 1); avr910_vfy_cmd_sent(pgm, "chip erase"); /* * avr910 firmware may not delay long enough */ usleep (p->chip_erase_delay); return 0; } static void avr910_enter_prog_mode(PROGRAMMER * pgm) { avr910_send(pgm, "P", 1); avr910_vfy_cmd_sent(pgm, "enter prog mode"); } static void avr910_leave_prog_mode(PROGRAMMER * pgm) { avr910_send(pgm, "L", 1); 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); fprintf(stderr, "Found programmer: Id = \"%s\"; type = %c\n", id, type); fprintf(stderr, " Software Version = %c.%c; ", sw[0], sw[1]); fprintf(stderr, "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') fprintf(stderr, "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; fprintf(stderr, "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); fprintf(stderr, "\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); fprintf(stderr, " 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; }; fprintf(stderr,"\n"); if (!dev_supported) { fprintf(stderr, "%s: %s: selected device is not supported by programmer: %s\n", progname, ovsigck? "warning": "error", p->id); if (!ovsigck) exit(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"); if (verbose) fprintf(stderr, "%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) { fprintf(stderr, "%s: avr910_parseextparms(): invalid devcode '%s'\n", progname, extended_param); rv = -1; continue; } if (verbose >= 2) { fprintf(stderr, "%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) { if (verbose >= 2) { fprintf(stderr, "%s: avr910_parseextparms(-x): no testing for Blockmode\n", progname); } PDATA(pgm)->test_blockmode = 0; continue; } fprintf(stderr, "%s: avr910_parseextparms(): invalid extended parameter '%s'\n", progname, extended_param); rv = -1; } return rv; } static int avr910_open(PROGRAMMER * pgm, char * port) { /* * If baudrate was not specified use 19.200 Baud */ if(pgm->baudrate == 0) { pgm->baudrate = 19200; } strcpy(pgm->port, port); if (serial_open(port, pgm->baudrate, &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) { fprintf(stderr, "%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; } avrdude-6.0.1/avr910.h000644 000153 000000 00000002054 12216240452 013720 0ustar00jwheel000000 000000 /* * 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: avr910.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #ifndef avr910_h #define avr910_h #include "avrpart.h" #ifdef __cplusplus extern "C" { #endif extern const char avr910_desc[]; void avr910_initpgm (PROGRAMMER * pgm); #ifdef __cplusplus } #endif #endif /* avr910_h */ avrdude-6.0.1/avrdude.h000644 000153 000000 00000002774 12216240452 014341 0ustar00jwheel000000 000000 /* * 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: avrdude.h 1203 2013-09-03 20:13:37Z joerg_wunsch $ */ #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) */ #if defined(WIN32NATIVE) #include "ac_cfg.h" #include #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 avrdude-6.0.1/avrftdi.c000644 000153 000000 00000110056 12216240452 014332 0ustar00jwheel000000 000000 /* * 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: avrftdi.c 1204 2013-09-03 20:33:52Z rliebscher $ */ /* * 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 "avr.h" #include "pgm.h" #include "pindefs.h" #include "avrftdi.h" #include "avrpart.h" #include "avrftdi_tpi.h" #include "avrftdi_private.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) { fprintf(stderr, "%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 }; /* This is for running the code without having a FTDI-device. * The generated code is useless! For debugging purposes only. * This should never be defined, unless you know what you are * doing. * If you think you know what you are doing: YOU DONT! */ //#define DRYRUN 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: fprintf(stderr, "E "); break; case WARN: fprintf(stderr, "W "); break; case INFO: fprintf(stderr, "I "); break; case DEBUG: fprintf(stderr, "D "); break; case TRACE: fprintf(stderr, "T "); break; default: fprintf(stderr, " "); } fprintf(stderr, "%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; fprintf(stderr, "%s begin:\n", desc); for (i = 0; i < offset; i++) fprintf(stderr, "%02x ", buf[i]); fprintf(stderr, "\n"); for (i++; i <= len; i++) { fprintf(stderr, "%02x ", buf[i-1]); if((i-offset) != 0 && (i-offset)%width == 0) fprintf(stderr, "\n"); } fprintf(stderr, "%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) { uint32_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); #ifndef DRYRUN E(ftdi_write_data(ftdi->ftdic, buf, 3) < 0, ftdi->ftdic); #endif 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))); //fprintf(stderr,"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; #ifndef DRYRUN E(ftdi_write_data(pdata->ftdic, cmd, sizeof(cmd)) != sizeof(cmd), pdata->ftdic); #endif while(remaining) { size_t transfer_size = (remaining > blocksize) ? blocksize : remaining; #ifndef DRYRUN E(ftdi_write_data(pdata->ftdic, &buf[written], transfer_size) != transfer_size, pdata->ftdic); #endif #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 { #ifndef DRYRUN n = ftdi_read_data(pdata->ftdic, &data[written + k], transfer_size - k); E(n < 0, pdata->ftdic); #else n = transfer_size - k; #endif 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); } #ifdef notyet /* this function tries to sync up with the FTDI. See FTDI application note AN_129. * AN_135 uses 0xab as bad command and enables/disables loopback around synchronisation. * This may fail if data is left in the buffer (i.e. avrdude aborted with ctrl-c) * or the device is in an illegal state (i.e. a previous program). * If the FTDI is out of sync, the buffers are cleared ("purged") and the * sync is re-tried. * if it still fails, we return an error code. higher level code may than abort. * the device may be reset by unplugging the device and plugging it back in. * resetting the device did not always help for me. */ static int ftdi_sync(avrftdi_t* pdata) { unsigned char illegal_cmd[] = {0xaa}; unsigned char reply[2]; unsigned int i, n; unsigned int retry = 0; unsigned char latency; ftdi_get_latency_timer(pdata->ftdic, &latency); fprintf(stderr, "Latency: %d\n", latency); do{ n = ftdi_read_data(pdata->ftdic, reply, 1); } while(n > 0); retry: /* send command "0xaa", which is an illegal command. */ E(ftdi_write_data(pdata->ftdic, illegal_cmd, sizeof(illegal_cmd)) != sizeof(illegal_cmd), pdata->ftdic); i = 0; do { #ifndef DRYRUN n = ftdi_read_data(pdata->ftdic, &reply[i], sizeof(reply) - i); E(n < 0, pdata->ftdic); //fprintf(stderr, "%s\n", ftdi_get_error_string(pdata->ftdic)); #else n = sizeof(reply) - i; #endif i += n; } while (i < sizeof(reply)); /* 0xfa is return code for illegal command - we expect that, since we issued an * illegal command (0xaa) * the next byte will be the illegal command, the FTDI is complaining about. */ if(reply[0] == 0xfa && reply[1] == illegal_cmd[0]) { /* if the FTDI is complaining about the right thing, everything is fine */ fprintf(stderr, "FTDI is in sync.\n"); return 0; } else { fprintf(stderr, "FTDI out of sync. Received 0x%02x 0x%02x\n", reply[0], reply[1]); if(retry < 4) { fprintf(stderr, "Trying to re-sync by purging buffers. Attempt\n"); E(ftdi_usb_purge_buffers(pdata->ftdic), pdata->ftdic); retry++; goto retry; } else fprintf(stderr, "Aborting. Try resetting or unplugging the device.\n"); } return -1; } #endif /* notyet */ 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; #ifndef DRYRUN E(ftdi_write_data(pdata->ftdic, buf, 6) != 6, pdata->ftdic); #endif 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 unkown, when the purge * command actually arrives at the chip. * Use read pin status command as sync. */ #ifndef DRYRUN //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); #endif 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 = 0x0403; if (pgm->usbpid) pid = pgm->usbpid; else pid = 0x6010; 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 occured: %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); #ifdef notyet ret = ftdi_sync(pdata); if(ret < 0) return ret; #endif 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 unkown 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); #ifndef DRYRUN /* reset state recommended by FTDI */ ftdi_set_bitmode(pdata->ftdic, 0, BITMODE_RESET); E_VOID(ftdi_usb_close(pdata->ftdic), pdata->ftdic); #endif } 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"); #ifndef DRYRUN return -1; #else return 0; #endif } 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); #ifndef DRYRUN if (0 > avrftdi_transmit(pgm, MPSSE_DO_WRITE, buf, buf, 4)) return -1; #endif 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); #ifndef DRYRUN pdata->ftdic = ftdi_new(); if(!pdata->ftdic) { log_err("Error allocating memory.\n"); exit(-ENOMEM); } E_VOID(ftdi_init(pdata->ftdic), pdata->ftdic); #endif 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) { #ifndef DRYRUN ftdi_deinit(pdata->ftdic); ftdi_free(pdata->ftdic); #endif 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."; avrdude-6.0.1/avrftdi.h000644 000153 000000 00000002041 12216240452 014331 0ustar00jwheel000000 000000 /* * 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: avrftdi.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #ifndef avrftdi_h #define avrfdti_h #include #ifdef __cplusplus extern "C" { #endif extern const char avrftdi_desc[]; void avrftdi_initpgm (PROGRAMMER * pgm); #ifdef __cplusplus } #endif #endif avrdude-6.0.1/avrftdi_private.h000644 000153 000000 00000006234 12216240452 016073 0ustar00jwheel000000 000000 #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 #include "pgm.h" #include "pindefs.h" 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)) \ { \ fprintf(stderr, "%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)) \ { \ fprintf(stderr, "%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 */ avrdude-6.0.1/avrftdi_tpi.c000644 000153 000000 00000012354 12216240452 015210 0ustar00jwheel000000 000000 #include "ac_cfg.h" #include #include #include #include #include "avr.h" #include "pgm.h" #include "avrpart.h" #include "pindefs.h" #include "tpi.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 */ avrdude-6.0.1/avrftdi_tpi.h000644 000153 000000 00000000554 12216240452 015214 0ustar00jwheel000000 000000 #pragma once #include "pgm.h" #include "avrpart.h" //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); avrdude-6.0.1/avrpart.c000644 000153 000000 00000035425 12216240452 014360 0ustar00jwheel000000 000000 /* * 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: avrpart.c 1161 2013-05-05 13:35:35Z rliebscher $ */ #include #include #include "avrdude.h" #include "avrpart.h" #include "pindefs.h" /*** *** Elementary functions dealing with OPCODE structures ***/ OPCODE * avr_new_opcode(void) { OPCODE * m; m = (OPCODE *)malloc(sizeof(*m)); if (m == NULL) { fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "%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) { fprintf(stderr, "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; } /* * 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); } avrdude-6.0.1/avrpart.h000644 000153 000000 00000024306 12216240452 014361 0ustar00jwheel000000 000000 /* * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2003-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: avrpart.h 1161 2013-05-05 13:35:35Z rliebscher $ */ #ifndef avrpart_h #define avrpart_h #include #include "lists.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 */ 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); 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 #endif /* avrpart_h */ avrdude-6.0.1/bitbang.c000644 000153 000000 00000037731 12216240452 014311 0ustar00jwheel000000 000000 /* * 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: bitbang.c 1196 2013-09-02 20:22:53Z joerg_wunsch $ */ #include "ac_cfg.h" #include #include #include #include #include #include #if !defined(WIN32NATIVE) # include # include #endif #include "avrdude.h" #include "avr.h" #include "pindefs.h" #include "pgm.h" #include "par.h" #include "serbb.h" #include "tpi.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; if (verbose >= 2) fprintf(stderr, "%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. */ if (verbose >= 2) fprintf(stderr, "%s: Using guessed per-microsecond delay count for bitbang delays\n", progname); delay_decrement = 100; } #else /* !WIN32NATIVE */ struct itimerval itv; volatile int i; if (verbose >= 2) fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, " 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(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 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, pgm->pinno[PIN_AVR_MOSI], b); pgm->setpin(pgm, pgm->pinno[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, pgm->pinno[PIN_AVR_MISO]); pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0); rbyte |= r << i; } return rbyte; } static int bitbang_tpi_clk(PROGRAMMER * pgm) { unsigned char r = 0; pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 1); r = pgm->getpin(pgm, pgm->pinno[PIN_AVR_MISO]); pgm->setpin(pgm, pgm->pinno[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, pgm->pinno[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, pgm->pinno[PIN_AVR_MOSI], b); bitbang_tpi_clk(pgm); } /* parity bit */ pgm->setpin(pgm, pgm->pinno[PIN_AVR_MOSI], parity); bitbang_tpi_clk(pgm); /* 2 stop bits */ pgm->setpin(pgm, pgm->pinno[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, pgm->pinno[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) { fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "bitbang_tpi_rx: stop bits not received correctly\n"); return -1; } return rbyte; } int bitbang_rdy_led(PROGRAMMER * pgm, int value) { pgm->setpin(pgm, pgm->pinno[PIN_LED_RDY], !value); return 0; } int bitbang_err_led(PROGRAMMER * pgm, int value) { pgm->setpin(pgm, pgm->pinno[PIN_LED_ERR], !value); return 0; } int bitbang_pgm_led(PROGRAMMER * pgm, int value) { pgm->setpin(pgm, pgm->pinno[PIN_LED_PGM], !value); return 0; } int bitbang_vfy_led(PROGRAMMER * pgm, int value) { pgm->setpin(pgm, pgm->pinno[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) { fprintf(stderr, "bitbang_cmd(): [ "); for(i = 0; i < 4; i++) fprintf(stderr, "%02X ", cmd[i]); fprintf(stderr, "] [ "); for(i = 0; i < 4; i++) { fprintf(stderr, "%02X ", res[i]); } fprintf(stderr, "]\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) { fprintf(stderr, "bitbang_cmd_tpi(): [ "); for(i = 0; i < cmd_len; i++) fprintf(stderr, "%02X ", cmd[i]); fprintf(stderr, "] [ "); for(i = 0; i < res_len; i++) { fprintf(stderr, "%02X ", res[i]); } fprintf(stderr, "]\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, pgm->pinno[PIN_LED_PGM], 0); for (i=0; isetpin(pgm, pgm->pinno[PIN_LED_PGM], 1); if(verbose >= 2) { fprintf(stderr, "bitbang_cmd(): [ "); for(i = 0; i < count; i++) fprintf(stderr, "%02X ", cmd[i]); fprintf(stderr, "] [ "); for(i = 0; i < count; i++) { fprintf(stderr, "%02X ", res[i]); } fprintf(stderr, "]\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) { fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "%s: Error: %s programmer does not support TPI\n", progname, pgm->type); return -1; } /* bring RESET high first */ pgm->setpin(pgm, pgm->pinno[PIN_AVR_RESET], 1); usleep(1000); if (verbose >= 2) fprintf(stderr, "doing MOSI-MISO link check\n"); pgm->setpin(pgm, pgm->pinno[PIN_AVR_MOSI], 0); if (pgm->getpin(pgm, pgm->pinno[PIN_AVR_MISO]) != 0) { fprintf(stderr, "MOSI->MISO 0 failed\n"); return -1; } pgm->setpin(pgm, pgm->pinno[PIN_AVR_MOSI], 1); if (pgm->getpin(pgm, pgm->pinno[PIN_AVR_MISO]) != 1) { fprintf(stderr, "MOSI->MISO 1 failed\n"); return -1; } if (verbose >= 2) fprintf(stderr, "MOSI-MISO link present\n"); } pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0); pgm->setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0); usleep(20000); if (p->flags & AVRPART_HAS_TPI) { /* keep TPIDATA high for 16 clock cycles */ pgm->setpin(pgm, pgm->pinno[PIN_AVR_MOSI], 1); for (i = 0; i < 16; i++) pgm->highpulsepin(pgm, pgm->pinno[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) { fprintf(stderr, "TPIIR not correct\n"); return -1; } } else { pgm->highpulsepin(pgm, pgm->pinno[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, pgm->pinno[p->retry_pulse/*PIN_AVR_SCK*/]); tries++; } while (tries < 65); /* * can't sync with the device, maybe it's not attached? */ if (rc) { fprintf(stderr, "%s: AVR device not responding\n", progname); return -1; } } return 0; } static void verify_pin_assigned(PROGRAMMER * pgm, int pin, char * desc) { if (pgm->pinno[pin] == 0) { fprintf(stderr, "%s: error: no pin has been assigned for %s\n", progname, desc); exit(1); } } /* * Verify all prerequisites for a bit-bang programmer are present. */ void bitbang_check_prerequisites(PROGRAMMER *pgm) { verify_pin_assigned(pgm, PIN_AVR_RESET, "AVR RESET"); verify_pin_assigned(pgm, PIN_AVR_SCK, "AVR SCK"); verify_pin_assigned(pgm, PIN_AVR_MISO, "AVR MISO"); verify_pin_assigned(pgm, PIN_AVR_MOSI, "AVR MOSI"); if (pgm->cmd == NULL) { fprintf(stderr, "%s: error: no cmd() method defined for bitbang programmer\n", progname); exit(1); } } avrdude-6.0.1/bitbang.h000644 000153 000000 00000004422 12216240452 014305 0ustar00jwheel000000 000000 /* * 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: bitbang.h 1196 2013-09-02 20:22:53Z joerg_wunsch $ */ #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); void 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 avrdude-6.0.1/buspirate.c000644 000153 000000 00000104315 12216240452 014672 0ustar00jwheel000000 000000 /* * 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: buspirate.c 1196 2013-09-02 20:22:53Z joerg_wunsch $ */ #include "ac_cfg.h" #include #include #include #include #if defined(WIN32NATIVE) # include /* for alloca() */ #endif #include "avrdude.h" #include "avr.h" #include "pgm.h" #include "serial.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(char *buf, size_t len) { size_t i; for (i = 0; i 1) { fprintf(stderr, "%s: buspirate_send_bin():\n", progname); dump_mem(data, len); } rc = serial_send(&pgm->fd, (unsigned char *)data, len); return rc; } static int buspirate_recv_bin(struct programmer_t *pgm, char *buf, size_t len) { int rc; rc = serial_recv(&pgm->fd, (unsigned char *)buf, len); if (rc < 0) return EOF; if (verbose > 1) { fprintf(stderr, "%s: buspirate_recv_bin():\n", progname); dump_mem(buf, len); } return len; } static int buspirate_expect_bin(struct programmer_t *pgm, char *send_data, size_t send_len, char *expect_data, size_t expect_len) { char *recv_buf = alloca(expect_len); if (!pgm->flag & BP_FLAG_IN_BINMODE) { fprintf(stderr, "BusPirate: Internal error: buspirate_send_bin() called from ascii mode"); exit(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, char send_byte, 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) { fprintf(stderr, "BusPirate: Internal error: buspirate_getc() called from binmode"); exit(1); } 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; if (verbose) fprintf(stderr, "%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) { fprintf(stderr, "%s: buspirate_readline(): programmer is not responding\n", progname); exit(1); } return ret; } static int buspirate_send(struct programmer_t *pgm, char *str) { int rc; if (verbose) fprintf(stderr, "%s: buspirate_send(): %s", progname, str); if (pgm->flag & BP_FLAG_IN_BINMODE) { fprintf(stderr, "BusPirate: Internal error: buspirate_send() called from binmode"); exit(1); } rc = serial_send(&pgm->fd, (unsigned char *)str, strlen(str)); if (rc) return rc; while (strcmp(buspirate_readline(pgm, NULL, 0), str) != 0) /* keep reading until we get what we sent there */ ; /* by now we should be in sync */ return 0; } static int buspirate_is_prompt(char *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 (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() */ int spifreq; 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=%d", &spifreq) == 1) { if (spifreq & (~0x07)) { fprintf(stderr, "BusPirate: spifreq must be between 0 and 7.\n"); fprintf(stderr, "BusPirate: see BusPirate manual for details.\n"); return -1; } pgm->flag = (pgm->flag & ~BP_FLAG_XPARM_RAWFREQ) | BP_FLAG_XPARM_SPIFREQ; PDATA(pgm)->spifreq = spifreq; continue; } unsigned rawfreq; if (sscanf(extended_param, "rawfreq=%u", &rawfreq) == 1) { if (rawfreq >= 4) { fprintf(stderr, "BusPirate: rawfreq must be " "between 0 and 3.\n"); return -1; } pgm->flag = (pgm->flag & ~BP_FLAG_XPARM_SPIFREQ) | BP_FLAG_XPARM_RAWFREQ; PDATA(pgm)->spifreq = rawfreq; continue; } if (sscanf(extended_param, "cpufreq=%d", &cpufreq) == 1) { /* lower limit comes from 'cpufreq > 4 * spifreq', spifreq in ascii mode is 30kHz. */ if (cpufreq < 125 || cpufreq > 4000) { fprintf(stderr, "BusPirate: cpufreq must be between 125 and 4000 kHz.\n"); fprintf(stderr, "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=%s", 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 { fprintf(stderr, "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) { fprintf(stderr, "BusPirate: serial_recv_timeout must be greater 0.\n"); return -1; } PDATA(pgm)->serial_recv_timeout = serial_recv_timeout; continue; } } 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)) { fprintf(stderr, "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)) { fprintf(stderr, "BusPirate: SPI speed selection is not supported in ASCII mode\n"); return -1; } if ((pgm->flag & BP_FLAG_XPARM_CPUFREQ) && !buspirate_uses_ascii(pgm)) { fprintf(stderr, "BusPirate: Setting cpufreq is only supported in ASCII mode\n"); return -1; } return 0; } /* ====== Programmer methods ======= */ static int buspirate_open(struct programmer_t *pgm, char * port) { /* BusPirate runs at 115200 by default */ if(pgm->baudrate == 0) pgm->baudrate = 115200; strcpy(pgm->port, port); if (serial_open(port, pgm->baudrate, &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) { char buf[10]; buf[0] = 0x00; /* BinMode: revert to HiZ */ buspirate_send_bin(pgm, buf, 1); 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(buf)) { pgm->flag &= ~BP_FLAG_IN_BINMODE; break; } if (rc == EOF) break; memset(buf, '\0', sizeof(buf)); } if (pgm->flag & BP_FLAG_IN_BINMODE) { fprintf(stderr, "BusPirate reset failed. You may need to powercycle it.\n"); exit(1); } if (verbose) fprintf(stderr, "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%d", .config = 0x8C, }; pgm->flag |= BP_FLAG_NOPAGEDWRITE; pgm->flag |= BP_FLAG_NOPAGEDREAD; } else { submode = &(const struct submode){ .name = "SPI", .enter = 0x01, .entered_format = "SPI%d", /* 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, }; } char buf[20] = { '\0' }; unsigned int ver = 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(buf, "BBIO%d", &PDATA(pgm)->binmode_version) != 1) { fprintf(stderr, "Binary mode not confirmed: '%s'\n", buf); buspirate_reset_from_binmode(pgm); return -1; } if (verbose) fprintf(stderr, "BusPirate binmode version: %d\n", PDATA(pgm)->binmode_version); pgm->flag |= BP_FLAG_IN_BINMODE; /* == 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(buf, submode->entered_format, &PDATA(pgm)->submode_version) != 1) { fprintf(stderr, "%s mode not confirmed: '%s'\n", submode->name, buf); buspirate_reset_from_binmode(pgm); return -1; } if (verbose) fprintf(stderr, "BusPirate %s version: %d\n", submode->name, PDATA(pgm)->submode_version); if (pgm->flag & BP_FLAG_NOPAGEDWRITE) { if (verbose) fprintf(stderr, "%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: */ strncpy(buf, "\x5\x0\x0\x0\x0", 5); buspirate_send_bin(pgm, buf, 5); 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); if (verbose) fprintf(stderr, "%s: Disabling paged flash write. (Need BusPirate firmware >=v5.10.)\n", progname); /* Flush serial buffer: */ serial_drain(&pgm->fd, 0); } else { if (verbose) fprintf(stderr, "%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; buspirate_expect_bin_byte(pgm, PDATA(pgm)->current_peripherals_config, 0x01); usleep(50000); // sleep for 50ms after power up /* 01100xxx - Set speed */ buspirate_expect_bin_byte(pgm, 0x60 | PDATA(pgm)->spifreq, 0x01); /* Submode config */ buspirate_expect_bin_byte(pgm, submode->config, 0x01); /* AVR Extended Commands - test for existence */ if (pgm->flag & BP_FLAG_NOPAGEDREAD) { if (verbose) fprintf(stderr, "%s: Paged flash read disabled.\n", progname); pgm->paged_load = NULL; } else { if (buspirate_expect_bin_byte(pgm, 0x06, 0x01)) { strncpy(buf, "\x1\x0\x0", 3); buspirate_send_bin(pgm, buf, 1); buspirate_recv_bin(pgm, buf, 3); ver = buf[1] << 8 | buf[2]; if (verbose) fprintf(stderr, "AVR Extended Commands version %d\n", ver); } else { if (verbose) fprintf(stderr, "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, mode[11], buf[5]; buspirate_send(pgm, "m\n"); while(1) { rcvd = buspirate_readline(pgm, NULL, 0); if (spi_cmd == -1 && sscanf(rcvd, "%d. %10s", &cmd, mode)) { if (strcmp(mode, "SPI") == 0) spi_cmd = cmd; } if (buspirate_is_prompt(rcvd)) break; } if (spi_cmd == -1) { fprintf(stderr, "%s: SPI mode number not found. Does your BusPirate support SPI?\n", progname); fprintf(stderr, "%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 (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, " %d.", &cmd); snprintf(buf, sizeof(buf), "%d\n", cmd); } if (buspirate_is_prompt(rcvd)) { if (strncmp(rcvd, "SPI>", 4) == 0) { if (verbose) fprintf(stderr, "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) { unsigned char *reset_str = "#\n"; unsigned char *accept_str = "y\n"; char *rcvd; int rc, print_banner = 0; /* Ensure configuration is self-consistant: */ if (buspirate_verifyconfig(pgm)<0) exit(1); /* Attempt to start binary SPI mode unless explicitly told otherwise: */ if (!buspirate_uses_ascii(pgm)) { fprintf(stderr, "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, "\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 fprintf(stderr, "%s: Failed to start binary mode, falling back to ASCII...\n", progname); } fprintf(stderr, "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, reset_str, strlen(reset_str)); if (rc) { fprintf(stderr, "BusPirate is not responding. Serial port error: %d\n", rc); exit(1); } while(1) { rcvd = buspirate_readline_noexit(pgm, NULL, 0); if (! rcvd) { fprintf(stderr, "%s: Fatal: Programmer is not responding.\n", progname); exit(1); } if (strncmp(rcvd, "Are you sure?", 13) == 0) { buspirate_send_bin(pgm, accept_str, strlen(accept_str)); } if (strncmp(rcvd, "RESET", 5) == 0) { print_banner = 1; continue; } if (buspirate_is_prompt(rcvd)) { puts("**"); break; } if (print_banner) fprintf(stderr, "** %s", rcvd); } if (!(pgm->flag & BP_FLAG_IN_BINMODE)) { fprintf(stderr, "BusPirate: using ASCII mode\n"); if (buspirate_start_spi_mode_ascii(pgm) < 0) { fprintf(stderr, "%s: Failed to start ascii SPI mode\n", progname); exit(1); } } } 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) { fprintf(stderr, "%s: warning: did not get a response to start PWM command.\n", progname); } } return; } } fprintf(stderr, "%s: warning: did not get a response to PowerUp command.\n", progname); fprintf(stderr, "%s: warning: Trying to continue anyway...\n", progname); } static void buspirate_powerdown(struct programmer_t *pgm) { if (pgm->flag & BP_FLAG_IN_BINMODE) { /* 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, 0x01)) return; } else { if (pgm->flag & BP_FLAG_XPARM_CPUFREQ) { if (!buspirate_expect(pgm, "g\n", "PWM disabled", 1)) { fprintf(stderr, "%s: warning: did not get a response to stop PWM command.\n", progname); } } if (buspirate_expect(pgm, "w\n", "Power supplies OFF", 1)) return; } fprintf(stderr, "%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 */ if (!buspirate_expect_bin_byte(pgm, 0x13, 0x01)) return -1; buspirate_send_bin(pgm, (char *)cmd, 4); buspirate_recv_bin(pgm, (char *)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); /* WRITE: 0xAC READ: 0x04 */ if (sscanf(rcvd, "WRITE: 0x%x READ: 0x%x", &spi_write, &spi_read) == 2) { res[i++] = spi_read; } if (buspirate_is_prompt(rcvd)) break; } if (i != 4) { fprintf(stderr, "%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; if (verbose > 1) fprintf(stderr, "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) { fprintf(stderr, "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 strncpy(commandbuf, "\x6\x2", 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) { fprintf(stderr, "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; char cmd_buf[4096] = {'\0'}; 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) { fprintf(stderr, "%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) { fprintf(stderr, "%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)) { fprintf(stderr, "BusPirate: Fatal error: Write Then Read did not succeed.\n"); pgm->pgm_led(pgm, OFF); pgm->err_led(pgm, ON); exit(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; buspirate_expect_bin_byte(pgm, PDATA(pgm)->current_peripherals_config, 0x01); } else buspirate_expect(pgm, "{\n", "CS ENABLED", 1); if (p->op[AVR_OP_PGM_ENABLE] == NULL) { fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "%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) { char buf[20] = { '\0' }; bitbang_check_prerequisites(pgm); fprintf(stderr, "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, "\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(buf, "BBIO%d", &PDATA(pgm)->binmode_version) != 1) { fprintf(stderr, "Binary mode not confirmed: '%s'\n", buf); buspirate_reset_from_binmode(pgm); exit(1); } fprintf(stderr, "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 pin) { unsigned char buf[10]; int value = 0; 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; if (verbose > 1) printf("get pin %d = %d\n", pin, value); return value; } static int buspirate_bb_setpin(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; if (verbose > 1) printf("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_highpulsepin(struct programmer_t *pgm, int pin) { int ret; ret = buspirate_bb_setpin(pgm, pin, 1); if (ret < 0) return ret; return buspirate_bb_setpin(pgm, pin, 0); } static void buspirate_bb_powerup(struct programmer_t *pgm) { buspirate_bb_setpin(pgm, 7, 1); } static void buspirate_bb_powerdown(struct programmer_t *pgm) { buspirate_bb_setpin(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; } avrdude-6.0.1/buspirate.h000644 000153 000000 00000002166 12216240452 014700 0ustar00jwheel000000 000000 /* * 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: buspirate.h 1138 2013-01-30 21:15:39Z rliebscher $ */ #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 avrdude-6.0.1/butterfly.c000644 000153 000000 00000043167 12216240452 014723 0ustar00jwheel000000 000000 /* * 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: butterfly.c 1227 2013-09-13 19:37:54Z joerg_wunsch $ */ /* * 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 "avr.h" #include "pgm.h" #include "butterfly.h" #include "serial.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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: butterfly_recv(): programmer is not responding\n", progname); exit(1); } return 0; } static int butterfly_drain(PROGRAMMER * pgm, int display) { return serial_drain(&pgm->fd, display); } static void butterfly_vfy_cmd_sent(PROGRAMMER * pgm, char * errmsg) { char c; butterfly_recv(pgm, &c, 1); if (c != '\r') { fprintf(stderr, "%s: error: programmer did not respond to command: %s\n", progname, errmsg); exit(1); } } 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); butterfly_vfy_cmd_sent(pgm, "chip erase"); 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. */ fprintf(stderr, "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 != '?') { fprintf(stderr, "\nConnection FAILED."); exit(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); fprintf(stderr, "Found programmer: Id = \"%s\"; type = %c\n", id, type); fprintf(stderr, " Software Version = %c.%c; ", sw[0], sw[1]); if (hw[0]=='?') { fprintf(stderr, "No Hardware Version given.\n"); } else { fprintf(stderr, "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') fprintf(stderr, "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') { fprintf(stderr, "%s: error: buffered memory access not supported. Maybe it isn't\n"\ "a butterfly/AVR109 but a AVR910 device?\n", progname); exit(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; fprintf(stderr, "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); fprintf(stderr, "\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; fprintf(stderr, " Device code: 0x%02x\n", (unsigned int)(unsigned char)c); }; fprintf(stderr,"\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); butterfly_vfy_cmd_sent(pgm, "select device"); if (verbose) fprintf(stderr, "%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) { strcpy(pgm->port, port); /* * If baudrate was not specified use 19200 Baud */ if(pgm->baudrate == 0) { pgm->baudrate = 19200; } if (serial_open(port, pgm->baudrate, &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); butterfly_vfy_cmd_sent(pgm, "write byte"); 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 */ fprintf(stderr, "%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); butterfly_vfy_cmd_sent(pgm, "clear LED"); #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); butterfly_vfy_cmd_sent(pgm, "write block"); 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) { fprintf(stderr, "%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; } avrdude-6.0.1/butterfly.h000644 000153 000000 00000002175 12216240452 014722 0ustar00jwheel000000 000000 /* * 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: butterfly.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #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 */ avrdude-6.0.1/config.c000644 000153 000000 00000012767 12216240452 014152 0ustar00jwheel000000 000000 /* * 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: config.c 1226 2013-09-13 17:22:38Z joerg_wunsch $ */ #include "ac_cfg.h" #include #include #include #include #include #include "avrdude.h" #include "avr.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) { fprintf(stderr, "%s: %s at %s:%d\n", progname, errmsg, infile, lineno); exit(1); } TOKEN * new_token(int primary) { TOKEN * tkn; tkn = (TOKEN *)malloc(sizeof(TOKEN)); if (tkn == NULL) { fprintf(stderr, "new_token(): out of memory\n"); exit(1); } 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); tkn->value.type = V_NUM; tkn->value.number = atoi(text); #if DEBUG fprintf(stderr, "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 fprintf(stderr, "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); tkn->value.type = V_NUM; tkn->value.number = strtoul(text, &e, 16); if ((e == text) || (*e != 0)) { fprintf(stderr, "error at %s:%d: can't scan hex number \"%s\"\n", infile, lineno, text); exit(1); } #if DEBUG fprintf(stderr, "HEXNUMBER(%g)\n", tkn->value.number); #endif return tkn; } TOKEN * string(char * text) { struct token_t * tkn; int len; tkn = new_token(TKN_STRING); len = strlen(text); tkn->value.type = V_STR; tkn->value.string = (char *) malloc(len+1); if (tkn->value.string == NULL) { fprintf(stderr, "id(): out of memory\n"); exit(1); } strcpy(tkn->value.string, text); #if DEBUG fprintf(stderr, "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; fprintf(stderr, "token = %d = ", tkn->primary); switch (tkn->value.type) { case V_NUM: fprintf(stderr, "NUMBER, value=%d", tkn->value.number); break; case V_NUM_REAL: fprintf(stderr, "NUMBER, value=%g", tkn->value.number_real); break; case V_STR: fprintf(stderr, "STRING, value=%s", tkn->value.string); break; default: fprintf(stderr, ""); break; } fprintf(stderr, "\n"); } void pyytext(void) { #if DEBUG fprintf(stderr, "TOKEN: \"%s\"\n", yytext); #endif } char * dup_string(const char * str) { char * s; s = strdup(str); if (s == NULL) { fprintf(stderr, "dup_string(): out of memory\n"); exit(1); } 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; f = fopen(file, "r"); if (f == NULL) { fprintf(stderr, "%s: can't open config file \"%s\": %s\n", progname, file, strerror(errno)); return -1; } lineno = 1; infile = file; yyin = f; yyparse(); #ifdef HAVE_YYLEX_DESTROY /* reset lexer and free any allocated memory */ yylex_destroy(); #endif fclose(f); return 0; } avrdude-6.0.1/config.h000644 000153 000000 00000005053 12216240452 014145 0ustar00jwheel000000 000000 /* * 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: config.h 1226 2013-09-13 17:22:38Z joerg_wunsch $ */ #ifndef config_h #define config_h #include "lists.h" #include "pindefs.h" #include "avr.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; extern LISTID part_list; extern LISTID programmers; extern char default_programmer[]; extern char default_parallel[]; extern char default_serial[]; extern double default_bitclock; extern int default_safemode; /* This name is fixed, it's only here for symmetry with * default_parallel and default_serial. */ #define DEFAULT_USB "usb" #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 init_config(void); void cleanup_config(void); 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); int read_config(const char * file); #ifdef __cplusplus } #endif #endif avrdude-6.0.1/confwin.c000644 000153 000000 00000002615 12216240452 014337 0ustar00jwheel000000 000000 /* * 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" #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 avrdude-6.0.1/confwin.h000644 000153 000000 00000002017 12216240452 014340 0ustar00jwheel000000 000000 /* * 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 . */ #if defined(WIN32NATIVE) #ifndef confwin_h #define confwin_h #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 #endif avrdude-6.0.1/crc16.c000644 000153 000000 00000006323 12216240452 013612 0ustar00jwheel000000 000000 /* * 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); } avrdude-6.0.1/crc16.h000644 000153 000000 00000001361 12216240452 013614 0ustar00jwheel000000 000000 #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 avrdude-6.0.1/fileio.c000644 000153 000000 00000117703 12216240452 014150 0ustar00jwheel000000 000000 /* * 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: fileio.c 1216 2013-09-11 09:21:37Z joerg_wunsch $ */ #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 "avr.h" #include "fileio.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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: invalid record at line %d of \"%s\"\n", progname, lineno, infile); return -1; } else if (rc != ihex.cksum) { fprintf(stderr, "%s: ERROR: checksum mismatch at line %d of \"%s\"\n", progname, lineno, infile); fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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: fprintf(stderr, "%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) { fprintf(stderr, "%s: ERROR: No valid record found in Intel Hex " "file \"%s\"\n", progname, infile); return -1; } else { fprintf(stderr, "%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) { fprintf(stderr, "%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 { fprintf(stderr, "%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) { fprintf(stderr, "%s: ERROR: invalid record at line %d of \"%s\"\n", progname, lineno, infile); return -1; } else if (rc != srec.cksum) { fprintf(stderr, "%s: ERROR: checksum mismatch at line %d of \"%s\"\n", progname, lineno, infile); fprintf(stderr, "%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) */ fprintf(stderr, "%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){ fprintf(stderr, "%s: ERROR: count of transmitted data records mismatch " "at line %d of \"%s\"\n", progname, lineno, infile); fprintf(stderr, "%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: fprintf(stderr, "%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) { fprintf(stderr, msg, progname, nextaddr, "(below fileoffset) ", lineno, infile); return -1; } nextaddr -= fileoffset; if (nextaddr + srec.reclen > bufsize) { fprintf(stderr, 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++; } } fprintf(stderr, "%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) { fprintf(stderr, "%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; } } fprintf(stderr, "%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 (strcmp(mem->desc, "lock") == 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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: ERROR: Error reading ehdr of \"%s\": %s\n", progname, infile, elf_errmsg(-1)); goto done; } if (eh->e_type != ET_EXEC) { fprintf(stderr, "%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) { fprintf(stderr, "%s: ERROR: ELF file \"%s\" is not for machine %s\n", progname, infile, mname); goto done; } if (eh->e_phnum == 0xffff /* PN_XNUM */) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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; if (verbose >= 2) { fprintf(stderr, "%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; if (verbose >= 2) { fprintf(stderr, "%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 { if (verbose >= 2) { fprintf(stderr, " => 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) { fprintf(stderr, "%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) { if (verbose >= 2) { fprintf(stderr, " 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) { fprintf(stderr, "%s: ERROR: unexpected data block at offset != 0\n", progname); } else if (foff >= d->d_size) { fprintf(stderr, "%s: ERROR: ELF file section does not contain byte at offset %d\n", progname, foff); } else { if (verbose >= 2) { fprintf(stderr, " 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; if (verbose >= 3) { fprintf(stderr, " 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: fprintf(stderr, "%s: fileio: invalid operation=%d\n", progname, fio->op); return -1; } if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) { fprintf(stderr, "%s: %s error %s %s: %s; %s %d of the expected %d bytes\n", progname, fio->iodesc, fio->dir, filename, strerror(errno), fio->rw, rc, size); return -1; } return rc; } 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) { fprintf(stderr, "%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: fprintf(stderr, "%s: fileio: invalid operation=%d\n", progname, fio->op); return -1; } if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) { fprintf(stderr, "%s: %s error %s %s: %s; %s %d of the expected %d bytes\n", progname, fio->iodesc, fio->dir, filename, strerror(errno), fio->rw, rc, size); return -1; } return rc; } 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: fprintf(stderr, "%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: fprintf(stderr, "%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: fprintf(stderr, "%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: fprintf(stderr, "%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: fprintf(stderr, "%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: fprintf(stderr, "%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: fprintf(stderr, "%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; f = fopen(fname, "r"); if (f == NULL) { fprintf(stderr, "%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) { if (using_stdio) { fprintf(stderr, "%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 = fmt_autodetect(fname); if (format < 0) { fprintf(stderr, "%s: can't determine file format for %s, specify explicitly\n", progname, fname); return -1; } if (quell_progress < 2) { fprintf(stderr, "%s: %s file %s auto detected as %s\n", progname, fio.iodesc, fname, fmtstr(format)); } } #if defined(WIN32NATIVE) /* Open Raw Binary format in binary mode on Windows.*/ if(format == FMT_RBIN) { 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) { fprintf(stderr, "%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 fprintf(stderr, "%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: fprintf(stderr, "%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; } avrdude-6.0.1/fileio.h000644 000153 000000 00000002556 12216240452 014154 0ustar00jwheel000000 000000 /* * 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: fileio.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #ifndef fileio_h #define fileio_h typedef enum { FMT_AUTO, FMT_SREC, FMT_IHEX, FMT_RBIN, FMT_IMM, FMT_HEX, FMT_DEC, FMT_OCT, FMT_BIN, FMT_ELF } FILEFMT; struct fioparms { int op; char * mode; char * iodesc; char * dir; char * rw; unsigned int fileoffset; }; enum { FIO_READ, FIO_WRITE }; #ifdef __cplusplus extern "C" { #endif char * fmtstr(FILEFMT format); int fileio(int op, char * filename, FILEFMT format, struct avrpart * p, char * memtype, int size); #ifdef __cplusplus } #endif #endif avrdude-6.0.1/freebsd_ppi.h000644 000153 000000 00000002354 12216240452 015163 0ustar00jwheel000000 000000 /* * 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: freebsd_ppi.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #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 */ avrdude-6.0.1/ft245r.c000644 000153 000000 00000065262 12216240452 013731 0ustar00jwheel000000 000000 /* * 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 "avr.h" #include "avrpart.h" #include "pindefs.h" #include "pgm.h" #include "config.h" #include "bitbang.h" #include "ft245r.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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf (stderr, "buffer overflow. Cannot happen!\n"); //exit (1); } buffer[head] = c; head = nh; sem_post (&buf_data); } static void *reader (void *arg) { 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) { fprintf(stderr, "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 ((verbose>1) || FT245R_DEBUG) { fprintf(stderr," ft245r: spi bitclk %d -> ft baudrate %d\n", rate / 2, rate); } r = ftdi_set_baudrate(handle, rate); if (r) { fprintf(stderr, "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_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) { fprintf(stderr, "%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 ((verbose>=1) || FT245R_DEBUG) { fprintf(stderr, "%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; } } fprintf(stderr, "%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) { ft245r_powerup(pgm); set_reset(pgm, OFF); usleep(5000); // 5ms set_reset(pgm, ON); usleep(5000); // 5ms set_reset(pgm, OFF); usleep(5000); // 5ms 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) { fprintf(stderr, "%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); rv = ftdi_usb_open_desc_index(handle, pgm->usbvid?pgm->usbvid:0x0403, pgm->usbpid?pgm->usbpid:0x6001, pgm->usbproduct[0]?pgm->usbproduct:NULL, pgm->usbsn[0]?pgm->usbsn:NULL, devnum); if (rv) { fprintf (stderr, "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) { fprintf(stderr, "%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 pthread_cancel(readerthread); pthread_join(readerthread, NULL); ftdi_usb_close(handle); ftdi_deinit (handle); // TODO this works with libftdi 0.20, but hangs with 1.0 free(handle); handle = NULL; } } static void ft245r_display(PROGRAMMER * pgm, const char * p) { fprintf(stderr, "%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) { fprintf(stderr, "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 fprintf(stderr, "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"; avrdude-6.0.1/ft245r.h000644 000153 000000 00000000226 12216240452 013723 0ustar00jwheel000000 000000 #ifndef ft245r_h #define ft245r_h #include "pgm.h" extern const char ft245r_desc[]; void ft245r_initpgm (PROGRAMMER * pgm); #endif /* ft245r_h */ avrdude-6.0.1/jtagmkI.c000644 000153 000000 00000105750 12216240452 014266 0ustar00jwheel000000 000000 /* * 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: jtagmkI.c 1131 2013-01-08 21:02:01Z joerg_wunsch $ */ /* * avrdude interface for Atmel JTAG ICE (mkI) programmer */ #include "ac_cfg.h" #include #include #include #include #include #include #include #include "avrdude.h" #include "avr.h" #include "crc16.h" #include "pgm.h" #include "jtagmkI.h" #include "jtagmkI_private.h" #include "serial.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) { fprintf(stderr, "%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) { fprintf(stderr, "Raw message:\n"); for (i = 0; i < len; i++) { fprintf(stderr, "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: fprintf(stderr, "OK\n"); break; case RESP_FAILED: fprintf(stderr, "FAILED\n"); break; case RESP_BREAK: fprintf(stderr, "breakpoint hit\n"); break; case RESP_INFO: fprintf(stderr, "IDR dirty\n"); break; case RESP_SYNC_ERROR: fprintf(stderr, "Synchronization lost\n"); break; case RESP_SLEEP: fprintf(stderr, "sleep instruction hit\n"); break; case RESP_POWER: fprintf(stderr, "target power lost\n"); default: fprintf(stderr, "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; if (verbose >= 3) fprintf(stderr, "\n%s: jtagmkI_send(): sending %u bytes\n", progname, (unsigned int)len); if ((buf = malloc(len + 2)) == NULL) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkI_send(): failed to send command to serial port\n", progname); exit(1); } free(buf); return 0; } static void jtagmkI_recv(PROGRAMMER * pgm, unsigned char * buf, size_t len) { if (serial_recv(&pgm->fd, buf, len) != 0) { fprintf(stderr, "\n%s: jtagmkI_recv(): failed to send command to serial port\n", progname); exit(1); } if (verbose >= 3) { putc('\n', stderr); jtagmkI_prmsg(pgm, buf, len); } } 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; if (verbose >= 3) fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_resync(): Sending sync command: ", progname); if (serial_send(&pgm->fd, buf, 1) != 0) { fprintf(stderr, "\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) { if (verbose >= 2) fprintf(stderr, "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] = ' '; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_resync(): Sending sign-on command: ", progname); if (serial_send(&pgm->fd, buf, 4) != 0) { fprintf(stderr, "\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) { if (verbose >= 2) fprintf(stderr, "got RESP_OK\n"); break; } } } if (tries >= maxtries) { if (verbose >= 2) fprintf(stderr, "%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); if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_getsync(): Sending sign-on command: ", progname); buf[0] = CMD_GET_SIGNON; jtagmkI_send(pgm, buf, 1); jtagmkI_recv(pgm, resp, 9); if (verbose >= 2) { resp[8] = '\0'; fprintf(stderr, "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; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_chip_erase(): Sending chip erase command: ", progname); jtagmkI_send(pgm, buf, 1); jtagmkI_recv(pgm, resp, 2); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%s: jtagmkI_chip_erase(): " "timeout/error communicating with programmer (resp %c)\n", progname, resp[0]); return -1; } else { if (verbose == 2) fprintf(stderr, "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; } } if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_set_devdescr(): " "Sending set device descriptor command: ", progname); jtagmkI_send(pgm, (unsigned char *)&sendbuf, sizeof(sendbuf)); jtagmkI_recv(pgm, resp, 2); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%s: jtagmkI_set_devdescr(): " "timeout/error communicating with programmer (resp %c)\n", progname, resp[0]); } else { if (verbose == 2) fprintf(stderr, "OK\n"); } } /* * Reset the target. */ static int jtagmkI_reset(PROGRAMMER * pgm) { unsigned char buf[1], resp[2]; buf[0] = CMD_RESET; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_reset(): Sending reset command: ", progname); jtagmkI_send(pgm, buf, 1); jtagmkI_recv(pgm, resp, 2); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%s: jtagmkI_reset(): " "timeout/error communicating with programmer (resp %c)\n", progname, resp[0]); return -1; } else { if (verbose == 2) fprintf(stderr, "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; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_program_enable(): " "Sending enter progmode command: ", progname); jtagmkI_send(pgm, buf, 1); jtagmkI_recv(pgm, resp, 2); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%s: jtagmkI_program_enable(): " "timeout/error communicating with programmer (resp %c)\n", progname, resp[0]); return -1; } else { if (verbose == 2) fprintf(stderr, "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; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_program_disable(): " "Sending leave progmode command: ", progname); jtagmkI_send(pgm, buf, 1); jtagmkI_recv(pgm, resp, 2); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%s: jtagmkI_program_disable(): " "timeout/error communicating with programmer (resp %c)\n", progname, resp[0]); return -1; } else { if (verbose == 2) fprintf(stderr, "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)) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkI_initialize(): unsupported baudrate %d\n", progname, pgm->baudrate); } else { if (verbose >= 2) fprintf(stderr, "%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) { if (verbose >= 2) fprintf(stderr, "%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); jtagmkI_recv(pgm, resp, 5); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%s: jtagmkI_initialize(): " "timeout/error communicating with programmer (resp %c)\n", progname, resp[0]); } else { if (verbose == 2) fprintf(stderr, "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) { fprintf(stderr, "%s: jtagmkI_initialize(): Out of memory\n", progname); return -1; } if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { fprintf(stderr, "%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) fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_open()\n", progname); strcpy(pgm->port, port); PDATA(pgm)->initial_baudrate = -1L; for (i = 0; i < sizeof(baudtab) / sizeof(baudtab[0]); i++) { if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_open(): trying to sync at baud rate %ld:\n", progname, baudtab[i].baud); if (serial_open(port, baudtab[i].baud, &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; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_open(): succeeded\n", progname); return 0; } serial_close(&pgm->fd); } fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkI_close(): unsupported baudrate %d\n", progname, PDATA(pgm)->initial_baudrate); } else { if (verbose >= 2) fprintf(stderr, "%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 if (verbose >= 2) fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkI_paged_write(): page size %d too large\n", progname, page_size); return -1; } if ((datacmd = malloc(page_size + 1)) == NULL) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkI_paged_write(): sync loss, retries exhausted\n", progname); return -1; } if ((n_bytes-addr) < page_size) block_size = n_bytes - addr; else block_size = page_size; if (verbose >= 3) fprintf(stderr, "%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); } if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_paged_write(): " "Sending write memory command: ", progname); /* First part, send the write command. */ jtagmkI_send(pgm, cmd, 6); jtagmkI_recv(pgm, resp, 1); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%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) fprintf(stderr, "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); jtagmkI_recv(pgm, resp, 2); if (resp[1] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%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) fprintf(stderr, "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 if (verbose >= 2) fprintf(stderr, "%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)) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkI_paged_load(): sync loss, retries exhausted\n", progname); return -1; } if ((n_bytes-addr) < page_size) block_size = n_bytes - addr; else block_size = page_size; if (verbose >= 3) fprintf(stderr, "%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); } if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_paged_load(): Sending read memory command: ", progname); jtagmkI_send(pgm, cmd, 6); jtagmkI_recv(pgm, resp, read_size + 3); if (resp[read_size + 3 - 1] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%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) fprintf(stderr, "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; if (verbose >= 2) fprintf(stderr, "%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); jtagmkI_recv(pgm, resp, respsize); if (resp[respsize - 1] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%s: jtagmkI_read_byte(): " "timeout/error communicating with programmer (resp %c)\n", progname, resp[respsize - 1]); exit(1); } else { if (verbose == 2) fprintf(stderr, "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; if (verbose >= 2) fprintf(stderr, "%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); jtagmkI_recv(pgm, resp, 1); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%s: jtagmkI_write_byte(): " "timeout/error communicating with programmer (resp %c)\n", progname, resp[0]); return -1; } else { if (verbose == 2) fprintf(stderr, "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); jtagmkI_recv(pgm, resp, 1); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%s: jtagmkI_write_byte(): " "timeout/error communicating with programmer (resp %c)\n", progname, resp[0]); return -1; } else { if (verbose == 2) fprintf(stderr, "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]; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_getparm()\n", progname); buf[0] = CMD_GET_PARAM; buf[1] = parm; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_getparm(): " "Sending get parameter command (parm 0x%02x): ", progname, parm); jtagmkI_send(pgm, buf, 2); jtagmkI_recv(pgm, resp, 3); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%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); fprintf(stderr, "%s: jtagmkI_getparm(): " "unknown parameter 0x%02x\n", progname, parm); return -1; } else { if (verbose == 2) fprintf(stderr, "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]; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_setparm()\n", progname); buf[0] = CMD_SET_PARAM; buf[1] = parm; buf[2] = value; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_setparm(): " "Sending set parameter command (parm 0x%02x): ", progname, parm); jtagmkI_send(pgm, buf, 3); jtagmkI_recv(pgm, resp, 2); if (resp[0] != RESP_OK) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%s: jtagmkI_setparm(): " "timeout/error communicating with programmer (resp %c)\n", progname, resp[0]); return -1; } else { if (verbose == 2) fprintf(stderr, "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; fprintf(stderr, "%sICE hardware version: 0x%02x\n", p, hw); fprintf(stderr, "%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; } fprintf(stderr, "%sVtarget : %.1f V\n", p, 6.25 * (unsigned)vtarget / 255.0); fprintf(stderr, "%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; } avrdude-6.0.1/jtagmkI.h000644 000153 000000 00000002007 12216240452 014262 0ustar00jwheel000000 000000 /* * 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: jtagmkI.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #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 avrdude-6.0.1/jtagmkI_private.h000644 000153 000000 00000013527 12216240452 016025 0ustar00jwheel000000 000000 /* * 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: jtagmkI_private.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ /* * 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 */ }; avrdude-6.0.1/jtagmkII.c000644 000153 000000 00000350375 12216240452 014404 0ustar00jwheel000000 000000 /* * 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: jtagmkII.c 1212 2013-09-08 19:57:58Z joerg_wunsch $ */ /* * 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 "avr.h" #include "crc16.h" #include "pgm.h" #include "jtagmkII.h" #include "jtagmkII_private.h" #include "serial.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) { fprintf(stderr, "%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++) { fprintf(stderr, "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) { fprintf(stderr, "Raw message:\n"); for (i = 0; i < len; i++) { fprintf(stderr, "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: fprintf(stderr, "OK\n"); break; case RSP_FAILED: fprintf(stderr, "FAILED\n"); break; case RSP_ILLEGAL_BREAKPOINT: fprintf(stderr, "Illegal breakpoint\n"); break; case RSP_ILLEGAL_COMMAND: fprintf(stderr, "Illegal command\n"); break; case RSP_ILLEGAL_EMULATOR_MODE: fprintf(stderr, "Illegal emulator mode"); if (len > 1) switch (data[1]) { case EMULATOR_MODE_DEBUGWIRE: fprintf(stderr, ": DebugWire"); break; case EMULATOR_MODE_JTAG: fprintf(stderr, ": JTAG"); break; case EMULATOR_MODE_HV: fprintf(stderr, ": HVSP/PP"); break; case EMULATOR_MODE_SPI: fprintf(stderr, ": SPI"); break; case EMULATOR_MODE_JTAG_XMEGA: fprintf(stderr, ": JTAG/Xmega"); break; } putc('\n', stderr); break; case RSP_ILLEGAL_JTAG_ID: fprintf(stderr, "Illegal JTAG ID\n"); break; case RSP_ILLEGAL_MCU_STATE: fprintf(stderr, "Illegal MCU state"); if (len > 1) switch (data[1]) { case STOPPED: fprintf(stderr, ": Stopped"); break; case RUNNING: fprintf(stderr, ": Running"); break; case PROGRAMMING: fprintf(stderr, ": Programming"); break; } putc('\n', stderr); break; case RSP_ILLEGAL_MEMORY_TYPE: fprintf(stderr, "Illegal memory type\n"); break; case RSP_ILLEGAL_MEMORY_RANGE: fprintf(stderr, "Illegal memory range\n"); break; case RSP_ILLEGAL_PARAMETER: fprintf(stderr, "Illegal parameter\n"); break; case RSP_ILLEGAL_POWER_STATE: fprintf(stderr, "Illegal power state\n"); break; case RSP_ILLEGAL_VALUE: fprintf(stderr, "Illegal value\n"); break; case RSP_NO_TARGET_POWER: fprintf(stderr, "No target power\n"); break; case RSP_SIGN_ON: fprintf(stderr, "Sign-on succeeded\n"); /* Sign-on data will be printed below anyway. */ break; case RSP_MEMORY: fprintf(stderr, "memory contents:\n"); jtagmkII_print_memory(data, len); break; case RSP_PARAMETER: fprintf(stderr, "parameter values:\n"); jtagmkII_print_memory(data, len); break; case RSP_SPI_DATA: fprintf(stderr, "SPI data returned:\n"); for (i = 1; i < len; i++) fprintf(stderr, "0x%02x ", data[i]); putc('\n', stderr); break; case EVT_BREAK: fprintf(stderr, "BREAK event"); if (len >= 6) { fprintf(stderr, ", PC = 0x%lx, reason ", b4_to_u32(data + 1)); switch (data[5]) { case 0x00: fprintf(stderr, "unspecified"); break; case 0x01: fprintf(stderr, "program break"); break; case 0x02: fprintf(stderr, "data break PDSB"); break; case 0x03: fprintf(stderr, "data break PDMSB"); break; default: fprintf(stderr, "unknown: 0x%02x", data[5]); } } putc('\n', stderr); break; default: fprintf(stderr, "unknown message 0x%02x\n", data[0]); } putc('\n', stderr); } int jtagmkII_send(PROGRAMMER * pgm, unsigned char * data, size_t len) { unsigned char *buf; if (verbose >= 3) fprintf(stderr, "\n%s: jtagmkII_send(): sending %lu bytes\n", progname, (unsigned long)len); if ((buf = malloc(len + 10)) == NULL) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkII_send(): failed to send command to serial port\n", progname); exit(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; if (verbose >= 4) fprintf(stderr, "%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 */ if (verbose > 1) fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) fprintf(stderr, "%s: jtagmkII_recv(): CRC OK", progname); state = sDONE; } else { fprintf(stderr, "%s: jtagmkII_recv(): checksum error\n", progname); free(buf); return -4; } } else state++; break; default: fprintf(stderr, "%s: jtagmkII_recv(): unknown state\n", progname); free(buf); return -5; } gettimeofday(&tv, NULL); tnow = tv.tv_sec; if (tnow - tstart > timeoutval) { fprintf(stderr, "%s: jtagmkII_recv_frame(): timeout\n", progname); return -1; } } if (verbose >= 3) fprintf(stderr, "\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; if (verbose >= 3) fprintf(stderr, "%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; fprintf(stderr, "%s: Recv: ", progname); while (i) { unsigned char c = *p; if (isprint(c)) { fprintf(stderr, "%c ", c); } else { fprintf(stderr, ". "); } fprintf(stderr, "[%02x] ", c); p++; i--; } fprintf(stderr, "\n"); } return rv; } if (r_seqno == 0xffff) { if (verbose >= 3) fprintf(stderr, "%s: jtagmkII_recv(): got asynchronous event\n", progname); } else { if (verbose >= 2) fprintf(stderr, "%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; if (verbose >= 3) fprintf(stderr, "%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 { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%s: jtagmkII_getsync(): Sending sign-on command: ", progname); jtagmkII_send(pgm, buf, 1); status = jtagmkII_recv(pgm, &resp); if (status <= 0) { fprintf(stderr, "%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) fprintf(stderr, "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 (verbose >= 1 && status > 17) { fprintf(stderr, "JTAG ICE mkII sign-on message:\n"); fprintf(stderr, "Communications protocol version: %u\n", (unsigned)resp[1]); fprintf(stderr, "M_MCU:\n"); fprintf(stderr, " boot-loader FW version: %u\n", (unsigned)resp[2]); fprintf(stderr, " firmware version: %u.%02u\n", (unsigned)resp[4], (unsigned)resp[3]); fprintf(stderr, " hardware version: %u\n", (unsigned)resp[5]); fprintf(stderr, "S_MCU:\n"); fprintf(stderr, " boot-loader FW version: %u\n", (unsigned)resp[6]); fprintf(stderr, " firmware version: %u.%02u\n", (unsigned)resp[8], (unsigned)resp[7]); fprintf(stderr, " hardware version: %u\n", (unsigned)resp[9]); fprintf(stderr, "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'; fprintf(stderr, "Device ID: %s\n", resp + 16); } break; } free(resp); } } if (tries >= MAXTRIES) { if (status <= 0) fprintf(stderr, "%s: jtagmkII_getsync(): " "timeout/error communicating with programmer (status %d)\n", progname, status); else fprintf(stderr, "%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; fprintf(stderr, "%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 (verbose >= 2 && mode != EMULATOR_MODE_SPI) fprintf(stderr, "%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)) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkII_getsync(): Xmega PDI support requires hardware " "revision >= 1\n", progname); return -1; } if (!is_dragon && fwver < FWVER(5, 37)) { fprintf(stderr, "%s: jtagmkII_getsync(): Xmega support requires firmware " "version >= 5.37\n", progname); return -1; } if (is_dragon && fwver < FWVER(6, 11)) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: Failed to return from debugWIRE to ISP.\n", progname); return -1; } fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%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; } if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%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) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%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 (strcmp(m->desc, "lock") == 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); } } if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%s: jtagmkII_reset(): " "bad response to reset command: %s\n", progname, jtagmkII_get_rc(c)); return -1; } return 0; } static int jtagmkII_program_enable_dummy(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; if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%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}; if (verbose > 0) fprintf(stderr, "%s: retrying with external reset applied\n", progname); (void)jtagmkII_setparm(pgm, PAR_EXTERNAL_RESET, parm); continue; } fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkII_initialize(): unsupported baudrate %d\n", progname, pgm->baudrate); } else { if (verbose >= 2) fprintf(stderr, "%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) { if (verbose >= 2) fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkII_initialize(): Out of memory\n", progname); return -1; } if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { fprintf(stderr, "%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) fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkII_parseextparms(): invalid JTAG chain '%s'\n", progname, extended_param); rv = -1; continue; } if (verbose >= 2) { fprintf(stderr, "%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; } fprintf(stderr, "%s: jtagmkII_parseextparms(): invalid extended parameter '%s'\n", progname, extended_param); rv = -1; } return rv; } static int jtagmkII_open(PROGRAMMER * pgm, char * port) { long baud; if (verbose >= 2) fprintf(stderr, "%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. */ 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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) { long baud; if (verbose >= 2) fprintf(stderr, "%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. */ 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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) { long baud; if (verbose >= 2) fprintf(stderr, "%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. */ 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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) { long baud; if (verbose >= 2) fprintf(stderr, "%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. */ 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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) { long baud; if (verbose >= 2) fprintf(stderr, "%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. */ 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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) { long baud; if (verbose >= 2) fprintf(stderr, "%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. */ 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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; if (verbose >= 2) fprintf(stderr, "%s: jtagmkII_close()\n", progname); if (pgm->flag & PGM_FL_IS_PDI) { /* When in PDI mode, restart target. */ buf[0] = CMND_GO; if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%s: jtagmkII_close(): " "bad response to GO command: %s\n", progname, jtagmkII_get_rc(c)); } } } buf[0] = CMND_SIGN_OFF; if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%s: jtagmkII_page_erase(.., %s, 0x%x)\n", progname, m->desc, addr); if (!(p->flags & AVRPART_HAS_PDI)) { fprintf(stderr, "%s: jtagmkII_page_erase: not an Xmega device\n", progname); return -1; } if ((pgm->flag & PGM_FL_IS_DW)) { fprintf(stderr, "%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: if (verbose >= 2) fprintf(stderr, "%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); if (verbose >= 1) fprintf(stderr, "%s: jtagmkII_page_erase(): " "timeout/error communicating with programmer (status %d)\n", progname, status); if (tries++ < 4) { serial_recv_timeout *= 2; goto retry; } fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); if (resp[0] != RSP_OK) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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) { fprintf(stderr, "%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; if (verbose >= 3) fprintf(stderr, "%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: if (verbose >= 2) fprintf(stderr, "%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); if (verbose >= 1) fprintf(stderr, "%s: jtagmkII_paged_write(): " "timeout/error communicating with programmer (status %d)\n", progname, status); if (tries++ < 4) { serial_recv_timeout *= 2; goto retry; } fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); if (resp[0] != RSP_OK) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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; if (verbose >= 3) fprintf(stderr, "%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: if (verbose >= 2) fprintf(stderr, "%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); if (verbose >= 1) fprintf(stderr, "%s: jtagmkII_paged_load(): " "timeout/error communicating with programmer (status %d)\n", progname, status); if (tries++ < 4) { serial_recv_timeout *= 2; goto retry; } fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); if (resp[0] != RSP_MEMORY) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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 (strcmp(mem->desc, "lock") == 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: fprintf(stderr, "%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: if (verbose >= 2) fprintf(stderr, "%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); if (verbose >= 1) fprintf(stderr, "%s: jtagmkII_read_byte(): " "timeout/error communicating with programmer (status %d)\n", progname, status); if (tries++ < 3) goto retry; fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); if (resp[0] != RSP_MEMORY) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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 (strcmp(mem->desc, "lock") == 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: if (verbose >= 2) fprintf(stderr, "%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); if (verbose > 1) fprintf(stderr, "%s: jtagmkII_write_byte(): " "timeout/error communicating with programmer (status %d)\n", progname, status); if (tries++ < 3) goto retry; fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); if (resp[0] != RSP_OK) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%s: jtagmkII_getparm()\n", progname); buf[0] = CMND_GET_PARAMETER; buf[1] = parm; if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; if (c != RSP_PARAMETER) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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: fprintf(stderr, "%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); if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%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; fprintf(stderr, "%sM_MCU hardware version: %d\n", p, hw[0]); fprintf(stderr, "%sM_MCU firmware version: %d.%02d\n", p, fw[1], fw[0]); fprintf(stderr, "%sS_MCU hardware version: %d\n", p, hw[1]); fprintf(stderr, "%sS_MCU firmware version: %d.%02d\n", p, fw[3], fw[2]); fprintf(stderr, "%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; fprintf(stderr, "%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]; fprintf(stderr, "%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; if(verbose) fprintf(stderr, "%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) { if(verbose) fprintf(stderr, "%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) { if(verbose) fprintf(stderr, "%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; if(verbose) fprintf(stderr, "%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: fprintf(stderr, "%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: fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtagmkII_initialize(): Out of memory\n", progname); return -1; } if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { fprintf(stderr, "%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); fprintf(stderr, "%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); fprintf(stderr, "%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]) { fprintf(stderr, "%s: Expected signature for %s is %02X %02X %02X\n", progname, p->desc, p->signature[0], p->signature[1], p->signature[2]); if (!ovsigck) { fprintf(stderr, "%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; if(verbose) fprintf(stderr, "%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: fprintf(stderr, "%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); fprintf(stderr, "%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; fprintf(stderr, "Cmd: "); for(i=0; i<6; ++i) fprintf(stderr, "%2.2x ", buf[i]); fprintf(stderr, "\n"); fprintf(stderr, "Data: "); for(i=0; i= 2) putc('\n', stderr); fprintf(stderr, "%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); fprintf(stderr, "%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); fprintf(stderr, "%s: jtagmkII_write_SABaddr(): " "timeout/error communicating with programmer (status %d)\n", progname, status); return -1; } if (verbose) { if (verbose >= 2) putc('\n', stderr); fprintf(stderr, "%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; long baud; if (verbose >= 2) fprintf(stderr, "%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. */ 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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; if (verbose >= 2) fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); c = resp[0]; free(resp); if (c != RSP_OK) { fprintf(stderr, "%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: fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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; } //fprintf(stderr, "\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; if (verbose >= 3) fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); if (resp[0] != 0x87) { fprintf(stderr, "%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; fprintf(stderr, "%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; //fprintf(stderr, "\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) { fprintf(stderr, "%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; if (verbose >= 3) fprintf(stderr, "%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) fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status); if (resp[0] != RSP_OK) { fprintf(stderr, "%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); fprintf(stderr, "%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: fprintf(stderr, "%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;} //fprintf(stderr, "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: fprintf(stderr, "%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: fprintf(stderr, "%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: fprintf(stderr, "%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_dummy; 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_dummy; 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_dummy; 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_dummy; 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_dummy; 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_dummy; 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_dummy; 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; } avrdude-6.0.1/jtagmkII.h000644 000153 000000 00000004117 12216240452 014377 0ustar00jwheel000000 000000 /* * 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: jtagmkII.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #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 avrdude-6.0.1/jtagmkII_private.h000644 000153 000000 00000042642 12216240452 016136 0ustar00jwheel000000 000000 /* * 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: jtagmkII_private.h 1212 2013-09-08 19:57:58Z joerg_wunsch $ */ /* * 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) avrdude-6.0.1/jtag3.c000644 000153 000000 00000145552 12216240452 013714 0ustar00jwheel000000 000000 /* * 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: jtag3.c 1237 2013-09-17 15:06:35Z joerg_wunsch $ */ /* * avrdude interface for Atmel JTAGICE3 programmer */ #include "ac_cfg.h" #include #include #include #include #include #include #include #include #include #include "avrdude.h" #include "avr.h" #include "crc16.h" #include "pgm.h" #include "jtag3.h" #include "jtag3_private.h" #include "serial.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) static int jtag3_open(PROGRAMMER * pgm, char * port); 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) { fprintf(stderr, "%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++) { fprintf(stderr, "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) { fprintf(stderr, "Raw message:\n"); for (i = 0; i < len; i++) { fprintf(stderr, "%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: fprintf(stderr, "[info] "); break; case SCOPE_GENERAL: fprintf(stderr, "[general] "); break; case SCOPE_AVR_ISP: fprintf(stderr, "[AVRISP] "); jtag3_print_data(data + 1, len - 1); return; case SCOPE_AVR: fprintf(stderr, "[AVR] "); break; default: fprintf(stderr, "[scope 0x%02x] ", data[0]); break; } switch (data[1]) { case RSP3_OK: fprintf(stderr, "OK\n"); break; case RSP3_FAILED: fprintf(stderr, "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; } fprintf(stderr, ", reason: %s\n", reason); } else { fprintf(stderr, ", unspecified reason\n"); } break; case RSP3_DATA: fprintf(stderr, "Data returned:\n"); jtag3_print_data(data + 2, len - 2); break; case RSP3_INFO: fprintf(stderr, "Info returned:\n"); for (i = 2; i < len; i++) { if (isprint(data[i])) putc(data[i], stderr); else fprintf(stderr, "\\%03o", data[i]); } putc('\n', stderr); break; case RSP3_PC: if (len < 7) { fprintf(stderr, "PC reply too short\n"); } else { unsigned long pc = (data[6] << 24) | (data[5] << 16) | (data[4] << 8) | data[3]; fprintf(stderr, "PC 0x%0lx\n", pc); } break; default: fprintf(stderr, "unknown message 0x%02x\n", data[1]); } } static void jtag3_prevent(PROGRAMMER * pgm, unsigned char * data, size_t len) { int i; if (verbose >= 4) { fprintf(stderr, "Raw event:\n"); for (i = 0; i < len; i++) { fprintf(stderr, "%02x ", data[i]); if (i % 16 == 15) putc('\n', stderr); else putc(' ', stderr); } if (i % 16 != 0) putc('\n', stderr); } fprintf(stderr, "Event serial 0x%04x, ", (data[3] << 8) | data[2]); switch (data[4]) { case SCOPE_INFO: fprintf(stderr, "[info] "); break; case SCOPE_GENERAL: fprintf(stderr, "[general] "); break; case SCOPE_AVR: fprintf(stderr, "[AVR] "); break; default: fprintf(stderr, "[scope 0x%02x] ", data[0]); break; } switch (data[5]) { case EVT3_BREAK: fprintf(stderr, "BREAK"); if (len >= 11) { fprintf(stderr, ", PC = 0x%lx, reason ", b4_to_u32(data + 6)); switch (data[10]) { case 0x00: fprintf(stderr, "unspecified"); break; case 0x01: fprintf(stderr, "program break"); break; case 0x02: fprintf(stderr, "data break PDSB"); break; case 0x03: fprintf(stderr, "data break PDMSB"); break; default: fprintf(stderr, "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) fprintf(stderr, "sleeping"); else if (len >= 8 && data[7] == 1) fprintf(stderr, "wakeup"); else fprintf(stderr, "unknown SLEEP event"); break; case EVT3_POWER: if (len >= 8 && data[7] == 0) fprintf(stderr, "power-down"); else if (len >= 8 && data[7] == 1) fprintf(stderr, "power-up"); else fprintf(stderr, "unknown POWER event"); break; default: fprintf(stderr, "UNKNOWN 0x%02x", data[5]); break; } putc('\n', stderr); } int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len) { unsigned char *buf; if (verbose >= 3) fprintf(stderr, "\n%s: jtag3_send(): sending %lu bytes\n", progname, (unsigned long)len); if ((buf = malloc(len + 4)) == NULL) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtag3_send(): failed to send command to serial port\n", progname); exit(1); } free(buf); 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 (verbose >= 4) fprintf(stderr, "%s: jtag3_recv():\n", progname); if ((buf = malloc(pgm->fd.usb.max_xfer)) == NULL) { fprintf(stderr, "%s: jtag3_recv(): out of memory\n", progname); return -1; } rv = serial_recv(&pgm->fd, buf, pgm->fd.usb.max_xfer); if (rv < 0) { /* timeout in receive */ if (verbose > 1) fprintf(stderr, "%s: jtag3_recv(): Timeout receiving packet\n", progname); free(buf); return -1; } *msg = buf; return rv; } 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]; if (verbose >= 3) fprintf(stderr, "%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. */ memmove(*msg, *msg + 3, rv); rv -= 3; return rv; } if (verbose >= 2) fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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); fprintf(stderr, "%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 if (verbose == 2) fprintf(stderr, "0x%02x (%d bytes msg)\n", (*resp)[1], status); c = (*resp)[1]; if ((c & RSP3_STATUS_MASK) != RSP3_OK) { fprintf(stderr, "%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; if (verbose >= 3) fprintf(stderr, "%s: jtag3_getsync()\n", progname); /* 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) { fprintf(stderr, "%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; 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] = SCOPE_AVR; buf[1] = CMD3_ENTER_PROGMODE; buf[2] = 0; if (jtag3_command(pgm, buf, 3, &resp, "enter progmode") >= 0) { free(resp); break; } /* XXX activate external reset here */ if (verbose > 0) fprintf(stderr, "%s: retrying with external reset applied\n", progname); } PDATA(pgm)->prog_enabled = 1; return 0; } 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) { fprintf(stderr, "%s: the JTAGICE3's firmware %d.%d is broken on USB 1.1 connections, sorry\n", progname, parm[0], parm[1]); if (ovsigck) { fprintf(stderr, "%s: forced to continue by option -F; THIS PUTS THE DEVICE'S DATA INTEGRITY AT RISK!\n", progname); } else { serial_close(&pgm->fd); 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) { fprintf(stderr, "%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 */ if (verbose >= 2) fprintf(stderr, "%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) { if (verbose >= 2) fprintf(stderr, "%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 (strcmp(m->desc, "lock") == 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 */ fprintf(stderr, "%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; } cmd[0] = SCOPE_AVR; cmd[1] = CMD3_SIGN_ON; cmd[2] = 0; cmd[3] = 0; /* external reset */ if ((status = jtag3_command(pgm, cmd, 4, &resp, "AVR sign-on")) < 0) 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 && verbose >= 1) /* JTAG ID has been returned */ fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtag3_initialize(): Out of memory\n", progname); return -1; } if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtag3_parseextparms(): invalid JTAG chain '%s'\n", progname, extended_param); rv = -1; continue; } if (verbose >= 2) { fprintf(stderr, "%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; } fprintf(stderr, "%s: jtag3_parseextparms(): invalid extended parameter '%s'\n", progname, extended_param); rv = -1; } return rv; } static int jtag3_open(PROGRAMMER * pgm, char * port) { long baud; if (verbose >= 2) fprintf(stderr, "%s: jtag3_open()\n", progname); /* * 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; baud = USB_DEVICE_JTAGICE3; 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; #else fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &pgm->fd)==-1) { return -1; } /* * drain any extraneous input */ jtag3_drain(pgm, 0); if (jtag3_getsync(pgm, PARM3_CONN_JTAG) < 0) return -1; return 0; } static int jtag3_open_dw(PROGRAMMER * pgm, char * port) { long baud; if (verbose >= 2) fprintf(stderr, "%s: jtag3_open_dw()\n", progname); /* * 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; baud = USB_DEVICE_JTAGICE3; 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; #else fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &pgm->fd)==-1) { return -1; } /* * drain any extraneous input */ jtag3_drain(pgm, 0); if (jtag3_getsync(pgm, PARM3_CONN_DW) < 0) return -1; return 0; } static int jtag3_open_pdi(PROGRAMMER * pgm, char * port) { long baud; if (verbose >= 2) fprintf(stderr, "%s: jtag3_open_pdi()\n", progname); /* * 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; baud = USB_DEVICE_JTAGICE3; 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; #else fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &pgm->fd)==-1) { return -1; } /* * drain any extraneous input */ jtag3_drain(pgm, 0); if (jtag3_getsync(pgm, PARM3_CONN_PDI) < 0) return -1; return 0; } void jtag3_close(PROGRAMMER * pgm) { unsigned char buf[4], *resp; if (verbose >= 2) fprintf(stderr, "%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); 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; if (verbose >= 2) fprintf(stderr, "%s: jtag3_page_erase(.., %s, 0x%x)\n", progname, m->desc, addr); if (!(p->flags & AVRPART_HAS_PDI)) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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) { fprintf(stderr, "%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; if (verbose >= 3) fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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; if (verbose >= 3) fprintf(stderr, "%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) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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 (strcmp(mem->desc, "lock") == 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 */ fprintf(stderr, "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) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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 (strcmp(mem->desc, "lock") == 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) { fprintf(stderr, "%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]; if (verbose >= 2) fprintf(stderr, "%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) { fprintf(stderr, "%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]; if (verbose >= 2) fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: jtag3_display(): response is not RSP3_INFO\n", progname); free(resp); return; } memmove(resp, resp + 3, status - 3); resp[status - 3] = 0; fprintf(stderr, "%sICE hardware version: %d\n", p, parms[0]); fprintf(stderr, "%sICE firmware version: %d.%02d (rel. %d)\n", p, parms[1], parms[2], (parms[3] | (parms[4] << 8))); fprintf(stderr, "%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; fprintf(stderr, "%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; fprintf(stderr, "%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; fprintf(stderr, "%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; fprintf(stderr, "%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; fprintf(stderr, "%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; } avrdude-6.0.1/jtag3.h000644 000153 000000 00000003710 12216240452 013706 0ustar00jwheel000000 000000 /* * 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: jtag3.h 1123 2012-12-03 21:03:06Z joerg_wunsch $ */ #ifndef jtag3_h #define jtag3_h #ifdef __cplusplus extern "C" { #endif 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 avrdude-6.0.1/jtag3_private.h000644 000153 000000 00000027464 12216240452 015454 0ustar00jwheel000000 000000 /* * 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: jtag3_private.h 1208 2013-09-05 21:18:01Z joerg_wunsch $ */ /* * 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 #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 */ avrdude-6.0.1/linuxgpio.c000644 000153 000000 00000020173 12216240452 014711 0ustar00jwheel000000 000000 /* * 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 "avr.h" #include "pindefs.h" #include "pgm.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), "%d", 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), "%d", 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%d/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%d/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 pin, int value) { int r; 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 pin) { unsigned char invert=0; char c; 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 pin) { if ( linuxgpio_fds[pin & PIN_MASK] < 0 ) return -1; linuxgpio_setpin(pgm, pin, 1); linuxgpio_setpin(pgm, pin, 0); return 0; } static void linuxgpio_display(PROGRAMMER *pgm, const char *p) { fprintf(stderr, "%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; bitbang_check_prerequisites(pgm); for (i=0; ipinno[i] != 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) { fprintf(stderr, "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) { fprintf(stderr, "%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 */ avrdude-6.0.1/linuxgpio.h000644 000153 000000 00000002123 12216240452 014711 0ustar00jwheel000000 000000 /* * 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 avrdude-6.0.1/linux_ppdev.h000644 000153 000000 00000003773 12216240452 015244 0ustar00jwheel000000 000000 /* * 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: linux_ppdev.h 1198 2013-09-02 20:53:12Z joerg_wunsch $ */ #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)) { \ fprintf(stderr, "%s: can't claim device \"%s\": %s\n\n", \ progname, port, strerror(errno)); \ close(fd); \ exit(1); \ } #define ppi_release(fd) \ if (ioctl(fd, PPRELEASE)) { \ fprintf(stderr, "%s: can't release device: %s\n\n", \ progname, strerror(errno)); \ exit(1); \ } #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 */ avrdude-6.0.1/lists.c000644 000153 000000 00000071165 12216240452 014040 0ustar00jwheel000000 000000 /* * 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: lists.c 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ /*---------------------------------------------------------------------- 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 "lists.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; } avrdude-6.0.1/lists.h000644 000153 000000 00000010160 12216240452 014031 0ustar00jwheel000000 000000 /* * 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: lists.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ /*---------------------------------------------------------------------- Id: lists.h,v 1.2 2001/08/19 23:13:17 bsd Exp $ ----------------------------------------------------------------------*/ /*---------------------------------------------------------------------- General purpose linked list routines - header file declarations. Author : Brian Dean Date : 10 January, 1990 ----------------------------------------------------------------------*/ #ifndef lists_h #define lists_h #include 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 #endif avrdude-6.0.1/my_ddk_hidsdi.h000644 000153 000000 00000004234 12216240452 015473 0ustar00jwheel000000 000000 /* * 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: my_ddk_hidsdi.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ /* 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 */ avrdude-6.0.1/par.c000644 000153 000000 00000022270 12216240452 013455 0ustar00jwheel000000 000000 /* * 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: par.c 1160 2013-05-03 22:35:00Z rliebscher $ */ #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 "avr.h" #include "pindefs.h" #include "pgm.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(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 void par_setmany(PROGRAMMER * pgm, unsigned int pinset, int value) { int pin, mask; /* 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(pgm, pin | mask, value); } } static int par_getpin(PROGRAMMER * pgm, int pin) { int value; int inverted; 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 pin) { 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) { 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, pgm->pinno[PPI_AVR_VCC], 1); /* power up */ usleep(100000); } /* * remove power from the AVR processor */ static void par_powerdown(PROGRAMMER * pgm) { par_setmany(pgm, pgm->pinno[PPI_AVR_VCC], 0); /* power down */ } static void par_disable(PROGRAMMER * pgm) { par_setmany(pgm, pgm->pinno[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, pgm->pinno[PIN_AVR_RESET], 0); usleep(1); /* * enable the 74367 buffer, if connected; this signal is active low */ par_setmany(pgm, pgm->pinno[PPI_AVR_BUFF], 0); } static int par_open(PROGRAMMER * pgm, char * port) { int rc; bitbang_check_prerequisites(pgm); ppi_open(port, &pgm->fd); if (pgm->fd.ifd < 0) { fprintf(stderr, "%s: failed to open parallel port \"%s\"\n\n", progname, port); exit(1); } /* * save pin values, so they can be restored when device is closed */ rc = ppi_getall(&pgm->fd, PPIDATA); if (rc < 0) { fprintf(stderr, "%s: error reading status of ppi data port\n", progname); return -1; } pgm->ppidata = rc; rc = ppi_getall(&pgm->fd, PPICTRL); if (rc < 0) { fprintf(stderr, "%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, pgm->pinno[PPI_AVR_BUFF], 1); /* * Handle exit specs. */ switch (pgm->exit_reset) { case EXIT_RESET_ENABLED: par_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0); break; case EXIT_RESET_DISABLED: par_setpin(pgm, pgm->pinno[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, pgm->pinno[PPI_AVR_VCC], 1); break; case EXIT_VCC_DISABLED: par_setmany(pgm, pgm->pinno[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) { fprintf(stderr, "%s: parallel port access not available in this configuration\n", progname); } #endif /* HAVE_PARPORT */ const char par_desc[] = "Parallel port bitbanging"; avrdude-6.0.1/par.h000644 000153 000000 00000001771 12216240453 013466 0ustar00jwheel000000 000000 /* * 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: par.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #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 avrdude-6.0.1/pgm.c000644 000153 000000 00000020574 12216240453 013464 0ustar00jwheel000000 000000 /* * 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 1161 2013-05-05 13:35:35Z rliebscher $ */ #include "ac_cfg.h" #include #include #include #include "avrdude.h" #include "pgm.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) { fprintf (stderr, "\n%s: Fatal error: Programmer does not support open()", progname); exit(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) { fprintf(stderr, "%s: out of memory allocating programmer structure\n", progname); exit(1); } memset(pgm, 0, sizeof(*pgm)); pgm->id = 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); p->id = 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; pgm = (PROGRAMMER *)malloc(sizeof(*pgm)); if (pgm == NULL) { fprintf(stderr, "%s: out of memory allocating programmer structure\n", progname); exit(1); } memcpy(pgm, src, sizeof(*pgm)); pgm->id = lcreat(NULL, 0); return pgm; } static void pgm_default(void) { fprintf(stderr, "%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) { fprintf(stderr, "%sProgrammer Type : %s\n", p, pgm->type); fprintf(stderr, "%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); } avrdude-6.0.1/pgm.h000644 000153 000000 00000015166 12216240453 013472 0ustar00jwheel000000 000000 /* * 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.h 1196 2013-09-02 20:22:53Z joerg_wunsch $ */ #ifndef pgm_h #define pgm_h #include #include "avrpart.h" #include "lists.h" #include "pindefs.h" #include "serial.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, 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 pin, int value); int (*getpin) (struct programmer_t * pgm, int pin); int (*highpulsepin) (struct programmer_t * pgm, int pin); 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); 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< * 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 "pgm_type.h" #include "arduino.h" #include "avr.h" #include "avr910.h" #include "avrftdi.h" #include "buspirate.h" #include "butterfly.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 const 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}, {"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); } } avrdude-6.0.1/pgm_type.h000644 000153 000000 00000003013 12216240452 014516 0ustar00jwheel000000 000000 /* * 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.h 1007 2011-09-14 21:49:42Z joerg_wunsch $ */ #ifndef pgm_type_h #define pgm_type_h #include "lists.h" #include "pgm.h" /*LISTID programmer_types;*/ typedef struct programmer_type_t { const char * const id; void (*initpgm)(struct programmer_t * pgm); const char * const desc; } PROGRAMMER_TYPE; #ifdef __cplusplus extern "C" { #endif const PROGRAMMER_TYPE * locate_programmer_type(/*LISTID programmer_types, */const char * id); typedef void (*walk_programmer_types_cb)(const char *id, const char *desc, void *cookie); void walk_programmer_types(/*LISTID programmer_types,*/ walk_programmer_types_cb cb, void *cookie); #ifdef __cplusplus } #endif #endif avrdude-6.0.1/pickit2.c000644 000153 000000 00000120627 12216240452 014245 0ustar00jwheel000000 000000 /* * 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 "avr.h" #include "pgm.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 { fprintf(stderr, __VA_ARGS__); } while(0) #else #define DEBUG(...) ((void)0) #endif #if 0 #define DEBUGRECV(...) do { fprintf(stderr, __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, 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) { fprintf(stderr, "%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 */ fprintf(stderr, "%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n", progname, PICKIT2_VID, PICKIT2_PID); exit(1); } else { // get the device description while we're at it short buff[PGM_DESCLEN], i; HidD_GetProductString(PDATA(pgm)->usb_handle, buff, PGM_DESCLEN); // convert from wide chars memset(&(pgm->type), 0, PGM_DESCLEN); for (i = 0; i < PGM_DESCLEN && buff[i]; i++) { pgm->type[i] = (char)buff[i]; } } #else if (usb_open_device(&(PDATA(pgm)->usb_handle), PICKIT2_VID, PICKIT2_PID) < 0) { /* no PICkit2 found */ fprintf(stderr, "%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n", progname, PICKIT2_VID, PICKIT2_PID); exit(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 */ char report[65] = {0, CMD_GET_VERSION, CMD_END_OF_BUFFER}; if ((errorCode = pickit2_write_report(pgm, report)) > 0) { memset(report, 0, sizeof(report)); if ((errorCode = pickit2_read_report(pgm, report)) >= 4) { if (verbose) { fprintf(stderr, "%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) 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) { fprintf(stderr, "pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror()); return -1; } } else { fprintf(stderr, "pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror()); return -1; } } else { fprintf(stderr, "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 */ uint8_t 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) { fprintf(stderr, "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 (verbose) { int i; fprintf(stderr, "program_enable(): sending command. Resp = "); for (i = 0; i < 4; i++) { fprintf(stderr, "%x ", (int)res[i]); } fprintf(stderr, "\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) { fprintf(stderr, "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 { fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "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 fprintf(stderr, "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) { fprintf(stderr, "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 int 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, 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, unsigned char report[65]) { return usb_write_interrupt(pgm, report, 65, PDATA(pgm)->transaction_timeout); } 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; fprintf(stderr, "%s: Warning: cannot open USB device: %s\n", progname, usb_strerror()); continue; } // return with opened device handle else { if (verbose) { fprintf(stderr, "Device %p seemed to open OK.\n", handle); } if ((errorCode = usb_set_configuration(handle, 1)) < 0) { fprintf(stderr, "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) { fprintf(stderr, "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, unsigned char report[65]) { // endpoint 1 OUT?? return usb_interrupt_write(PDATA(pgm)->usb_handle, USB_ENDPOINT_OUT | 1, 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, 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) { fprintf(stderr, "%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 if (verbose >= 2) { fprintf(stderr, "%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) { fprintf(stderr, "%s: pickit2_parseextparms(): invalid timeout '%s'\n", progname, extended_param); rv = -1; continue; } if (verbose >= 2) { fprintf(stderr, "%s: pickit2_parseextparms(): usb timeout set to 0x%02x\n", progname, timeout); } PDATA(pgm)->transaction_timeout = timeout; continue; } fprintf(stderr, "%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) { fprintf(stderr, #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); exit(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"; avrdude-6.0.1/pickit2.h000644 000153 000000 00000001775 12216240452 014254 0ustar00jwheel000000 000000 /* * 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 #include "avrpart.h" #ifdef __cplusplus extern "C" { #endif extern const char pickit2_desc[]; void pickit2_initpgm (PROGRAMMER * pgm); #ifdef __cplusplus } #endif #endif // pickit2_h avrdude-6.0.1/pindefs.c000644 000153 000000 00000030015 12216240452 014317 0ustar00jwheel000000 000000 /* * 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 "pindefs.h" #include "pgm.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 void 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) { fprintf(stderr, "Multiple pins found\n"); //TODO exit(1); } found = true; *pinno = i; if(pindef->inverse[i / PIN_FIELD_ELEMENT_SIZE] & (1 << (i % PIN_FIELD_ELEMENT_SIZE))) { *pinno |= PIN_INVERSE; } } } } /** * 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 void 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) { fprintf(stderr, "Pins of higher index than max field size for old pinno found\n"); exit(1); } 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 { fprintf(stderr, "pins have different polarity set\n"); exit(1); } } else if(pindef->mask[i] != 0) { fprintf(stderr, "Pins have higher number than fit in old format\n"); exit(1); } } } /** * Convert for given programmer new pin definitions to old pin definitions. * * @param[inout] pgm programmer whose pins shall be converted. */ void pgm_fill_old_pins(struct programmer_t * const pgm) { pin_fill_old_pinlist(&(pgm->pin[PPI_AVR_VCC]), &(pgm->pinno[PPI_AVR_VCC])); pin_fill_old_pinlist(&(pgm->pin[PPI_AVR_BUFF]), &(pgm->pinno[PPI_AVR_BUFF])); pin_fill_old_pinno(&(pgm->pin[PIN_AVR_RESET]), &(pgm->pinno[PIN_AVR_RESET])); pin_fill_old_pinno(&(pgm->pin[PIN_AVR_SCK]), &(pgm->pinno[PIN_AVR_SCK])); pin_fill_old_pinno(&(pgm->pin[PIN_AVR_MOSI]), &(pgm->pinno[PIN_AVR_MOSI])); pin_fill_old_pinno(&(pgm->pin[PIN_AVR_MISO]), &(pgm->pinno[PIN_AVR_MISO])); pin_fill_old_pinno(&(pgm->pin[PIN_LED_ERR]), &(pgm->pinno[PIN_LED_ERR])); pin_fill_old_pinno(&(pgm->pin[PIN_LED_RDY]), &(pgm->pinno[PIN_LED_RDY])); pin_fill_old_pinno(&(pgm->pin[PIN_LED_PGM]), &(pgm->pinno[PIN_LED_PGM])); pin_fill_old_pinno(&(pgm->pin[PIN_LED_VFY]), &(pgm->pinno[PIN_LED_VFY])); } /** * 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) { fprintf(stderr, "%s: %s: Following pins are not valid pins for this function: %s\n", progname, avr_pin_name(pinname), pinmask_to_str(invalid_used)); if(verbose >= 2) { fprintf(stderr, "%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) { fprintf(stderr, "%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)); if(verbose >= 2) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: %s: Mandatory pin is not defined.\n", progname, avr_pin_name(pinname)); } is_ok = false; } if(!is_ok) { rv = -1; } else if(output && verbose >= 3) { fprintf(stderr, "%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 ""; } } avrdude-6.0.1/pindefs.h000644 000153 000000 00000015566 12216240452 014342 0ustar00jwheel000000 000000 /* * 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 1184 2013-06-19 17:40:32Z rliebscher $ */ #ifndef __pindefs_h__ #define __pindefs_h__ #include #include "ac_cfg.h" /* 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 #include 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_LINUX_GPIO /* 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. */ void 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); #endif avrdude-6.0.1/ppi.c000644 000153 000000 00000010675 12216240452 013471 0ustar00jwheel000000 000000 /* * 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: ppi.c 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #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 "avr.h" #include "pindefs.h" #include "pgm.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: fprintf(stderr, "%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) { fprintf(stderr, "%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 */ avrdude-6.0.1/ppi.h000644 000153 000000 00000002745 12216240452 013475 0ustar00jwheel000000 000000 /* * 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: ppi.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #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 avrdude-6.0.1/ppiwin.c000644 000153 000000 00000021025 12216240452 014176 0ustar00jwheel000000 000000 /* * 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: ppiwin.c 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ /* 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" #include "avrdude.h" #if defined (WIN32NATIVE) #include #include #include #include #include #include #include #include #include #include "serial.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) { fprintf(stderr, "%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') { fprintf(stderr, "%s: port name \"%s\" is neither lpt1/2/3 nor valid number\n", progname, port); fd = -1; } } if(fd < 0) { fprintf(stderr, "%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 = CreateFile(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); \ fprintf(stderr, \ "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 avrdude-6.0.1/safemode.c000644 000153 000000 00000024144 12216240452 014460 0ustar00jwheel000000 000000 /* * 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 "avr.h" #include "pgm.h" #include "safemode.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, int verbose) { 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 */ if (verbose > 0) { fprintf(stderr, "%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, int verbose) { 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; } if (verbose > 2) { fprintf(stderr, "%s: safemode read 1, fuse value: %x\n",progname, safemode_fuse); } if(pgm->read_byte(pgm, p, m, 0, &value) != 0) { allowfuseread = 0; } if (verbose > 2) { fprintf(stderr, "%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; } if (verbose > 2) { fprintf(stderr, "%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) { fprintf(stderr, "%s: safemode: Verify error - unable to read fuse properly. " "Programmer may not be reliable.\n", progname); return -1; } else if ((fusegood == 1) && (verbose > 0)) { fprintf(stderr, "%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; } if (verbose > 2) { fprintf(stderr, "%s: safemode read 1, lfuse value: %x\n",progname, safemode_lfuse); } if (pgm->read_byte(pgm, p, m, 0, &value) != 0) { allowfuseread = 0; } if (verbose > 2) { fprintf(stderr, "%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; } if (verbose > 2) { fprintf(stderr, "%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) { fprintf(stderr, "%s: safemode: Verify error - unable to read lfuse properly. " "Programmer may not be reliable.\n", progname); return -1; } else if ((fusegood == 1) && (verbose > 0)) { fprintf(stderr, "%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; } if (verbose > 2) { fprintf(stderr, "%s: safemode read 1, hfuse value: %x\n",progname, safemode_hfuse); } if (pgm->read_byte(pgm, p, m, 0, &value) != 0) { allowfuseread = 0; } if (verbose > 2) { fprintf(stderr, "%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; } if (verbose > 2) { fprintf(stderr, "%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) { fprintf(stderr, "%s: safemode: Verify error - unable to read hfuse properly. " "Programmer may not be reliable.\n", progname); return -2; } else if ((fusegood == 1) && (verbose > 0)){ fprintf(stderr, "%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; } if (verbose > 2) { fprintf(stderr, "%s: safemode read 1, efuse value: %x\n",progname, safemode_efuse); } if (pgm->read_byte(pgm, p, m, 0, &value) != 0) { allowfuseread = 0; } if (verbose > 2) { fprintf(stderr, "%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; } if (verbose > 2) { fprintf(stderr, "%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) { fprintf(stderr, "%s: safemode: Verify error - unable to read efuse properly. " "Programmer may not be reliable.\n", progname); return -3; } else if ((fusegood == 1) && (verbose > 0)) { fprintf(stderr, "%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; } avrdude-6.0.1/safemode.h000644 000153 000000 00000004134 12216240452 014462 0ustar00jwheel000000 000000 /* * avrdude - A Downloader/Uploader for AVR device programmers * avrdude is Copyright (C) 2000-2004 Brian S. Dean * * This file: Copyright (C) 2005 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 . */ #ifndef safemode_h #define safemode_h #ifdef __cplusplus extern "C" { #endif /* 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, int verbose); /* 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, int verbose); /* 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); #ifdef __cplusplus } #endif #endif /* safemode_h */ avrdude-6.0.1/serial.h000644 000153 000000 00000005165 12216240452 014163 0ustar00jwheel000000 000000 /* * 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: serial.h 1108 2012-11-26 16:24:56Z joerg_wunsch $ */ /* 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. */ #ifndef serial_h #define serial_h 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 */ } usb; }; struct serial_device { // open should return -1 on error, other values on success int (*open)(char * port, long baud, union filedescriptor *fd); int (*setspeed)(union filedescriptor *fd, long baud); void (*close)(union filedescriptor *fd); int (*send)(union filedescriptor *fd, 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; #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) #endif /* serial_h */ avrdude-6.0.1/serbb.h000644 000153 000000 00000002110 12216240452 013764 0ustar00jwheel000000 000000 /* * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean * 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: serbb.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #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 avrdude-6.0.1/serbb_posix.c000644 000153 000000 00000015561 12216240452 015217 0ustar00jwheel000000 000000 /* * 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: serbb_posix.c 1160 2013-05-03 22:35:00Z rliebscher $ */ /* * 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 "avr.h" #include "pindefs.h" #include "pgm.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 pin, int value) { unsigned int ctl; int r; 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 pin) { unsigned int ctl; unsigned char invert; int r; 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 pin) { if ( (pin & PIN_MASK) < 1 || (pin & PIN_MASK) > DB9PINS ) return -1; serbb_setpin(pgm, pin, 1); serbb_setpin(pgm, pin, 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; bitbang_check_prerequisites(pgm); /* 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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: ", port); perror("tcsetattr"); return(-1); } /* Clear O_NONBLOCK flag. */ flags = fcntl(pgm->fd.ifd, F_GETFL, 0); if (flags == -1) { fprintf(stderr, "%s: Can not get flags: %s\n", progname, strerror(errno)); return(-1); } flags &= ~O_NONBLOCK; if (fcntl(pgm->fd.ifd, F_SETFL, flags) == -1) { fprintf(stderr, "%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, pgm->pinno[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 */ avrdude-6.0.1/serbb_win32.c000644 000153 000000 00000024417 12216240452 015017 0ustar00jwheel000000 000000 /* * 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: serbb_win32.c 1160 2013-05-03 22:35:00Z rliebscher $ */ /* * Win32 serial bitbanging interface for avrdude. */ #include "avrdude.h" #if defined(WIN32NATIVE) #include "ac_cfg.h" #include #include #include "avr.h" #include "pindefs.h" #include "pgm.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 pin, int value) { 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: if (verbose) fprintf(stderr, "%s: serbb_setpin(): unknown pin %d\n", progname, pin + 1); return -1; } if (verbose > 4) fprintf(stderr, "%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); fprintf(stderr, "%s: serbb_setpin(): SetCommState() failed: %s\n", progname, (char *)lpMsgBuf); CloseHandle(hComPort); LocalFree(lpMsgBuf); exit(1); } if (pgm->ispdelay > 1) bitbang_delay(pgm->ispdelay); return 0; } static int serbb_getpin(PROGRAMMER * pgm, int pin) { 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); fprintf(stderr, "%s: serbb_setpin(): GetCommModemStatus() failed: %s\n", progname, (char *)lpMsgBuf); CloseHandle(hComPort); LocalFree(lpMsgBuf); exit(1); } if (verbose > 4) fprintf(stderr, "%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: if (verbose) fprintf(stderr, "%s: serbb_getpin(): unknown pin %d\n", progname, pin + 1); return -1; } if (verbose > 4) fprintf(stderr, "%s: serbb_getpin(): return cached state for %s\n", progname, name); if (invert) rv = !rv; return rv; } static int serbb_highpulsepin(PROGRAMMER * pgm, int pin) { if ( (pin & PIN_MASK) < 1 || (pin & PIN_MASK) > DB9PINS ) return -1; serbb_setpin(pgm, pin, 1); serbb_setpin(pgm, pin, 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; bitbang_check_prerequisites(pgm); hComPort = CreateFile(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); fprintf(stderr, "%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); fprintf(stderr, "%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); fprintf(stderr, "%s: ser_open(): can't set com-state for \"%s\"\n", progname, port); return -1; } if (verbose > 2) fprintf(stderr, "%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, pgm->pinno[PIN_AVR_RESET], 1); CloseHandle (hComPort); } if (verbose > 2) fprintf(stderr, "%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 */ avrdude-6.0.1/ser_avrdoper.c000644 000153 000000 00000054155 12216240452 015375 0ustar00jwheel000000 000000 /* * 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: ser_avrdoper.c 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ /* * 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 "serial.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; fprintf(stderr, "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; fprintf(stderr, "Warning: cannot query manufacturer for device: %s\n", usb_strerror()); }else{ errorCode = USB_ERROR_NOTFOUND; /* fprintf(stderr, "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; fprintf(stderr, "Warning: cannot query product for device: %s\n", usb_strerror()); }else{ errorCode = USB_ERROR_NOTFOUND; /* fprintf(stderr, "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)){ fprintf(stderr, "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){ fprintf(stderr, "Warning: could not detach kernel HID driver: %s\n", usb_strerror()); } #endif } if(rval != 0) fprintf(stderr, "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) fprintf(stderr, "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){ fprintf(stderr, "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(char *prefix, unsigned char *buf, int len) { int i; if(len <= 8){ /* more compact format for short blocks */ fprintf(stderr, "%s: %d bytes: ", prefix, len); for(i = 0; i < len; i++){ fprintf(stderr, "%02x ", buf[i]); } fprintf(stderr, " \""); for(i = 0; i < len; i++){ if(buf[i] >= 0x20 && buf[i] < 0x7f){ fputc(buf[i], stderr); }else{ fputc('.', stderr); } } fprintf(stderr, "\"\n"); }else{ fprintf(stderr, "%s: %d bytes:\n", prefix, len); while(len > 0){ for(i = 0; i < 16; i++){ if(i < len){ fprintf(stderr, "%02x ", buf[i]); }else{ fprintf(stderr, " "); } if(i == 7) fputc(' ', stderr); } fprintf(stderr, " \""); for(i = 0; i < 16; i++){ if(i < len){ if(buf[i] >= 0x20 && buf[i] < 0x7f){ fputc(buf[i], stderr); }else{ fputc('.', stderr); } } } fprintf(stderr, "\"\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, long baud, 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){ fprintf(stderr, "%s: avrdoper_open(): %s\n", progname, usbErrorText(rval)); exit(1); //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, 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); if(verbose > 3) fprintf(stderr, "Sending %d bytes data chunk\n", thisLen); rval = usbSetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, (char *)buffer, reportDataSizes[lenIndex] + 2); if(rval != 0){ fprintf(stderr, "%s: avrdoper_send(): %s\n", progname, usbErrorText(rval)); exit(1); } buflen -= thisLen; buf += thisLen; } return 0; } /* ------------------------------------------------------------------------- */ static void 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){ fprintf(stderr, "%s: avrdoperFillBuffer(): %s\n", progname, usbErrorText(usbErr)); exit(1); } if(verbose > 3) fprintf(stderr, "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)){ fprintf(stderr, "%s: avrdoperFillBuffer(): internal error: buffer overflow\n", progname); exit(1); } memcpy(avrdoperRxBuffer + avrdoperRxLength, buffer + 2, len); avrdoperRxLength += len; } } 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 */ avrdoperFillBuffer(fdp); 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{ avrdoperFillBuffer(fdp); }while(avrdoperRxLength > 0); return 0; } /* ------------------------------------------------------------------------- */ static int avrdoper_set_dtr_rts(union filedescriptor *fdp, int is_on) { fprintf(stderr, "%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)) */ avrdude-6.0.1/ser_posix.c000644 000153 000000 00000025253 12216240452 014712 0ustar00jwheel000000 000000 /* * 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: ser_posix.c 1200 2013-09-03 11:05:13Z joerg_wunsch $ */ /* * 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 "serial.h" long serial_recv_timeout = 5000; /* ms */ 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 */ if (verbose > 0) fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: net_open(): Out of memory!\n", progname); return -1; } if (((pstr = strchr(hstr, ':')) == NULL) || (pstr == hstr)) { fprintf(stderr, "%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)) { fprintf(stderr, "%s: net_open(): Bad port number \"%s\"\n", progname, pstr); free(hstr); return -1; } if ((hp = gethostbyname(hstr)) == NULL) { fprintf(stderr, "%s: net_open(): unknown host \"%s\"\n", progname, hstr); free(hstr); return -1; } free(hstr); if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { fprintf(stderr, "%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))) { fprintf(stderr, "%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, long baud, 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) { fprintf(stderr, "%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, baud); if (rc) { fprintf(stderr, "%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) { fprintf(stderr, "%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, unsigned char * buf, size_t buflen) { int rc; unsigned char * p = buf; size_t len = buflen; if (!len) return 0; if (verbose > 3) { fprintf(stderr, "%s: Send: ", progname); while (buflen) { unsigned char c = *buf; if (isprint(c)) { fprintf(stderr, "%c ", c); } else { fprintf(stderr, ". "); } fprintf(stderr, "[%02x] ", c); buf++; buflen--; } fprintf(stderr, "\n"); } while (len) { rc = write(fd->ifd, p, (len > 1024) ? 1024 : len); if (rc < 0) { fprintf(stderr, "%s: ser_send(): write error: %s\n", progname, strerror(errno)); exit(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; 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) fprintf(stderr, "%s: ser_recv(): programmer is not responding\n", progname); return -1; } else if (nfds == -1) { if (errno == EINTR || errno == EAGAIN) { fprintf(stderr, "%s: ser_recv(): programmer is not responding,reselecting\n", progname); goto reselect; } else { fprintf(stderr, "%s: ser_recv(): select(): %s\n", progname, strerror(errno)); exit(1); } } rc = read(fd->ifd, p, (buflen - len > 1024) ? 1024 : buflen - len); if (rc < 0) { fprintf(stderr, "%s: ser_recv(): read error: %s\n", progname, strerror(errno)); exit(1); } p += rc; len += rc; } p = buf; if (verbose > 3) { fprintf(stderr, "%s: Recv: ", progname); while (len) { unsigned char c = *p; if (isprint(c)) { fprintf(stderr, "%c ", c); } else { fprintf(stderr, ". "); } fprintf(stderr, "[%02x] ", c); p++; len--; } fprintf(stderr, "\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; timeout.tv_sec = 0; timeout.tv_usec = 250000; if (display) { fprintf(stderr, "drain>"); } while (1) { FD_ZERO(&rfds); FD_SET(fd->ifd, &rfds); reselect: nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &timeout); if (nfds == 0) { if (display) { fprintf(stderr, "ifd, &buf, 1); if (rc < 0) { fprintf(stderr, "%s: ser_drain(): read error: %s\n", progname, strerror(errno)); exit(1); } if (display) { fprintf(stderr, "%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 */ avrdude-6.0.1/ser_win32.c000644 000153 000000 00000021632 12216240452 014507 0ustar00jwheel000000 000000 /* * 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: ser_win32.c 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ /* * Native Win32 serial interface for avrdude. */ #include "avrdude.h" #if defined(WIN32NATIVE) #include #include #include /* for isprint */ #include "serial.h" long serial_recv_timeout = 5000; /* ms */ #define W32SERBUFSIZE 1024 struct baud_mapping { long baud; DWORD speed; }; /* 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 */ if (verbose > 0) fprintf(stderr, "%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)); ctmo.ReadIntervalTimeout = timeout; ctmo.ReadTotalTimeoutMultiplier = timeout; ctmo.ReadTotalTimeoutConstant = timeout; return SetCommTimeouts(hComPort, &ctmo); } static int ser_setspeed(union filedescriptor *fd, long baud) { 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; } static int ser_open(char * port, long baud, 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. * * This is curently not implemented for Win32. */ if (strncmp(port, "net:", strlen("net:")) == 0) { fprintf(stderr, "%s: ser_open(): network connects are currently not" "implemented for Win32 environments\n", progname); return -1; } if (strncasecmp(port, "com", strlen("com")) == 0) { // prepend "\\\\.\\" to name, required for port # >= 10 newname = malloc(strlen("\\\\.\\") + strlen(port) + 1); if (newname == 0) { fprintf(stderr, "%s: ser_open(): out of memory\n", progname); exit(1); } strcpy(newname, "\\\\.\\"); strcat(newname, port); port = newname; } hComPort = CreateFile(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); fprintf(stderr, "%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); fprintf(stderr, "%s: ser_open(): can't set buffers for \"%s\"\n", progname, port); return -1; } fdp->pfd = (void *)hComPort; if (ser_setspeed(fdp, baud) != 0) { CloseHandle(hComPort); fprintf(stderr, "%s: ser_open(): can't set com-state for \"%s\"\n", progname, port); return -1; } if (!serial_w32SetTimeOut(hComPort,0)) { CloseHandle(hComPort); fprintf(stderr, "%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) { 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) { HANDLE hComPort=(HANDLE)fd->pfd; if (is_on) { EscapeCommFunction(hComPort, SETDTR); EscapeCommFunction(hComPort, SETRTS); } else { EscapeCommFunction(hComPort, CLRDTR); EscapeCommFunction(hComPort, CLRRTS); } return 0; } static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen) { size_t len = buflen; unsigned char c='\0'; DWORD written; unsigned char * b = buf; HANDLE hComPort=(HANDLE)fd->pfd; if (hComPort == INVALID_HANDLE_VALUE) { fprintf(stderr, "%s: ser_send(): port not open\n", progname); exit(1); } if (!len) return 0; if (verbose > 3) { fprintf(stderr, "%s: Send: ", progname); while (len) { c = *b; if (isprint(c)) { fprintf(stderr, "%c ", c); } else { fprintf(stderr, ". "); } fprintf(stderr, "[%02x] ", c); b++; len--; } fprintf(stderr, "\n"); } serial_w32SetTimeOut(hComPort,500); if (!WriteFile (hComPort, buf, buflen, &written, NULL)) { fprintf(stderr, "%s: ser_send(): write error: %s\n", progname, "sorry no info avail"); // TODO exit(1); } if (written != buflen) { fprintf(stderr, "%s: ser_send(): size/send mismatch\n", progname); exit(1); } return 0; } static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen) { unsigned char c; unsigned char * p = buf; DWORD read; HANDLE hComPort=(HANDLE)fd->pfd; if (hComPort == INVALID_HANDLE_VALUE) { fprintf(stderr, "%s: ser_read(): port not open\n", progname); exit(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 ); fprintf(stderr, "%s: ser_recv(): read error: %s\n", progname, (char*)lpMsgBuf); LocalFree( lpMsgBuf ); exit(1); } /* time out detected */ if (read == 0) { if (verbose > 1) fprintf(stderr, "%s: ser_recv(): programmer is not responding\n", progname); return -1; } p = buf; if (verbose > 3) { fprintf(stderr, "%s: Recv: ", progname); while (read) { c = *p; if (isprint(c)) { fprintf(stderr, "%c ", c); } else { fprintf(stderr, ". "); } fprintf(stderr, "[%02x] ", c); p++; read--; } fprintf(stderr, "\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) { fprintf(stderr, "%s: ser_drain(): port not open\n", progname); exit(1); } serial_w32SetTimeOut(hComPort,250); if (display) { fprintf(stderr, "drain>"); } while (1) { 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 ); fprintf(stderr, "%s: ser_drain(): read error: %s\n", progname, (char*)lpMsgBuf); LocalFree( lpMsgBuf ); exit(1); } if (read) { // data avail if (display) fprintf(stderr, "%02x ", buf[0]); } else { // no more data if (display) fprintf(stderr, ". */ /* $Id: solaris_ecpp.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #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 */ avrdude-6.0.1/stk500.c000644 000153 000000 00000074047 12216240452 013732 0ustar00jwheel000000 000000 /* * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2002-2004 Brian S. Dean * Copyright (C) 2008 Joerg Wunsch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * 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: stk500.c 1223 2013-09-13 14:59:15Z joerg_wunsch $ */ /* * 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 "avr.h" #include "pgm.h" #include "stk500.h" #include "stk500_private.h" #include "serial.h" #define STK500_XTAL 7372800U #define MAX_SYNC_ATTEMPTS 10 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) { fprintf(stderr, "%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; } fprintf(stderr, "%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) { fprintf(stderr, "%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) exit(1); if (buf[0] != Resp_STK_INSYNC) { fprintf(stderr, "%s: stk500_cmd(): programmer is out of sync\n", progname); exit(1); } res[0] = cmd[1]; res[1] = cmd[2]; res[2] = cmd[3]; if (stk500_recv(pgm, &res[3], 1) < 0) exit(1); if (stk500_recv(pgm, buf, 1) < 0) exit(1); if (buf[0] != Resp_STK_OK) { fprintf(stderr, "%s: stk500_cmd(): protocol error\n", progname); exit(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) { fprintf(stderr, "%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) { fprintf(stderr, "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) exit(1); if (buf[0] == Resp_STK_NOSYNC) { if (tries > 33) { fprintf(stderr, "%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) { fprintf(stderr, "%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) exit(1); if (buf[0] == Resp_STK_OK) { return 0; } else if (buf[0] == Resp_STK_NODEVICE) { fprintf(stderr, "%s: stk500_program_enable(): no device\n", progname); return -1; } if(buf[0] == Resp_STK_FAILED) { fprintf(stderr, "%s: stk500_program_enable(): failed to enter programming mode\n", progname); return -1; } fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) exit(1); if (buf[0] == Resp_STK_OK) { return 0; } else if (buf[0] == Resp_STK_NODEVICE) { fprintf(stderr, "%s: stk500_set_extended_parms(): no device\n", progname); return -1; } if(buf[0] == Resp_STK_FAILED) { fprintf(stderr, "%s: stk500_set_extended_parms(): failed to set extended " "device programming parameters\n", progname); return -1; } fprintf(stderr, "%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) exit(1); if (buf[0] == Resp_STK_NOSYNC) { if (tries > 33) { fprintf(stderr, "%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) { fprintf(stderr, "%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) exit(1); if (buf[0] == Resp_STK_OK) { return 0; } else if (buf[0] == Resp_STK_NODEVICE) { fprintf(stderr, "%s: mib510_isp(): no device\n", progname); return -1; } if (buf[0] == Resp_STK_FAILED) { fprintf(stderr, "%s: mib510_isp(): command %d failed\n", progname, cmd); return -1; } fprintf(stderr, "%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 fprintf(stderr, "%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) exit(1); if (buf[0] == Resp_STK_NOSYNC) { fprintf(stderr, "%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) { fprintf(stderr, "%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) exit(1); if (buf[0] != Resp_STK_OK) { fprintf(stderr, "%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)) { if (verbose > 1) fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500_initialize(): failed\n", progname); exit(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) exit(1); if (buf[0] == Resp_STK_NOSYNC) { if (tries > 33) { fprintf(stderr, "%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) { fprintf(stderr, "%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) exit(1); if (buf[0] == Resp_STK_OK) { return; } else if (buf[0] == Resp_STK_NODEVICE) { fprintf(stderr, "%s: stk500_disable(): no device\n", progname); return; } fprintf(stderr, "%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) { strcpy(pgm->port, port); if (serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &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, unsigned int addr) { unsigned char buf[16]; int tries; tries = 0; retry: tries++; 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) exit(1); if (buf[0] == Resp_STK_NOSYNC) { if (tries > 33) { fprintf(stderr, "%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) { fprintf(stderr, "%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) exit(1); if (buf[0] == Resp_STK_OK) { return 0; } fprintf(stderr, "%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[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 fprintf(stderr, "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, 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) exit(1); if (buf[0] == Resp_STK_NOSYNC) { if (tries > 33) { fprintf(stderr, "\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) { fprintf(stderr, "\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) exit(1); if (buf[0] != Resp_STK_OK) { fprintf(stderr, "\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, 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) exit(1); if (buf[0] == Resp_STK_NOSYNC) { if (tries > 33) { fprintf(stderr, "\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) { fprintf(stderr, "\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) exit(1); if (stk500_recv(pgm, buf, 1) < 0) exit(1); if(strcmp(ldata(lfirst(pgm->id)), "mib510") == 0) { if (buf[0] != Resp_STK_INSYNC) { fprintf(stderr, "\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) { fprintf(stderr, "\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) { fprintf(stderr, "%s: stk500_set_vtarget(): cannot obtain V[aref]\n", progname); return -1; } if (uaref > utarg) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500_set_varef(): cannot obtain V[target]\n", progname); return -1; } if (uaref > utarg) { fprintf(stderr, "%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"; fprintf(stderr, "%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])) { fprintf(stderr, "%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; fprintf(stderr, "%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; fprintf(stderr, "%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) exit(1); if (buf[0] == Resp_STK_NOSYNC) { if (tries > 33) { fprintf(stderr, "\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) { fprintf(stderr, "\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) exit(1); v = buf[0]; if (stk500_recv(pgm, buf, 1) < 0) exit(1); if (buf[0] == Resp_STK_FAILED) { fprintf(stderr, "\n%s: stk500_getparm(): parameter 0x%02x failed\n", progname, v); return -3; } else if (buf[0] != Resp_STK_OK) { fprintf(stderr, "\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) exit(1); if (buf[0] == Resp_STK_NOSYNC) { if (tries > 33) { fprintf(stderr, "\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) { fprintf(stderr, "\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) exit(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) exit(1); if (buf[0] == Resp_STK_FAILED) { fprintf(stderr, "\n%s: stk500_setparm(): parameter 0x%02x failed\n", progname, parm); return -3; } else { fprintf(stderr, "\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); fprintf(stderr, "%sHardware Version: %d\n", p, hdw); fprintf(stderr, "%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; } fprintf(stderr, "%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); fprintf(stderr, "%sVtarget : %.1f V\n", p, vtarget / 10.0); fprintf(stderr, "%sVaref : %.1f V\n", p, vadjust / 10.0); fprintf(stderr, "%sOscillator : ", p); if (osc_pscale == 0) fprintf(stderr, "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"; fprintf(stderr, "%.3f %s\n", f, unit); } fprintf(stderr, "%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, ""); } 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->page_size = 256; } avrdude-6.0.1/stk500.h000644 000153 000000 00000002213 12216240452 013721 0ustar00jwheel000000 000000 /* * 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: stk500.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #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 avrdude-6.0.1/stk500_private.h000644 000153 000000 00000010644 12216240453 015463 0ustar00jwheel000000 000000 //**** 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 ]************************** avrdude-6.0.1/stk500v2.c000644 000153 000000 00000411205 12216240452 014171 0ustar00jwheel000000 000000 /* * 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: stk500v2.c 1229 2013-09-13 21:32:00Z joerg_wunsch $ */ /* 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 #include #include "avrdude.h" #include "avr.h" #include "pgm.h" #include "stk500_private.h" // temp until all code converted #include "stk500v2.h" #include "stk500v2_private.h" #include "serial.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(...) fprintf(stderr, __VA_ARGS__) #else #define DEBUG(...) #endif #if 0 #define DEBUGRECV(...) fprintf(stderr, __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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr,"%s: stk500_send_mk2(): failed to send command to serial port\n",progname); exit(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) { unsigned char *cmdbuf; int rv; unsigned short sz; void *mycookie; sz = get_jtagisp_return_size(data[0]); if (sz == 0) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { unsigned char *cmdbuf; int rv; void *mycookie; if ((cmdbuf = malloc(len + 1)) == NULL) { fprintf(stderr, "%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) { fprintf(stderr,"%s: stk500_send(): failed to send command to serial port\n",progname); exit(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) { fprintf(stderr, "%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) { 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) { fprintf(stderr, "%s: stk500v2_jtagmkII_recv(): error in jtagmkII_recv()\n", progname); return -1; } if (rv - 1 > maxsize) { fprintf(stderr, "%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: fprintf(stderr, "%s: stk500v2_jtagmkII_recv(): failed\n", progname); return -1; case RSP_ILLEGAL_MCU_STATE: fprintf(stderr, "%s: stk500v2_jtagmkII_recv(): illegal MCU state\n", progname); return -1; default: fprintf(stderr, "%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) { 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) { fprintf(stderr, "%s: stk500v2_jtag3_recv(): error in jtagmkII_recv()\n", progname); return -1; } if (rv - 1 > maxsize) { fprintf(stderr, "%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) { fprintf(stderr, "%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; 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) ) { 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 { fprintf(stderr, "%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)) { fprintf(stderr, "%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; fprintf(stderr, "%s: stk500v2_recv(): checksum error\n", progname); return -4; } break; default: fprintf(stderr, "%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: fprintf(stderr, "%s: stk500v2_ReceiveMessage(): timeout\n", progname); return -1; } } /* while */ DEBUG("\n"); return (int)(msglen+6); } int stk500v2_getsync(PROGRAMMER * pgm) { 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++; // send the sync command and see if we can get there buf[0] = CMD_SIGN_ON; stk500v2_send(pgm, buf, 1); // try to get the response back and see where we got status = stk500v2_recv(pgm, resp, sizeof(resp)); // 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; if (verbose) fprintf(stderr, "%s: stk500v2_getsync(): got response from unknown " "programmer %s, assuming STK500\n", progname, resp + 3); PDATA(pgm)->pgmtype = PGMTYPE_STK500; } if (verbose >= 3) fprintf(stderr, "%s: stk500v2_getsync(): found %s programmer\n", progname, pgmname[PDATA(pgm)->pgmtype]); return 0; } else { if (tries > RETRIES) { fprintf(stderr, "%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) { fprintf(stderr,"%s: stk500v2_getsync(): timeout communicating with programmer\n", progname); return -1; } else goto retry; // or any other error } else { if (tries > RETRIES) { fprintf(stderr,"%s: stk500v2_getsync(): error communicating with programmer: (%d)\n", progname,status); } else goto retry; } return 0; } 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) { fprintf(stderr, "%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; } fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500v2_command(): warning: %s\n", progname, msg); } } else if (buf[1] == STATUS_CMD_OK) { return status; } else if (buf[1] == STATUS_CMD_FAILED) { fprintf(stderr, "%s: stk500v2_command(): command failed\n", progname); } else if (buf[1] == STATUS_CMD_UNKNOWN) { fprintf(stderr, "%s: stk500v2_command(): unknown command\n", progname); } else { fprintf(stderr, "%s: stk500v2_command(): unknown status 0x%02x\n", progname, buf[1]); } return -1; } } // otherwise try to sync up again status = stk500v2_getsync(pgm); if (status != 0) { if (tries > RETRIES) { fprintf(stderr,"%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) { fprintf(stderr, "%s: stk500v2_cmd(): failed to send command\n", progname); return -1; } else if (result < 6) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500v2_program_enable(): cannot get connection status\n", progname); } else { stk500v2_translate_conn_status(buf[0], msg); fprintf(stderr, "%s: stk500v2_program_enable():" " bad AVRISPmkII connection status: %s\n", progname, msg); } break; case PGMTYPE_JTAGICE3: if (buf[1] == STATUS_CMD_FAILED && (p->flags & AVRPART_HAS_DW) != 0) { void *mycookie; unsigned char cmd[4], *resp; /* Try debugWIRE, and MONCON_DISABLE */ if (verbose >= 2) fprintf(stderr, "%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) { fprintf(stderr, "%s: Failed to return from debugWIRE to ISP.\n", progname); break; } fprintf(stderr, "%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) { 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) { fprintf(stderr, "%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); } 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) { unsigned char parm[4], *resp; LNODEID ln; AVRMEM * m; void *mycookie; if ((p->flags & AVRPART_HAS_PDI) || (p->flags & AVRPART_HAS_TPI)) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500hv_initialize(): Out of memory\n", progname); return -1; } if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { fprintf(stderr, "%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)) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500hv_initialize(): Out of memory\n", progname); return -1; } if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500hv_disable(): " "failed to leave programming mode\n", progname); exit(1); } 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) { long baud = 115200; DEBUG("STK500V2: stk500v2_open()\n"); if (pgm->baudrate) 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 fprintf(stderr, "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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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) { long baud = 115200; DEBUG("STK500V2: stk600_open()\n"); if (pgm->baudrate) 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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; } if (verbose >= 2) fprintf(stderr, "%s: stk500hv_read_byte(): Sending read memory command: ", progname); result = stk500v2_command(pgm, buf, cmdlen, sizeof(buf)); if (result < 0) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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); if (verbose >= 2) fprintf(stderr, "%s: stk500isp_read_byte(): Sending read memory command: ", progname); result = stk500v2_command(pgm, buf, 6, sizeof(buf)); if (result < 0) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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 { fprintf(stderr, "%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) { buf[3] |= stk500v2_mode_for_pagesize(pagesize); 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--; } } if (verbose >= 2) fprintf(stderr, "%s: stk500hv_write_byte(): Sending write memory command: ", progname); result = stk500v2_command(pgm, buf, cmdlen, sizeof(buf)); if (result < 0) { fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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. 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. */ memset(cache_ptr, 0xff, pagesize); cache_ptr[addr & (pagesize - 1)] = data; memcpy(mem->buf + paddr, cache_ptr, pagesize); stk500v2_paged_write(pgm, p, mem, pagesize, addr, pagesize); /* Invalidate the page cache. */ *paddr_ptr = (unsigned long)-1L; 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 { fprintf(stderr, "%s: stk500isp_write_byte(): " "unsupported memory type: %s\n", progname, mem->desc); return -1; } if ((op = mem->op[AVR_OP_WRITE]) == NULL) { fprintf(stderr, "%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); if (verbose >= 2) fprintf(stderr, "%s: stk500isp_write_byte(): Sending write memory command: ", progname); result = stk500v2_command(pgm, buf, 5, sizeof(buf)); if (result < 0) { fprintf(stderr, "%s: stk500isp_write_byte(): " "timeout/error communicating with programmer\n", progname); return -1; } if (buf[0] == CMD_PROGRAM_FUSE_ISP) { /* * The JTAGICE3 needs one leave progmode / enter progmode cycle * after writing fuses, before being able to read them back. */ buf[0] = CMD_LEAVE_PROGMODE_ISP; buf[1] = 1; // preDelay; buf[2] = 1; // postDelay; stk500v2_command(pgm, buf, 3, sizeof(buf)); pgm->program_enable(pgm, p); } return 0; } static int stk500v2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned int page_size, unsigned int addr, unsigned int n_bytes) { 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; 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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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 += 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)){ if (stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift)) < 0) return -1; } last_addr=addr; memcpy(buf+10,m->buf+addr, block_size); result = stk500v2_command(pgm,buf,block_size+10, sizeof(buf)); if (result < 0) { fprintf(stderr, "%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) { commandbuf[3] |= stk500v2_mode_for_pagesize(page_size); 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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500hv_paged_load: read command failed\n", progname); return -1; } #if 0 for (i = 0; i < page_size; i++) { fprintf(stderr, "%02X", buf[2 + i]); if (i % 16 == 15) fprintf(stderr, "\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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500v2_set_vtarget(): cannot obtain V[aref]\n", progname); return -1; } if (uaref > utarg) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500v2_set_varef(): cannot obtain V[target]\n", progname); return -1; } if (uaref > utarg) { fprintf(stderr, "%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"; fprintf(stderr, "%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])) { fprintf(stderr, "%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; } if (verbose > 2) fprintf(stderr, "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; } fprintf(stderr, "%s: stk500v2_mode_for_pagesize(): invalid pagesize: %u\n", progname, pagesize); exit(1); } /* * 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) { fprintf(stderr, "%s: stk500v2_set_vtarget(): cannot obtain V[aref][0]\n", progname); return -1; } if (uaref > (unsigned)utarg * 10) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500v2_set_vtarget(): cannot obtain V[aref][1]\n", progname); return -1; } if (uaref > (unsigned)utarg * 10) { fprintf(stderr, "%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) { fprintf(stderr, "%s: stk500v2_set_varef(): cannot obtain V[target]\n", progname); return -1; } if (uaref > (unsigned)utarg * 10) { fprintf(stderr, "%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: fprintf(stderr, "%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) { fprintf(stderr,"%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) { fprintf(stderr, "\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) fprintf(stderr, "%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 && verbose > 2) { fprintf(stderr, "%s: Skipping paramter 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) { fprintf(stderr,"%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) { fprintf(stderr, "\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) { fprintf(stderr, "%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); fprintf(stderr, "%sHardware Version: %d\n", p, hdw); fprintf(stderr, "%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); fprintf(stderr, "%sFirmware Version Slave 1: %d.%02d\n", p, maj_s1, min_s1); fprintf(stderr, "%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; } fprintf(stderr, "%sTopcard : %s\n", p, topcard_name); } else if (PDATA(pgm)->pgmtype == PGMTYPE_STK600) { stk500v2_getparm(pgm, PARAM_ROUTINGCARD_ID, &topcard); fprintf(stderr, "%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); fprintf(stderr, "%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); fprintf(stderr, "%sRC_ID table rev : %d\n", p, rev); stk500v2_getparm2(pgm, PARAM2_EC_ID_TABLE_REV, &rev); fprintf(stderr, "%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; 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) { mycookie = pgm->cookie; pgm->cookie = PDATA(pgm)->chained_pdata; jtagmkII_getparm(pgm, PAR_OCD_VTARGET, vtarget_jtag); pgm->cookie = mycookie; fprintf(stderr, "%sVtarget : %.1f V\n", p, b2_to_u16(vtarget_jtag) / 1000.0); } else if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE3) { mycookie = pgm->cookie; pgm->cookie = PDATA(pgm)->chained_pdata; jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VTARGET, vtarget_jtag, 2); pgm->cookie = mycookie; fprintf(stderr, "%sVtarget : %.1f V\n", p, b2_to_u16(vtarget_jtag) / 1000.0); } else { stk500v2_getparm(pgm, PARAM_VTARGET, &vtarget); fprintf(stderr, "%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); fprintf(stderr, "%sSCK period : %.1f us\n", p, stk500v2_sck_to_us(pgm, sck_duration)); fprintf(stderr, "%sVaref : %.1f V\n", p, vadjust / 10.0); fprintf(stderr, "%sOscillator : ", p); if (osc_pscale == 0) fprintf(stderr, "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); fprintf(stderr, "%.3f %s\n", f, unit); } break; case PGMTYPE_AVRISP_MKII: case PGMTYPE_JTAGICE_MKII: stk500v2_getparm(pgm, PARAM_SCK_DURATION, &sck_duration); fprintf(stderr, "%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); fprintf(stderr, "%sSCK period : %.2f us\n", p, (float)(1E6 / (1000.0 * sck))); } } break; case PGMTYPE_STK600: stk500v2_getparm2(pgm, PARAM2_AREF0, &varef); fprintf(stderr, "%sVaref 0 : %.2f V\n", p, varef / 100.0); stk500v2_getparm2(pgm, PARAM2_AREF1, &varef); fprintf(stderr, "%sVaref 1 : %.2f V\n", p, varef / 100.0); stk500v2_getparm2(pgm, PARAM2_SCK_DURATION, &sck_stk600); fprintf(stderr, "%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); fprintf(stderr, "%sOscillator : %.3f %s\n", p, f, unit); break; default: fprintf(stderr, "%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) { fprintf(stderr, "%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) { long baud; void *mycookie; int rv; if (verbose >= 2) fprintf(stderr, "%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. */ 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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) fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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; if (verbose >= 2) fprintf(stderr, "%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) { long baud; void *mycookie; if (verbose >= 2) fprintf(stderr, "%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. */ 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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) { fprintf(stderr, "%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) { long baud; void *mycookie; if (verbose >= 2) fprintf(stderr, "%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. */ 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; baud = 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 fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &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) { fprintf(stderr, "%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) { long baud; void *mycookie; int rv; if (verbose >= 2) fprintf(stderr, "%s: stk500v2_jtag3_open()\n", progname); /* * 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; baud = USB_DEVICE_JTAGICE3; 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; #else fprintf(stderr, "avrdude was compiled without usb support.\n"); return -1; #endif } strcpy(pgm->port, port); if (serial_open(port, baud, &pgm->fd)==-1) { return -1; } /* * drain any extraneous input */ stk500v2_drain(pgm, 0); mycookie = pgm->cookie; pgm->cookie = PDATA(pgm)->chained_pdata; if ((rv = jtag3_getsync(pgm, 42)) != 0) { if (rv != JTAGII_GETSYNC_FAIL_GRACEFUL) fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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 { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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 { fprintf(stderr, "%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) { fprintf(stderr, "%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 { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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 { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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 { fprintf(stderr, "%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) { fprintf(stderr, "%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 = avr_read_byte_default; pgm->write_byte = avr_write_byte_default; 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 = avr_read_byte_default; pgm->write_byte = avr_write_byte_default; /* * 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; } 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 = avr_read_byte_default; pgm->write_byte = avr_write_byte_default; /* * 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 = avr_read_byte_default; pgm->write_byte = avr_write_byte_default; /* * 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 = avr_read_byte_default; pgm->write_byte = avr_write_byte_default; /* * 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; } avrdude-6.0.1/stk500v2.h000644 000153 000000 00000004124 12216240452 014174 0ustar00jwheel000000 000000 /* * 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: stk500v2.h 1119 2012-12-03 15:52:38Z joerg_wunsch $ */ #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); #ifdef __cplusplus } #endif #endif avrdude-6.0.1/tpi.h000644 000153 000000 00000003746 12216240452 013503 0ustar00jwheel000000 000000 /* * 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: tpi.h 1167 2013-05-06 12:49:26Z hweisbach $ */ #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 avrdude-6.0.1/stk500v2_private.h000644 000153 000000 00000027323 12216240452 015734 0ustar00jwheel000000 000000 //**** 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 //* //************************************************************************** #include "pgm.h" // *****************[ 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 // *** 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; }; avrdude-6.0.1/stk500generic.c000644 000153 000000 00000004603 12216240452 015256 0ustar00jwheel000000 000000 /* * 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: stk500generic.c 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ /* * 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 "pgm.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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: successfully opened stk500v2 device -- please use -c stk500v2\n", progname); return 0; } fprintf(stderr, "%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; } avrdude-6.0.1/stk500generic.h000644 000153 000000 00000001742 12216240452 015264 0ustar00jwheel000000 000000 /* * 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: stk500generic.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #ifndef stk500generic_h__ #define stk500generic_h__ extern const char stk500generic_desc[]; void stk500generic_initpgm (PROGRAMMER * pgm); #endif avrdude-6.0.1/usbasp.c000644 000153 000000 00000107110 12216240452 014165 0ustar00jwheel000000 000000 /* * 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: usbasp.c 1196 2013-09-02 20:22:53Z joerg_wunsch $ */ /* * 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 "avr.h" #include "pgm.h" #include "usbasp.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) { fprintf(stderr, "%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) { fprintf(stderr, "%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; fprintf(stderr, "%s => ", progbuf); for (i = 0; i < buffersize; i++) fprintf(stderr, "[%02x] ", buffer[i]); fprintf(stderr, "\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, (char *)buffer, buffersize & 0xffff, 5000); if(nbytes < 0){ fprintf(stderr, "%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){ fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror()); return -1; } #endif if (verbose > 3 && receive && nbytes > 0) { int i; fprintf(stderr, "%s<= ", progbuf); for (i = 0; i < nbytes; i++) fprintf(stderr, "[%02x] ", buffer[i]); fprintf(stderr, "\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 1) fprintf(stderr, "%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) */ r = libusb_get_string_descriptor_ascii(handle, descriptor.iProduct & 0xff, string, sizeof(string)); if (r < 0) { if ((productName != NULL) && (productName[0] != 0)) { errorCode = USB_ERROR_IO; fprintf(stderr, "%s: Warning: cannot query product for device: %s\n", progname, strerror(libusb_to_errno(r))); } } else { if (verbose > 1) fprintf(stderr, "%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; fprintf(stderr, "%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; fprintf(stderr, "%s: Warning: cannot query manufacturer for device: %s\n", progname, usb_strerror()); } } else { if (verbose > 1) fprintf(stderr, "%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; fprintf(stderr, "%s: Warning: cannot query product for device: %s\n", progname, usb_strerror()); } } else { if (verbose > 1) fprintf(stderr, "%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) { if (verbose > 2) fprintf(stderr, "%s: usbasp_open(\"%s\")\n", progname, port); /* usb_init will be done in usbOpenDevice */ if (usbOpenDevice(&PDATA(pgm)->usbhandle, pgm->usbvid, pgm->usbvendor, pgm->usbpid, pgm->usbproduct) != 0) { /* try alternatives */ if(strcasecmp(ldata(lfirst(pgm->id)), "usbasp") == 0) { /* for id usbasp autodetect some variants */ if(strcasecmp(port, "nibobee") == 0) { fprintf(stderr, "%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) { fprintf(stderr, "%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 */ fprintf(stderr, "%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 */ } fprintf(stderr, "%s: error: could not find USB device with vid=0x%x pid=0x%x", progname, pgm->usbvid, pgm->usbpid); if (pgm->usbvendor[0] != 0) { fprintf(stderr, " vendor='%s'", pgm->usbvendor); } if (pgm->usbproduct[0] != 0) { fprintf(stderr, " product='%s'", pgm->usbproduct); } fprintf(stderr,"\n"); return -1; } return 0; } static void usbasp_close(PROGRAMMER * pgm) { if (verbose > 2) fprintf(stderr, "%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); if (verbose > 2) fprintf(stderr, "%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) { if (verbose > 2) fprintf(stderr, "%s: usbasp_cpi_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); fprintf(stderr, "%s: error: wrong responds size\n", progname); return -1; } if (verbose > 2) { if (verbose > 3) fprintf(stderr, "%s: usbasp_cpi_cmd()", progname); fprintf(stderr, " => 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; if (verbose > 2) fprintf(stderr, "%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)) { fprintf(stderr, "%s: error: programm 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]; if (verbose > 2) fprintf(stderr, "%s: usbasp_chip_erase()\n", progname); if (p->op[AVR_OP_CHIP_ERASE] == NULL) { fprintf(stderr, "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; if (verbose > 2) fprintf(stderr, "%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) { fprintf(stderr, "%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; if (verbose > 2) fprintf(stderr, "%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; blockflags |= USBASP_BLOCKFLAG_LAST; } 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) { fprintf(stderr, "%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]; if (verbose > 2) fprintf(stderr, "%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 */ if (verbose >= 1) fprintf(stderr, "%s: auto set sck period (because given equals null)\n", progname); } else { int sckfreq = 1 / sckperiod; /* sck in Hz */ int usefreq = 0; if (verbose >= 2) fprintf(stderr, "%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; fprintf(stderr, "%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)) { fprintf(stderr, "%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) { fprintf(stderr, "%s: error: wrong responds size\n", progname); return -1; } return temp[0]; } static int usbasp_tpi_nvm_waitbusy(PROGRAMMER * pgm) { int retry; if (verbose > 2) fprintf(stderr, "%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; if (verbose > 2) fprintf(stderr, " ready\n"); return 0; } if (verbose > 2) fprintf(stderr, " failure\n"); return -1; } static int usbasp_tpi_cmd(PROGRAMMER * pgm, const unsigned char *cmd, unsigned char *res) { fprintf(stderr, "%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; if (verbose > 2) fprintf(stderr, "%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) { fprintf(stderr, "%s: error: programm enable: target doesn't answer.\n", progname); return -1; } return 0; } static int usbasp_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p) { if (verbose > 2) fprintf(stderr, "%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; if (verbose > 2) fprintf(stderr, "%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) { fprintf(stderr, "%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; if (verbose > 2) fprintf(stderr, "%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) { fprintf(stderr, "%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; if (verbose > 2) fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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/"; avrdude-6.0.1/usbasp.h000644 000153 000000 00000010310 12216240452 014165 0ustar00jwheel000000 000000 /* * 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: usbasp.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #ifndef usbasp_h #define usbasp_h #include "avrpart.h" /* USB identifiers */ #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 */ /* 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 */ avrdude-6.0.1/usbdevs.h000644 000153 000000 00000003523 12216240452 014353 0ustar00jwheel000000 000000 /* * 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: usbdevs.h 1126 2012-12-18 10:45:23Z joerg_wunsch $ */ /* * 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 /* 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 */ avrdude-6.0.1/usb_libusb.c000644 000153 000000 00000032132 12216240453 015023 0ustar00jwheel000000 000000 /* * 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_libusb.c 1228 2013-09-13 19:56:07Z joerg_wunsch $ */ /* * 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 "serial.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, long baud, 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; 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) { fprintf(stderr, "%s: usbdev_open(): invalid serial number \"%s\"\n", progname, serno); exit(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 == USB_VENDOR_ATMEL && dev->descriptor.idProduct == (unsigned short)baud) { udev = usb_open(dev); if (udev) { /* yeah, we found something */ if (usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string)) < 0) { fprintf(stderr, "%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) exit(1); /* no chance */ else strcpy(string, "[unknown]"); } if (usb_get_string_simple(udev, dev->descriptor.iProduct, product, sizeof(product)) < 0) { fprintf(stderr, "%s: usb_open(): cannot read product name \"%s\"\n", progname, usb_strerror()); strcpy(product, "[unnamed product]"); } if (verbose) fprintf(stderr, "%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) { if (verbose > 2) fprintf(stderr, "%s: usbdev_open(): serial number doesn't match\n", progname); usb_close(udev); continue; } } if (dev->config == NULL) { fprintf(stderr, "%s: usbdev_open(): USB device has no configuration\n", progname); goto trynext; } if (usb_set_configuration(udev, dev->config[0].bConfigurationValue)) { fprintf(stderr, "%s: usbdev_open(): error setting configuration %d: %s\n", progname, dev->config[0].bConfigurationValue, usb_strerror()); goto trynext; } usb_interface = dev->config[0].interface[0].altsetting[0].bInterfaceNumber; if (usb_claim_interface(udev, usb_interface)) { fprintf(stderr, "%s: usbdev_open(): error claiming interface %d: %s\n", progname, usb_interface, usb_strerror()); 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[0].altsetting[0].bNumEndpoints; i++) { int possible_ep = dev->config[0].interface[0].altsetting[0]. endpoint[i].bEndpointAddress; if ((possible_ep & USB_ENDPOINT_DIR_MASK) != 0) { if (verbose > 1) { fprintf(stderr, "%s: usbdev_open(): using read endpoint 0x%02x\n", progname, possible_ep); } fd->usb.rep = possible_ep; break; } } if (fd->usb.rep == 0) { fprintf(stderr, "%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[0].altsetting[0].bNumEndpoints; i++) { if ((dev->config[0].interface[0].altsetting[0].endpoint[i].bEndpointAddress == fd->usb.rep || dev->config[0].interface[0].altsetting[0].endpoint[i].bEndpointAddress == fd->usb.wep) && dev->config[0].interface[0].altsetting[0].endpoint[i].wMaxPacketSize < fd->usb.max_xfer) { if (verbose != 0) fprintf(stderr, "%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[0].altsetting[0].endpoint[i].wMaxPacketSize, dev->config[0].interface[0].altsetting[0].endpoint[i].bEndpointAddress); fd->usb.max_xfer = dev->config[0].interface[0].altsetting[0].endpoint[i].wMaxPacketSize; } } return 0; trynext: usb_close(udev); } else fprintf(stderr, "%s: usbdev_open(): cannot open device: %s\n", progname, usb_strerror()); } } } fprintf(stderr, "%s: usbdev_open(): did not find any%s USB device \"%s\"\n", progname, serno? " (matching)": "", port); exit(1); } static void usbdev_close(union filedescriptor *fd) { usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle; (void)usb_release_interface(udev, usb_interface); #if !( defined(__FreeBSD__) ) // || ( defined(__APPLE__) && defined(__MACH__) ) ) /* * 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, unsigned char *bp, size_t mlen) { usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle; int rv; int i = mlen; unsigned char * p = bp; int tx_size; /* * 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; rv = usb_bulk_write(udev, fd->usb.wep, (char *)bp, tx_size, 10000); if (rv != tx_size) { fprintf(stderr, "%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 (tx_size == fd->usb.max_xfer); if (verbose > 3) { fprintf(stderr, "%s: Sent: ", progname); while (i) { unsigned char c = *p; if (isprint(c)) { fprintf(stderr, "%c ", c); } else { fprintf(stderr, ". "); } fprintf(stderr, "[%02x] ", c); p++; i--; } fprintf(stderr, "\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 rv; rv = usb_bulk_read(udev, ep, usbbuf, maxsize, 10000); if (rv < 0) { if (verbose > 1) fprintf(stderr, "%s: usb_fill_buf(): usb_bulk_read() error %s\n", progname, 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; for (i = 0; nbytes > 0;) { if (buflen <= bufptr) { if (usb_fill_buf(udev, fd->usb.max_xfer, fd->usb.rep) < 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) { fprintf(stderr, "%s: Recv: ", progname); while (i) { unsigned char c = *p; if (isprint(c)) { fprintf(stderr, "%c ", c); } else { fprintf(stderr, ". "); } fprintf(stderr, "[%02x] ", c); p++; i--; } fprintf(stderr, "\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 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) { fprintf(stderr, "Short event len = %d, ignored.\n", rv); /* fallthrough */ } } n = 0; do { rv = usb_bulk_read(udev, fd->usb.rep, usbbuf, fd->usb.max_xfer, 10000); if (rv < 0) { if (verbose > 1) fprintf(stderr, "%s: usbdev_recv_frame(): usb_bulk_read(): %s\n", progname, usb_strerror()); return -1; } if (rv <= nbytes) { memcpy (buf, usbbuf, rv); buf += rv; } n += rv; nbytes -= rv; } while (rv == fd->usb.max_xfer); if (nbytes < 0) return -1; printout: if (verbose > 3) { i = n & USB_RECV_LENGTH_MASK; fprintf(stderr, "%s: Recv: ", progname); while (i) { unsigned char c = *p; if (isprint(c)) { fprintf(stderr, "%c ", c); } else { fprintf(stderr, ". "); } fprintf(stderr, "[%02x] ", c); p++; i--; } fprintf(stderr, "\n"); } return n; } static int usbdev_drain(union filedescriptor *fd, int display) { usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle; int rv; do { rv = usb_bulk_read(udev, fd->usb.rep, usbbuf, fd->usb.max_xfer, 100); if (rv > 0 && verbose >= 4) fprintf(stderr, "%s: usbdev_drain(): flushed %d characters\n", progname, rv); } while (rv > 0); 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 */ avrdude-6.0.1/usbtiny.h000644 000153 000000 00000005332 12216240452 014375 0ustar00jwheel000000 000000 /* * 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 #include "avrpart.h" // 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 // 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 */ avrdude-6.0.1/usbtiny.c000644 000153 000000 00000043306 12216240453 014374 0ustar00jwheel000000 000000 /* * 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 "avr.h" #include "pgm.h" #include "config.h" #include "usbtiny.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) { fprintf(stderr, "%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){ fprintf(stderr, "\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++; } fprintf(stderr, "\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) { fprintf(stderr, "%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) { fprintf(stderr, "\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) { fprintf( stderr, "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; if (pgm->usbpid) pid = pgm->usbpid; 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? if(verbose) fprintf(stderr, "%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) { fprintf(stderr, "%s: Warning: cannot open USB device: %s\n", progname, usb_strerror()); continue; } } } } if(NULL != name && NULL == dev_name) { fprintf(stderr, "%s: Error: Invalid -P value: '%s'\n", progname, name); fprintf(stderr, "%sUse -P usb:bus:device\n", progbuf); return -1; } if (!PDATA(pgm)->usb_handle) { fprintf( stderr, "%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; if (verbose) { fprintf(stderr, "%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; if (verbose) { fprintf(stderr, "%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"); if (verbose > 1) { // print out the data we sent and received fprintf(stderr, "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) { fprintf(stderr, "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) { fprintf(stderr, "%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"; avrdude-6.0.1/update.h000644 000153 000000 00000002771 12216240453 014167 0ustar00jwheel000000 000000 /* * 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: update.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #ifndef update_h #define update_h enum { DEVICE_READ, DEVICE_WRITE, DEVICE_VERIFY }; enum updateflags { UF_NONE = 0, UF_NOWRITE = 1, UF_AUTO_ERASE = 2, }; typedef struct update_t { char * memtype; int op; char * filename; int format; } UPDATE; #ifdef __cplusplus extern "C" { #endif extern UPDATE * parse_op(char * s); extern UPDATE * dup_update(UPDATE * upd); extern UPDATE * new_update(int op, char * memtype, int filefmt, char * filename); extern void free_update(UPDATE * upd); extern int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags flags); #ifdef __cplusplus } #endif #endif avrdude-6.0.1/update.c000644 000153 000000 00000023374 12216240452 014163 0ustar00jwheel000000 000000 /* * 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: update.c 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #include #include #include #include #include #include "avrdude.h" #include "avr.h" #include "config.h" #include "confwin.h" #include "fileio.h" #include "update.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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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 { fprintf(stderr, "%s: invalid I/O mode '%c' in update specification\n", progname, *p); fprintf(stderr, " 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 != ':') { fprintf(stderr, "%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: fprintf(stderr, "%s: invalid file format '%s' in update specifier\n", progname, p); free(upd->memtype); free(upd); return NULL; } } if (upd->filename == NULL) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "\"%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) { fprintf(stderr, "%s: reading %s memory:\n", progname, mem->desc); } report_progress(0,1,"Reading"); rc = avr_read(pgm, p, upd->memtype, 0); if (rc < 0) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: writing %s (%d bytes):\n", progname, mem->desc, 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) { fprintf(stderr, "%s: failed to write %s memory, rc=%d\n", progname, mem->desc, rc); return -1; } vsize = rc; if (quell_progress < 2) { fprintf(stderr, "%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) { fprintf(stderr, "%s: verifying %s memory against %s:\n", progname, mem->desc, upd->filename); fprintf(stderr, "%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) { fprintf(stderr, "%s: read from file '%s' failed\n", progname, upd->filename); return -1; } v = avr_dup_part(p); size = rc; if (quell_progress < 2) { fprintf(stderr, "%s: input file %s contains %d bytes\n", progname, upd->filename, size); fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: verifying ...\n", progname); } rc = avr_verify(p, v, upd->memtype, size); if (rc < 0) { fprintf(stderr, "%s: verification error; content mismatch\n", progname); pgm->err_led(pgm, ON); return -1; } if (quell_progress < 2) { fprintf(stderr, "%s: %d bytes of %s verified\n", progname, rc, mem->desc); } pgm->vfy_led(pgm, OFF); } else { fprintf(stderr, "%s: invalid update operation (%d) requested\n", progname, upd->op); return -1; } return 0; } avrdude-6.0.1/wiring.h000644 000153 000000 00000001650 12216240452 014176 0ustar00jwheel000000 000000 /* * 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: wiring.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #ifndef wiring_h__ #define wiring_h__ extern const char wiring_desc[]; void wiring_initpgm(PROGRAMMER * pgm); #endif avrdude-6.0.1/wiring.c000644 000153 000000 00000014215 12216240452 014172 0ustar00jwheel000000 000000 /* * 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: wiring.c 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ /* * 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 "pgm.h" #include "stk500v2_private.h" #include "stk500v2.h" #include "serial.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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: wiring_parseextparms(): invalid snooze time '%s'\n", progname, extended_param); rv = -1; continue; } if (verbose >= 2) { fprintf(stderr, "%s: wiring_parseextparms(): snooze time set to %d ms\n", progname, newsnooze); } WIRINGPDATA(mycookie)->snoozetime = newsnooze; continue; } fprintf(stderr, "%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; strcpy(pgm->port, port); serial_open(port, pgm->baudrate ? pgm->baudrate: 115200, &pgm->fd); /* If we have a snoozetime, then we wait and do NOT toggle DTR/RTS */ if (WIRINGPDATA(mycookie)->snoozetime > 0) { timetosnooze = WIRINGPDATA(mycookie)->snoozetime; if (verbose >= 2) { fprintf(stderr, "%s: wiring_open(): snoozing for %d ms\n", progname, timetosnooze); } while (timetosnooze--) usleep(1000); if (verbose >= 2) { fprintf(stderr, "%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. */ if (verbose >= 2) { fprintf(stderr, "%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. */ if (verbose >= 2) { fprintf(stderr, "%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; } avrdude-6.0.1/main.c000644 000153 000000 00000113777 12216240453 013635 0ustar00jwheel000000 000000 /* * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2000-2005 Brian S. Dean * Copyright 2007-2013 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: main.c 1243 2013-09-18 05:58:44Z joerg_wunsch $ */ /* * 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 #include #include "avr.h" #include "config.h" #include "confwin.h" #include "fileio.h" #include "lists.h" #include "par.h" #include "pindefs.h" #include "term.h" #include "safemode.h" #include "update.h" #include "pgm_type.h" /* Get VERSION from ac_cfg.h */ char * version = VERSION; char * progname; char progbuf[PATH_MAX]; /* temporary buffer of spaces the same length as progname; used for lining up multiline messages */ 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; /* * 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) { fprintf(stderr, "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) { fprintf (stderr, "\n%s | ", hdr); last = 0; done = 0; } else { while ((cnt > last) && (done == 0)) { fprintf (stderr, "#"); cnt -= 2; } } if ((percent == 100) && (done == 0)) { fprintf (stderr, " | 100%% %0.2fs\n\n", etime); 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 void cleanup_main(void) { 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(); } /* * main routine */ int main(int argc, char * argv []) { 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],'/'); #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) { fprintf(stderr, "%s: cannot initialize updater list\n", progname); exit(1); } extended_params = lcreat(NULL, 0); if (extended_params == NULL) { fprintf(stderr, "%s: cannot initialize extended parameter list\n", progname); exit(1); } additional_config_files = lcreat(NULL, 0); if (additional_config_files == NULL) { fprintf(stderr, "%s: cannot initialize additional config files list\n", progname); exit(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': fprintf(stderr, "%s: erase cycle counter no longer supported\n", progname); break; case 'Y': fprintf(stderr, "%s: erase cycle counter no longer supported\n", progname); break; case '?': /* help */ usage(); exit(0); break; default: fprintf(stderr, "%s: invalid option -%c\n\n", progname, ch); usage(); exit(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 ); } } if (verbose) { /* * Print out an identifying string so folks can tell what version * they are running */ fprintf(stderr, "\n%s: Version %s, compiled on %s at %s\n" "%sCopyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/\n" "%sCopyright (c) 2007-2009 Joerg Wunsch\n\n", progname, version, __DATE__, __TIME__, progbuf, progbuf); } if (verbose) { fprintf(stderr, "%sSystem wide configuration file is \"%s\"\n", progbuf, sys_config); } rc = read_config(sys_config); if (rc) { fprintf(stderr, "%s: error reading system wide configuration file \"%s\"\n", progname, sys_config); exit(1); } if (usr_config[0] != 0) { if (verbose) { fprintf(stderr, "%sUser configuration file is \"%s\"\n", progbuf, usr_config); } rc = stat(usr_config, &sb); if ((rc < 0) || ((sb.st_mode & S_IFREG) == 0)) { if (verbose) { fprintf(stderr, "%sUser configuration file does not exist or is not a " "regular file, skipping\n", progbuf); } } else { rc = read_config(usr_config); if (rc) { fprintf(stderr, "%s: error reading user configuration file \"%s\"\n", progname, usr_config); exit(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); if (verbose) { fprintf(stderr, "%sAdditional configuration file is \"%s\"\n", progbuf, p); } rc = read_config(p); if (rc) { fprintf(stderr, "%s: error reading additional configuration file \"%s\"\n", progname, p); exit(1); } } } // set bitclock from configuration files unless changed by command line if (default_bitclock > 0 && bitclock == 0.0) { bitclock = default_bitclock; } if (verbose) { fprintf(stderr, "\n"); } if (partdesc) { if (strcmp(partdesc, "?") == 0) { fprintf(stderr, "\n"); fprintf(stderr,"Valid parts are:\n"); list_parts(stderr, " ", part_list); fprintf(stderr, "\n"); exit(1); } } if (programmer) { if (strcmp(programmer, "?") == 0) { fprintf(stderr, "\n"); fprintf(stderr,"Valid programmers are:\n"); list_programmers(stderr, " ", programmers); fprintf(stderr,"\n"); exit(1); } if (strcmp(programmer, "?type") == 0) { fprintf(stderr, "\n"); fprintf(stderr,"Valid programmer types are:\n"); list_programmer_types(stderr, " "); fprintf(stderr,"\n"); exit(1); } } if (programmer[0] == 0) { fprintf(stderr, "\n%s: no programmer has been specified on the command line " "or the config file\n", progname); fprintf(stderr, "%sSpecify a programmer using the -c option and try again\n\n", progbuf); exit(1); } pgm = locate_programmer(programmers, programmer); if (pgm == NULL) { fprintf(stderr,"\n"); fprintf(stderr, "%s: Can't find programmer id \"%s\"\n", progname, programmer); fprintf(stderr,"\nValid programmers are:\n"); list_programmers(stderr, " ", programmers); fprintf(stderr,"\n"); exit(1); } if (pgm->initpgm) { pgm->initpgm(pgm); } else { fprintf(stderr, "\n%s: Can't initialize the programmer.\n\n", progname); exit(1); } if (pgm->setup) { pgm->setup(pgm); } if (pgm->teardown) { atexit(exithook); } if (lsize(extended_params) > 0) { if (pgm->parseextparams == NULL) { fprintf(stderr, "%s: WARNING: Programmer doesn't support extended parameters," " -x option(s) ignored\n", progname); } else { if (pgm->parseextparams(pgm, extended_params) < 0) { fprintf(stderr, "%s: Error parsing extended parameter list\n", progname); exit(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) { fprintf(stderr, "%s: No AVR part has been specified, use \"-p Part\"\n\n", progname); fprintf(stderr,"Valid parts are:\n"); list_parts(stderr, " ", part_list); fprintf(stderr, "\n"); exit(1); } p = locate_part(part_list, partdesc); if (p == NULL) { fprintf(stderr, "%s: AVR Part \"%s\" not found.\n\n", progname, partdesc); fprintf(stderr,"Valid parts are:\n"); list_parts(stderr, " ", part_list); fprintf(stderr, "\n"); exit(1); } if (exitspecs != NULL) { if (pgm->parseexitspecs == NULL) { fprintf(stderr, "%s: WARNING: -E option not supported by this programmer type\n", progname); exitspecs = NULL; } else if (pgm->parseexitspecs(pgm, exitspecs) < 0) { usage(); exit(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) { fprintf(stderr, "\n%s: failed to initialize memories\n", progname); exit(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"; if (verbose >= 2) { fprintf(stderr, "%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) { fprintf(stderr, "%s: out of memory\n", progname); exit(1); } } } /* * open the programmer */ if (port[0] == 0) { fprintf(stderr, "\n%s: no port has been specified on the command line " "or the config file\n", progname); fprintf(stderr, "%sSpecify a port using the -P option and try again\n\n", progbuf); exit(1); } if (verbose) { fprintf(stderr, "%sUsing Port : %s\n", progbuf, port); fprintf(stderr, "%sUsing Programmer : %s\n", progbuf, programmer); if ((strcmp(pgm->type, "avr910") == 0)) { fprintf(stderr, "%savr910_devcode (avrdude.conf) : ", progbuf); if(p->avr910_devcode)fprintf(stderr, "0x%x\n", p->avr910_devcode); else fprintf(stderr, "none\n"); } } if (baudrate != 0) { if (verbose) { fprintf(stderr, "%sOverriding Baud Rate : %d\n", progbuf, baudrate); } pgm->baudrate = baudrate; } if (bitclock != 0.0) { if (verbose) { fprintf(stderr, "%sSetting bit clk period : %.1f\n", progbuf, bitclock); } pgm->bitclock = bitclock * 1e-6; } if (ispdelay != 0) { if (verbose) { fprintf(stderr, "%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) { fprintf(stderr, "%s: programmer does not support RC oscillator calibration\n", progname); exitrc = 1; } else { fprintf(stderr, "%s: performing RC oscillator calibration\n", progname); exitrc = pgm->perform_osccal(pgm); } if (exitrc == 0 && quell_progress < 2) { fprintf(stderr, "%s: calibration value is now stored in EEPROM at address 0\n", progname); } goto main_exit; } if (verbose) { avr_display(stderr, p, progbuf, verbose); fprintf(stderr, "\n"); programmer_display(pgm, progbuf); } if (quell_progress < 2) { fprintf(stderr, "\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) { fprintf(stderr, "%s: initialization failed, rc=%d\n", progname, rc); if (!ovsigck) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: error reading signature data, rc=%d\n", progname, rc); exitrc = 1; goto main_exit; } } sig = avr_locate_mem(p, "signature"); if (sig == NULL) { fprintf(stderr, "%s: WARNING: signature data not defined for device \"%s\"\n", progname, p->desc); } if (sig != NULL) { int ff, zz; if (quell_progress < 2) { fprintf(stderr, "%s: Device signature = 0x", progname); } ff = zz = 1; for (i=0; isize; i++) { if (quell_progress < 2) { fprintf(stderr, "%02x", sig->buf[i]); } if (sig->buf[i] != 0xff) ff = 0; if (sig->buf[i] != 0x00) zz = 0; } if (ff || zz) { if (++attempt < 3) { waittime *= 5; if (quell_progress < 2) { fprintf(stderr, " (retrying)\n"); } goto sig_again; } if (quell_progress < 2) { fprintf(stderr, "\n"); } fprintf(stderr, "%s: Yikes! Invalid device signature.\n", progname); if (!ovsigck) { fprintf(stderr, "%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) { fprintf(stderr, "\n"); } } if (sig->size != 3 || sig->buf[0] != p->signature[0] || sig->buf[1] != p->signature[1] || sig->buf[2] != p->signature[2]) { fprintf(stderr, "%s: Expected signature for %s is %02X %02X %02X\n", progname, p->desc, p->signature[0], p->signature[1], p->signature[2]); if (!ovsigck) { fprintf(stderr, "%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, verbose); if (rc != 0) { //Check if the programmer just doesn't support reading if (rc == -5) { if (verbose > 0) { fprintf(stderr, "%s: safemode: Fuse reading not support by programmer.\n" " Safemode disabled.\n", progname); } safemode = 0; } else { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%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) { fprintf(stderr, "%s: conflicting -e and -n options specified, NOT erasing chip\n", progname); } else { if (quell_progress < 2) { fprintf(stderr, "%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) { fprintf(stderr, "\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, verbose) != 0) { /* Uh-oh.. try once more to read back fuses */ if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse, &safemodeafter_efuse, &safemodeafter_fuse, pgm, p, verbose) != 0) { fprintf(stderr, "%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; fprintf(stderr, "%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, verbose) == 0) { fprintf(stderr, "%s: safemode: and is now rescued\n", progname); } else { fprintf(stderr, "%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; fprintf(stderr, "%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, verbose) == 0) { fprintf(stderr, "%s: safemode: and is now rescued\n", progname); } else { fprintf(stderr, "%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; fprintf(stderr, "%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, verbose) == 0) { fprintf(stderr, "%s: safemode: and is now rescued\n", progname); } else { fprintf(stderr, "%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; fprintf(stderr, "%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, verbose) == 0) { fprintf(stderr, "%s: safemode: and is now rescued\n", progname); } else { fprintf(stderr, "%s: and COULD NOT be changed\n", progname); failures++; } } } if (quell_progress < 2) { fprintf(stderr, "%s: safemode: ", progname); if (failures == 0) { fprintf(stderr, "Fuses OK (H:%02X, E:%02X, L:%02X)\n", safemode_efuse, safemode_hfuse, safemode_lfuse); } else { fprintf(stderr, "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) { fprintf(stderr, "\n%s done. Thank you.\n\n", progname); } return exitrc; } avrdude-6.0.1/term.c000644 000153 000000 00000052506 12216240452 013647 0ustar00jwheel000000 000000 /* * 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: term.c 1211 2013-09-08 19:31:48Z joerg_wunsch $ */ #include "ac_cfg.h" #include #include #include #include #include #if defined(HAVE_LIBREADLINE) #if !defined(WIN32NATIVE) # include # include #endif #endif #include "avrdude.h" #include "avr.h" #include "config.h" #include "lists.h" #include "pgm.h" #include "pindefs.h" #include "ppi.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))) { fprintf(stderr, "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) { fprintf(stderr, "\"%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])) { fprintf(stderr, "%s (dump): can't parse address \"%s\"\n", progname, argv[2]); return -1; } len = strtol(argv[3], &e, 0); if (*e || (e == argv[3])) { fprintf(stderr, "%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 { fprintf(stderr, "%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) { fprintf(stderr, "%s (dump): out of memory\n", progname); return -1; } for (i=0; iread_byte(pgm, p, mem, addr+i, &buf[i]); if (rc != 0) { fprintf(stderr, "error reading %s address 0x%05lx of part %s\n", mem->desc, addr+i, p->desc); if (rc == -1) fprintf(stderr, "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) { fprintf(stderr, "Usage: write " " ... byteN>\n"); return -1; } memtype = argv[1]; mem = avr_locate_mem(p, memtype); if (mem == NULL) { fprintf(stderr, "\"%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])) { fprintf(stderr, "%s (write): can't parse address \"%s\"\n", progname, argv[2]); return -1; } if (addr > maxsize) { fprintf(stderr, "%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) { fprintf(stderr, "%s (write): selected address and # bytes exceed " "range for %s memory\n", progname, memtype); return -1; } buf = malloc(len); if (buf == NULL) { fprintf(stderr, "%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]) { fprintf(stderr, "%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) { fprintf(stderr, "The %s programmer does not support direct ISP commands.\n", pgm->type); return -1; } if (spi_mode && (pgm->spi == NULL)) { fprintf(stderr, "The %s programmer does not support direct SPI transfers.\n", pgm->type); return -1; } if ((argc > 5) || ((argc < 5) && (!spi_mode))) { fprintf(stderr, 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 */ fprintf(stderr, "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) { fprintf(stderr, "error reading signature data, rc=%d\n", rc); } m = avr_locate_mem(p, "signature"); if (m == NULL) { fprintf(stderr, "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) { fprintf(stderr, "%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) { fprintf(stderr, "Usage: vtarg \n"); return -1; } v = strtod(argv[1], &endp); if (endp == argv[1]) { fprintf(stderr, "%s (vtarg): can't parse voltage \"%s\"\n", progname, argv[1]); return -1; } if (pgm->set_vtarget == NULL) { fprintf(stderr, "%s (vtarg): the %s programmer cannot set V[target]\n", progname, pgm->type); return -2; } if ((rc = pgm->set_vtarget(pgm, v)) != 0) { fprintf(stderr, "%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) { fprintf(stderr, "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 { fprintf(stderr, "%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) { fprintf(stderr, "%s (fosc): the %s programmer cannot set oscillator frequency\n", progname, pgm->type); return -2; } if ((rc = pgm->set_fosc(pgm, v)) != 0) { fprintf(stderr, "%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) { fprintf(stderr, "Usage: sck \n"); return -1; } v = strtod(argv[1], &endp); if (endp == argv[1]) { fprintf(stderr, "%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) { fprintf(stderr, "%s (sck): the %s programmer cannot set SCK period\n", progname, pgm->type); return -2; } if ((rc = pgm->set_sck_period(pgm, v)) != 0) { fprintf(stderr, "%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) { fprintf(stderr, "Usage: varef [channel] \n"); return -1; } if (argc == 2) { chan = 0; v = strtod(argv[1], &endp); if (endp == argv[1]) { fprintf(stderr, "%s (varef): can't parse voltage \"%s\"\n", progname, argv[1]); return -1; } } else { chan = strtoul(argv[1], &endp, 10); if (endp == argv[1]) { fprintf(stderr, "%s (varef): can't parse channel \"%s\"\n", progname, argv[1]); return -1; } v = strtod(argv[2], &endp); if (endp == argv[2]) { fprintf(stderr, "%s (varef): can't parse voltage \"%s\"\n", progname, argv[2]); return -1; } } if (pgm->set_varef == NULL) { fprintf(stderr, "%s (varef): the %s programmer cannot set V[aref]\n", progname, pgm->type); return -2; } if ((rc = pgm->set_varef(pgm, chan, v)) != 0) { fprintf(stderr, "%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, pgm->pinno[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, pgm->pinno[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) { fprintf(stderr, "Usage: verbose []\n"); return -1; } if (argc == 1) { fprintf(stderr, "Verbosity level: %d\n", verbose); return 0; } nverb = strtol(argv[1], &endp, 0); if (endp == argv[2]) { fprintf(stderr, "%s: can't parse verbosity level \"%s\"\n", progname, argv[2]); return -1; } if (nverb < 0) { fprintf(stderr, "%s: verbosity level must be positive: %d\n", progname, nverb); return -1; } verbose = nverb; fprintf(stderr, "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; } avrdude-6.0.1/term.h000644 000153 000000 00000002075 12216240452 013650 0ustar00jwheel000000 000000 /* * 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: term.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ #ifndef term_h #define term_h #include "avr.h" #include "pgm.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 avrdude-6.0.1/ChangeLog-2001000644 000153 000000 00000045604 12216240452 014667 0ustar00jwheel000000 000000 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. avrdude-6.0.1/ChangeLog-2002000644 000153 000000 00000016440 12216240452 014664 0ustar00jwheel000000 000000 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). avrdude-6.0.1/ChangeLog-2003000644 000153 000000 00000110444 12216240452 014664 0ustar00jwheel000000 000000 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 Weier * 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! avrdude-6.0.1/ChangeLog-2004-2006000644 000153 000000 00000155202 12216240452 015253 0ustar00jwheel000000 000000 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. avrdude-6.0.1/ChangeLog-2007000644 000153 000000 00000026153 12216240452 014673 0ustar00jwheel000000 000000 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. avrdude-6.0.1/ChangeLog-2008000644 000153 000000 00000015736 12216240452 014701 0ustar00jwheel000000 000000 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. avrdude-6.0.1/ChangeLog-2009000644 000153 000000 00000033201 12216240452 014665 0ustar00jwheel000000 000000 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.) avrdude-6.0.1/doc/000755 000153 000000 00000000000 12216243567 013303 5ustar00jwheel000000 000000 avrdude-6.0.1/ChangeLog-2010000644 000153 000000 00000027475 12216240453 014676 0ustar00jwheel000000 000000 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. avrdude-6.0.1/ChangeLog-2011000644 000153 000000 00000042057 12216240453 014670 0ustar00jwheel000000 000000 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. avrdude-6.0.1/ChangeLog-2012000644 000153 000000 00000063575 12216240453 014701 0ustar00jwheel000000 000000 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. avrdude-6.0.1/avrdude.1000644 000153 000000 00000111762 12216240452 014250 0ustar00jwheel000000 000000 .\" .\" avrdude - A Downloader/Uploader for AVR device programmers .\" Copyright (C) 2001, 2002, 2003, 2005 - 2013 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.1 1226 2013-09-13 17:22:38Z joerg_wunsch $ .\" .Dd DATE September 13, 2013 .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 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 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. If .Nm avrdude does not know about a part that you have, simply add it to the config file (be sure and submit a patch back to the author so that it can be incorporated for the next version). See the sample config file for the format. 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. 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. If you have a programmer or part that .Nm avrdude does not know about, you can add it to the config file (be sure and submit a patch back to the author so that it can be incorporated for the next version). 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. .Em This feature is currently not implemented for Win32 systems. .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 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 and JTAGICE3 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 Programmers accepting extended parameters .Bl -tag -offset indent -width indent .It Ar JTAG ICE mkII .It Ar JTAGICE3 .It Ar AVR Dragon When using the JTAG ICE mkII, JTAGICE3 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 compatability 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. This setting is only available in ASCII mode. (The lower limit was chosen so the CPU frequency is at least for four times the SPI frequency which is in ASCII mode 30kHz.) .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 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'. avrdude-6.0.1/avrdude.spec000644 000153 000000 00000005324 12216243117 015037 0ustar00jwheel000000 000000 ## -*- mode: rpm-spec; -*- ## ## $Id: avrdude.spec.in 558 2005-11-29 20:28:51Z joerg_wunsch $ ## ## avrdude.spec. Generated from avrdude.spec.in by configure. ## %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: 6.0.1 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. avrdude-6.0.1/bootstrap000755 000153 000000 00000000471 12216240452 014471 0ustar00jwheel000000 000000 #! /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 ${ACLOCAL} ${AUTOHEADER} ${AUTOCONF} ${AUTOMAKE} -a -c avrdude-6.0.1/windows/000755 000153 000000 00000000000 12216243567 014230 5ustar00jwheel000000 000000 avrdude-6.0.1/windows/Makefile.in000644 000153 000000 00000045633 12216243011 016270 0ustar00jwheel000000 000000 # Makefile.in generated by automake 1.14 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # # 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: Makefile.am 1107 2012-11-20 14:03:50Z joerg_wunsch $ # # # This Makefile will only be used on windows based systems. # VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = loaddrv$(EXEEXT) subdir = windows DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/ac_cfg.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_loaddrv_OBJECTS = loaddrv.$(OBJEXT) loaddrv_OBJECTS = $(am_loaddrv_OBJECTS) loaddrv_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(loaddrv_SOURCES) DIST_SOURCES = $(loaddrv_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_PAR_PORT = @DEFAULT_PAR_PORT@ DEFAULT_SER_PORT = @DEFAULT_SER_PORT@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DIST_SUBDIRS_AC = @DIST_SUBDIRS_AC@ DOC_INST_DIR = @DOC_INST_DIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_WARNINGS = @ENABLE_WARNINGS@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBELF = @LIBELF@ LIBFTDI = @LIBFTDI@ LIBFTDI1 = @LIBFTDI1@ LIBHID = @LIBHID@ LIBOBJS = @LIBOBJS@ LIBPTHREAD = @LIBPTHREAD@ LIBS = @LIBS@ LIBUSB = @LIBUSB@ LIBUSB_1_0 = @LIBUSB_1_0@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBDIRS_AC = @SUBDIRS_AC@ VERSION = @VERSION@ WINDOWS_DIRS = @WINDOWS_DIRS@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ local_install_list = \ giveio.sys \ install_giveio.bat \ remove_giveio.bat \ status_giveio.bat EXTRA_DIST = \ giveio.c \ $(local_install_list) loaddrv_SOURCES = \ loaddrv.c \ loaddrv.h all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu windows/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu windows/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) loaddrv$(EXEEXT): $(loaddrv_OBJECTS) $(loaddrv_DEPENDENCIES) $(EXTRA_loaddrv_DEPENDENCIES) @rm -f loaddrv$(EXEEXT) $(AM_V_CCLD)$(LINK) $(loaddrv_OBJECTS) $(loaddrv_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loaddrv.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-exec-local install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-local .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ clean-binPROGRAMS clean-generic cscopelist-am ctags ctags-am \ distclean distclean-compile distclean-generic distclean-tags \ distdir dvi dvi-am html html-am info info-am install \ install-am install-binPROGRAMS install-data install-data-am \ install-dvi install-dvi-am install-exec install-exec-am \ install-exec-local install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-binPROGRAMS uninstall-local 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 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: avrdude-6.0.1/windows/Makefile.am000644 000153 000000 00000003061 12216240451 016251 0ustar00jwheel000000 000000 # # 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: Makefile.am 1107 2012-11-20 14:03:50Z joerg_wunsch $ # # # 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 avrdude-6.0.1/windows/loaddrv.c000644 000153 000000 00000040413 12216240451 016016 0ustar00jwheel000000 000000 // 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 avrdude-6.0.1/windows/loaddrv.h000644 000153 000000 00000000616 12216240451 016024 0ustar00jwheel000000 000000 #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 avrdude-6.0.1/windows/giveio.c000644 000153 000000 00000012722 12216240451 015647 0ustar00jwheel000000 000000 /********************************************************************* 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; } avrdude-6.0.1/windows/giveio.sys000644 000153 000000 00000012200 12216240451 016232 0ustar00jwheel000000 000000 MZ@ !L!This program cannot be run in DOS mode. $PEL4c1z 2@ @U3 4T.texth@@ `.rdataT`@@.dataJ ` @.idata@.relocH ` @BU 0VW$}f= th PEЍMPQMQMq_^]t$P5 jjL$33҉AA3U\VWL}f$} h f ui= 3E̍MP5Q֍MEQP֍MUQujjj"RjV|"EMPQ|F8F4@3_^]%%4c1 4c104c10@\DosDevices\giveio\Device\giveio2Jbx2JbxIoDeleteDeviceIoDeleteSymbolicLinkRtlInitUnicodeStringrMmFreeNonCachedMemoryKe386SetIoAccessMapKe386IoSetAccessProcessIoGetCurrentProcessIofCompleteRequestIoCreateSymbolicLinkIoCreateDeviceiMmAllocateNonCachedMemoryntoskrnl.exe4N2[2h2o2}2222222233,3B3i3{33333z @.filegC:\dale\ddj\distrib\giveio\giveio.c.data .text@_.data$&.text .debug$F.text.debug$F.text.debug$F.text .dataL.idata$6.idata$5X.idata$4X.idata$6X.idata$5X.idata$4X.idata$6X.idata$5X.idata$4X.idata$6X.idata$5X.idata$4X.idata$6X.idata$5X.idata$4X.idata$6X.textX.idata$5X.idata$4X.idata$6xX.textX.idata$5X.idata$4X.idata$6bX.idata$5X.idata$4X.idata$6JX.idata$5X.idata$4X.idata$62X.idata$5X.idata$4X.idata$6X.idata$5X.idata$4X.idata$6Xheader@     ^ #$L5j,Hfend_DriverEntry@8_GiveioUnload@4??_C@_1CG@GPLM@?$AA?2?$AAD?$AAo?$AAs?$AAD?$AAe?$AAv?$AAi?$AAc?$AAe?$AAs?$AA?2?$AAg?$AAi?$AAv?$AAe?$AAi?$AAo?$AA?$AA?$AA?$AA@_SetIOPermissionMap@4_GiveIO@0_GiveioCreateDispatch@8??_C@_1BO@MPDE@?$AA?2?$AAD?$AAe?$AAv?$AAi?$AAc?$AAe?$AA?2?$AAg?$AAi?$AAv?$AAe?$AAi?$AAo?$AA?$AA?$AA?$AA?$AA?$AA?$AAo?$AA?$AA?$AA?$AA@_IOPM_local__imp__IoDeleteDevice@4__imp__IoDeleteSymbolicLink@4__imp__RtlInitUnicodeString@8__imp__MmFreeNonCachedMemory@8_Ke386SetIoAccessMap@8_Ke386IoSetAccessProcess@8__imp__IoGetCurrentProcess@0__imp_@IofCompleteRequest@8__imp__IoCreateSymbolicLink@8__imp__IoCreateDevice@28__imp__MmAllocateNonCachedMemory@4_IoDeleteDevice@4ntoskrnl_IMPORT_DESCRIPTOR_IoDeleteSymbolicLink@4_RtlInitUnicodeString@8_MmFreeNonCachedMemory@8__imp__Ke386SetIoAccessMap@8__imp__Ke386IoSetAccessProcess@8_IoGetCurrentProcess@0@IofCompleteRequest@8_IoCreateSymbolicLink@8_IoCreateDevice@28_MmAllocateNonCachedMemory@4NULL_IMPORT_DESCRIPTORntoskrnl_NULL_THUNK_DATA܈.\i386\free\giveio.sys avrdude-6.0.1/windows/install_giveio.bat000755 000153 000000 00000001363 12216240451 017723 0ustar00jwheel000000 000000 @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 avrdude-6.0.1/windows/remove_giveio.bat000755 000153 000000 00000000345 12216240451 017551 0ustar00jwheel000000 000000 @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 avrdude-6.0.1/windows/status_giveio.bat000755 000153 000000 00000000254 12216240451 017576 0ustar00jwheel000000 000000 @set DIRVERNAME=giveio @loaddrv status %DIRVERNAME% @if errorlevel 1 goto error @goto exit :error @echo ERROR: Status querry for %DIRVERNAME% failed :exit avrdude-6.0.1/doc/Makefile.in000644 000153 000000 00000065470 12216243010 015343 0ustar00jwheel000000 000000 # Makefile.in generated by automake 1.14 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # # 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: Makefile.am 1107 2012-11-20 14:03:50Z joerg_wunsch $ # VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = doc DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am mdate-sh \ $(srcdir)/version.texi $(srcdir)/stamp-vti texinfo.tex TODO ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/ac_cfg.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = AM_V_DVIPS = $(am__v_DVIPS_@AM_V@) am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@) am__v_DVIPS_0 = @echo " DVIPS " $@; am__v_DVIPS_1 = AM_V_MAKEINFO = $(am__v_MAKEINFO_@AM_V@) am__v_MAKEINFO_ = $(am__v_MAKEINFO_@AM_DEFAULT_V@) am__v_MAKEINFO_0 = @echo " MAKEINFO" $@; am__v_MAKEINFO_1 = AM_V_INFOHTML = $(am__v_INFOHTML_@AM_V@) am__v_INFOHTML_ = $(am__v_INFOHTML_@AM_DEFAULT_V@) am__v_INFOHTML_0 = @echo " INFOHTML" $@; am__v_INFOHTML_1 = AM_V_TEXI2DVI = $(am__v_TEXI2DVI_@AM_V@) am__v_TEXI2DVI_ = $(am__v_TEXI2DVI_@AM_DEFAULT_V@) am__v_TEXI2DVI_0 = @echo " TEXI2DVI" $@; am__v_TEXI2DVI_1 = AM_V_TEXI2PDF = $(am__v_TEXI2PDF_@AM_V@) am__v_TEXI2PDF_ = $(am__v_TEXI2PDF_@AM_DEFAULT_V@) am__v_TEXI2PDF_0 = @echo " TEXI2PDF" $@; am__v_TEXI2PDF_1 = AM_V_texinfo = $(am__v_texinfo_@AM_V@) am__v_texinfo_ = $(am__v_texinfo_@AM_DEFAULT_V@) am__v_texinfo_0 = -q am__v_texinfo_1 = AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = INFO_DEPS = $(srcdir)/avrdude.info am__TEXINFO_TEX_DIR = $(srcdir) DVIS = avrdude.dvi PDFS = avrdude.pdf PSS = avrdude.ps HTMLS = avrdude.html TEXINFOS = avrdude.texi TEXI2DVI = texi2dvi TEXI2PDF = $(TEXI2DVI) --pdf --batch MAKEINFOHTML = $(MAKEINFO) --html AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) DVIPS = dvips am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__installdirs = "$(DESTDIR)$(infodir)" am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_PAR_PORT = @DEFAULT_PAR_PORT@ DEFAULT_SER_PORT = @DEFAULT_SER_PORT@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DIST_SUBDIRS_AC = @DIST_SUBDIRS_AC@ DOC_INST_DIR = @DOC_INST_DIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENABLE_WARNINGS = @ENABLE_WARNINGS@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBELF = @LIBELF@ LIBFTDI = @LIBFTDI@ LIBFTDI1 = @LIBFTDI1@ LIBHID = @LIBHID@ LIBOBJS = @LIBOBJS@ LIBPTHREAD = @LIBPTHREAD@ LIBS = @LIBS@ LIBUSB = @LIBUSB@ LIBUSB_1_0 = @LIBUSB_1_0@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBDIRS_AC = @SUBDIRS_AC@ VERSION = @VERSION@ WINDOWS_DIRS = @WINDOWS_DIRS@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ 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: all-am .SUFFIXES: .SUFFIXES: .dvi .html .info .pdf .ps .texi $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu doc/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): .texi.info: $(AM_V_MAKEINFO)restore=: && backupdir="$(am__leading_dot)am$$$$" && \ am__cwd=`pwd` && $(am__cd) $(srcdir) && \ rm -rf $$backupdir && mkdir $$backupdir && \ if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \ if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \ done; \ else :; fi && \ cd "$$am__cwd"; \ if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ -o $@ $<; \ then \ rc=0; \ $(am__cd) $(srcdir); \ else \ rc=$$?; \ $(am__cd) $(srcdir) && \ $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \ fi; \ rm -rf $$backupdir; exit $$rc .texi.dvi: $(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ $(TEXI2DVI) $(AM_V_texinfo) --build-dir=$(@:.dvi=.t2d) -o $@ $(AM_V_texidevnull) \ $< .texi.pdf: $(AM_V_TEXI2PDF)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ $(TEXI2PDF) $(AM_V_texinfo) --build-dir=$(@:.pdf=.t2p) -o $@ $(AM_V_texidevnull) \ $< .texi.html: $(AM_V_MAKEINFO)rm -rf $(@:.html=.htp) $(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ -o $(@:.html=.htp) $<; \ then \ rm -rf $@ && mv $(@:.html=.htp) $@; \ else \ rm -rf $(@:.html=.htp); exit 1; \ fi $(srcdir)/avrdude.info: avrdude.texi $(srcdir)/version.texi avrdude.dvi: avrdude.texi $(srcdir)/version.texi avrdude.pdf: avrdude.texi $(srcdir)/version.texi avrdude.html: avrdude.texi $(srcdir)/version.texi $(srcdir)/version.texi: $(srcdir)/stamp-vti $(srcdir)/stamp-vti: avrdude.texi $(top_srcdir)/configure @(dir=.; test -f ./avrdude.texi || dir=$(srcdir); \ set `$(SHELL) $(srcdir)/mdate-sh $$dir/avrdude.texi`; \ echo "@set UPDATED $$1 $$2 $$3"; \ echo "@set UPDATED-MONTH $$2 $$3"; \ echo "@set EDITION $(VERSION)"; \ echo "@set VERSION $(VERSION)") > vti.tmp @cmp -s vti.tmp $(srcdir)/version.texi \ || (echo "Updating $(srcdir)/version.texi"; \ cp vti.tmp $(srcdir)/version.texi) -@rm -f vti.tmp @cp $(srcdir)/version.texi $@ mostlyclean-vti: -rm -f vti.tmp maintainer-clean-vti: -rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi .dvi.ps: $(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ $(DVIPS) $(AM_V_texinfo) -o $@ $< uninstall-dvi-am: @$(NORMAL_UNINSTALL) @list='$(DVIS)'; test -n "$(dvidir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \ rm -f "$(DESTDIR)$(dvidir)/$$f"; \ done uninstall-html-am: @$(NORMAL_UNINSTALL) @list='$(HTMLS)'; test -n "$(htmldir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \ rm -rf "$(DESTDIR)$(htmldir)/$$f"; \ done uninstall-info-am: @$(PRE_UNINSTALL) @if test -d '$(DESTDIR)$(infodir)' && $(am__can_run_installinfo); then \ list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \ if install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \ then :; else test ! -f "$(DESTDIR)$(infodir)/$$relfile" || exit 1; fi; \ done; \ else :; fi @$(NORMAL_UNINSTALL) @list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \ (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \ echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \ rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \ else :; fi); \ done uninstall-pdf-am: @$(NORMAL_UNINSTALL) @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(pdfdir)/$$f'"; \ rm -f "$(DESTDIR)$(pdfdir)/$$f"; \ done uninstall-ps-am: @$(NORMAL_UNINSTALL) @list='$(PSS)'; test -n "$(psdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \ rm -f "$(DESTDIR)$(psdir)/$$f"; \ done dist-info: $(INFO_DEPS) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ list='$(INFO_DEPS)'; \ for base in $$list; do \ case $$base in \ $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \ esac; \ if test -f $$base; then d=.; else d=$(srcdir); fi; \ base_i=`echo "$$base" | sed 's|\.info$$||;s|$$|.i|'`; \ for file in $$d/$$base $$d/$$base-[0-9] $$d/$$base-[0-9][0-9] $$d/$$base_i[0-9] $$d/$$base_i[0-9][0-9]; do \ if test -f $$file; then \ relfile=`expr "$$file" : "$$d/\(.*\)"`; \ test -f "$(distdir)/$$relfile" || \ cp -p $$file "$(distdir)/$$relfile"; \ else :; fi; \ done; \ done mostlyclean-aminfo: -rm -rf avrdude.t2d avrdude.t2p clean-aminfo: -test -z "avrdude.dvi avrdude.pdf avrdude.ps avrdude.html" \ || rm -rf avrdude.dvi avrdude.pdf avrdude.ps avrdude.html maintainer-clean-aminfo: @list='$(INFO_DEPS)'; for i in $$list; do \ i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \ echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \ rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \ done tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-info check-am: all-am check: check-am all-am: Makefile $(INFO_DEPS) all-local installdirs: for dir in "$(DESTDIR)$(infodir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-aminfo clean-generic clean-local mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: $(DVIS) html-am: $(HTMLS) info: info-am info-am: $(INFO_DEPS) install-data-am: install-data-local install-info-am install-dvi: install-dvi-am install-dvi-am: $(DVIS) @$(NORMAL_INSTALL) @list='$(DVIS)'; test -n "$(dvidir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(dvidir)'"; \ $(MKDIR_P) "$(DESTDIR)$(dvidir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dvidir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(dvidir)" || exit $$?; \ done install-exec-am: install-html: install-html-am install-html-am: $(HTMLS) @$(NORMAL_INSTALL) @list='$(HTMLS)'; list2=; test -n "$(htmldir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)'"; \ $(MKDIR_P) "$(DESTDIR)$(htmldir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \ $(am__strip_dir) \ d2=$$d$$p; \ if test -d "$$d2"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \ $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ echo " $(INSTALL_DATA) '$$d2'/* '$(DESTDIR)$(htmldir)/$$f'"; \ $(INSTALL_DATA) "$$d2"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \ else \ list2="$$list2 $$d2"; \ fi; \ done; \ test -z "$$list2" || { echo "$$list2" | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \ done; } install-info: install-info-am install-info-am: $(INFO_DEPS) @$(NORMAL_INSTALL) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(infodir)'"; \ $(MKDIR_P) "$(DESTDIR)$(infodir)" || exit 1; \ fi; \ for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ esac; \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \ for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \ $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \ if test -f $$ifile; then \ echo "$$ifile"; \ else : ; fi; \ done; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(infodir)" || exit $$?; done @$(POST_INSTALL) @if $(am__can_run_installinfo); then \ list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\ install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\ done; \ else : ; fi install-man: install-pdf: install-pdf-am install-pdf-am: $(PDFS) @$(NORMAL_INSTALL) @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pdfdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pdfdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pdfdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pdfdir)" || exit $$?; done install-ps: install-ps-am install-ps-am: $(PSS) @$(NORMAL_INSTALL) @list='$(PSS)'; test -n "$(psdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(psdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(psdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(psdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(psdir)" || exit $$?; done installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-aminfo \ maintainer-clean-generic maintainer-clean-vti mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-aminfo mostlyclean-generic mostlyclean-vti pdf: pdf-am pdf-am: $(PDFS) ps: ps-am ps-am: $(PSS) uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \ uninstall-local uninstall-pdf-am uninstall-ps-am .MAKE: install-am install-strip .PHONY: all all-am all-local check check-am clean clean-aminfo \ clean-generic clean-local cscopelist-am ctags-am dist-info \ distclean distclean-generic distdir dvi dvi-am html html-am \ info info-am install install-am install-data install-data-am \ install-data-local install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-aminfo maintainer-clean-generic \ maintainer-clean-vti mostlyclean mostlyclean-aminfo \ mostlyclean-generic mostlyclean-vti pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am uninstall-dvi-am \ uninstall-html-am uninstall-info-am uninstall-local \ uninstall-pdf-am uninstall-ps-am 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) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: avrdude-6.0.1/doc/Makefile.am000644 000153 000000 00000006012 12216240451 015323 0ustar00jwheel000000 000000 # # 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: Makefile.am 1107 2012-11-20 14:03:50Z joerg_wunsch $ # 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) avrdude-6.0.1/doc/mdate-sh000555 000153 000000 00000013637 12216240532 014730 0ustar00jwheel000000 000000 #!/bin/sh # Get modification time of a file or directory and pretty-print it. scriptversion=2010-08-21.06; # UTC # Copyright (C) 1995-2013 Free Software Foundation, Inc. # written by Ulrich Drepper , June 1995 # # 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, 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 to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST fi case $1 in '') echo "$0: No file. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: mdate-sh [--help] [--version] FILE Pretty-print the modification day of FILE, in the format: 1 January 1970 Report bugs to . EOF exit $? ;; -v | --v*) echo "mdate-sh $scriptversion" exit $? ;; esac error () { echo "$0: $1" >&2 exit 1 } # Prevent date giving response in another language. LANG=C export LANG LC_ALL=C export LC_ALL LC_TIME=C export LC_TIME # GNU ls changes its time format in response to the TIME_STYLE # variable. Since we cannot assume 'unset' works, revert this # variable to its documented default. if test "${TIME_STYLE+set}" = set; then TIME_STYLE=posix-long-iso export TIME_STYLE fi save_arg1=$1 # Find out how to get the extended ls output of a file or directory. if ls -L /dev/null 1>/dev/null 2>&1; then ls_command='ls -L -l -d' else ls_command='ls -l -d' fi # Avoid user/group names that might have spaces, when possible. if ls -n /dev/null 1>/dev/null 2>&1; then ls_command="$ls_command -n" fi # A 'ls -l' line looks as follows on OS/2. # drwxrwx--- 0 Aug 11 2001 foo # This differs from Unix, which adds ownership information. # drwxrwx--- 2 root root 4096 Aug 11 2001 foo # # To find the date, we split the line on spaces and iterate on words # until we find a month. This cannot work with files whose owner is a # user named "Jan", or "Feb", etc. However, it's unlikely that '/' # will be owned by a user whose name is a month. So we first look at # the extended ls output of the root directory to decide how many # words should be skipped to get the date. # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below. set x`$ls_command /` # Find which argument is the month. month= command= until test $month do test $# -gt 0 || error "failed parsing '$ls_command /' output" shift # Add another shift to the command. command="$command shift;" case $1 in Jan) month=January; nummonth=1;; Feb) month=February; nummonth=2;; Mar) month=March; nummonth=3;; Apr) month=April; nummonth=4;; May) month=May; nummonth=5;; Jun) month=June; nummonth=6;; Jul) month=July; nummonth=7;; Aug) month=August; nummonth=8;; Sep) month=September; nummonth=9;; Oct) month=October; nummonth=10;; Nov) month=November; nummonth=11;; Dec) month=December; nummonth=12;; esac done test -n "$month" || error "failed parsing '$ls_command /' output" # Get the extended ls output of the file or directory. set dummy x`eval "$ls_command \"\\\$save_arg1\""` # Remove all preceding arguments eval $command # Because of the dummy argument above, month is in $2. # # On a POSIX system, we should have # # $# = 5 # $1 = file size # $2 = month # $3 = day # $4 = year or time # $5 = filename # # On Darwin 7.7.0 and 7.6.0, we have # # $# = 4 # $1 = day # $2 = month # $3 = year or time # $4 = filename # Get the month. case $2 in Jan) month=January; nummonth=1;; Feb) month=February; nummonth=2;; Mar) month=March; nummonth=3;; Apr) month=April; nummonth=4;; May) month=May; nummonth=5;; Jun) month=June; nummonth=6;; Jul) month=July; nummonth=7;; Aug) month=August; nummonth=8;; Sep) month=September; nummonth=9;; Oct) month=October; nummonth=10;; Nov) month=November; nummonth=11;; Dec) month=December; nummonth=12;; esac case $3 in ???*) day=$1;; *) day=$3; shift;; esac # Here we have to deal with the problem that the ls output gives either # the time of day or the year. case $3 in *:*) set `date`; eval year=\$$# case $2 in Jan) nummonthtod=1;; Feb) nummonthtod=2;; Mar) nummonthtod=3;; Apr) nummonthtod=4;; May) nummonthtod=5;; Jun) nummonthtod=6;; Jul) nummonthtod=7;; Aug) nummonthtod=8;; Sep) nummonthtod=9;; Oct) nummonthtod=10;; Nov) nummonthtod=11;; Dec) nummonthtod=12;; esac # For the first six month of the year the time notation can also # be used for files modified in the last year. if (expr $nummonth \> $nummonthtod) > /dev/null; then year=`expr $year - 1` fi;; *) year=$3;; esac # The result. echo $day $month $year # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: avrdude-6.0.1/doc/version.texi000644 000153 000000 00000000147 12216243245 015656 0ustar00jwheel000000 000000 @set UPDATED 18 September 2013 @set UPDATED-MONTH September 2013 @set EDITION 6.0.1 @set VERSION 6.0.1 avrdude-6.0.1/doc/stamp-vti000644 000153 000000 00000000147 12216243245 015145 0ustar00jwheel000000 000000 @set UPDATED 18 September 2013 @set UPDATED-MONTH September 2013 @set EDITION 6.0.1 @set VERSION 6.0.1 avrdude-6.0.1/doc/texinfo.tex000444 000153 000000 00001167036 12216240532 015502 0ustar00jwheel000000 000000 % texinfo.tex -- TeX macros to handle Texinfo files. % % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % \def\texinfoversion{2013-02-01.11} % % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, % 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. % % This texinfo.tex file 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 texinfo.tex file 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, when this file is read by TeX when processing % a Texinfo source document, you may use the result without % restriction. This Exception is an additional permission under section 7 % of the GNU General Public License, version 3 ("GPLv3"). % % Please try the latest version of texinfo.tex before submitting bug % reports; you can get the latest version from: % http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or % http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or % http://www.gnu.org/software/texinfo/ (the Texinfo home page) % The texinfo.tex in any given distribution could well be out % of date, so if that's what you're using, please check. % % Send bug reports to bug-texinfo@gnu.org. Please include including a % complete document in each bug report with which we can reproduce the % problem. Patches are, of course, greatly appreciated. % % To process a Texinfo manual with TeX, it's most reliable to use the % texi2dvi shell script that comes with the distribution. For a simple % manual foo.texi, however, you can get away with this: % tex foo.texi % texindex foo.?? % tex foo.texi % tex foo.texi % dvips foo.dvi -o # or whatever; this makes foo.ps. % The extra TeX runs get the cross-reference information correct. % Sometimes one run after texindex suffices, and sometimes you need more % than two; texi2dvi does it as many times as necessary. % % It is possible to adapt texinfo.tex for other languages, to some % extent. You can get the existing language-specific files from the % full Texinfo distribution. % % The GNU Texinfo home page is http://www.gnu.org/software/texinfo. \message{Loading texinfo [version \texinfoversion]:} % If in a .fmt file, print the version number % and turn on active characters that we couldn't do earlier because % they might have appeared in the input file name. \everyjob{\message{[Texinfo version \texinfoversion]}% \catcode`+=\active \catcode`\_=\active} \chardef\other=12 % We never want plain's \outer definition of \+ in Texinfo. % For @tex, we can use \tabalign. \let\+ = \relax % Save some plain tex macros whose names we will redefine. \let\ptexb=\b \let\ptexbullet=\bullet \let\ptexc=\c \let\ptexcomma=\, \let\ptexdot=\. \let\ptexdots=\dots \let\ptexend=\end \let\ptexequiv=\equiv \let\ptexexclam=\! \let\ptexfootnote=\footnote \let\ptexgtr=> \let\ptexhat=^ \let\ptexi=\i \let\ptexindent=\indent \let\ptexinsert=\insert \let\ptexlbrace=\{ \let\ptexless=< \let\ptexnewwrite\newwrite \let\ptexnoindent=\noindent \let\ptexplus=+ \let\ptexraggedright=\raggedright \let\ptexrbrace=\} \let\ptexslash=\/ \let\ptexstar=\* \let\ptext=\t \let\ptextop=\top {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode % If this character appears in an error message or help string, it % starts a new line in the output. \newlinechar = `^^J % Use TeX 3.0's \inputlineno to get the line number, for better error % messages, but if we're using an old version of TeX, don't do anything. % \ifx\inputlineno\thisisundefined \let\linenumber = \empty % Pre-3.0. \else \def\linenumber{l.\the\inputlineno:\space} \fi % Set up fixed words for English if not already set. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi \ifx\putworderror\undefined \gdef\putworderror{error}\fi \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi \ifx\putwordin\undefined \gdef\putwordin{in}\fi \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi \ifx\putwordof\undefined \gdef\putwordof{of}\fi \ifx\putwordon\undefined \gdef\putwordon{on}\fi \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi % \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi % \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi % Since the category of space is not known, we have to be careful. \chardef\spacecat = 10 \def\spaceisspace{\catcode`\ =\spacecat} % sometimes characters are active, so we need control sequences. \chardef\ampChar = `\& \chardef\colonChar = `\: \chardef\commaChar = `\, \chardef\dashChar = `\- \chardef\dotChar = `\. \chardef\exclamChar= `\! \chardef\hashChar = `\# \chardef\lquoteChar= `\` \chardef\questChar = `\? \chardef\rquoteChar= `\' \chardef\semiChar = `\; \chardef\slashChar = `\/ \chardef\underChar = `\_ % Ignore a token. % \def\gobble#1{} % The following is used inside several \edef's. \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} % Hyphenation fixes. \hyphenation{ Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script ap-pen-dix bit-map bit-maps data-base data-bases eshell fall-ing half-way long-est man-u-script man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces spell-ing spell-ings stand-alone strong-est time-stamp time-stamps which-ever white-space wide-spread wrap-around } % Margin to add to right of even pages, to left of odd pages. \newdimen\bindingoffset \newdimen\normaloffset \newdimen\pagewidth \newdimen\pageheight % For a final copy, take out the rectangles % that mark overfull boxes (in case you have decided % that the text looks ok even though it passes the margin). % \def\finalout{\overfullrule=0pt } % Sometimes it is convenient to have everything in the transcript file % and nothing on the terminal. We don't just call \tracingall here, % since that produces some useless output on the terminal. We also make % some effort to order the tracing commands to reduce output in the log % file; cf. trace.sty in LaTeX. % \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% \def\loggingall{% \tracingstats2 \tracingpages1 \tracinglostchars2 % 2 gives us more in etex \tracingparagraphs1 \tracingoutput1 \tracingmacros2 \tracingrestores1 \showboxbreadth\maxdimen \showboxdepth\maxdimen \ifx\eTeXversion\thisisundefined\else % etex gives us more logging \tracingscantokens1 \tracingifs1 \tracinggroups1 \tracingnesting2 \tracingassigns1 \fi \tracingcommands3 % 3 gives us more in etex \errorcontextlines16 }% % @errormsg{MSG}. Do the index-like expansions on MSG, but if things % aren't perfect, it's not the end of the world, being an error message, % after all. % \def\errormsg{\begingroup \indexnofonts \doerrormsg} \def\doerrormsg#1{\errmessage{#1}} % add check for \lastpenalty to plain's definitions. If the last thing % we did was a \nobreak, we don't want to insert more space. % \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount \removelastskip\penalty-50\smallskip\fi\fi} \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount \removelastskip\penalty-100\medskip\fi\fi} \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount \removelastskip\penalty-200\bigskip\fi\fi} % Do @cropmarks to get crop marks. % \newif\ifcropmarks \let\cropmarks = \cropmarkstrue % % Dimensions to add cropmarks at corners. % Added by P. A. MacKay, 12 Nov. 1986 % \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines \newdimen\cornerlong \cornerlong=1pc \newdimen\cornerthick \cornerthick=.3pt \newdimen\topandbottommargin \topandbottommargin=.75in % Output a mark which sets \thischapter, \thissection and \thiscolor. % We dump everything together because we only have one kind of mark. % This works because we only use \botmark / \topmark, not \firstmark. % % A mark contains a subexpression of the \ifcase ... \fi construct. % \get*marks macros below extract the needed part using \ifcase. % % Another complication is to let the user choose whether \thischapter % (\thissection) refers to the chapter (section) in effect at the top % of a page, or that at the bottom of a page. The solution is % described on page 260 of The TeXbook. It involves outputting two % marks for the sectioning macros, one before the section break, and % one after. I won't pretend I can describe this better than DEK... \def\domark{% \toks0=\expandafter{\lastchapterdefs}% \toks2=\expandafter{\lastsectiondefs}% \toks4=\expandafter{\prevchapterdefs}% \toks6=\expandafter{\prevsectiondefs}% \toks8=\expandafter{\lastcolordefs}% \mark{% \the\toks0 \the\toks2 \noexpand\or \the\toks4 \the\toks6 \noexpand\else \the\toks8 }% } % \topmark doesn't work for the very first chapter (after the title % page or the contents), so we use \firstmark there -- this gets us % the mark with the chapter defs, unless the user sneaks in, e.g., % @setcolor (or @url, or @link, etc.) between @contents and the very % first @chapter. \def\gettopheadingmarks{% \ifcase0\topmark\fi \ifx\thischapter\empty \ifcase0\firstmark\fi \fi } \def\getbottomheadingmarks{\ifcase1\botmark\fi} \def\getcolormarks{\ifcase2\topmark\fi} % Avoid "undefined control sequence" errors. \def\lastchapterdefs{} \def\lastsectiondefs{} \def\prevchapterdefs{} \def\prevsectiondefs{} \def\lastcolordefs{} % Main output routine. \chardef\PAGE = 255 \output = {\onepageout{\pagecontents\PAGE}} \newbox\headlinebox \newbox\footlinebox % \onepageout takes a vbox as an argument. Note that \pagecontents % does insertions, but you have to call it yourself. \def\onepageout#1{% \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi % \ifodd\pageno \advance\hoffset by \bindingoffset \else \advance\hoffset by -\bindingoffset\fi % % Do this outside of the \shipout so @code etc. will be expanded in % the headline as they should be, not taken literally (outputting ''code). \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% % {% % Have to do this stuff outside the \shipout because we want it to % take effect in \write's, yet the group defined by the \vbox ends % before the \shipout runs. % \indexdummies % don't expand commands in the output. \normalturnoffactive % \ in index entries must not stay \, e.g., if % the page break happens to be in the middle of an example. % We don't want .vr (or whatever) entries like this: % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} % "\acronym" won't work when it's read back in; % it needs to be % {\code {{\tt \backslashcurfont }acronym} \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi % \ifcropmarks \vbox to \outervsize\bgroup \hsize = \outerhsize \vskip-\topandbottommargin \vtop to0pt{% \line{\ewtop\hfil\ewtop}% \nointerlineskip \line{% \vbox{\moveleft\cornerthick\nstop}% \hfill \vbox{\moveright\cornerthick\nstop}% }% \vss}% \vskip\topandbottommargin \line\bgroup \hfil % center the page within the outer (page) hsize. \ifodd\pageno\hskip\bindingoffset\fi \vbox\bgroup \fi % \unvbox\headlinebox \pagebody{#1}% \ifdim\ht\footlinebox > 0pt % Only leave this space if the footline is nonempty. % (We lessened \vsize for it in \oddfootingyyy.) % The \baselineskip=24pt in plain's \makefootline has no effect. \vskip 24pt \unvbox\footlinebox \fi % \ifcropmarks \egroup % end of \vbox\bgroup \hfil\egroup % end of (centering) \line\bgroup \vskip\topandbottommargin plus1fill minus1fill \boxmaxdepth = \cornerthick \vbox to0pt{\vss \line{% \vbox{\moveleft\cornerthick\nsbot}% \hfill \vbox{\moveright\cornerthick\nsbot}% }% \nointerlineskip \line{\ewbot\hfil\ewbot}% }% \egroup % \vbox from first cropmarks clause \fi }% end of \shipout\vbox }% end of group with \indexdummies \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi } \newinsert\margin \dimen\margin=\maxdimen \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} {\catcode`\@ =11 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi % marginal hacks, juha@viisa.uucp (Juha Takala) \ifvoid\margin\else % marginal info is present \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi \dimen@=\dp#1\relax \unvbox#1\relax \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi \ifr@ggedbottom \kern-\dimen@ \vfil \fi} } % Here are the rules for the cropmarks. Note that they are % offset so that the space between them is truly \outerhsize or \outervsize % (P. A. MacKay, 12 November, 1986) % \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} \def\nstop{\vbox {\hrule height\cornerthick depth\cornerlong width\cornerthick}} \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} \def\nsbot{\vbox {\hrule height\cornerlong depth\cornerthick width\cornerthick}} % Parse an argument, then pass it to #1. The argument is the rest of % the input line (except we remove a trailing comment). #1 should be a % macro which expects an ordinary undelimited TeX argument. % \def\parsearg{\parseargusing{}} \def\parseargusing#1#2{% \def\argtorun{#2}% \begingroup \obeylines \spaceisspace #1% \parseargline\empty% Insert the \empty token, see \finishparsearg below. } {\obeylines % \gdef\parseargline#1^^M{% \endgroup % End of the group started in \parsearg. \argremovecomment #1\comment\ArgTerm% }% } % First remove any @comment, then any @c comment. \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} % Each occurrence of `\^^M' or `\^^M' is replaced by a single space. % % \argremovec might leave us with trailing space, e.g., % @end itemize @c foo % This space token undergoes the same procedure and is eventually removed % by \finishparsearg. % \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% \def\temp{#3}% \ifx\temp\empty % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: \let\temp\finishparsearg \else \let\temp\argcheckspaces \fi % Put the space token in: \temp#1 #3\ArgTerm } % If a _delimited_ argument is enclosed in braces, they get stripped; so % to get _exactly_ the rest of the line, we had to prevent such situation. % We prepended an \empty token at the very beginning and we expand it now, % just before passing the control to \argtorun. % (Similarly, we have to think about #3 of \argcheckspacesY above: it is % either the null string, or it ends with \^^M---thus there is no danger % that a pair of braces would be stripped. % % But first, we have to remove the trailing space token. % \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} % \parseargdef\foo{...} % is roughly equivalent to % \def\foo{\parsearg\Xfoo} % \def\Xfoo#1{...} % % Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my % favourite TeX trick. --kasal, 16nov03 \def\parseargdef#1{% \expandafter \doparseargdef \csname\string#1\endcsname #1% } \def\doparseargdef#1#2{% \def#2{\parsearg#1}% \def#1##1% } % Several utility definitions with active space: { \obeyspaces \gdef\obeyedspace{ } % Make each space character in the input produce a normal interword % space in the output. Don't allow a line break at this space, as this % is used only in environments like @example, where each line of input % should produce a line of output anyway. % \gdef\sepspaces{\obeyspaces\let =\tie} % If an index command is used in an @example environment, any spaces % therein should become regular spaces in the raw index file, not the % expansion of \tie (\leavevmode \penalty \@M \ ). \gdef\unsepspaces{\let =\space} } \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} % Define the framework for environments in texinfo.tex. It's used like this: % % \envdef\foo{...} % \def\Efoo{...} % % It's the responsibility of \envdef to insert \begingroup before the % actual body; @end closes the group after calling \Efoo. \envdef also % defines \thisenv, so the current environment is known; @end checks % whether the environment name matches. The \checkenv macro can also be % used to check whether the current environment is the one expected. % % Non-false conditionals (@iftex, @ifset) don't fit into this, so they % are not treated as environments; they don't open a group. (The % implementation of @end takes care not to call \endgroup in this % special case.) % At run-time, environments start with this: \def\startenvironment#1{\begingroup\def\thisenv{#1}} % initialize \let\thisenv\empty % ... but they get defined via ``\envdef\foo{...}'': \long\def\envdef#1#2{\def#1{\startenvironment#1#2}} \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} % Check whether we're in the right environment: \def\checkenv#1{% \def\temp{#1}% \ifx\thisenv\temp \else \badenverr \fi } % Environment mismatch, #1 expected: \def\badenverr{% \errhelp = \EMsimple \errmessage{This command can appear only \inenvironment\temp, not \inenvironment\thisenv}% } \def\inenvironment#1{% \ifx#1\empty outside of any environment% \else in environment \expandafter\string#1% \fi } % @end foo executes the definition of \Efoo. % But first, it executes a specialized version of \checkenv % \parseargdef\end{% \if 1\csname iscond.#1\endcsname \else % The general wording of \badenverr may not be ideal. \expandafter\checkenv\csname#1\endcsname \csname E#1\endcsname \endgroup \fi } \newhelp\EMsimple{Press RETURN to continue.} % Be sure we're in horizontal mode when doing a tie, since we make space % equivalent to this in @example-like environments. Otherwise, a space % at the beginning of a line will start with \penalty -- and % since \penalty is valid in vertical mode, we'd end up putting the % penalty on the vertical list instead of in the new paragraph. {\catcode`@ = 11 % Avoid using \@M directly, because that causes trouble % if the definition is written into an index file. \global\let\tiepenalty = \@M \gdef\tie{\leavevmode\penalty\tiepenalty\ } } % @: forces normal size whitespace following. \def\:{\spacefactor=1000 } % @* forces a line break. \def\*{\unskip\hfil\break\hbox{}\ignorespaces} % @/ allows a line break. \let\/=\allowbreak % @. is an end-of-sentence period. \def\.{.\spacefactor=\endofsentencespacefactor\space} % @! is an end-of-sentence bang. \def\!{!\spacefactor=\endofsentencespacefactor\space} % @? is an end-of-sentence query. \def\?{?\spacefactor=\endofsentencespacefactor\space} % @frenchspacing on|off says whether to put extra space after punctuation. % \def\onword{on} \def\offword{off} % \parseargdef\frenchspacing{% \def\temp{#1}% \ifx\temp\onword \plainfrenchspacing \else\ifx\temp\offword \plainnonfrenchspacing \else \errhelp = \EMsimple \errmessage{Unknown @frenchspacing option `\temp', must be on|off}% \fi\fi } % @w prevents a word break. Without the \leavevmode, @w at the % beginning of a paragraph, when TeX is still in vertical mode, would % produce a whole line of output instead of starting the paragraph. \def\w#1{\leavevmode\hbox{#1}} % @group ... @end group forces ... to be all on one page, by enclosing % it in a TeX vbox. We use \vtop instead of \vbox to construct the box % to keep its height that of a normal line. According to the rules for % \topskip (p.114 of the TeXbook), the glue inserted is % max (\topskip - \ht (first item), 0). If that height is large, % therefore, no glue is inserted, and the space between the headline and % the text is small, which looks bad. % % Another complication is that the group might be very large. This can % cause the glue on the previous page to be unduly stretched, because it % does not have much material. In this case, it's better to add an % explicit \vfill so that the extra space is at the bottom. The % threshold for doing this is if the group is more than \vfilllimit % percent of a page (\vfilllimit can be changed inside of @tex). % \newbox\groupbox \def\vfilllimit{0.7} % \envdef\group{% \ifnum\catcode`\^^M=\active \else \errhelp = \groupinvalidhelp \errmessage{@group invalid in context where filling is enabled}% \fi \startsavinginserts % \setbox\groupbox = \vtop\bgroup % Do @comment since we are called inside an environment such as % @example, where each end-of-line in the input causes an % end-of-line in the output. We don't want the end-of-line after % the `@group' to put extra space in the output. Since @group % should appear on a line by itself (according to the Texinfo % manual), we don't worry about eating any user text. \comment } % % The \vtop produces a box with normal height and large depth; thus, TeX puts % \baselineskip glue before it, and (when the next line of text is done) % \lineskip glue after it. Thus, space below is not quite equal to space % above. But it's pretty close. \def\Egroup{% % To get correct interline space between the last line of the group % and the first line afterwards, we have to propagate \prevdepth. \endgraf % Not \par, as it may have been set to \lisppar. \global\dimen1 = \prevdepth \egroup % End the \vtop. % \dimen0 is the vertical size of the group's box. \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox % \dimen2 is how much space is left on the page (more or less). \dimen2 = \pageheight \advance\dimen2 by -\pagetotal % if the group doesn't fit on the current page, and it's a big big % group, force a page break. \ifdim \dimen0 > \dimen2 \ifdim \pagetotal < \vfilllimit\pageheight \page \fi \fi \box\groupbox \prevdepth = \dimen1 \checkinserts } % % TeX puts in an \escapechar (i.e., `@') at the beginning of the help % message, so this ends up printing `@group can only ...'. % \newhelp\groupinvalidhelp{% group can only be used in environments such as @example,^^J% where each line of input produces a line of output.} % @need space-in-mils % forces a page break if there is not space-in-mils remaining. \newdimen\mil \mil=0.001in \parseargdef\need{% % Ensure vertical mode, so we don't make a big box in the middle of a % paragraph. \par % % If the @need value is less than one line space, it's useless. \dimen0 = #1\mil \dimen2 = \ht\strutbox \advance\dimen2 by \dp\strutbox \ifdim\dimen0 > \dimen2 % % Do a \strut just to make the height of this box be normal, so the % normal leading is inserted relative to the preceding line. % And a page break here is fine. \vtop to #1\mil{\strut\vfil}% % % TeX does not even consider page breaks if a penalty added to the % main vertical list is 10000 or more. But in order to see if the % empty box we just added fits on the page, we must make it consider % page breaks. On the other hand, we don't want to actually break the % page after the empty box. So we use a penalty of 9999. % % There is an extremely small chance that TeX will actually break the % page at this \penalty, if there are no other feasible breakpoints in % sight. (If the user is using lots of big @group commands, which % almost-but-not-quite fill up a page, TeX will have a hard time doing % good page breaking, for example.) However, I could not construct an % example where a page broke at this \penalty; if it happens in a real % document, then we can reconsider our strategy. \penalty9999 % % Back up by the size of the box, whether we did a page break or not. \kern -#1\mil % % Do not allow a page break right after this kern. \nobreak \fi } % @br forces paragraph break (and is undocumented). \let\br = \par % @page forces the start of a new page. % \def\page{\par\vfill\supereject} % @exdent text.... % outputs text on separate line in roman font, starting at standard page margin % This records the amount of indent in the innermost environment. % That's how much \exdent should take out. \newskip\exdentamount % This defn is used inside fill environments such as @defun. \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} % This defn is used inside nofill environments such as @example. \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount \leftline{\hskip\leftskip{\rm#1}}}} % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current % paragraph. For more general purposes, use the \margin insertion % class. WHICH is `l' or `r'. Not documented, written for gawk manual. % \newskip\inmarginspacing \inmarginspacing=1cm \def\strutdepth{\dp\strutbox} % \def\doinmargin#1#2{\strut\vadjust{% \nobreak \kern-\strutdepth \vtop to \strutdepth{% \baselineskip=\strutdepth \vss % if you have multiple lines of stuff to put here, you'll need to % make the vbox yourself of the appropriate size. \ifx#1l% \llap{\ignorespaces #2\hskip\inmarginspacing}% \else \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% \fi \null }% }} \def\inleftmargin{\doinmargin l} \def\inrightmargin{\doinmargin r} % % @inmargin{TEXT [, RIGHT-TEXT]} % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; % else use TEXT for both). % \def\inmargin#1{\parseinmargin #1,,\finish} \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0 > 0pt \def\lefttext{#1}% have both texts \def\righttext{#2}% \else \def\lefttext{#1}% have only one text \def\righttext{#1}% \fi % \ifodd\pageno \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin \else \def\temp{\inleftmargin\lefttext}% \fi \temp } % @| inserts a changebar to the left of the current line. It should % surround any changed text. This approach does *not* work if the % change spans more than two lines of output. To handle that, we would % have adopt a much more difficult approach (putting marks into the main % vertical list for the beginning and end of each change). This command % is not documented, not supported, and doesn't work. % \def\|{% % \vadjust can only be used in horizontal mode. \leavevmode % % Append this vertical mode material after the current line in the output. \vadjust{% % We want to insert a rule with the height and depth of the current % leading; that is exactly what \strutbox is supposed to record. \vskip-\baselineskip % % \vadjust-items are inserted at the left edge of the type. So % the \llap here moves out into the left-hand margin. \llap{% % % For a thicker or thinner bar, change the `1pt'. \vrule height\baselineskip width1pt % % This is the space between the bar and the text. \hskip 12pt }% }% } % @include FILE -- \input text of FILE. % \def\include{\parseargusing\filenamecatcodes\includezzz} \def\includezzz#1{% \pushthisfilestack \def\thisfile{#1}% {% \makevalueexpandable % we want to expand any @value in FILE. \turnoffactive % and allow special characters in the expansion \indexnofonts % Allow `@@' and other weird things in file names. \wlog{texinfo.tex: doing @include of #1^^J}% \edef\temp{\noexpand\input #1 }% % % This trickery is to read FILE outside of a group, in case it makes % definitions, etc. \expandafter }\temp \popthisfilestack } \def\filenamecatcodes{% \catcode`\\=\other \catcode`~=\other \catcode`^=\other \catcode`_=\other \catcode`|=\other \catcode`<=\other \catcode`>=\other \catcode`+=\other \catcode`-=\other \catcode`\`=\other \catcode`\'=\other } \def\pushthisfilestack{% \expandafter\pushthisfilestackX\popthisfilestack\StackTerm } \def\pushthisfilestackX{% \expandafter\pushthisfilestackY\thisfile\StackTerm } \def\pushthisfilestackY #1\StackTerm #2\StackTerm {% \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% } \def\popthisfilestack{\errthisfilestackempty} \def\errthisfilestackempty{\errmessage{Internal error: the stack of filenames is empty.}} % \def\thisfile{} % @center line % outputs that line, centered. % \parseargdef\center{% \ifhmode \let\centersub\centerH \else \let\centersub\centerV \fi \centersub{\hfil \ignorespaces#1\unskip \hfil}% \let\centersub\relax % don't let the definition persist, just in case } \def\centerH#1{{% \hfil\break \advance\hsize by -\leftskip \advance\hsize by -\rightskip \line{#1}% \break }} % \newcount\centerpenalty \def\centerV#1{% % The idea here is the same as in \startdefun, \cartouche, etc.: if % @center is the first thing after a section heading, we need to wipe % out the negative parskip inserted by \sectionheading, but still % prevent a page break here. \centerpenalty = \lastpenalty \ifnum\centerpenalty>10000 \vskip\parskip \fi \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi \line{\kern\leftskip #1\kern\rightskip}% } % @sp n outputs n lines of vertical space % \parseargdef\sp{\vskip #1\baselineskip} % @comment ...line which is ignored... % @c is the same as @comment % @ignore ... @end ignore is another way to write a comment % \def\comment{\begingroup \catcode`\^^M=\other% \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% \commentxxx} {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} % \let\c=\comment % @paragraphindent NCHARS % We'll use ems for NCHARS, close enough. % NCHARS can also be the word `asis' or `none'. % We cannot feasibly implement @paragraphindent asis, though. % \def\asisword{asis} % no translation, these are keywords \def\noneword{none} % \parseargdef\paragraphindent{% \def\temp{#1}% \ifx\temp\asisword \else \ifx\temp\noneword \defaultparindent = 0pt \else \defaultparindent = #1em \fi \fi \parindent = \defaultparindent } % @exampleindent NCHARS % We'll use ems for NCHARS like @paragraphindent. % It seems @exampleindent asis isn't necessary, but % I preserve it to make it similar to @paragraphindent. \parseargdef\exampleindent{% \def\temp{#1}% \ifx\temp\asisword \else \ifx\temp\noneword \lispnarrowing = 0pt \else \lispnarrowing = #1em \fi \fi } % @firstparagraphindent WORD % If WORD is `none', then suppress indentation of the first paragraph % after a section heading. If WORD is `insert', then do indent at such % paragraphs. % % The paragraph indentation is suppressed or not by calling % \suppressfirstparagraphindent, which the sectioning commands do. % We switch the definition of this back and forth according to WORD. % By default, we suppress indentation. % \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} \def\insertword{insert} % \parseargdef\firstparagraphindent{% \def\temp{#1}% \ifx\temp\noneword \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent \else\ifx\temp\insertword \let\suppressfirstparagraphindent = \relax \else \errhelp = \EMsimple \errmessage{Unknown @firstparagraphindent option `\temp'}% \fi\fi } % Here is how we actually suppress indentation. Redefine \everypar to % \kern backwards by \parindent, and then reset itself to empty. % % We also make \indent itself not actually do anything until the next % paragraph. % \gdef\dosuppressfirstparagraphindent{% \gdef\indent{% \restorefirstparagraphindent \indent }% \gdef\noindent{% \restorefirstparagraphindent \noindent }% \global\everypar = {% \kern -\parindent \restorefirstparagraphindent }% } \gdef\restorefirstparagraphindent{% \global \let \indent = \ptexindent \global \let \noindent = \ptexnoindent \global \everypar = {}% } % @refill is a no-op. \let\refill=\relax % If working on a large document in chapters, it is convenient to % be able to disable indexing, cross-referencing, and contents, for test runs. % This is done with @novalidate (before @setfilename). % \newif\iflinks \linkstrue % by default we want the aux files. \let\novalidate = \linksfalse % @setfilename is done at the beginning of every texinfo file. % So open here the files we need to have open while reading the input. % This makes it possible to make a .fmt file for texinfo. \def\setfilename{% \fixbackslash % Turn off hack to swallow `\input texinfo'. \iflinks \tryauxfile % Open the new aux file. TeX will close it automatically at exit. \immediate\openout\auxfile=\jobname.aux \fi % \openindices needs to do some work in any case. \openindices \let\setfilename=\comment % Ignore extra @setfilename cmds. % % If texinfo.cnf is present on the system, read it. % Useful for site-wide @afourpaper, etc. \openin 1 texinfo.cnf \ifeof 1 \else \input texinfo.cnf \fi \closein 1 % \comment % Ignore the actual filename. } % Called from \setfilename. % \def\openindices{% \newindex{cp}% \newcodeindex{fn}% \newcodeindex{vr}% \newcodeindex{tp}% \newcodeindex{ky}% \newcodeindex{pg}% } % @bye. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} \message{pdf,} % adobe `portable' document format \newcount\tempnum \newcount\lnkcount \newtoks\filename \newcount\filenamelength \newcount\pgn \newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD \newbox\boxA \newcount\countA \newif\ifpdf \newif\ifpdfmakepagedest % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 % can be set). So we test for \relax and 0 as well as being undefined. \ifx\pdfoutput\thisisundefined \else \ifx\pdfoutput\relax \else \ifcase\pdfoutput \else \pdftrue \fi \fi \fi % PDF uses PostScript string constants for the names of xref targets, % for display in the outlines, and in other places. Thus, we have to % double any backslashes. Otherwise, a name like "\node" will be % interpreted as a newline (\n), followed by o, d, e. Not good. % % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and % related messages. The final outcome is that it is up to the TeX user % to double the backslashes and otherwise make the string valid, so % that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to % do this reliably, so we use it. % #1 is a control sequence in which to do the replacements, % which we \xdef. \def\txiescapepdf#1{% \ifx\pdfescapestring\thisisundefined % No primitive available; should we give a warning or log? % Many times it won't matter. \else % The expandable \pdfescapestring primitive escapes parentheses, % backslashes, and other special chars. \xdef#1{\pdfescapestring{#1}}% \fi } \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images with PDF output, and none of those formats could be found. (.eps cannot be supported due to the design of the PDF format; use regular TeX (DVI output) for that.)} \ifpdf % % Color manipulation macros based on pdfcolor.tex, % except using rgb instead of cmyk; the latter is said to render as a % very dark gray on-screen and a very dark halftone in print, instead % of actual black. \def\rgbDarkRed{0.50 0.09 0.12} \def\rgbBlack{0 0 0} % % k sets the color for filling (usual text, etc.); % K sets the color for stroking (thin rules, e.g., normal _'s). \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} % % Set color, and create a mark which defines \thiscolor accordingly, % so that \makeheadline knows which color to restore. \def\setcolor#1{% \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% \domark \pdfsetcolor{#1}% } % \def\maincolor{\rgbBlack} \pdfsetcolor{\maincolor} \edef\thiscolor{\maincolor} \def\lastcolordefs{} % \def\makefootline{% \baselineskip24pt \line{\pdfsetcolor{\maincolor}\the\footline}% } % \def\makeheadline{% \vbox to 0pt{% \vskip-22.5pt \line{% \vbox to8.5pt{}% % Extract \thiscolor definition from the marks. \getcolormarks % Typeset the headline with \maincolor, then restore the color. \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% }% \vss }% \nointerlineskip } % % \pdfcatalog{/PageMode /UseOutlines} % % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). \def\dopdfimage#1#2#3{% \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% % % pdftex (and the PDF format) support .pdf, .png, .jpg (among % others). Let's try in that order, PDF first since if % someone has a scalable image, presumably better to use that than a % bitmap. \let\pdfimgext=\empty \begingroup \openin 1 #1.pdf \ifeof 1 \openin 1 #1.PDF \ifeof 1 \openin 1 #1.png \ifeof 1 \openin 1 #1.jpg \ifeof 1 \openin 1 #1.jpeg \ifeof 1 \openin 1 #1.JPG \ifeof 1 \errhelp = \nopdfimagehelp \errmessage{Could not find image file #1 for pdf}% \else \gdef\pdfimgext{JPG}% \fi \else \gdef\pdfimgext{jpeg}% \fi \else \gdef\pdfimgext{jpg}% \fi \else \gdef\pdfimgext{png}% \fi \else \gdef\pdfimgext{PDF}% \fi \else \gdef\pdfimgext{pdf}% \fi \closein 1 \endgroup % % without \immediate, ancient pdftex seg faults when the same image is % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) \ifnum\pdftexversion < 14 \immediate\pdfimage \else \immediate\pdfximage \fi \ifdim \wd0 >0pt width \pdfimagewidth \fi \ifdim \wd2 >0pt height \pdfimageheight \fi \ifnum\pdftexversion<13 #1.\pdfimgext \else {#1.\pdfimgext}% \fi \ifnum\pdftexversion < 14 \else \pdfrefximage \pdflastximage \fi} % \def\pdfmkdest#1{{% % We have to set dummies so commands such as @code, and characters % such as \, aren't expanded when present in a section title. \indexnofonts \turnoffactive \makevalueexpandable \def\pdfdestname{#1}% \txiescapepdf\pdfdestname \safewhatsit{\pdfdest name{\pdfdestname} xyz}% }} % % used to mark target names; must be expandable. \def\pdfmkpgn#1{#1} % % by default, use a color that is dark enough to print on paper as % nearly black, but still distinguishable for online viewing. \def\urlcolor{\rgbDarkRed} \def\linkcolor{\rgbDarkRed} \def\endlink{\setcolor{\maincolor}\pdfendlink} % % Adding outlines to PDF; macros for calculating structure of outlines % come from Petr Olsak \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% \else \csname#1\endcsname \fi} \def\advancenumber#1{\tempnum=\expnumber{#1}\relax \advance\tempnum by 1 \expandafter\xdef\csname#1\endcsname{\the\tempnum}} % % #1 is the section text, which is what will be displayed in the % outline by the pdf viewer. #2 is the pdf expression for the number % of subentries (or empty, for subsubsections). #3 is the node text, % which might be empty if this toc entry had no corresponding node. % #4 is the page number % \def\dopdfoutline#1#2#3#4{% % Generate a link to the node text if that exists; else, use the % page number. We could generate a destination for the section % text in the case where a section has no node, but it doesn't % seem worth the trouble, since most documents are normally structured. \edef\pdfoutlinedest{#3}% \ifx\pdfoutlinedest\empty \def\pdfoutlinedest{#4}% \else \txiescapepdf\pdfoutlinedest \fi % % Also escape PDF chars in the display string. \edef\pdfoutlinetext{#1}% \txiescapepdf\pdfoutlinetext % \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}% } % \def\pdfmakeoutlines{% \begingroup % Read toc silently, to get counts of subentries for \pdfoutline. \def\partentry##1##2##3##4{}% ignore parts in the outlines \def\numchapentry##1##2##3##4{% \def\thischapnum{##2}% \def\thissecnum{0}% \def\thissubsecnum{0}% }% \def\numsecentry##1##2##3##4{% \advancenumber{chap\thischapnum}% \def\thissecnum{##2}% \def\thissubsecnum{0}% }% \def\numsubsecentry##1##2##3##4{% \advancenumber{sec\thissecnum}% \def\thissubsecnum{##2}% }% \def\numsubsubsecentry##1##2##3##4{% \advancenumber{subsec\thissubsecnum}% }% \def\thischapnum{0}% \def\thissecnum{0}% \def\thissubsecnum{0}% % % use \def rather than \let here because we redefine \chapentry et % al. a second time, below. \def\appentry{\numchapentry}% \def\appsecentry{\numsecentry}% \def\appsubsecentry{\numsubsecentry}% \def\appsubsubsecentry{\numsubsubsecentry}% \def\unnchapentry{\numchapentry}% \def\unnsecentry{\numsecentry}% \def\unnsubsecentry{\numsubsecentry}% \def\unnsubsubsecentry{\numsubsubsecentry}% \readdatafile{toc}% % % Read toc second time, this time actually producing the outlines. % The `-' means take the \expnumber as the absolute number of % subentries, which we calculated on our first read of the .toc above. % % We use the node names as the destinations. \def\numchapentry##1##2##3##4{% \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% \def\numsecentry##1##2##3##4{% \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% \def\numsubsecentry##1##2##3##4{% \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% \def\numsubsubsecentry##1##2##3##4{% count is always zero \dopdfoutline{##1}{}{##3}{##4}}% % % PDF outlines are displayed using system fonts, instead of % document fonts. Therefore we cannot use special characters, % since the encoding is unknown. For example, the eogonek from % Latin 2 (0xea) gets translated to a | character. Info from % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. % % TODO this right, we have to translate 8-bit characters to % their "best" equivalent, based on the @documentencoding. Too % much work for too little return. Just use the ASCII equivalents % we use for the index sort strings. % \indexnofonts \setupdatafile % We can have normal brace characters in the PDF outlines, unlike % Texinfo index files. So set that up. \def\{{\lbracecharliteral}% \def\}{\rbracecharliteral}% \catcode`\\=\active \otherbackslash \input \tocreadfilename \endgroup } {\catcode`[=1 \catcode`]=2 \catcode`{=\other \catcode`}=\other \gdef\lbracecharliteral[{]% \gdef\rbracecharliteral[}]% ] % \def\skipspaces#1{\def\PP{#1}\def\D{|}% \ifx\PP\D\let\nextsp\relax \else\let\nextsp\skipspaces \addtokens{\filename}{\PP}% \advance\filenamelength by 1 \fi \nextsp} \def\getfilename#1{% \filenamelength=0 % If we don't expand the argument now, \skipspaces will get % snagged on things like "@value{foo}". \edef\temp{#1}% \expandafter\skipspaces\temp|\relax } \ifnum\pdftexversion < 14 \let \startlink \pdfannotlink \else \let \startlink \pdfstartlink \fi % make a live url in pdf output. \def\pdfurl#1{% \begingroup % it seems we really need yet another set of dummies; have not % tried to figure out what each command should do in the context % of @url. for now, just make @/ a no-op, that's the only one % people have actually reported a problem with. % \normalturnoffactive \def\@{@}% \let\/=\empty \makevalueexpandable % do we want to go so far as to use \indexnofonts instead of just % special-casing \var here? \def\var##1{##1}% % \leavevmode\setcolor{\urlcolor}% \startlink attr{/Border [0 0 0]}% user{/Subtype /Link /A << /S /URI /URI (#1) >>}% \endgroup} \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} \def\maketoks{% \expandafter\poptoks\the\toksA|ENDTOKS|\relax \ifx\first0\adn0 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 \else \ifnum0=\countA\else\makelink\fi \ifx\first.\let\next=\done\else \let\next=\maketoks \addtokens{\toksB}{\the\toksD} \ifx\first,\addtokens{\toksB}{\space}\fi \fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \next} \def\makelink{\addtokens{\toksB}% {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} \def\pdflink#1{% \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} \setcolor{\linkcolor}#1\endlink} \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} \else % non-pdf mode \let\pdfmkdest = \gobble \let\pdfurl = \gobble \let\endlink = \relax \let\setcolor = \gobble \let\pdfsetcolor = \gobble \let\pdfmakeoutlines = \relax \fi % \ifx\pdfoutput \message{fonts,} % Change the current font style to #1, remembering it in \curfontstyle. % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in % italics, not bold italics. % \def\setfontstyle#1{% \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. \csname ten#1\endcsname % change the current font } % Select #1 fonts with the current style. % \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} \def\rm{\fam=0 \setfontstyle{rm}} \def\it{\fam=\itfam \setfontstyle{it}} \def\sl{\fam=\slfam \setfontstyle{sl}} \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} \def\tt{\fam=\ttfam \setfontstyle{tt}} % Unfortunately, we have to override this for titles and the like, since % in those cases "rm" is bold. Sigh. \def\rmisbold{\rm\def\curfontstyle{bf}} % Texinfo sort of supports the sans serif font style, which plain TeX does not. % So we set up a \sf. \newfam\sffam \def\sf{\fam=\sffam \setfontstyle{sf}} \let\li = \sf % Sometimes we call it \li, not \sf. % We don't need math for this font style. \def\ttsl{\setfontstyle{ttsl}} % Set the baselineskip to #1, and the lineskip and strut size % correspondingly. There is no deep meaning behind these magic numbers % used as factors; they just match (closely enough) what Knuth defined. % \def\lineskipfactor{.08333} \def\strutheightpercent{.70833} \def\strutdepthpercent {.29167} % % can get a sort of poor man's double spacing by redefining this. \def\baselinefactor{1} % \newdimen\textleading \def\setleading#1{% \dimen0 = #1\relax \normalbaselineskip = \baselinefactor\dimen0 \normallineskip = \lineskipfactor\normalbaselineskip \normalbaselines \setbox\strutbox =\hbox{% \vrule width0pt height\strutheightpercent\baselineskip depth \strutdepthpercent \baselineskip }% } % PDF CMaps. See also LaTeX's t1.cmap. % % do nothing with this by default. \expandafter\let\csname cmapOT1\endcsname\gobble \expandafter\let\csname cmapOT1IT\endcsname\gobble \expandafter\let\csname cmapOT1TT\endcsname\gobble % if we are producing pdf, and we have \pdffontattr, then define cmaps. % (\pdffontattr was introduced many years ago, but people still run % older pdftex's; it's easy to conditionalize, so we do.) \ifpdf \ifx\pdffontattr\thisisundefined \else \begingroup \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap %%DocumentNeededResources: ProcSet (CIDInit) %%IncludeResource: ProcSet (CIDInit) %%BeginResource: CMap (TeX-OT1-0) %%Title: (TeX-OT1-0 TeX OT1 0) %%Version: 1.000 %%EndComments /CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo << /Registry (TeX) /Ordering (OT1) /Supplement 0 >> def /CMapName /TeX-OT1-0 def /CMapType 2 def 1 begincodespacerange <00> <7F> endcodespacerange 8 beginbfrange <00> <01> <0393> <09> <0A> <03A8> <23> <26> <0023> <28> <3B> <0028> <3F> <5B> <003F> <5D> <5E> <005D> <61> <7A> <0061> <7B> <7C> <2013> endbfrange 40 beginbfchar <02> <0398> <03> <039B> <04> <039E> <05> <03A0> <06> <03A3> <07> <03D2> <08> <03A6> <0B> <00660066> <0C> <00660069> <0D> <0066006C> <0E> <006600660069> <0F> <00660066006C> <10> <0131> <11> <0237> <12> <0060> <13> <00B4> <14> <02C7> <15> <02D8> <16> <00AF> <17> <02DA> <18> <00B8> <19> <00DF> <1A> <00E6> <1B> <0153> <1C> <00F8> <1D> <00C6> <1E> <0152> <1F> <00D8> <21> <0021> <22> <201D> <27> <2019> <3C> <00A1> <3D> <003D> <3E> <00BF> <5C> <201C> <5F> <02D9> <60> <2018> <7D> <02DD> <7E> <007E> <7F> <00A8> endbfchar endcmap CMapName currentdict /CMap defineresource pop end end %%EndResource %%EOF }\endgroup \expandafter\edef\csname cmapOT1\endcsname#1{% \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% }% % % \cmapOT1IT \begingroup \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap %%DocumentNeededResources: ProcSet (CIDInit) %%IncludeResource: ProcSet (CIDInit) %%BeginResource: CMap (TeX-OT1IT-0) %%Title: (TeX-OT1IT-0 TeX OT1IT 0) %%Version: 1.000 %%EndComments /CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo << /Registry (TeX) /Ordering (OT1IT) /Supplement 0 >> def /CMapName /TeX-OT1IT-0 def /CMapType 2 def 1 begincodespacerange <00> <7F> endcodespacerange 8 beginbfrange <00> <01> <0393> <09> <0A> <03A8> <25> <26> <0025> <28> <3B> <0028> <3F> <5B> <003F> <5D> <5E> <005D> <61> <7A> <0061> <7B> <7C> <2013> endbfrange 42 beginbfchar <02> <0398> <03> <039B> <04> <039E> <05> <03A0> <06> <03A3> <07> <03D2> <08> <03A6> <0B> <00660066> <0C> <00660069> <0D> <0066006C> <0E> <006600660069> <0F> <00660066006C> <10> <0131> <11> <0237> <12> <0060> <13> <00B4> <14> <02C7> <15> <02D8> <16> <00AF> <17> <02DA> <18> <00B8> <19> <00DF> <1A> <00E6> <1B> <0153> <1C> <00F8> <1D> <00C6> <1E> <0152> <1F> <00D8> <21> <0021> <22> <201D> <23> <0023> <24> <00A3> <27> <2019> <3C> <00A1> <3D> <003D> <3E> <00BF> <5C> <201C> <5F> <02D9> <60> <2018> <7D> <02DD> <7E> <007E> <7F> <00A8> endbfchar endcmap CMapName currentdict /CMap defineresource pop end end %%EndResource %%EOF }\endgroup \expandafter\edef\csname cmapOT1IT\endcsname#1{% \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% }% % % \cmapOT1TT \begingroup \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap %%DocumentNeededResources: ProcSet (CIDInit) %%IncludeResource: ProcSet (CIDInit) %%BeginResource: CMap (TeX-OT1TT-0) %%Title: (TeX-OT1TT-0 TeX OT1TT 0) %%Version: 1.000 %%EndComments /CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo << /Registry (TeX) /Ordering (OT1TT) /Supplement 0 >> def /CMapName /TeX-OT1TT-0 def /CMapType 2 def 1 begincodespacerange <00> <7F> endcodespacerange 5 beginbfrange <00> <01> <0393> <09> <0A> <03A8> <21> <26> <0021> <28> <5F> <0028> <61> <7E> <0061> endbfrange 32 beginbfchar <02> <0398> <03> <039B> <04> <039E> <05> <03A0> <06> <03A3> <07> <03D2> <08> <03A6> <0B> <2191> <0C> <2193> <0D> <0027> <0E> <00A1> <0F> <00BF> <10> <0131> <11> <0237> <12> <0060> <13> <00B4> <14> <02C7> <15> <02D8> <16> <00AF> <17> <02DA> <18> <00B8> <19> <00DF> <1A> <00E6> <1B> <0153> <1C> <00F8> <1D> <00C6> <1E> <0152> <1F> <00D8> <20> <2423> <27> <2019> <60> <2018> <7F> <00A8> endbfchar endcmap CMapName currentdict /CMap defineresource pop end end %%EndResource %%EOF }\endgroup \expandafter\edef\csname cmapOT1TT\endcsname#1{% \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% }% \fi\fi % Set the font macro #1 to the font named \fontprefix#2. % #3 is the font's design size, #4 is a scale factor, #5 is the CMap % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit). % Example: % #1 = \textrm % #2 = \rmshape % #3 = 10 % #4 = \mainmagstep % #5 = OT1 % \def\setfont#1#2#3#4#5{% \font#1=\fontprefix#2#3 scaled #4 \csname cmap#5\endcsname#1% } % This is what gets called when #5 of \setfont is empty. \let\cmap\gobble % % (end of cmaps) % Use cm as the default font prefix. % To specify the font prefix, you must define \fontprefix % before you read in texinfo.tex. \ifx\fontprefix\thisisundefined \def\fontprefix{cm} \fi % Support font families that don't use the same naming scheme as CM. \def\rmshape{r} \def\rmbshape{bx} % where the normal face is bold \def\bfshape{b} \def\bxshape{bx} \def\ttshape{tt} \def\ttbshape{tt} \def\ttslshape{sltt} \def\itshape{ti} \def\itbshape{bxti} \def\slshape{sl} \def\slbshape{bxsl} \def\sfshape{ss} \def\sfbshape{ss} \def\scshape{csc} \def\scbshape{csc} % Definitions for a main text size of 11pt. (The default in Texinfo.) % \def\definetextfontsizexi{% % Text fonts (11.2pt, magstep1). \def\textnominalsize{11pt} \edef\mainmagstep{\magstephalf} \setfont\textrm\rmshape{10}{\mainmagstep}{OT1} \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} \setfont\textbf\bfshape{10}{\mainmagstep}{OT1} \setfont\textit\itshape{10}{\mainmagstep}{OT1IT} \setfont\textsl\slshape{10}{\mainmagstep}{OT1} \setfont\textsf\sfshape{10}{\mainmagstep}{OT1} \setfont\textsc\scshape{10}{\mainmagstep}{OT1} \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} \font\texti=cmmi10 scaled \mainmagstep \font\textsy=cmsy10 scaled \mainmagstep \def\textecsize{1095} % A few fonts for @defun names and args. \setfont\defbf\bfshape{10}{\magstep1}{OT1} \setfont\deftt\ttshape{10}{\magstep1}{OT1TT} \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} % Fonts for indices, footnotes, small examples (9pt). \def\smallnominalsize{9pt} \setfont\smallrm\rmshape{9}{1000}{OT1} \setfont\smalltt\ttshape{9}{1000}{OT1TT} \setfont\smallbf\bfshape{10}{900}{OT1} \setfont\smallit\itshape{9}{1000}{OT1IT} \setfont\smallsl\slshape{9}{1000}{OT1} \setfont\smallsf\sfshape{9}{1000}{OT1} \setfont\smallsc\scshape{10}{900}{OT1} \setfont\smallttsl\ttslshape{10}{900}{OT1TT} \font\smalli=cmmi9 \font\smallsy=cmsy9 \def\smallecsize{0900} % Fonts for small examples (8pt). \def\smallernominalsize{8pt} \setfont\smallerrm\rmshape{8}{1000}{OT1} \setfont\smallertt\ttshape{8}{1000}{OT1TT} \setfont\smallerbf\bfshape{10}{800}{OT1} \setfont\smallerit\itshape{8}{1000}{OT1IT} \setfont\smallersl\slshape{8}{1000}{OT1} \setfont\smallersf\sfshape{8}{1000}{OT1} \setfont\smallersc\scshape{10}{800}{OT1} \setfont\smallerttsl\ttslshape{10}{800}{OT1TT} \font\smalleri=cmmi8 \font\smallersy=cmsy8 \def\smallerecsize{0800} % Fonts for title page (20.4pt): \def\titlenominalsize{20pt} \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} \setfont\titleit\itbshape{10}{\magstep4}{OT1IT} \setfont\titlesl\slbshape{10}{\magstep4}{OT1} \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} \setfont\titlesf\sfbshape{17}{\magstep1}{OT1} \let\titlebf=\titlerm \setfont\titlesc\scbshape{10}{\magstep4}{OT1} \font\titlei=cmmi12 scaled \magstep3 \font\titlesy=cmsy10 scaled \magstep4 \def\titleecsize{2074} % Chapter (and unnumbered) fonts (17.28pt). \def\chapnominalsize{17pt} \setfont\chaprm\rmbshape{12}{\magstep2}{OT1} \setfont\chapit\itbshape{10}{\magstep3}{OT1IT} \setfont\chapsl\slbshape{10}{\magstep3}{OT1} \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT} \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT} \setfont\chapsf\sfbshape{17}{1000}{OT1} \let\chapbf=\chaprm \setfont\chapsc\scbshape{10}{\magstep3}{OT1} \font\chapi=cmmi12 scaled \magstep2 \font\chapsy=cmsy10 scaled \magstep3 \def\chapecsize{1728} % Section fonts (14.4pt). \def\secnominalsize{14pt} \setfont\secrm\rmbshape{12}{\magstep1}{OT1} \setfont\secit\itbshape{10}{\magstep2}{OT1IT} \setfont\secsl\slbshape{10}{\magstep2}{OT1} \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT} \setfont\secsf\sfbshape{12}{\magstep1}{OT1} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep2}{OT1} \font\seci=cmmi12 scaled \magstep1 \font\secsy=cmsy10 scaled \magstep2 \def\sececsize{1440} % Subsection fonts (13.15pt). \def\ssecnominalsize{13pt} \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1} \setfont\ssecit\itbshape{10}{1315}{OT1IT} \setfont\ssecsl\slbshape{10}{1315}{OT1} \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT} \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT} \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1} \let\ssecbf\ssecrm \setfont\ssecsc\scbshape{10}{1315}{OT1} \font\sseci=cmmi12 scaled \magstephalf \font\ssecsy=cmsy10 scaled 1315 \def\ssececsize{1200} % Reduced fonts for @acro in text (10pt). \def\reducednominalsize{10pt} \setfont\reducedrm\rmshape{10}{1000}{OT1} \setfont\reducedtt\ttshape{10}{1000}{OT1TT} \setfont\reducedbf\bfshape{10}{1000}{OT1} \setfont\reducedit\itshape{10}{1000}{OT1IT} \setfont\reducedsl\slshape{10}{1000}{OT1} \setfont\reducedsf\sfshape{10}{1000}{OT1} \setfont\reducedsc\scshape{10}{1000}{OT1} \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT} \font\reducedi=cmmi10 \font\reducedsy=cmsy10 \def\reducedecsize{1000} \textleading = 13.2pt % line spacing for 11pt CM \textfonts % reset the current fonts \rm } % end of 11pt text font size definitions, \definetextfontsizexi % Definitions to make the main text be 10pt Computer Modern, with % section, chapter, etc., sizes following suit. This is for the GNU % Press printing of the Emacs 22 manual. Maybe other manuals in the % future. Used with @smallbook, which sets the leading to 12pt. % \def\definetextfontsizex{% % Text fonts (10pt). \def\textnominalsize{10pt} \edef\mainmagstep{1000} \setfont\textrm\rmshape{10}{\mainmagstep}{OT1} \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} \setfont\textbf\bfshape{10}{\mainmagstep}{OT1} \setfont\textit\itshape{10}{\mainmagstep}{OT1IT} \setfont\textsl\slshape{10}{\mainmagstep}{OT1} \setfont\textsf\sfshape{10}{\mainmagstep}{OT1} \setfont\textsc\scshape{10}{\mainmagstep}{OT1} \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} \font\texti=cmmi10 scaled \mainmagstep \font\textsy=cmsy10 scaled \mainmagstep \def\textecsize{1000} % A few fonts for @defun names and args. \setfont\defbf\bfshape{10}{\magstephalf}{OT1} \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} % Fonts for indices, footnotes, small examples (9pt). \def\smallnominalsize{9pt} \setfont\smallrm\rmshape{9}{1000}{OT1} \setfont\smalltt\ttshape{9}{1000}{OT1TT} \setfont\smallbf\bfshape{10}{900}{OT1} \setfont\smallit\itshape{9}{1000}{OT1IT} \setfont\smallsl\slshape{9}{1000}{OT1} \setfont\smallsf\sfshape{9}{1000}{OT1} \setfont\smallsc\scshape{10}{900}{OT1} \setfont\smallttsl\ttslshape{10}{900}{OT1TT} \font\smalli=cmmi9 \font\smallsy=cmsy9 \def\smallecsize{0900} % Fonts for small examples (8pt). \def\smallernominalsize{8pt} \setfont\smallerrm\rmshape{8}{1000}{OT1} \setfont\smallertt\ttshape{8}{1000}{OT1TT} \setfont\smallerbf\bfshape{10}{800}{OT1} \setfont\smallerit\itshape{8}{1000}{OT1IT} \setfont\smallersl\slshape{8}{1000}{OT1} \setfont\smallersf\sfshape{8}{1000}{OT1} \setfont\smallersc\scshape{10}{800}{OT1} \setfont\smallerttsl\ttslshape{10}{800}{OT1TT} \font\smalleri=cmmi8 \font\smallersy=cmsy8 \def\smallerecsize{0800} % Fonts for title page (20.4pt): \def\titlenominalsize{20pt} \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} \setfont\titleit\itbshape{10}{\magstep4}{OT1IT} \setfont\titlesl\slbshape{10}{\magstep4}{OT1} \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} \setfont\titlesf\sfbshape{17}{\magstep1}{OT1} \let\titlebf=\titlerm \setfont\titlesc\scbshape{10}{\magstep4}{OT1} \font\titlei=cmmi12 scaled \magstep3 \font\titlesy=cmsy10 scaled \magstep4 \def\titleecsize{2074} % Chapter fonts (14.4pt). \def\chapnominalsize{14pt} \setfont\chaprm\rmbshape{12}{\magstep1}{OT1} \setfont\chapit\itbshape{10}{\magstep2}{OT1IT} \setfont\chapsl\slbshape{10}{\magstep2}{OT1} \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT} \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT} \setfont\chapsf\sfbshape{12}{\magstep1}{OT1} \let\chapbf\chaprm \setfont\chapsc\scbshape{10}{\magstep2}{OT1} \font\chapi=cmmi12 scaled \magstep1 \font\chapsy=cmsy10 scaled \magstep2 \def\chapecsize{1440} % Section fonts (12pt). \def\secnominalsize{12pt} \setfont\secrm\rmbshape{12}{1000}{OT1} \setfont\secit\itbshape{10}{\magstep1}{OT1IT} \setfont\secsl\slbshape{10}{\magstep1}{OT1} \setfont\sectt\ttbshape{12}{1000}{OT1TT} \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT} \setfont\secsf\sfbshape{12}{1000}{OT1} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep1}{OT1} \font\seci=cmmi12 \font\secsy=cmsy10 scaled \magstep1 \def\sececsize{1200} % Subsection fonts (10pt). \def\ssecnominalsize{10pt} \setfont\ssecrm\rmbshape{10}{1000}{OT1} \setfont\ssecit\itbshape{10}{1000}{OT1IT} \setfont\ssecsl\slbshape{10}{1000}{OT1} \setfont\ssectt\ttbshape{10}{1000}{OT1TT} \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT} \setfont\ssecsf\sfbshape{10}{1000}{OT1} \let\ssecbf\ssecrm \setfont\ssecsc\scbshape{10}{1000}{OT1} \font\sseci=cmmi10 \font\ssecsy=cmsy10 \def\ssececsize{1000} % Reduced fonts for @acro in text (9pt). \def\reducednominalsize{9pt} \setfont\reducedrm\rmshape{9}{1000}{OT1} \setfont\reducedtt\ttshape{9}{1000}{OT1TT} \setfont\reducedbf\bfshape{10}{900}{OT1} \setfont\reducedit\itshape{9}{1000}{OT1IT} \setfont\reducedsl\slshape{9}{1000}{OT1} \setfont\reducedsf\sfshape{9}{1000}{OT1} \setfont\reducedsc\scshape{10}{900}{OT1} \setfont\reducedttsl\ttslshape{10}{900}{OT1TT} \font\reducedi=cmmi9 \font\reducedsy=cmsy9 \def\reducedecsize{0900} \divide\parskip by 2 % reduce space between paragraphs \textleading = 12pt % line spacing for 10pt CM \textfonts % reset the current fonts \rm } % end of 10pt text font size definitions, \definetextfontsizex % We provide the user-level command % @fonttextsize 10 % (or 11) to redefine the text font size. pt is assumed. % \def\xiword{11} \def\xword{10} \def\xwordpt{10pt} % \parseargdef\fonttextsize{% \def\textsizearg{#1}% %\wlog{doing @fonttextsize \textsizearg}% % % Set \globaldefs so that documents can use this inside @tex, since % makeinfo 4.8 does not support it, but we need it nonetheless. % \begingroup \globaldefs=1 \ifx\textsizearg\xword \definetextfontsizex \else \ifx\textsizearg\xiword \definetextfontsizexi \else \errhelp=\EMsimple \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} \fi\fi \endgroup } % In order for the font changes to affect most math symbols and letters, % we have to define the \textfont of the standard families. Since % texinfo doesn't allow for producing subscripts and superscripts except % in the main text, we don't bother to reset \scriptfont and % \scriptscriptfont (which would also require loading a lot more fonts). % \def\resetmathfonts{% \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf \textfont\ttfam=\tentt \textfont\sffam=\tensf } % The font-changing commands redefine the meanings of \tenSTYLE, instead % of just \STYLE. We do this because \STYLE needs to also set the % current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire % \tenSTYLE to set the current font. % % Each font-changing command also sets the names \lsize (one size lower) % and \lllsize (three sizes lower). These relative commands are used in % the LaTeX logo and acronyms. % % This all needs generalizing, badly. % \def\textfonts{% \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl \def\curfontsize{text}% \def\lsize{reduced}\def\lllsize{smaller}% \resetmathfonts \setleading{\textleading}} \def\titlefonts{% \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy \let\tenttsl=\titlettsl \def\curfontsize{title}% \def\lsize{chap}\def\lllsize{subsec}% \resetmathfonts \setleading{27pt}} \def\titlefont#1{{\titlefonts\rmisbold #1}} \def\chapfonts{% \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl \def\curfontsize{chap}% \def\lsize{sec}\def\lllsize{text}% \resetmathfonts \setleading{19pt}} \def\secfonts{% \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl \def\curfontsize{sec}% \def\lsize{subsec}\def\lllsize{reduced}% \resetmathfonts \setleading{16pt}} \def\subsecfonts{% \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl \def\curfontsize{ssec}% \def\lsize{text}\def\lllsize{small}% \resetmathfonts \setleading{15pt}} \let\subsubsecfonts = \subsecfonts \def\reducedfonts{% \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy \let\tenttsl=\reducedttsl \def\curfontsize{reduced}% \def\lsize{small}\def\lllsize{smaller}% \resetmathfonts \setleading{10.5pt}} \def\smallfonts{% \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy \let\tenttsl=\smallttsl \def\curfontsize{small}% \def\lsize{smaller}\def\lllsize{smaller}% \resetmathfonts \setleading{10.5pt}} \def\smallerfonts{% \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy \let\tenttsl=\smallerttsl \def\curfontsize{smaller}% \def\lsize{smaller}\def\lllsize{smaller}% \resetmathfonts \setleading{9.5pt}} % Fonts for short table of contents. \setfont\shortcontrm\rmshape{12}{1000}{OT1} \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 \setfont\shortcontsl\slshape{12}{1000}{OT1} \setfont\shortconttt\ttshape{12}{1000}{OT1TT} % Define these just so they can be easily changed for other fonts. \def\angleleft{$\langle$} \def\angleright{$\rangle$} % Set the fonts to use with the @small... environments. \let\smallexamplefonts = \smallfonts % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample % can fit this many characters: % 8.5x11=86 smallbook=72 a4=90 a5=69 % If we use \scriptfonts (8pt), then we can fit this many characters: % 8.5x11=90+ smallbook=80 a4=90+ a5=77 % For me, subjectively, the few extra characters that fit aren't worth % the additional smallness of 8pt. So I'm making the default 9pt. % % By the way, for comparison, here's what fits with @example (10pt): % 8.5x11=71 smallbook=60 a4=75 a5=58 % --karl, 24jan03. % Set up the default fonts, so we can use them for creating boxes. % \definetextfontsizexi \message{markup,} % Check if we are currently using a typewriter font. Since all the % Computer Modern typewriter fonts have zero interword stretch (and % shrink), and it is reasonable to expect all typewriter fonts to have % this property, we can check that font parameter. % \def\ifmonospace{\ifdim\fontdimen3\font=0pt } % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will % define and register \INITMACRO to be called on markup style changes. % \INITMACRO can check \currentmarkupstyle for the innermost % style and the set of \ifmarkupSTYLE switches for all styles % currently in effect. \newif\ifmarkupvar \newif\ifmarkupsamp \newif\ifmarkupkey %\newif\ifmarkupfile % @file == @samp. %\newif\ifmarkupoption % @option == @samp. \newif\ifmarkupcode \newif\ifmarkupkbd %\newif\ifmarkupenv % @env == @code. %\newif\ifmarkupcommand % @command == @code. \newif\ifmarkuptex % @tex (and part of @math, for now). \newif\ifmarkupexample \newif\ifmarkupverb \newif\ifmarkupverbatim \let\currentmarkupstyle\empty \def\setupmarkupstyle#1{% \csname markup#1true\endcsname \def\currentmarkupstyle{#1}% \markupstylesetup } \let\markupstylesetup\empty \def\defmarkupstylesetup#1{% \expandafter\def\expandafter\markupstylesetup \expandafter{\markupstylesetup #1}% \def#1% } % Markup style setup for left and right quotes. \defmarkupstylesetup\markupsetuplq{% \expandafter\let\expandafter \temp \csname markupsetuplq\currentmarkupstyle\endcsname \ifx\temp\relax \markupsetuplqdefault \else \temp \fi } \defmarkupstylesetup\markupsetuprq{% \expandafter\let\expandafter \temp \csname markupsetuprq\currentmarkupstyle\endcsname \ifx\temp\relax \markupsetuprqdefault \else \temp \fi } { \catcode`\'=\active \catcode`\`=\active \gdef\markupsetuplqdefault{\let`\lq} \gdef\markupsetuprqdefault{\let'\rq} \gdef\markupsetcodequoteleft{\let`\codequoteleft} \gdef\markupsetcodequoteright{\let'\codequoteright} } \let\markupsetuplqcode \markupsetcodequoteleft \let\markupsetuprqcode \markupsetcodequoteright % \let\markupsetuplqexample \markupsetcodequoteleft \let\markupsetuprqexample \markupsetcodequoteright % \let\markupsetuplqkbd \markupsetcodequoteleft \let\markupsetuprqkbd \markupsetcodequoteright % \let\markupsetuplqsamp \markupsetcodequoteleft \let\markupsetuprqsamp \markupsetcodequoteright % \let\markupsetuplqverb \markupsetcodequoteleft \let\markupsetuprqverb \markupsetcodequoteright % \let\markupsetuplqverbatim \markupsetcodequoteleft \let\markupsetuprqverbatim \markupsetcodequoteright % Allow an option to not use regular directed right quote/apostrophe % (char 0x27), but instead the undirected quote from cmtt (char 0x0d). % The undirected quote is ugly, so don't make it the default, but it % works for pasting with more pdf viewers (at least evince), the % lilypond developers report. xpdf does work with the regular 0x27. % \def\codequoteright{% \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax '% \else \char'15 \fi \else \char'15 \fi } % % and a similar option for the left quote char vs. a grave accent. % Modern fonts display ASCII 0x60 as a grave accent, so some people like % the code environments to do likewise. % \def\codequoteleft{% \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax % [Knuth] pp. 380,381,391 % \relax disables Spanish ligatures ?` and !` of \tt font. \relax`% \else \char'22 \fi \else \char'22 \fi } % Commands to set the quote options. % \parseargdef\codequoteundirected{% \def\temp{#1}% \ifx\temp\onword \expandafter\let\csname SETtxicodequoteundirected\endcsname = t% \else\ifx\temp\offword \expandafter\let\csname SETtxicodequoteundirected\endcsname = \relax \else \errhelp = \EMsimple \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}% \fi\fi } % \parseargdef\codequotebacktick{% \def\temp{#1}% \ifx\temp\onword \expandafter\let\csname SETtxicodequotebacktick\endcsname = t% \else\ifx\temp\offword \expandafter\let\csname SETtxicodequotebacktick\endcsname = \relax \else \errhelp = \EMsimple \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}% \fi\fi } % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. \def\noligaturesquoteleft{\relax\lq} % Count depth in font-changes, for error checks \newcount\fontdepth \fontdepth=0 % Font commands. % #1 is the font command (\sl or \it), #2 is the text to slant. % If we are in a monospaced environment, however, 1) always use \ttsl, % and 2) do not add an italic correction. \def\dosmartslant#1#2{% \ifusingtt {{\ttsl #2}\let\next=\relax}% {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% \next } \def\smartslanted{\dosmartslant\sl} \def\smartitalic{\dosmartslant\it} % Output an italic correction unless \next (presumed to be the following % character) is such as not to need one. \def\smartitaliccorrection{% \ifx\next,% \else\ifx\next-% \else\ifx\next.% \else\ptexslash \fi\fi\fi \aftersmartic } % Unconditional use \ttsl, and no ic. @var is set to this for defuns. \def\ttslanted#1{{\ttsl #1}} % @cite is like \smartslanted except unconditionally use \sl. We never want % ttsl for book titles, do we? \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} \def\aftersmartic{} \def\var#1{% \let\saveaftersmartic = \aftersmartic \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% \smartslanted{#1}% } \let\i=\smartitalic \let\slanted=\smartslanted \let\dfn=\smartslanted \let\emph=\smartitalic % Explicit font changes: @r, @sc, undocumented @ii. \def\r#1{{\rm #1}} % roman font \def\sc#1{{\smallcaps#1}} % smallcaps font \def\ii#1{{\it #1}} % italic font % @b, explicit bold. Also @strong. \def\b#1{{\bf #1}} \let\strong=\b % @sansserif, explicit sans. \def\sansserif#1{{\sf #1}} % We can't just use \exhyphenpenalty, because that only has effect at % the end of a paragraph. Restore normal hyphenation at the end of the % group within which \nohyphenation is presumably called. % \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} \def\restorehyphenation{\hyphenchar\font = `- } % Set sfcode to normal for the chars that usually have another value. % Can't use plain's \frenchspacing because it uses the `\x notation, and % sometimes \x has an active definition that messes things up. % \catcode`@=11 \def\plainfrenchspacing{% \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m \def\endofsentencespacefactor{1000}% for @. and friends } \def\plainnonfrenchspacing{% \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000 \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250 \def\endofsentencespacefactor{3000}% for @. and friends } \catcode`@=\other \def\endofsentencespacefactor{3000}% default % @t, explicit typewriter. \def\t#1{% {\tt \rawbackslash \plainfrenchspacing #1}% \null } % @samp. \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}} % @indicateurl is \samp, that is, with quotes. \let\indicateurl=\samp % @code (and similar) prints in typewriter, but with spaces the same % size as normal in the surrounding text, without hyphenation, etc. % This is a subroutine for that. \def\tclose#1{% {% % Change normal interword space to be same as for the current font. \spaceskip = \fontdimen2\font % % Switch to typewriter. \tt % % But `\ ' produces the large typewriter interword space. \def\ {{\spaceskip = 0pt{} }}% % % Turn off hyphenation. \nohyphenation % \rawbackslash \plainfrenchspacing #1% }% \null % reset spacefactor to 1000 } % We *must* turn on hyphenation at `-' and `_' in @code. % Otherwise, it is too hard to avoid overfull hboxes % in the Emacs manual, the Library manual, etc. % % Unfortunately, TeX uses one parameter (\hyphenchar) to control % both hyphenation at - and hyphenation within words. % We must therefore turn them both off (\tclose does that) % and arrange explicitly to hyphenate at a dash. % -- rms. { \catcode`\-=\active \catcode`\_=\active \catcode`\'=\active \catcode`\`=\active \global\let'=\rq \global\let`=\lq % default definitions % \global\def\code{\begingroup \setupmarkupstyle{code}% % The following should really be moved into \setupmarkupstyle handlers. \catcode\dashChar=\active \catcode\underChar=\active \ifallowcodebreaks \let-\codedash \let_\codeunder \else \let-\normaldash \let_\realunder \fi \codex } } \def\codex #1{\tclose{#1}\endgroup} \def\normaldash{-} \def\codedash{-\discretionary{}{}{}} \def\codeunder{% % this is all so @math{@code{var_name}+1} can work. In math mode, _ % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) % will therefore expand the active definition of _, which is us % (inside @code that is), therefore an endless loop. \ifusingtt{\ifmmode \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. \else\normalunderscore \fi \discretionary{}{}{}}% {\_}% } % An additional complication: the above will allow breaks after, e.g., % each of the four underscores in __typeof__. This is bad. % @allowcodebreaks provides a document-level way to turn breaking at - % and _ on and off. % \newif\ifallowcodebreaks \allowcodebreakstrue \def\keywordtrue{true} \def\keywordfalse{false} \parseargdef\allowcodebreaks{% \def\txiarg{#1}% \ifx\txiarg\keywordtrue \allowcodebreakstrue \else\ifx\txiarg\keywordfalse \allowcodebreaksfalse \else \errhelp = \EMsimple \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}% \fi\fi } % For @command, @env, @file, @option quotes seem unnecessary, % so use \code rather than \samp. \let\command=\code \let\env=\code \let\file=\code \let\option=\code % @uref (abbreviation for `urlref') takes an optional (comma-separated) % second argument specifying the text to display and an optional third % arg as text to display instead of (rather than in addition to) the url % itself. First (mandatory) arg is the url. % (This \urefnobreak definition isn't used now, leaving it for a while % for comparison.) \def\urefnobreak#1{\dourefnobreak #1,,,\finish} \def\dourefnobreak#1,#2,#3,#4\finish{\begingroup \unsepspaces \pdfurl{#1}% \setbox0 = \hbox{\ignorespaces #3}% \ifdim\wd0 > 0pt \unhbox0 % third arg given, show only that \else \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0 > 0pt \ifpdf \unhbox0 % PDF: 2nd arg given, show only it \else \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url \fi \else \code{#1}% only url given, so show it \fi \fi \endlink \endgroup} % This \urefbreak definition is the active one. \def\urefbreak{\begingroup \urefcatcodes \dourefbreak} \let\uref=\urefbreak \def\dourefbreak#1{\urefbreakfinish #1,,,\finish} \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example \unsepspaces \pdfurl{#1}% \setbox0 = \hbox{\ignorespaces #3}% \ifdim\wd0 > 0pt \unhbox0 % third arg given, show only that \else \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0 > 0pt \ifpdf \unhbox0 % PDF: 2nd arg given, show only it \else \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url \fi \else \urefcode{#1}% only url given, so show it \fi \fi \endlink \endgroup} % Allow line breaks around only a few characters (only). \def\urefcatcodes{% \catcode\ampChar=\active \catcode\dotChar=\active \catcode\hashChar=\active \catcode\questChar=\active \catcode\slashChar=\active } { \urefcatcodes % \global\def\urefcode{\begingroup \setupmarkupstyle{code}% \urefcatcodes \let&\urefcodeamp \let.\urefcodedot \let#\urefcodehash \let?\urefcodequest \let/\urefcodeslash \codex } % % By default, they are just regular characters. \global\def&{\normalamp} \global\def.{\normaldot} \global\def#{\normalhash} \global\def?{\normalquest} \global\def/{\normalslash} } % we put a little stretch before and after the breakable chars, to help % line breaking of long url's. The unequal skips make look better in % cmtt at least, especially for dots. \def\urefprestretch{\urefprebreak \hskip0pt plus.13em } \def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em } % \def\urefcodeamp{\urefprestretch \&\urefpoststretch} \def\urefcodedot{\urefprestretch .\urefpoststretch} \def\urefcodehash{\urefprestretch \#\urefpoststretch} \def\urefcodequest{\urefprestretch ?\urefpoststretch} \def\urefcodeslash{\futurelet\next\urefcodeslashfinish} { \catcode`\/=\active \global\def\urefcodeslashfinish{% \urefprestretch \slashChar % Allow line break only after the final / in a sequence of % slashes, to avoid line break between the slashes in http://. \ifx\next/\else \urefpoststretch \fi } } % One more complication: by default we'll break after the special % characters, but some people like to break before the special chars, so % allow that. Also allow no breaking at all, for manual control. % \parseargdef\urefbreakstyle{% \def\txiarg{#1}% \ifx\txiarg\wordnone \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak} \else\ifx\txiarg\wordbefore \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak} \else\ifx\txiarg\wordafter \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak} \else \errhelp = \EMsimple \errmessage{Unknown @urefbreakstyle setting `\txiarg'}% \fi\fi\fi } \def\wordafter{after} \def\wordbefore{before} \def\wordnone{none} \urefbreakstyle after % @url synonym for @uref, since that's how everyone uses it. % \let\url=\uref % rms does not like angle brackets --karl, 17may97. % So now @email is just like @uref, unless we are pdf. % %\def\email#1{\angleleft{\tt #1}\angleright} \ifpdf \def\email#1{\doemail#1,,\finish} \def\doemail#1,#2,#3\finish{\begingroup \unsepspaces \pdfurl{mailto:#1}% \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi \endlink \endgroup} \else \let\email=\uref \fi % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), % `example' (@kbd uses ttsl only inside of @example and friends), % or `code' (@kbd uses normal tty font always). \parseargdef\kbdinputstyle{% \def\txiarg{#1}% \ifx\txiarg\worddistinct \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% \else\ifx\txiarg\wordexample \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% \else\ifx\txiarg\wordcode \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% \else \errhelp = \EMsimple \errmessage{Unknown @kbdinputstyle setting `\txiarg'}% \fi\fi\fi } \def\worddistinct{distinct} \def\wordexample{example} \def\wordcode{code} % Default is `distinct'. \kbdinputstyle distinct % @kbd is like @code, except that if the argument is just one @key command, % then @kbd has no effect. \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}} \def\xkey{\key} \def\kbdsub#1#2#3\par{% \def\one{#1}\def\three{#3}\def\threex{??}% \ifx\one\xkey\ifx\threex\three \key{#2}% \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi } % definition of @key that produces a lozenge. Doesn't adjust to text size. %\setfont\keyrm\rmshape{8}{1000}{OT1} %\font\keysy=cmsy9 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% % \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% % \vbox{\hrule\kern-0.4pt % \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% % \kern-0.4pt\hrule}% % \kern-.06em\raise0.4pt\hbox{\angleright}}}} % definition of @key with no lozenge. If the current font is already % monospace, don't change it; that way, we respect @kbdinputstyle. But % if it isn't monospace, then use \tt. % \def\key#1{{\setupmarkupstyle{key}% \nohyphenation \ifmonospace\else\tt\fi #1}\null} % @clicksequence{File @click{} Open ...} \def\clicksequence#1{\begingroup #1\endgroup} % @clickstyle @arrow (by default) \parseargdef\clickstyle{\def\click{#1}} \def\click{\arrow} % Typeset a dimension, e.g., `in' or `pt'. The only reason for the % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. % \def\dmn#1{\thinspace #1} % @l was never documented to mean ``switch to the Lisp font'', % and it is not used as such in any manual I can find. We need it for % Polish suppressed-l. --karl, 22sep96. %\def\l#1{{\li #1}\null} % @acronym for "FBI", "NATO", and the like. % We print this one point size smaller, since it's intended for % all-uppercase. % \def\acronym#1{\doacronym #1,,\finish} \def\doacronym#1,#2,#3\finish{% {\selectfonts\lsize #1}% \def\temp{#2}% \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi \null % reset \spacefactor=1000 } % @abbr for "Comput. J." and the like. % No font change, but don't do end-of-sentence spacing. % \def\abbr#1{\doabbr #1,,\finish} \def\doabbr#1,#2,#3\finish{% {\plainfrenchspacing #1}% \def\temp{#2}% \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi \null % reset \spacefactor=1000 } % @asis just yields its argument. Used with @table, for example. % \def\asis#1{#1} % @math outputs its argument in math mode. % % One complication: _ usually means subscripts, but it could also mean % an actual _ character, as in @math{@var{some_variable} + 1}. So make % _ active, and distinguish by seeing if the current family is \slfam, % which is what @var uses. { \catcode`\_ = \active \gdef\mathunderscore{% \catcode`\_=\active \def_{\ifnum\fam=\slfam \_\else\sb\fi}% } } % Another complication: we want \\ (and @\) to output a math (or tt) \. % FYI, plain.tex uses \\ as a temporary control sequence (for no % particular reason), but this is not advertised and we don't care. % % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} % \def\math{% \tex \mathunderscore \let\\ = \mathbackslash \mathactive % make the texinfo accent commands work in math mode \let\"=\ddot \let\'=\acute \let\==\bar \let\^=\hat \let\`=\grave \let\u=\breve \let\v=\check \let\~=\tilde \let\dotaccent=\dot $\finishmath } \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. % Some active characters (such as <) are spaced differently in math. % We have to reset their definitions in case the @math was an argument % to a command which sets the catcodes (such as @item or @section). % { \catcode`^ = \active \catcode`< = \active \catcode`> = \active \catcode`+ = \active \catcode`' = \active \gdef\mathactive{% \let^ = \ptexhat \let< = \ptexless \let> = \ptexgtr \let+ = \ptexplus \let' = \ptexquoteright } } % ctrl is no longer a Texinfo command, but leave this definition for fun. \def\ctrl #1{{\tt \rawbackslash \hat}#1} % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. % Ignore unless FMTNAME == tex; then it is like @iftex and @tex, % except specified as a normal braced arg, so no newlines to worry about. % \def\outfmtnametex{tex} % \long\def\inlinefmt#1{\doinlinefmt #1,\finish} \long\def\doinlinefmt#1,#2,\finish{% \def\inlinefmtname{#1}% \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi } % For raw, must switch into @tex before parsing the argument, to avoid % setting catcodes prematurely. Doing it this way means that, for % example, @inlineraw{html, foo{bar} gets a parse error instead of being % ignored. But this isn't important because if people want a literal % *right* brace they would have to use a command anyway, so they may as % well use a command to get a left brace too. We could re-use the % delimiter character idea from \verb, but it seems like overkill. % \long\def\inlineraw{\tex \doinlineraw} \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish} \def\doinlinerawtwo#1,#2,\finish{% \def\inlinerawname{#1}% \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi \endgroup % close group opened by \tex. } \message{glyphs,} % and logos. % @@ prints an @, as does @atchar{}. \def\@{\char64 } \let\atchar=\@ % @{ @} @lbracechar{} @rbracechar{} all generate brace characters. % Unless we're in typewriter, use \ecfont because the CM text fonts do % not have braces, and we don't want to switch into math. \def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}} \def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}} \let\{=\mylbrace \let\lbracechar=\{ \let\}=\myrbrace \let\rbracechar=\} \begingroup % Definitions to produce \{ and \} commands for indices, % and @{ and @} for the aux/toc files. \catcode`\{ = \other \catcode`\} = \other \catcode`\[ = 1 \catcode`\] = 2 \catcode`\! = 0 \catcode`\\ = \other !gdef!lbracecmd[\{]% !gdef!rbracecmd[\}]% !gdef!lbraceatcmd[@{]% !gdef!rbraceatcmd[@}]% !endgroup % @comma{} to avoid , parsing problems. \let\comma = , % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. \let\, = \ptexc \let\dotaccent = \ptexdot \def\ringaccent#1{{\accent23 #1}} \let\tieaccent = \ptext \let\ubaraccent = \ptexb \let\udotaccent = \d % Other special characters: @questiondown @exclamdown @ordf @ordm % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. \def\questiondown{?`} \def\exclamdown{!`} \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} % Dotless i and dotless j, used for accents. \def\imacro{i} \def\jmacro{j} \def\dotless#1{% \def\temp{#1}% \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi \else \errmessage{@dotless can be used only with i or j}% \fi\fi } % The \TeX{} logo, as in plain, but resetting the spacing so that a % period following counts as ending a sentence. (Idea found in latex.) % \edef\TeX{\TeX \spacefactor=1000 } % @LaTeX{} logo. Not quite the same results as the definition in % latex.ltx, since we use a different font for the raised A; it's most % convenient for us to use an explicitly smaller font, rather than using % the \scriptstyle font (since we don't reset \scriptstyle and % \scriptscriptstyle). % \def\LaTeX{% L\kern-.36em {\setbox0=\hbox{T}% \vbox to \ht0{\hbox{% \ifx\textnominalsize\xwordpt % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX. % Revert to plain's \scriptsize, which is 7pt. \count255=\the\fam $\fam\count255 \scriptstyle A$% \else % For 11pt, we can use our lllsize. \selectfonts\lllsize A% \fi }% \vss }}% \kern-.15em \TeX } % Some math mode symbols. \def\bullet{$\ptexbullet$} \def\geq{\ifmmode \ge\else $\ge$\fi} \def\leq{\ifmmode \le\else $\le$\fi} \def\minus{\ifmmode -\else $-$\fi} % @dots{} outputs an ellipsis using the current font. % We do .5em per period so that it has the same spacing in the cm % typewriter fonts as three actual period characters; on the other hand, % in other typewriter fonts three periods are wider than 1.5em. So do % whichever is larger. % \def\dots{% \leavevmode \setbox0=\hbox{...}% get width of three periods \ifdim\wd0 > 1.5em \dimen0 = \wd0 \else \dimen0 = 1.5em \fi \hbox to \dimen0{% \hskip 0pt plus.25fil .\hskip 0pt plus1fil .\hskip 0pt plus1fil .\hskip 0pt plus.5fil }% } % @enddots{} is an end-of-sentence ellipsis. % \def\enddots{% \dots \spacefactor=\endofsentencespacefactor } % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. % % Since these characters are used in examples, they should be an even number of % \tt widths. Each \tt character is 1en, so two makes it 1em. % \def\point{$\star$} \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}} \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}} \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}} % The @error{} command. % Adapted from the TeXbook's \boxit. % \newbox\errorbox % {\tentt \global\dimen0 = 3em}% Width of the box. \dimen2 = .55pt % Thickness of rules % The text. (`r' is open on the right, `e' somewhat less so on the left.) \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} % \setbox\errorbox=\hbox to \dimen0{\hfil \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. \advance\hsize by -2\dimen2 % Rules. \vbox{% \hrule height\dimen2 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. \kern3pt\vrule width\dimen2}% Space to right. \hrule height\dimen2} \hfil} % \def\error{\leavevmode\lower.7ex\copy\errorbox} % @pounds{} is a sterling sign, which Knuth put in the CM italic font. % \def\pounds{{\it\$}} % @euro{} comes from a separate font, depending on the current style. % We use the free feym* fonts from the eurosym package by Henrik % Theiling, which support regular, slanted, bold and bold slanted (and % "outlined" (blackboard board, sort of) versions, which we don't need). % It is available from http://www.ctan.org/tex-archive/fonts/eurosym. % % Although only regular is the truly official Euro symbol, we ignore % that. The Euro is designed to be slightly taller than the regular % font height. % % feymr - regular % feymo - slanted % feybr - bold % feybo - bold slanted % % There is no good (free) typewriter version, to my knowledge. % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. % Hmm. % % Also doesn't work in math. Do we need to do math with euro symbols? % Hope not. % % \def\euro{{\eurofont e}} \def\eurofont{% % We set the font at each command, rather than predefining it in % \textfonts and the other font-switching commands, so that % installations which never need the symbol don't have to have the % font installed. % % There is only one designed size (nominal 10pt), so we always scale % that to the current nominal size. % % By the way, simply using "at 1em" works for cmr10 and the like, but % does not work for cmbx10 and other extended/shrunken fonts. % \def\eurosize{\csname\curfontsize nominalsize\endcsname}% % \ifx\curfontstyle\bfstylename % bold: \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize \else % regular: \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize \fi \thiseurofont } % Glyphs from the EC fonts. We don't use \let for the aliases, because % sometimes we redefine the original macro, and the alias should reflect % the redefinition. % % Use LaTeX names for the Icelandic letters. \def\DH{{\ecfont \char"D0}} % Eth \def\dh{{\ecfont \char"F0}} % eth \def\TH{{\ecfont \char"DE}} % Thorn \def\th{{\ecfont \char"FE}} % thorn % \def\guillemetleft{{\ecfont \char"13}} \def\guillemotleft{\guillemetleft} \def\guillemetright{{\ecfont \char"14}} \def\guillemotright{\guillemetright} \def\guilsinglleft{{\ecfont \char"0E}} \def\guilsinglright{{\ecfont \char"0F}} \def\quotedblbase{{\ecfont \char"12}} \def\quotesinglbase{{\ecfont \char"0D}} % % This positioning is not perfect (see the ogonek LaTeX package), but % we have the precomposed glyphs for the most common cases. We put the % tests to use those glyphs in the single \ogonek macro so we have fewer % dummy definitions to worry about for index entries, etc. % % ogonek is also used with other letters in Lithuanian (IOU), but using % the precomposed glyphs for those is not so easy since they aren't in % the same EC font. \def\ogonek#1{{% \def\temp{#1}% \ifx\temp\macrocharA\Aogonek \else\ifx\temp\macrochara\aogonek \else\ifx\temp\macrocharE\Eogonek \else\ifx\temp\macrochare\eogonek \else \ecfont \setbox0=\hbox{#1}% \ifdim\ht0=1ex\accent"0C #1% \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}% \fi \fi\fi\fi\fi }% } \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A} \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a} \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} % % Use the ec* fonts (cm-super in outline format) for non-CM glyphs. \def\ecfont{% % We can't distinguish serif/sans and italic/slanted, but this % is used for crude hacks anyway (like adding French and German % quotes to documents typeset with CM, where we lose kerning), so % hopefully nobody will notice/care. \edef\ecsize{\csname\curfontsize ecsize\endcsname}% \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% \ifmonospace % typewriter: \font\thisecfont = ectt\ecsize \space at \nominalsize \else \ifx\curfontstyle\bfstylename % bold: \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize \else % regular: \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize \fi \fi \thisecfont } % @registeredsymbol - R in a circle. The font for the R should really % be smaller yet, but lllsize is the best we can do for now. % Adapted from the plain.tex definition of \copyright. % \def\registeredsymbol{% $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% \hfil\crcr\Orb}}% }$% } % @textdegree - the normal degrees sign. % \def\textdegree{$^\circ$} % Laurent Siebenmann reports \Orb undefined with: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 % so we'll define it if necessary. % \ifx\Orb\thisisundefined \def\Orb{\mathhexbox20D} \fi % Quotes. \chardef\quotedblleft="5C \chardef\quotedblright=`\" \chardef\quoteleft=`\` \chardef\quoteright=`\' \message{page headings,} \newskip\titlepagetopglue \titlepagetopglue = 1.5in \newskip\titlepagebottomglue \titlepagebottomglue = 2pc % First the title page. Must do @settitle before @titlepage. \newif\ifseenauthor \newif\iffinishedtitlepage % Do an implicit @contents or @shortcontents after @end titlepage if the % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. % \newif\ifsetcontentsaftertitlepage \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue \newif\ifsetshortcontentsaftertitlepage \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue \parseargdef\shorttitlepage{% \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}% \endgroup\page\hbox{}\page} \envdef\titlepage{% % Open one extra group, as we want to close it in the middle of \Etitlepage. \begingroup \parindent=0pt \textfonts % Leave some space at the very top of the page. \vglue\titlepagetopglue % No rule at page bottom unless we print one at the top with @title. \finishedtitlepagetrue % % Most title ``pages'' are actually two pages long, with space % at the top of the second. We don't want the ragged left on the second. \let\oldpage = \page \def\page{% \iffinishedtitlepage\else \finishtitlepage \fi \let\page = \oldpage \page \null }% } \def\Etitlepage{% \iffinishedtitlepage\else \finishtitlepage \fi % It is important to do the page break before ending the group, % because the headline and footline are only empty inside the group. % If we use the new definition of \page, we always get a blank page % after the title page, which we certainly don't want. \oldpage \endgroup % % Need this before the \...aftertitlepage checks so that if they are % in effect the toc pages will come out with page numbers. \HEADINGSon % % If they want short, they certainly want long too. \ifsetshortcontentsaftertitlepage \shortcontents \contents \global\let\shortcontents = \relax \global\let\contents = \relax \fi % \ifsetcontentsaftertitlepage \contents \global\let\contents = \relax \global\let\shortcontents = \relax \fi } \def\finishtitlepage{% \vskip4pt \hrule height 2pt width \hsize \vskip\titlepagebottomglue \finishedtitlepagetrue } % Settings used for typesetting titles: no hyphenation, no indentation, % don't worry much about spacing, ragged right. This should be used % inside a \vbox, and fonts need to be set appropriately first. Because % it is always used for titles, nothing else, we call \rmisbold. \par % should be specified before the end of the \vbox, since a vbox is a group. % \def\raggedtitlesettings{% \rmisbold \hyphenpenalty=10000 \parindent=0pt \tolerance=5000 \ptexraggedright } % Macros to be used within @titlepage: \let\subtitlerm=\tenrm \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} \parseargdef\title{% \checkenv\titlepage \vbox{\titlefonts \raggedtitlesettings #1\par}% % print a rule at the page bottom also. \finishedtitlepagefalse \vskip4pt \hrule height 4pt width \hsize \vskip4pt } \parseargdef\subtitle{% \checkenv\titlepage {\subtitlefont \rightline{#1}}% } % @author should come last, but may come many times. % It can also be used inside @quotation. % \parseargdef\author{% \def\temp{\quotation}% \ifx\thisenv\temp \def\quotationauthor{#1}% printed in \Equotation. \else \checkenv\titlepage \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi {\secfonts\rmisbold \leftline{#1}}% \fi } % Set up page headings and footings. \let\thispage=\folio \newtoks\evenheadline % headline on even pages \newtoks\oddheadline % headline on odd pages \newtoks\evenfootline % footline on even pages \newtoks\oddfootline % footline on odd pages % Now make TeX use those variables \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}} \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}\HEADINGShook} \let\HEADINGShook=\relax % Commands to set those variables. % For example, this is what @headings on does % @evenheading @thistitle|@thispage|@thischapter % @oddheading @thischapter|@thispage|@thistitle % @evenfooting @thisfile|| % @oddfooting ||@thisfile \def\evenheading{\parsearg\evenheadingxxx} \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} \def\evenheadingyyy #1\|#2\|#3\|#4\finish{% \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \def\oddheading{\parsearg\oddheadingxxx} \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} \def\oddheadingyyy #1\|#2\|#3\|#4\finish{% \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% \def\evenfooting{\parsearg\evenfootingxxx} \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} \def\evenfootingyyy #1\|#2\|#3\|#4\finish{% \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \def\oddfooting{\parsearg\oddfootingxxx} \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} \def\oddfootingyyy #1\|#2\|#3\|#4\finish{% \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% % % Leave some space for the footline. Hopefully ok to assume % @evenfooting will not be used by itself. \global\advance\pageheight by -12pt \global\advance\vsize by -12pt } \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} % @evenheadingmarks top \thischapter <- chapter at the top of a page % @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page % % The same set of arguments for: % % @oddheadingmarks % @evenfootingmarks % @oddfootingmarks % @everyheadingmarks % @everyfootingmarks \def\evenheadingmarks{\headingmarks{even}{heading}} \def\oddheadingmarks{\headingmarks{odd}{heading}} \def\evenfootingmarks{\headingmarks{even}{footing}} \def\oddfootingmarks{\headingmarks{odd}{footing}} \def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1} \headingmarks{odd}{heading}{#1} } \def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1} \headingmarks{odd}{footing}{#1} } % #1 = even/odd, #2 = heading/footing, #3 = top/bottom. \def\headingmarks#1#2#3 {% \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname \global\expandafter\let\csname get#1#2marks\endcsname \temp } \everyheadingmarks bottom \everyfootingmarks bottom % @headings double turns headings on for double-sided printing. % @headings single turns headings on for single-sided printing. % @headings off turns them off. % @headings on same as @headings double, retained for compatibility. % @headings after turns on double-sided headings after this page. % @headings doubleafter turns on double-sided headings after this page. % @headings singleafter turns on single-sided headings after this page. % By default, they are off at the start of a document, % and turned `on' after @end titlepage. \def\headings #1 {\csname HEADINGS#1\endcsname} \def\headingsoff{% non-global headings elimination \evenheadline={\hfil}\evenfootline={\hfil}% \oddheadline={\hfil}\oddfootline={\hfil}% } \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting \HEADINGSoff % it's the default % When we turn headings on, set the page number to 1. % For double-sided printing, put current file name in lower left corner, % chapter name on inside top of right hand pages, document % title on inside top of left hand pages, and page numbers on outside top % edge of all pages. \def\HEADINGSdouble{% \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } \let\contentsalignmacro = \chappager % For single-sided printing, chapter title goes across top left of page, % page number on top right. \def\HEADINGSsingle{% \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } \def\HEADINGSon{\HEADINGSdouble} \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} \let\HEADINGSdoubleafter=\HEADINGSafter \def\HEADINGSdoublex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} \def\HEADINGSsinglex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } % Subroutines used in generating headings % This produces Day Month Year style of output. % Only define if not already defined, in case a txi-??.tex file has set % up a different format (e.g., txi-cs.tex does this). \ifx\today\thisisundefined \def\today{% \number\day\space \ifcase\month \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec \fi \space\number\year} \fi % @settitle line... specifies the title of the document, for headings. % It generates no output of its own. \def\thistitle{\putwordNoTitle} \def\settitle{\parsearg{\gdef\thistitle}} \message{tables,} % Tables -- @table, @ftable, @vtable, @item(x). % default indentation of table text \newdimen\tableindent \tableindent=.8in % default indentation of @itemize and @enumerate text \newdimen\itemindent \itemindent=.3in % margin between end of table item and start of table text. \newdimen\itemmargin \itemmargin=.1in % used internally for \itemindent minus \itemmargin \newdimen\itemmax % Note @table, @ftable, and @vtable define @item, @itemx, etc., with % these defs. % They also define \itemindex % to index the item name in whatever manner is desired (perhaps none). \newif\ifitemxneedsnegativevskip \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} \def\internalBitem{\smallbreak \parsearg\itemzzz} \def\internalBitemx{\itemxpar \parsearg\itemzzz} \def\itemzzz #1{\begingroup % \advance\hsize by -\rightskip \advance\hsize by -\tableindent \setbox0=\hbox{\itemindicate{#1}}% \itemindex{#1}% \nobreak % This prevents a break before @itemx. % % If the item text does not fit in the space we have, put it on a line % by itself, and do not allow a page break either before or after that % line. We do not start a paragraph here because then if the next % command is, e.g., @kindex, the whatsit would get put into the % horizontal list on a line by itself, resulting in extra blank space. \ifdim \wd0>\itemmax % % Make this a paragraph so we get the \parskip glue and wrapping, % but leave it ragged-right. \begingroup \advance\leftskip by-\tableindent \advance\hsize by\tableindent \advance\rightskip by0pt plus1fil\relax \leavevmode\unhbox0\par \endgroup % % We're going to be starting a paragraph, but we don't want the % \parskip glue -- logically it's part of the @item we just started. \nobreak \vskip-\parskip % % Stop a page break at the \parskip glue coming up. However, if % what follows is an environment such as @example, there will be no % \parskip glue; then the negative vskip we just inserted would % cause the example and the item to crash together. So we use this % bizarre value of 10001 as a signal to \aboveenvbreak to insert % \parskip glue after all. Section titles are handled this way also. % \penalty 10001 \endgroup \itemxneedsnegativevskipfalse \else % The item text fits into the space. Start a paragraph, so that the % following text (if any) will end up on the same line. \noindent % Do this with kerns and \unhbox so that if there is a footnote in % the item text, it can migrate to the main vertical list and % eventually be printed. \nobreak\kern-\tableindent \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 \unhbox0 \nobreak\kern\dimen0 \endgroup \itemxneedsnegativevskiptrue \fi } \def\item{\errmessage{@item while not in a list environment}} \def\itemx{\errmessage{@itemx while not in a list environment}} % @table, @ftable, @vtable. \envdef\table{% \let\itemindex\gobble \tablecheck{table}% } \envdef\ftable{% \def\itemindex ##1{\doind {fn}{\code{##1}}}% \tablecheck{ftable}% } \envdef\vtable{% \def\itemindex ##1{\doind {vr}{\code{##1}}}% \tablecheck{vtable}% } \def\tablecheck#1{% \ifnum \the\catcode`\^^M=\active \endgroup \errmessage{This command won't work in this context; perhaps the problem is that we are \inenvironment\thisenv}% \def\next{\doignore{#1}}% \else \let\next\tablex \fi \next } \def\tablex#1{% \def\itemindicate{#1}% \parsearg\tabley } \def\tabley#1{% {% \makevalueexpandable \edef\temp{\noexpand\tablez #1\space\space\space}% \expandafter }\temp \endtablez } \def\tablez #1 #2 #3 #4\endtablez{% \aboveenvbreak \ifnum 0#1>0 \advance \leftskip by #1\mil \fi \ifnum 0#2>0 \tableindent=#2\mil \fi \ifnum 0#3>0 \advance \rightskip by #3\mil \fi \itemmax=\tableindent \advance \itemmax by -\itemmargin \advance \leftskip by \tableindent \exdentamount=\tableindent \parindent = 0pt \parskip = \smallskipamount \ifdim \parskip=0pt \parskip=2pt \fi \let\item = \internalBitem \let\itemx = \internalBitemx } \def\Etable{\endgraf\afterenvbreak} \let\Eftable\Etable \let\Evtable\Etable \let\Eitemize\Etable \let\Eenumerate\Etable % This is the counter used by @enumerate, which is really @itemize \newcount \itemno \envdef\itemize{\parsearg\doitemize} \def\doitemize#1{% \aboveenvbreak \itemmax=\itemindent \advance\itemmax by -\itemmargin \advance\leftskip by \itemindent \exdentamount=\itemindent \parindent=0pt \parskip=\smallskipamount \ifdim\parskip=0pt \parskip=2pt \fi % % Try typesetting the item mark that if the document erroneously says % something like @itemize @samp (intending @table), there's an error % right away at the @itemize. It's not the best error message in the % world, but it's better than leaving it to the @item. This means if % the user wants an empty mark, they have to say @w{} not just @w. \def\itemcontents{#1}% \setbox0 = \hbox{\itemcontents}% % % @itemize with no arg is equivalent to @itemize @bullet. \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi % \let\item=\itemizeitem } % Definition of @item while inside @itemize and @enumerate. % \def\itemizeitem{% \advance\itemno by 1 % for enumerations {\let\par=\endgraf \smallbreak}% reasonable place to break {% % If the document has an @itemize directly after a section title, a % \nobreak will be last on the list, and \sectionheading will have % done a \vskip-\parskip. In that case, we don't want to zero % parskip, or the item text will crash with the heading. On the % other hand, when there is normal text preceding the item (as there % usually is), we do want to zero parskip, or there would be too much % space. In that case, we won't have a \nobreak before. At least % that's the theory. \ifnum\lastpenalty<10000 \parskip=0in \fi \noindent \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% % \vadjust{\penalty 1200}}% not good to break after first line of item. \flushcr } % \splitoff TOKENS\endmark defines \first to be the first token in % TOKENS, and \rest to be the remainder. % \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% % Allow an optional argument of an uppercase letter, lowercase letter, % or number, to specify the first label in the enumerated list. No % argument is the same as `1'. % \envparseargdef\enumerate{\enumeratey #1 \endenumeratey} \def\enumeratey #1 #2\endenumeratey{% % If we were given no argument, pretend we were given `1'. \def\thearg{#1}% \ifx\thearg\empty \def\thearg{1}\fi % % Detect if the argument is a single token. If so, it might be a % letter. Otherwise, the only valid thing it can be is a number. % (We will always have one token, because of the test we just made. % This is a good thing, since \splitoff doesn't work given nothing at % all -- the first parameter is undelimited.) \expandafter\splitoff\thearg\endmark \ifx\rest\empty % Only one token in the argument. It could still be anything. % A ``lowercase letter'' is one whose \lccode is nonzero. % An ``uppercase letter'' is one whose \lccode is both nonzero, and % not equal to itself. % Otherwise, we assume it's a number. % % We need the \relax at the end of the \ifnum lines to stop TeX from % continuing to look for a . % \ifnum\lccode\expandafter`\thearg=0\relax \numericenumerate % a number (we hope) \else % It's a letter. \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax \lowercaseenumerate % lowercase letter \else \uppercaseenumerate % uppercase letter \fi \fi \else % Multiple tokens in the argument. We hope it's a number. \numericenumerate \fi } % An @enumerate whose labels are integers. The starting integer is % given in \thearg. % \def\numericenumerate{% \itemno = \thearg \startenumeration{\the\itemno}% } % The starting (lowercase) letter is in \thearg. \def\lowercaseenumerate{% \itemno = \expandafter`\thearg \startenumeration{% % Be sure we're not beyond the end of the alphabet. \ifnum\itemno=0 \errmessage{No more lowercase letters in @enumerate; get a bigger alphabet}% \fi \char\lccode\itemno }% } % The starting (uppercase) letter is in \thearg. \def\uppercaseenumerate{% \itemno = \expandafter`\thearg \startenumeration{% % Be sure we're not beyond the end of the alphabet. \ifnum\itemno=0 \errmessage{No more uppercase letters in @enumerate; get a bigger alphabet} \fi \char\uccode\itemno }% } % Call \doitemize, adding a period to the first argument and supplying the % common last two arguments. Also subtract one from the initial value in % \itemno, since @item increments \itemno. % \def\startenumeration#1{% \advance\itemno by -1 \doitemize{#1.}\flushcr } % @alphaenumerate and @capsenumerate are abbreviations for giving an arg % to @enumerate. % \def\alphaenumerate{\enumerate{a}} \def\capsenumerate{\enumerate{A}} \def\Ealphaenumerate{\Eenumerate} \def\Ecapsenumerate{\Eenumerate} % @multitable macros % Amy Hendrickson, 8/18/94, 3/6/96 % % @multitable ... @end multitable will make as many columns as desired. % Contents of each column will wrap at width given in preamble. Width % can be specified either with sample text given in a template line, % or in percent of \hsize, the current width of text on page. % Table can continue over pages but will only break between lines. % To make preamble: % % Either define widths of columns in terms of percent of \hsize: % @multitable @columnfractions .25 .3 .45 % @item ... % % Numbers following @columnfractions are the percent of the total % current hsize to be used for each column. You may use as many % columns as desired. % Or use a template: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item ... % using the widest term desired in each column. % Each new table line starts with @item, each subsequent new column % starts with @tab. Empty columns may be produced by supplying @tab's % with nothing between them for as many times as empty columns are needed, % ie, @tab@tab@tab will produce two empty columns. % @item, @tab do not need to be on their own lines, but it will not hurt % if they are. % Sample multitable: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item first col stuff @tab second col stuff @tab third col % @item % first col stuff % @tab % second col stuff % @tab % third col % @item first col stuff @tab second col stuff % @tab Many paragraphs of text may be used in any column. % % They will wrap at the width determined by the template. % @item@tab@tab This will be in third column. % @end multitable % Default dimensions may be reset by user. % @multitableparskip is vertical space between paragraphs in table. % @multitableparindent is paragraph indent in table. % @multitablecolmargin is horizontal space to be left between columns. % @multitablelinespace is space to leave between table items, baseline % to baseline. % 0pt means it depends on current normal line spacing. % \newskip\multitableparskip \newskip\multitableparindent \newdimen\multitablecolspace \newskip\multitablelinespace \multitableparskip=0pt \multitableparindent=6pt \multitablecolspace=12pt \multitablelinespace=0pt % Macros used to set up halign preamble: % \let\endsetuptable\relax \def\xendsetuptable{\endsetuptable} \let\columnfractions\relax \def\xcolumnfractions{\columnfractions} \newif\ifsetpercent % #1 is the @columnfraction, usually a decimal number like .5, but might % be just 1. We just use it, whatever it is. % \def\pickupwholefraction#1 {% \global\advance\colcount by 1 \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% \setuptable } \newcount\colcount \def\setuptable#1{% \def\firstarg{#1}% \ifx\firstarg\xendsetuptable \let\go = \relax \else \ifx\firstarg\xcolumnfractions \global\setpercenttrue \else \ifsetpercent \let\go\pickupwholefraction \else \global\advance\colcount by 1 \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a % separator; typically that is always in the input, anyway. \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% \fi \fi \ifx\go\pickupwholefraction % Put the argument back for the \pickupwholefraction call, so % we'll always have a period there to be parsed. \def\go{\pickupwholefraction#1}% \else \let\go = \setuptable \fi% \fi \go } % multitable-only commands. % % @headitem starts a heading row, which we typeset in bold. % Assignments have to be global since we are inside the implicit group % of an alignment entry. \everycr resets \everytab so we don't have to % undo it ourselves. \def\headitemfont{\b}% for people to use in the template row; not changeable \def\headitem{% \checkenv\multitable \crcr \global\everytab={\bf}% can't use \headitemfont since the parsing differs \the\everytab % for the first item }% % % A \tab used to include \hskip1sp. But then the space in a template % line is not enough. That is bad. So let's go back to just `&' until % we again encounter the problem the 1sp was intended to solve. % --karl, nathan@acm.org, 20apr99. \def\tab{\checkenv\multitable &\the\everytab}% % @multitable ... @end multitable definitions: % \newtoks\everytab % insert after every tab. % \envdef\multitable{% \vskip\parskip \startsavinginserts % % @item within a multitable starts a normal row. % We use \def instead of \let so that if one of the multitable entries % contains an @itemize, we don't choke on the \item (seen as \crcr aka % \endtemplate) expanding \doitemize. \def\item{\crcr}% % \tolerance=9500 \hbadness=9500 \setmultitablespacing \parskip=\multitableparskip \parindent=\multitableparindent \overfullrule=0pt \global\colcount=0 % \everycr = {% \noalign{% \global\everytab={}% \global\colcount=0 % Reset the column counter. % Check for saved footnotes, etc. \checkinserts % Keeps underfull box messages off when table breaks over pages. %\filbreak % Maybe so, but it also creates really weird page breaks when the % table breaks over pages. Wouldn't \vfil be better? Wait until the % problem manifests itself, so it can be fixed for real --karl. }% }% % \parsearg\domultitable } \def\domultitable#1{% % To parse everything between @multitable and @item: \setuptable#1 \endsetuptable % % This preamble sets up a generic column definition, which will % be used as many times as user calls for columns. % \vtop will set a single line and will also let text wrap and % continue for many paragraphs if desired. \halign\bgroup &% \global\advance\colcount by 1 \multistrut \vtop{% % Use the current \colcount to find the correct column width: \hsize=\expandafter\csname col\the\colcount\endcsname % % In order to keep entries from bumping into each other % we will add a \leftskip of \multitablecolspace to all columns after % the first one. % % If a template has been used, we will add \multitablecolspace % to the width of each template entry. % % If the user has set preamble in terms of percent of \hsize we will % use that dimension as the width of the column, and the \leftskip % will keep entries from bumping into each other. Table will start at % left margin and final column will justify at right margin. % % Make sure we don't inherit \rightskip from the outer environment. \rightskip=0pt \ifnum\colcount=1 % The first column will be indented with the surrounding text. \advance\hsize by\leftskip \else \ifsetpercent \else % If user has not set preamble in terms of percent of \hsize % we will advance \hsize by \multitablecolspace. \advance\hsize by \multitablecolspace \fi % In either case we will make \leftskip=\multitablecolspace: \leftskip=\multitablecolspace \fi % Ignoring space at the beginning and end avoids an occasional spurious % blank line, when TeX decides to break the line at the space before the % box from the multistrut, so the strut ends up on a line by itself. % For example: % @multitable @columnfractions .11 .89 % @item @code{#} % @tab Legal holiday which is valid in major parts of the whole country. % Is automatically provided with highlighting sequences respectively % marking characters. \noindent\ignorespaces##\unskip\multistrut }\cr } \def\Emultitable{% \crcr \egroup % end the \halign \global\setpercentfalse } \def\setmultitablespacing{% \def\multistrut{\strut}% just use the standard line spacing % % Compute \multitablelinespace (if not defined by user) for use in % \multitableparskip calculation. We used define \multistrut based on % this, but (ironically) that caused the spacing to be off. % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100. \ifdim\multitablelinespace=0pt \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip \global\advance\multitablelinespace by-\ht0 \fi % Test to see if parskip is larger than space between lines of % table. If not, do nothing. % If so, set to same dimension as multitablelinespace. \ifdim\multitableparskip>\multitablelinespace \global\multitableparskip=\multitablelinespace \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller % than skip between lines in the table. \fi% \ifdim\multitableparskip=0pt \global\multitableparskip=\multitablelinespace \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller % than skip between lines in the table. \fi} \message{conditionals,} % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, % @ifnotxml always succeed. They currently do nothing; we don't % attempt to check whether the conditionals are properly nested. But we % have to remember that they are conditionals, so that @end doesn't % attempt to close an environment group. % \def\makecond#1{% \expandafter\let\csname #1\endcsname = \relax \expandafter\let\csname iscond.#1\endcsname = 1 } \makecond{iftex} \makecond{ifnotdocbook} \makecond{ifnothtml} \makecond{ifnotinfo} \makecond{ifnotplaintext} \makecond{ifnotxml} % Ignore @ignore, @ifhtml, @ifinfo, and the like. % \def\direntry{\doignore{direntry}} \def\documentdescription{\doignore{documentdescription}} \def\docbook{\doignore{docbook}} \def\html{\doignore{html}} \def\ifdocbook{\doignore{ifdocbook}} \def\ifhtml{\doignore{ifhtml}} \def\ifinfo{\doignore{ifinfo}} \def\ifnottex{\doignore{ifnottex}} \def\ifplaintext{\doignore{ifplaintext}} \def\ifxml{\doignore{ifxml}} \def\ignore{\doignore{ignore}} \def\menu{\doignore{menu}} \def\xml{\doignore{xml}} % Ignore text until a line `@end #1', keeping track of nested conditionals. % % A count to remember the depth of nesting. \newcount\doignorecount \def\doignore#1{\begingroup % Scan in ``verbatim'' mode: \obeylines \catcode`\@ = \other \catcode`\{ = \other \catcode`\} = \other % % Make sure that spaces turn into tokens that match what \doignoretext wants. \spaceisspace % % Count number of #1's that we've seen. \doignorecount = 0 % % Swallow text until we reach the matching `@end #1'. \dodoignore{#1}% } { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. \obeylines % % \gdef\dodoignore#1{% % #1 contains the command name as a string, e.g., `ifinfo'. % % Define a command to find the next `@end #1'. \long\def\doignoretext##1^^M@end #1{% \doignoretextyyy##1^^M@#1\_STOP_}% % % And this command to find another #1 command, at the beginning of a % line. (Otherwise, we would consider a line `@c @ifset', for % example, to count as an @ifset for nesting.) \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% % % And now expand that command. \doignoretext ^^M% }% } \def\doignoreyyy#1{% \def\temp{#1}% \ifx\temp\empty % Nothing found. \let\next\doignoretextzzz \else % Found a nested condition, ... \advance\doignorecount by 1 \let\next\doignoretextyyy % ..., look for another. % If we're here, #1 ends with ^^M\ifinfo (for example). \fi \next #1% the token \_STOP_ is present just after this macro. } % We have to swallow the remaining "\_STOP_". % \def\doignoretextzzz#1{% \ifnum\doignorecount = 0 % We have just found the outermost @end. \let\next\enddoignore \else % Still inside a nested condition. \advance\doignorecount by -1 \let\next\doignoretext % Look for the next @end. \fi \next } % Finish off ignored text. { \obeylines% % Ignore anything after the last `@end #1'; this matters in verbatim % environments, where otherwise the newline after an ignored conditional % would result in a blank line in the output. \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% } % @set VAR sets the variable VAR to an empty value. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. % % Since we want to separate VAR from REST-OF-LINE (which might be % empty), we can't just use \parsearg; we have to insert a space of our % own to delimit the rest of the line, and then take it out again if we % didn't need it. % We rely on the fact that \parsearg sets \catcode`\ =10. % \parseargdef\set{\setyyy#1 \endsetyyy} \def\setyyy#1 #2\endsetyyy{% {% \makevalueexpandable \def\temp{#2}% \edef\next{\gdef\makecsname{SET#1}}% \ifx\temp\empty \next{}% \else \setzzz#2\endsetzzz \fi }% } % Remove the trailing space \setxxx inserted. \def\setzzz#1 \endsetzzz{\next{#1}} % @clear VAR clears (i.e., unsets) the variable VAR. % \parseargdef\clear{% {% \makevalueexpandable \global\expandafter\let\csname SET#1\endcsname=\relax }% } % @value{foo} gets the text saved in variable foo. \def\value{\begingroup\makevalueexpandable\valuexxx} \def\valuexxx#1{\expandablevalue{#1}\endgroup} { \catcode`\- = \active \catcode`\_ = \active % \gdef\makevalueexpandable{% \let\value = \expandablevalue % We don't want these characters active, ... \catcode`\-=\other \catcode`\_=\other % ..., but we might end up with active ones in the argument if % we're called from @code, as @code{@value{foo-bar_}}, though. % So \let them to their normal equivalents. \let-\normaldash \let_\normalunderscore } } % We have this subroutine so that we can handle at least some @value's % properly in indexes (we call \makevalueexpandable in \indexdummies). % The command has to be fully expandable (if the variable is set), since % the result winds up in the index file. This means that if the % variable's value contains other Texinfo commands, it's almost certain % it will fail (although perhaps we could fix that with sufficient work % to do a one-level expansion on the result, instead of complete). % \def\expandablevalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax {[No value for ``#1'']}% \message{Variable `#1', used in @value, is not set.}% \else \csname SET#1\endcsname \fi } % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined % with @set. % % To get special treatment of `@end ifset,' call \makeond and the redefine. % \makecond{ifset} \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} \def\doifset#1#2{% {% \makevalueexpandable \let\next=\empty \expandafter\ifx\csname SET#2\endcsname\relax #1% If not set, redefine \next. \fi \expandafter }\next } \def\ifsetfail{\doignore{ifset}} % @ifclear VAR ... @end executes the `...' iff VAR has never been % defined with @set, or has been undefined with @clear. % % The `\else' inside the `\doifset' parameter is a trick to reuse the % above code: if the variable is not set, do nothing, if it is set, % then redefine \next to \ifclearfail. % \makecond{ifclear} \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} \def\ifclearfail{\doignore{ifclear}} % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written % without the @) is in fact defined. We can only feasibly check at the % TeX level, so something like `mathcode' is going to considered % defined even though it is not a Texinfo command. % \makecond{ifcommanddefined} \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}} % \def\doifcmddefined#1#2{{% \makevalueexpandable \let\next=\empty \expandafter\ifx\csname #2\endcsname\relax #1% If not defined, \let\next as above. \fi \expandafter }\next } \def\ifcmddefinedfail{\doignore{ifcommanddefined}} % @ifcommandnotdefined CMD ... handled similar to @ifclear above. \makecond{ifcommandnotdefined} \def\ifcommandnotdefined{% \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}} \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}} % Set the `txicommandconditionals' variable, so documents have a way to % test if the @ifcommand...defined conditionals are available. \set txicommandconditionals % @dircategory CATEGORY -- specify a category of the dir file % which this file should belong to. Ignore this in TeX. \let\dircategory=\comment % @defininfoenclose. \let\definfoenclose=\comment \message{indexing,} % Index generation facilities % Define \newwrite to be identical to plain tex's \newwrite % except not \outer, so it can be used within macros and \if's. \edef\newwrite{\makecsname{ptexnewwrite}} % \newindex {foo} defines an index named foo. % It automatically defines \fooindex such that % \fooindex ...rest of line... puts an entry in the index foo. % It also defines \fooindfile to be the number of the output channel for % the file that accumulates this index. The file's extension is foo. % The name of an index should be no more than 2 characters long % for the sake of vms. % \def\newindex#1{% \iflinks \expandafter\newwrite \csname#1indfile\endcsname \openout \csname#1indfile\endcsname \jobname.#1 % Open the file \fi \expandafter\xdef\csname#1index\endcsname{% % Define @#1index \noexpand\doindex{#1}} } % @defindex foo == \newindex{foo} % \def\defindex{\parsearg\newindex} % Define @defcodeindex, like @defindex except put all entries in @code. % \def\defcodeindex{\parsearg\newcodeindex} % \def\newcodeindex#1{% \iflinks \expandafter\newwrite \csname#1indfile\endcsname \openout \csname#1indfile\endcsname \jobname.#1 \fi \expandafter\xdef\csname#1index\endcsname{% \noexpand\docodeindex{#1}}% } % @synindex foo bar makes index foo feed into index bar. % Do this instead of @defindex foo if you don't want it as a separate index. % % @syncodeindex foo bar similar, but put all entries made for index foo % inside @code. % \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), % #3 the target index (bar). \def\dosynindex#1#2#3{% % Only do \closeout if we haven't already done it, else we'll end up % closing the target index. \expandafter \ifx\csname donesynindex#2\endcsname \relax % The \closeout helps reduce unnecessary open files; the limit on the % Acorn RISC OS is a mere 16 files. \expandafter\closeout\csname#2indfile\endcsname \expandafter\let\csname donesynindex#2\endcsname = 1 \fi % redefine \fooindfile: \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname \expandafter\let\csname#2indfile\endcsname=\temp % redefine \fooindex: \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% } % Define \doindex, the driver for all \fooindex macros. % Argument #1 is generated by the calling \fooindex macro, % and it is "foo", the name of the index. % \doindex just uses \parsearg; it calls \doind for the actual work. % This is because \doind is more useful to call from other macros. % There is also \dosubind {index}{topic}{subtopic} % which makes an entry in a two-level index such as the operation index. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} \def\singleindexer #1{\doind{\indexname}{#1}} % like the previous two, but they put @code around the argument. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} % Take care of Texinfo commands that can appear in an index entry. % Since there are some commands we want to expand, and others we don't, % we have to laboriously prevent expansion for those that we don't. % \def\indexdummies{% \escapechar = `\\ % use backslash in output files. \def\@{@}% change to @@ when we switch to @ as escape char in index files. \def\ {\realbackslash\space }% % % Need these unexpandable (because we define \tt as a dummy) % definitions when @{ or @} appear in index entry text. Also, more % complicated, when \tex is in effect and \{ is a \delimiter again. % We can't use \lbracecmd and \rbracecmd because texindex assumes % braces and backslashes are used only as delimiters. Perhaps we % should define @lbrace and @rbrace commands a la @comma. \def\{{{\tt\char123}}% \def\}{{\tt\char125}}% % % I don't entirely understand this, but when an index entry is % generated from a macro call, the \endinput which \scanmacro inserts % causes processing to be prematurely terminated. This is, % apparently, because \indexsorttmp is fully expanded, and \endinput % is an expandable command. The redefinition below makes \endinput % disappear altogether for that purpose -- although logging shows that % processing continues to some further point. On the other hand, it % seems \endinput does not hurt in the printed index arg, since that % is still getting written without apparent harm. % % Sample source (mac-idx3.tex, reported by Graham Percival to % help-texinfo, 22may06): % @macro funindex {WORD} % @findex xyz % @end macro % ... % @funindex commtest % % The above is not enough to reproduce the bug, but it gives the flavor. % % Sample whatsit resulting: % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}} % % So: \let\endinput = \empty % % Do the redefinitions. \commondummies } % For the aux and toc files, @ is the escape character. So we want to % redefine everything using @ as the escape character (instead of % \realbackslash, still used for index files). When everything uses @, % this will be simpler. % \def\atdummies{% \def\@{@@}% \def\ {@ }% \let\{ = \lbraceatcmd \let\} = \rbraceatcmd % % Do the redefinitions. \commondummies \otherbackslash } % Called from \indexdummies and \atdummies. % \def\commondummies{% % % \definedummyword defines \#1 as \string\#1\space, thus effectively % preventing its expansion. This is used only for control words, % not control letters, because the \space would be incorrect for % control characters, but is needed to separate the control word % from whatever follows. % % For control letters, we have \definedummyletter, which omits the % space. % % These can be used both for control words that take an argument and % those that do not. If it is followed by {arg} in the input, then % that will dutifully get written to the index (or wherever). % \def\definedummyword ##1{\def##1{\string##1\space}}% \def\definedummyletter##1{\def##1{\string##1}}% \let\definedummyaccent\definedummyletter % \commondummiesnofonts % \definedummyletter\_% \definedummyletter\-% % % Non-English letters. \definedummyword\AA \definedummyword\AE \definedummyword\DH \definedummyword\L \definedummyword\O \definedummyword\OE \definedummyword\TH \definedummyword\aa \definedummyword\ae \definedummyword\dh \definedummyword\exclamdown \definedummyword\l \definedummyword\o \definedummyword\oe \definedummyword\ordf \definedummyword\ordm \definedummyword\questiondown \definedummyword\ss \definedummyword\th % % Although these internal commands shouldn't show up, sometimes they do. \definedummyword\bf \definedummyword\gtr \definedummyword\hat \definedummyword\less \definedummyword\sf \definedummyword\sl \definedummyword\tclose \definedummyword\tt % \definedummyword\LaTeX \definedummyword\TeX % % Assorted special characters. \definedummyword\arrow \definedummyword\bullet \definedummyword\comma \definedummyword\copyright \definedummyword\registeredsymbol \definedummyword\dots \definedummyword\enddots \definedummyword\entrybreak \definedummyword\equiv \definedummyword\error \definedummyword\euro \definedummyword\expansion \definedummyword\geq \definedummyword\guillemetleft \definedummyword\guillemetright \definedummyword\guilsinglleft \definedummyword\guilsinglright \definedummyword\lbracechar \definedummyword\leq \definedummyword\minus \definedummyword\ogonek \definedummyword\pounds \definedummyword\point \definedummyword\print \definedummyword\quotedblbase \definedummyword\quotedblleft \definedummyword\quotedblright \definedummyword\quoteleft \definedummyword\quoteright \definedummyword\quotesinglbase \definedummyword\rbracechar \definedummyword\result \definedummyword\textdegree % % We want to disable all macros so that they are not expanded by \write. \macrolist % \normalturnoffactive % % Handle some cases of @value -- where it does not contain any % (non-fully-expandable) commands. \makevalueexpandable } % \commondummiesnofonts: common to \commondummies and \indexnofonts. % \def\commondummiesnofonts{% % Control letters and accents. \definedummyletter\!% \definedummyaccent\"% \definedummyaccent\'% \definedummyletter\*% \definedummyaccent\,% \definedummyletter\.% \definedummyletter\/% \definedummyletter\:% \definedummyaccent\=% \definedummyletter\?% \definedummyaccent\^% \definedummyaccent\`% \definedummyaccent\~% \definedummyword\u \definedummyword\v \definedummyword\H \definedummyword\dotaccent \definedummyword\ogonek \definedummyword\ringaccent \definedummyword\tieaccent \definedummyword\ubaraccent \definedummyword\udotaccent \definedummyword\dotless % % Texinfo font commands. \definedummyword\b \definedummyword\i \definedummyword\r \definedummyword\sansserif \definedummyword\sc \definedummyword\slanted \definedummyword\t % % Commands that take arguments. \definedummyword\abbr \definedummyword\acronym \definedummyword\anchor \definedummyword\cite \definedummyword\code \definedummyword\command \definedummyword\dfn \definedummyword\dmn \definedummyword\email \definedummyword\emph \definedummyword\env \definedummyword\file \definedummyword\image \definedummyword\indicateurl \definedummyword\inforef \definedummyword\kbd \definedummyword\key \definedummyword\math \definedummyword\option \definedummyword\pxref \definedummyword\ref \definedummyword\samp \definedummyword\strong \definedummyword\tie \definedummyword\uref \definedummyword\url \definedummyword\var \definedummyword\verb \definedummyword\w \definedummyword\xref } % \indexnofonts is used when outputting the strings to sort the index % by, and when constructing control sequence names. It eliminates all % control sequences and just writes whatever the best ASCII sort string % would be for a given command (usually its argument). % \def\indexnofonts{% % Accent commands should become @asis. \def\definedummyaccent##1{\let##1\asis}% % We can just ignore other control letters. \def\definedummyletter##1{\let##1\empty}% % All control words become @asis by default; overrides below. \let\definedummyword\definedummyaccent % \commondummiesnofonts % % Don't no-op \tt, since it isn't a user-level command % and is used in the definitions of the active chars like <, >, |, etc. % Likewise with the other plain tex font commands. %\let\tt=\asis % \def\ { }% \def\@{@}% \def\_{\normalunderscore}% \def\-{}% @- shouldn't affect sorting % % Unfortunately, texindex is not prepared to handle braces in the % content at all. So for index sorting, we map @{ and @} to strings % starting with |, since that ASCII character is between ASCII { and }. \def\{{|a}% \def\lbracechar{|a}% % \def\}{|b}% \def\rbracechar{|b}% % % Non-English letters. \def\AA{AA}% \def\AE{AE}% \def\DH{DZZ}% \def\L{L}% \def\OE{OE}% \def\O{O}% \def\TH{ZZZ}% \def\aa{aa}% \def\ae{ae}% \def\dh{dzz}% \def\exclamdown{!}% \def\l{l}% \def\oe{oe}% \def\ordf{a}% \def\ordm{o}% \def\o{o}% \def\questiondown{?}% \def\ss{ss}% \def\th{zzz}% % \def\LaTeX{LaTeX}% \def\TeX{TeX}% % % Assorted special characters. % (The following {} will end up in the sort string, but that's ok.) \def\arrow{->}% \def\bullet{bullet}% \def\comma{,}% \def\copyright{copyright}% \def\dots{...}% \def\enddots{...}% \def\equiv{==}% \def\error{error}% \def\euro{euro}% \def\expansion{==>}% \def\geq{>=}% \def\guillemetleft{<<}% \def\guillemetright{>>}% \def\guilsinglleft{<}% \def\guilsinglright{>}% \def\leq{<=}% \def\minus{-}% \def\point{.}% \def\pounds{pounds}% \def\print{-|}% \def\quotedblbase{"}% \def\quotedblleft{"}% \def\quotedblright{"}% \def\quoteleft{`}% \def\quoteright{'}% \def\quotesinglbase{,}% \def\registeredsymbol{R}% \def\result{=>}% \def\textdegree{o}% % \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax \else \indexlquoteignore \fi % % We need to get rid of all macros, leaving only the arguments (if present). % Of course this is not nearly correct, but it is the best we can do for now. % makeinfo does not expand macros in the argument to @deffn, which ends up % writing an index entry, and texindex isn't prepared for an index sort entry % that starts with \. % % Since macro invocations are followed by braces, we can just redefine them % to take a single TeX argument. The case of a macro invocation that % goes to end-of-line is not handled. % \macrolist } % Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us % ignore left quotes in the sort term. {\catcode`\`=\active \gdef\indexlquoteignore{\let`=\empty}} \let\indexbackslash=0 %overridden during \printindex. \let\SETmarginindex=\relax % put index entries in margin (undocumented)? % Most index entries go through here, but \dosubind is the general case. % #1 is the index name, #2 is the entry text. \def\doind#1#2{\dosubind{#1}{#2}{}} % Workhorse for all \fooindexes. % #1 is name of index, #2 is stuff to put there, #3 is subentry -- % empty if called from \doind, as we usually are (the main exception % is with most defuns, which call us directly). % \def\dosubind#1#2#3{% \iflinks {% % Store the main index entry text (including the third arg). \toks0 = {#2}% % If third arg is present, precede it with a space. \def\thirdarg{#3}% \ifx\thirdarg\empty \else \toks0 = \expandafter{\the\toks0 \space #3}% \fi % \edef\writeto{\csname#1indfile\endcsname}% % \safewhatsit\dosubindwrite }% \fi } % Write the entry in \toks0 to the index file: % \def\dosubindwrite{% % Put the index entry in the margin if desired. \ifx\SETmarginindex\relax\else \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% \fi % % Remember, we are within a group. \indexdummies % Must do this here, since \bf, etc expand at this stage \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now % so it will be output as is; and it will print as backslash. % % Process the index entry with all font commands turned off, to % get the string to sort by. {\indexnofonts \edef\temp{\the\toks0}% need full expansion \xdef\indexsorttmp{\temp}% }% % % Set up the complete index entry, with both the sort key and % the original text, including any font commands. We write % three arguments to \entry to the .?? file (four in the % subentry case), texindex reduces to two when writing the .??s % sorted result. \edef\temp{% \write\writeto{% \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}% }% \temp } % Take care of unwanted page breaks/skips around a whatsit: % % If a skip is the last thing on the list now, preserve it % by backing up by \lastskip, doing the \write, then inserting % the skip again. Otherwise, the whatsit generated by the % \write or \pdfdest will make \lastskip zero. The result is that % sequences like this: % @end defun % @tindex whatever % @defun ... % will have extra space inserted, because the \medbreak in the % start of the @defun won't see the skip inserted by the @end of % the previous defun. % % But don't do any of this if we're not in vertical mode. We % don't want to do a \vskip and prematurely end a paragraph. % % Avoid page breaks due to these extra skips, too. % % But wait, there is a catch there: % We'll have to check whether \lastskip is zero skip. \ifdim is not % sufficient for this purpose, as it ignores stretch and shrink parts % of the skip. The only way seems to be to check the textual % representation of the skip. % % The following is almost like \def\zeroskipmacro{0.0pt} except that % the ``p'' and ``t'' characters have catcode \other, not 11 (letter). % \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} % \newskip\whatsitskip \newcount\whatsitpenalty % % ..., ready, GO: % \def\safewhatsit#1{\ifhmode #1% \else % \lastskip and \lastpenalty cannot both be nonzero simultaneously. \whatsitskip = \lastskip \edef\lastskipmacro{\the\lastskip}% \whatsitpenalty = \lastpenalty % % If \lastskip is nonzero, that means the last item was a % skip. And since a skip is discardable, that means this % -\whatsitskip glue we're inserting is preceded by a % non-discardable item, therefore it is not a potential % breakpoint, therefore no \nobreak needed. \ifx\lastskipmacro\zeroskipmacro \else \vskip-\whatsitskip \fi % #1% % \ifx\lastskipmacro\zeroskipmacro % If \lastskip was zero, perhaps the last item was a penalty, and % perhaps it was >=10000, e.g., a \nobreak. In that case, we want % to re-insert the same penalty (values >10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: % @deffn deffn-whatever % @vindex index-whatever % Description. % would allow a break between the index-whatever whatsit % and the "Description." paragraph. \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi \else % On the other hand, if we had a nonzero \lastskip, % this make-up glue would be preceded by a non-discardable item % (the whatsit from the \write), so we must insert a \nobreak. \nobreak\vskip\whatsitskip \fi \fi} % The index entry written in the file actually looks like % \entry {sortstring}{page}{topic} % or % \entry {sortstring}{page}{topic}{subtopic} % The texindex program reads in these files and writes files % containing these kinds of lines: % \initial {c} % before the first topic whose initial is c % \entry {topic}{pagelist} % for a topic that is used without subtopics % \primary {topic} % for the beginning of a topic that is used with subtopics % \secondary {subtopic}{pagelist} % for each subtopic. % Define the user-accessible indexing commands % @findex, @vindex, @kindex, @cindex. \def\findex {\fnindex} \def\kindex {\kyindex} \def\cindex {\cpindex} \def\vindex {\vrindex} \def\tindex {\tpindex} \def\pindex {\pgindex} \def\cindexsub {\begingroup\obeylines\cindexsub} {\obeylines % \gdef\cindexsub "#1" #2^^M{\endgroup % \dosubind{cp}{#2}{#1}}} % Define the macros used in formatting output of the sorted index material. % @printindex causes a particular index (the ??s file) to get printed. % It does not print any chapter heading (usually an @unnumbered). % \parseargdef\printindex{\begingroup \dobreak \chapheadingskip{10000}% % \smallfonts \rm \tolerance = 9500 \plainfrenchspacing \everypar = {}% don't want the \kern\-parindent from indentation suppression. % % See if the index file exists and is nonempty. % Change catcode of @ here so that if the index file contains % \initial {@} % as its first line, TeX doesn't complain about mismatched braces % (because it thinks @} is a control sequence). \catcode`\@ = 11 \openin 1 \jobname.#1s \ifeof 1 % \enddoublecolumns gets confused if there is no text in the index, % and it loses the chapter title and the aux file entries for the % index. The easiest way to prevent this problem is to make sure % there is some text. \putwordIndexNonexistent \else % % If the index file exists but is empty, then \openin leaves \ifeof % false. We have to make TeX try to read something from the file, so % it can discover if there is anything in it. \read 1 to \temp \ifeof 1 \putwordIndexIsEmpty \else % Index files are almost Texinfo source, but we use \ as the escape % character. It would be better to use @, but that's too big a change % to make right now. \def\indexbackslash{\backslashcurfont}% \catcode`\\ = 0 \escapechar = `\\ \begindoublecolumns \input \jobname.#1s \enddoublecolumns \fi \fi \closein 1 \endgroup} % These macros are used by the sorted index file itself. % Change them to control the appearance of the index. \def\initial#1{{% % Some minor font changes for the special characters. \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt % % Remove any glue we may have, we'll be inserting our own. \removelastskip % % We like breaks before the index initials, so insert a bonus. \nobreak \vskip 0pt plus 3\baselineskip \penalty 0 \vskip 0pt plus -3\baselineskip % % Typeset the initial. Making this add up to a whole number of % baselineskips increases the chance of the dots lining up from column % to column. It still won't often be perfect, because of the stretch % we need before each entry, but it's better. % % No shrink because it confuses \balancecolumns. \vskip 1.67\baselineskip plus .5\baselineskip \leftline{\secbf #1}% % Do our best not to break after the initial. \nobreak \vskip .33\baselineskip plus .1\baselineskip }} % \entry typesets a paragraph consisting of the text (#1), dot leaders, and % then page number (#2) flushed to the right margin. It is used for index % and table of contents entries. The paragraph is indented by \leftskip. % % A straightforward implementation would start like this: % \def\entry#1#2{... % But this freezes the catcodes in the argument, and can cause problems to % @code, which sets - active. This problem was fixed by a kludge--- % ``-'' was active throughout whole index, but this isn't really right. % The right solution is to prevent \entry from swallowing the whole text. % --kasal, 21nov03 \def\entry{% \begingroup % % Start a new paragraph if necessary, so our assignments below can't % affect previous text. \par % % Do not fill out the last line with white space. \parfillskip = 0in % % No extra space above this paragraph. \parskip = 0in % % Do not prefer a separate line ending with a hyphen to fewer lines. \finalhyphendemerits = 0 % % \hangindent is only relevant when the entry text and page number % don't both fit on one line. In that case, bob suggests starting the % dots pretty far over on the line. Unfortunately, a large % indentation looks wrong when the entry text itself is broken across % lines. So we use a small indentation and put up with long leaders. % % \hangafter is reset to 1 (which is the value we want) at the start % of each paragraph, so we need not do anything with that. \hangindent = 2em % % When the entry text needs to be broken, just fill out the first line % with blank space. \rightskip = 0pt plus1fil % % A bit of stretch before each entry for the benefit of balancing % columns. \vskip 0pt plus1pt % % When reading the text of entry, convert explicit line breaks % from @* into spaces. The user might give these in long section % titles, for instance. \def\*{\unskip\space\ignorespaces}% \def\entrybreak{\hfil\break}% % % Swallow the left brace of the text (first parameter): \afterassignment\doentry \let\temp = } \def\entrybreak{\unskip\space\ignorespaces}% \def\doentry{% \bgroup % Instead of the swallowed brace. \noindent \aftergroup\finishentry % And now comes the text of the entry. } \def\finishentry#1{% % #1 is the page number. % % The following is kludged to not output a line of dots in the index if % there are no page numbers. The next person who breaks this will be % cursed by a Unix daemon. \setbox\boxA = \hbox{#1}% \ifdim\wd\boxA = 0pt \ % \else % % If we must, put the page number on a line of its own, and fill out % this line with blank space. (The \hfil is overwhelmed with the % fill leaders glue in \indexdotfill if the page number does fit.) \hfil\penalty50 \null\nobreak\indexdotfill % Have leaders before the page number. % % The `\ ' here is removed by the implicit \unskip that TeX does as % part of (the primitive) \par. Without it, a spurious underfull % \hbox ensues. \ifpdf \pdfgettoks#1.% \ \the\toksA \else \ #1% \fi \fi \par \endgroup } % Like plain.tex's \dotfill, except uses up at least 1 em. \def\indexdotfill{\cleaders \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill} \def\primary #1{\line{#1\hfil}} \newskip\secondaryindent \secondaryindent=0.5cm \def\secondary#1#2{{% \parfillskip=0in \parskip=0in \hangindent=1in \hangafter=1 \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill \ifpdf \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. \else #2 \fi \par }} % Define two-column mode, which we use to typeset indexes. % Adapted from the TeXbook, page 416, which is to say, % the manmac.tex format used to print the TeXbook itself. \catcode`\@=11 \newbox\partialpage \newdimen\doublecolumnhsize \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns % Grab any single-column material above us. \output = {% % % Here is a possibility not foreseen in manmac: if we accumulate a % whole lot of material, we might end up calling this \output % routine twice in a row (see the doublecol-lose test, which is % essentially a couple of indexes with @setchapternewpage off). In % that case we just ship out what is in \partialpage with the normal % output routine. Generally, \partialpage will be empty when this % runs and this will be a no-op. See the indexspread.tex test case. \ifvoid\partialpage \else \onepageout{\pagecontents\partialpage}% \fi % \global\setbox\partialpage = \vbox{% % Unvbox the main output page. \unvbox\PAGE \kern-\topskip \kern\baselineskip }% }% \eject % run that output routine to set \partialpage % % Use the double-column output routine for subsequent pages. \output = {\doublecolumnout}% % % Change the page size parameters. We could do this once outside this % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 % format, but then we repeat the same computation. Repeating a couple % of assignments once per index is clearly meaningless for the % execution time, so we may as well do it in one place. % % First we halve the line length, less a little for the gutter between % the columns. We compute the gutter based on the line length, so it % changes automatically with the paper format. The magic constant % below is chosen so that the gutter has the same value (well, +-<1pt) % as it did when we hard-coded it. % % We put the result in a separate register, \doublecolumhsize, so we % can restore it in \pagesofar, after \hsize itself has (potentially) % been clobbered. % \doublecolumnhsize = \hsize \advance\doublecolumnhsize by -.04154\hsize \divide\doublecolumnhsize by 2 \hsize = \doublecolumnhsize % % Double the \vsize as well. (We don't need a separate register here, % since nobody clobbers \vsize.) \vsize = 2\vsize } % The double-column output routine for all double-column pages except % the last. % \def\doublecolumnout{% \splittopskip=\topskip \splitmaxdepth=\maxdepth % Get the available space for the double columns -- the normal % (undoubled) page height minus any material left over from the % previous page. \dimen@ = \vsize \divide\dimen@ by 2 \advance\dimen@ by -\ht\partialpage % % box0 will be the left-hand column, box2 the right. \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ \onepageout\pagesofar \unvbox255 \penalty\outputpenalty } % % Re-output the contents of the output page -- any previous material, % followed by the two boxes we just split, in box0 and box2. \def\pagesofar{% \unvbox\partialpage % \hsize = \doublecolumnhsize \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}% } % % All done with double columns. \def\enddoublecolumns{% % The following penalty ensures that the page builder is exercised % _before_ we change the output routine. This is necessary in the % following situation: % % The last section of the index consists only of a single entry. % Before this section, \pagetotal is less than \pagegoal, so no % break occurs before the last section starts. However, the last % section, consisting of \initial and the single \entry, does not % fit on the page and has to be broken off. Without the following % penalty the page builder will not be exercised until \eject % below, and by that time we'll already have changed the output % routine to the \balancecolumns version, so the next-to-last % double-column page will be processed with \balancecolumns, which % is wrong: The two columns will go to the main vertical list, with % the broken-off section in the recent contributions. As soon as % the output routine finishes, TeX starts reconsidering the page % break. The two columns and the broken-off section both fit on the % page, because the two columns now take up only half of the page % goal. When TeX sees \eject from below which follows the final % section, it invokes the new output routine that we've set after % \balancecolumns below; \onepageout will try to fit the two columns % and the final section into the vbox of \pageheight (see % \pagebody), causing an overfull box. % % Note that glue won't work here, because glue does not exercise the % page builder, unlike penalties (see The TeXbook, pp. 280-281). \penalty0 % \output = {% % Split the last of the double-column material. Leave it on the % current page, no automatic page break. \balancecolumns % % If we end up splitting too much material for the current page, % though, there will be another page break right after this \output % invocation ends. Having called \balancecolumns once, we do not % want to call it again. Therefore, reset \output to its normal % definition right away. (We hope \balancecolumns will never be % called on to balance too much material, but if it is, this makes % the output somewhat more palatable.) \global\output = {\onepageout{\pagecontents\PAGE}}% }% \eject \endgroup % started in \begindoublecolumns % % \pagegoal was set to the doubled \vsize above, since we restarted % the current page. We're now back to normal single-column % typesetting, so reset \pagegoal to the normal \vsize (after the % \endgroup where \vsize got restored). \pagegoal = \vsize } % % Called at the end of the double column material. \def\balancecolumns{% \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. \dimen@ = \ht0 \advance\dimen@ by \topskip \advance\dimen@ by-\baselineskip \divide\dimen@ by 2 % target to split to %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% \splittopskip = \topskip % Loop until we get a decent breakpoint. {% \vbadness = 10000 \loop \global\setbox3 = \copy0 \global\setbox1 = \vsplit3 to \dimen@ \ifdim\ht3>\dimen@ \global\advance\dimen@ by 1pt \repeat }% %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% \setbox0=\vbox to\dimen@{\unvbox1}% \setbox2=\vbox to\dimen@{\unvbox3}% % \pagesofar } \catcode`\@ = \other \message{sectioning,} % Chapters, sections, etc. % Let's start with @part. \outer\parseargdef\part{\partzzz{#1}} \def\partzzz#1{% \chapoddpage \null \vskip.3\vsize % move it down on the page a bit \begingroup \noindent \titlefonts\rmisbold #1\par % the text \let\lastnode=\empty % no node to associate with \writetocentry{part}{#1}{}% but put it in the toc \headingsoff % no headline or footline on the part page \chapoddpage \endgroup } % \unnumberedno is an oxymoron. But we count the unnumbered % sections so that we can refer to them unambiguously in the pdf % outlines by their "section number". We avoid collisions with chapter % numbers by starting them at 10000. (If a document ever has 10000 % chapters, we're in trouble anyway, I'm sure.) \newcount\unnumberedno \unnumberedno = 10000 \newcount\chapno \newcount\secno \secno=0 \newcount\subsecno \subsecno=0 \newcount\subsubsecno \subsubsecno=0 % This counter is funny since it counts through charcodes of letters A, B, ... \newcount\appendixno \appendixno = `\@ % % \def\appendixletter{\char\the\appendixno} % We do the following ugly conditional instead of the above simple % construct for the sake of pdftex, which needs the actual % letter in the expansion, not just typeset. % \def\appendixletter{% \ifnum\appendixno=`A A% \else\ifnum\appendixno=`B B% \else\ifnum\appendixno=`C C% \else\ifnum\appendixno=`D D% \else\ifnum\appendixno=`E E% \else\ifnum\appendixno=`F F% \else\ifnum\appendixno=`G G% \else\ifnum\appendixno=`H H% \else\ifnum\appendixno=`I I% \else\ifnum\appendixno=`J J% \else\ifnum\appendixno=`K K% \else\ifnum\appendixno=`L L% \else\ifnum\appendixno=`M M% \else\ifnum\appendixno=`N N% \else\ifnum\appendixno=`O O% \else\ifnum\appendixno=`P P% \else\ifnum\appendixno=`Q Q% \else\ifnum\appendixno=`R R% \else\ifnum\appendixno=`S S% \else\ifnum\appendixno=`T T% \else\ifnum\appendixno=`U U% \else\ifnum\appendixno=`V V% \else\ifnum\appendixno=`W W% \else\ifnum\appendixno=`X X% \else\ifnum\appendixno=`Y Y% \else\ifnum\appendixno=`Z Z% % The \the is necessary, despite appearances, because \appendixletter is % expanded while writing the .toc file. \char\appendixno is not % expandable, thus it is written literally, thus all appendixes come out % with the same letter (or @) in the toc without it. \else\char\the\appendixno \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} % Each @chapter defines these (using marks) as the number+name, number % and name of the chapter. Page headings and footings can use % these. @section does likewise. \def\thischapter{} \def\thischapternum{} \def\thischaptername{} \def\thissection{} \def\thissectionnum{} \def\thissectionname{} \newcount\absseclevel % used to calculate proper heading level \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count % @raisesections: treat @section as chapter, @subsection as section, etc. \def\raisesections{\global\advance\secbase by -1} \let\up=\raisesections % original BFox name % @lowersections: treat @chapter as section, @section as subsection, etc. \def\lowersections{\global\advance\secbase by 1} \let\down=\lowersections % original BFox name % we only have subsub. \chardef\maxseclevel = 3 % % A numbered section within an unnumbered changes to unnumbered too. % To achieve this, remember the "biggest" unnum. sec. we are currently in: \chardef\unnlevel = \maxseclevel % % Trace whether the current chapter is an appendix or not: % \chapheadtype is "N" or "A", unnumbered chapters are ignored. \def\chapheadtype{N} % Choose a heading macro % #1 is heading type % #2 is heading level % #3 is text for heading \def\genhead#1#2#3{% % Compute the abs. sec. level: \absseclevel=#2 \advance\absseclevel by \secbase % Make sure \absseclevel doesn't fall outside the range: \ifnum \absseclevel < 0 \absseclevel = 0 \else \ifnum \absseclevel > 3 \absseclevel = 3 \fi \fi % The heading type: \def\headtype{#1}% \if \headtype U% \ifnum \absseclevel < \unnlevel \chardef\unnlevel = \absseclevel \fi \else % Check for appendix sections: \ifnum \absseclevel = 0 \edef\chapheadtype{\headtype}% \else \if \headtype A\if \chapheadtype N% \errmessage{@appendix... within a non-appendix chapter}% \fi\fi \fi % Check for numbered within unnumbered: \ifnum \absseclevel > \unnlevel \def\headtype{U}% \else \chardef\unnlevel = 3 \fi \fi % Now print the heading: \if \headtype U% \ifcase\absseclevel \unnumberedzzz{#3}% \or \unnumberedseczzz{#3}% \or \unnumberedsubseczzz{#3}% \or \unnumberedsubsubseczzz{#3}% \fi \else \if \headtype A% \ifcase\absseclevel \appendixzzz{#3}% \or \appendixsectionzzz{#3}% \or \appendixsubseczzz{#3}% \or \appendixsubsubseczzz{#3}% \fi \else \ifcase\absseclevel \chapterzzz{#3}% \or \seczzz{#3}% \or \numberedsubseczzz{#3}% \or \numberedsubsubseczzz{#3}% \fi \fi \fi \suppressfirstparagraphindent } % an interface: \def\numhead{\genhead N} \def\apphead{\genhead A} \def\unnmhead{\genhead U} % @chapter, @appendix, @unnumbered. Increment top-level counter, reset % all lower-level sectioning counters to zero. % % Also set \chaplevelprefix, which we prepend to @float sequence numbers % (e.g., figures), q.v. By default (before any chapter), that is empty. \let\chaplevelprefix = \empty % \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz \def\chapterzzz#1{% % section resetting is \global in case the chapter is in a group, such % as an @include file. \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 \global\advance\chapno by 1 % % Used for \float. \gdef\chaplevelprefix{\the\chapno.}% \resetallfloatnos % % \putwordChapter can contain complex things in translations. \toks0=\expandafter{\putwordChapter}% \message{\the\toks0 \space \the\chapno}% % % Write the actual heading. \chapmacro{#1}{Ynumbered}{\the\chapno}% % % So @section and the like are numbered underneath this chapter. \global\let\section = \numberedsec \global\let\subsection = \numberedsubsec \global\let\subsubsection = \numberedsubsubsec } \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz % \def\appendixzzz#1{% \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 \global\advance\appendixno by 1 \gdef\chaplevelprefix{\appendixletter.}% \resetallfloatnos % % \putwordAppendix can contain complex things in translations. \toks0=\expandafter{\putwordAppendix}% \message{\the\toks0 \space \appendixletter}% % \chapmacro{#1}{Yappendix}{\appendixletter}% % \global\let\section = \appendixsec \global\let\subsection = \appendixsubsec \global\let\subsubsection = \appendixsubsubsec } % normally unnmhead0 calls unnumberedzzz: \outer\parseargdef\unnumbered{\unnmhead0{#1}} \def\unnumberedzzz#1{% \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 \global\advance\unnumberedno by 1 % % Since an unnumbered has no number, no prefix for figures. \global\let\chaplevelprefix = \empty \resetallfloatnos % % This used to be simply \message{#1}, but TeX fully expands the % argument to \message. Therefore, if #1 contained @-commands, TeX % expanded them. For example, in `@unnumbered The @cite{Book}', TeX % expanded @cite (which turns out to cause errors because \cite is meant % to be executed, not expanded). % % Anyway, we don't want the fully-expanded definition of @cite to appear % as a result of the \message, we just want `@cite' itself. We use % \the to achieve this: TeX expands \the only once, % simply yielding the contents of . (We also do this for % the toc entries.) \toks0 = {#1}% \message{(\the\toks0)}% % \chapmacro{#1}{Ynothing}{\the\unnumberedno}% % \global\let\section = \unnumberedsec \global\let\subsection = \unnumberedsubsec \global\let\subsubsection = \unnumberedsubsubsec } % @centerchap is like @unnumbered, but the heading is centered. \outer\parseargdef\centerchap{% % Well, we could do the following in a group, but that would break % an assumption that \chapmacro is called at the outermost level. % Thus we are safer this way: --kasal, 24feb04 \let\centerparametersmaybe = \centerparameters \unnmhead0{#1}% \let\centerparametersmaybe = \relax } % @top is like @unnumbered. \let\top\unnumbered % Sections. % \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz \def\seczzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% } % normally calls appendixsectionzzz: \outer\parseargdef\appendixsection{\apphead1{#1}} \def\appendixsectionzzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% } \let\appendixsec\appendixsection % normally calls unnumberedseczzz: \outer\parseargdef\unnumberedsec{\unnmhead1{#1}} \def\unnumberedseczzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% } % Subsections. % % normally calls numberedsubseczzz: \outer\parseargdef\numberedsubsec{\numhead2{#1}} \def\numberedsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% } % normally calls appendixsubseczzz: \outer\parseargdef\appendixsubsec{\apphead2{#1}} \def\appendixsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Yappendix}% {\appendixletter.\the\secno.\the\subsecno}% } % normally calls unnumberedsubseczzz: \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} \def\unnumberedsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Ynothing}% {\the\unnumberedno.\the\secno.\the\subsecno}% } % Subsubsections. % % normally numberedsubsubseczzz: \outer\parseargdef\numberedsubsubsec{\numhead3{#1}} \def\numberedsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Ynumbered}% {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% } % normally appendixsubsubseczzz: \outer\parseargdef\appendixsubsubsec{\apphead3{#1}} \def\appendixsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Yappendix}% {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% } % normally unnumberedsubsubseczzz: \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} \def\unnumberedsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Ynothing}% {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% } % These macros control what the section commands do, according % to what kind of chapter we are in (ordinary, appendix, or unnumbered). % Define them by default for a numbered chapter. \let\section = \numberedsec \let\subsection = \numberedsubsec \let\subsubsection = \numberedsubsubsec % Define @majorheading, @heading and @subheading \def\majorheading{% {\advance\chapheadingskip by 10pt \chapbreak }% \parsearg\chapheadingzzz } \def\chapheading{\chapbreak \parsearg\chapheadingzzz} \def\chapheadingzzz#1{% \vbox{\chapfonts \raggedtitlesettings #1\par}% \nobreak\bigskip \nobreak \suppressfirstparagraphindent } % @heading, @subheading, @subsubheading. \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} \suppressfirstparagraphindent} \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} \suppressfirstparagraphindent} \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} \suppressfirstparagraphindent} % These macros generate a chapter, section, etc. heading only % (including whitespace, linebreaking, etc. around it), % given all the information in convenient, parsed form. % Args are the skip and penalty (usually negative) \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} % Parameter controlling skip before chapter headings (if needed) \newskip\chapheadingskip % Define plain chapter starts, and page on/off switching for it. \def\chapbreak{\dobreak \chapheadingskip {-4000}} \def\chappager{\par\vfill\supereject} % Because \domark is called before \chapoddpage, the filler page will % get the headings for the next chapter, which is wrong. But we don't % care -- we just disable all headings on the filler page. \def\chapoddpage{% \chappager \ifodd\pageno \else \begingroup \headingsoff \null \chappager \endgroup \fi } \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} \def\CHAPPAGoff{% \global\let\contentsalignmacro = \chappager \global\let\pchapsepmacro=\chapbreak \global\let\pagealignmacro=\chappager} \def\CHAPPAGon{% \global\let\contentsalignmacro = \chappager \global\let\pchapsepmacro=\chappager \global\let\pagealignmacro=\chappager \global\def\HEADINGSon{\HEADINGSsingle}} \def\CHAPPAGodd{% \global\let\contentsalignmacro = \chapoddpage \global\let\pchapsepmacro=\chapoddpage \global\let\pagealignmacro=\chapoddpage \global\def\HEADINGSon{\HEADINGSdouble}} \CHAPPAGon % Chapter opening. % % #1 is the text, #2 is the section type (Ynumbered, Ynothing, % Yappendix, Yomitfromtoc), #3 the chapter number. % % To test against our argument. \def\Ynothingkeyword{Ynothing} \def\Yomitfromtockeyword{Yomitfromtoc} \def\Yappendixkeyword{Yappendix} % \def\chapmacro#1#2#3{% % Insert the first mark before the heading break (see notes for \domark). \let\prevchapterdefs=\lastchapterdefs \let\prevsectiondefs=\lastsectiondefs \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% \gdef\thissection{}}% % \def\temptype{#2}% \ifx\temptype\Ynothingkeyword \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% \gdef\thischapter{\thischaptername}}% \else\ifx\temptype\Yomitfromtockeyword \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% \gdef\thischapter{}}% \else\ifx\temptype\Yappendixkeyword \toks0={#1}% \xdef\lastchapterdefs{% \gdef\noexpand\thischaptername{\the\toks0}% \gdef\noexpand\thischapternum{\appendixletter}% % \noexpand\putwordAppendix avoids expanding indigestible % commands in some of the translations. \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} \noexpand\thischapternum: \noexpand\thischaptername}% }% \else \toks0={#1}% \xdef\lastchapterdefs{% \gdef\noexpand\thischaptername{\the\toks0}% \gdef\noexpand\thischapternum{\the\chapno}% % \noexpand\putwordChapter avoids expanding indigestible % commands in some of the translations. \gdef\noexpand\thischapter{\noexpand\putwordChapter{} \noexpand\thischapternum: \noexpand\thischaptername}% }% \fi\fi\fi % % Output the mark. Pass it through \safewhatsit, to take care of % the preceding space. \safewhatsit\domark % % Insert the chapter heading break. \pchapsepmacro % % Now the second mark, after the heading break. No break points % between here and the heading. \let\prevchapterdefs=\lastchapterdefs \let\prevsectiondefs=\lastsectiondefs \domark % {% \chapfonts \rmisbold % % Have to define \lastsection before calling \donoderef, because the % xref code eventually uses it. On the other hand, it has to be called % after \pchapsepmacro, or the headline will change too soon. \gdef\lastsection{#1}% % % Only insert the separating space if we have a chapter/appendix % number, and don't print the unnumbered ``number''. \ifx\temptype\Ynothingkeyword \setbox0 = \hbox{}% \def\toctype{unnchap}% \else\ifx\temptype\Yomitfromtockeyword \setbox0 = \hbox{}% contents like unnumbered, but no toc entry \def\toctype{omit}% \else\ifx\temptype\Yappendixkeyword \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% \def\toctype{app}% \else \setbox0 = \hbox{#3\enspace}% \def\toctype{numchap}% \fi\fi\fi % % Write the toc entry for this chapter. Must come before the % \donoderef, because we include the current node name in the toc % entry, and \donoderef resets it to empty. \writetocentry{\toctype}{#1}{#3}% % % For pdftex, we have to write out the node definition (aka, make % the pdfdest) after any page break, but before the actual text has % been typeset. If the destination for the pdf outline is after the % text, then jumping from the outline may wind up with the text not % being visible, for instance under high magnification. \donoderef{#2}% % % Typeset the actual heading. \nobreak % Avoid page breaks at the interline glue. \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe \unhbox0 #1\par}% }% \nobreak\bigskip % no page break after a chapter title \nobreak } % @centerchap -- centered and unnumbered. \let\centerparametersmaybe = \relax \def\centerparameters{% \advance\rightskip by 3\rightskip \leftskip = \rightskip \parfillskip = 0pt } % I don't think this chapter style is supported any more, so I'm not % updating it with the new noderef stuff. We'll see. --karl, 11aug03. % \def\setchapterstyle #1 {\csname CHAPF#1\endcsname} % \def\unnchfopen #1{% \chapoddpage \vbox{\chapfonts \raggedtitlesettings #1\par}% \nobreak\bigskip\nobreak } \def\chfopen #1#2{\chapoddpage {\chapfonts \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% \par\penalty 5000 % } \def\centerchfopen #1{% \chapoddpage \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}% \nobreak\bigskip \nobreak } \def\CHAPFopen{% \global\let\chapmacro=\chfopen \global\let\centerchapmacro=\centerchfopen} % Section titles. These macros combine the section number parts and % call the generic \sectionheading to do the printing. % \newskip\secheadingskip \def\secheadingbreak{\dobreak \secheadingskip{-1000}} % Subsection titles. \newskip\subsecheadingskip \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} % Subsubsection titles. \def\subsubsecheadingskip{\subsecheadingskip} \def\subsubsecheadingbreak{\subsecheadingbreak} % Print any size, any type, section title. % % #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the % section number. % \def\seckeyword{sec} % \def\sectionheading#1#2#3#4{% {% \checkenv{}% should not be in an environment. % % Switch to the right set of fonts. \csname #2fonts\endcsname \rmisbold % \def\sectionlevel{#2}% \def\temptype{#3}% % % Insert first mark before the heading break (see notes for \domark). \let\prevsectiondefs=\lastsectiondefs \ifx\temptype\Ynothingkeyword \ifx\sectionlevel\seckeyword \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% \gdef\thissection{\thissectionname}}% \fi \else\ifx\temptype\Yomitfromtockeyword % Don't redefine \thissection. \else\ifx\temptype\Yappendixkeyword \ifx\sectionlevel\seckeyword \toks0={#1}% \xdef\lastsectiondefs{% \gdef\noexpand\thissectionname{\the\toks0}% \gdef\noexpand\thissectionnum{#4}% % \noexpand\putwordSection avoids expanding indigestible % commands in some of the translations. \gdef\noexpand\thissection{\noexpand\putwordSection{} \noexpand\thissectionnum: \noexpand\thissectionname}% }% \fi \else \ifx\sectionlevel\seckeyword \toks0={#1}% \xdef\lastsectiondefs{% \gdef\noexpand\thissectionname{\the\toks0}% \gdef\noexpand\thissectionnum{#4}% % \noexpand\putwordSection avoids expanding indigestible % commands in some of the translations. \gdef\noexpand\thissection{\noexpand\putwordSection{} \noexpand\thissectionnum: \noexpand\thissectionname}% }% \fi \fi\fi\fi % % Go into vertical mode. Usually we'll already be there, but we % don't want the following whatsit to end up in a preceding paragraph % if the document didn't happen to have a blank line. \par % % Output the mark. Pass it through \safewhatsit, to take care of % the preceding space. \safewhatsit\domark % % Insert space above the heading. \csname #2headingbreak\endcsname % % Now the second mark, after the heading break. No break points % between here and the heading. \let\prevsectiondefs=\lastsectiondefs \domark % % Only insert the space after the number if we have a section number. \ifx\temptype\Ynothingkeyword \setbox0 = \hbox{}% \def\toctype{unn}% \gdef\lastsection{#1}% \else\ifx\temptype\Yomitfromtockeyword % for @headings -- no section number, don't include in toc, % and don't redefine \lastsection. \setbox0 = \hbox{}% \def\toctype{omit}% \let\sectionlevel=\empty \else\ifx\temptype\Yappendixkeyword \setbox0 = \hbox{#4\enspace}% \def\toctype{app}% \gdef\lastsection{#1}% \else \setbox0 = \hbox{#4\enspace}% \def\toctype{num}% \gdef\lastsection{#1}% \fi\fi\fi % % Write the toc entry (before \donoderef). See comments in \chapmacro. \writetocentry{\toctype\sectionlevel}{#1}{#4}% % % Write the node reference (= pdf destination for pdftex). % Again, see comments in \chapmacro. \donoderef{#3}% % % Interline glue will be inserted when the vbox is completed. % That glue will be a valid breakpoint for the page, since it'll be % preceded by a whatsit (usually from the \donoderef, or from the % \writetocentry if there was no node). We don't want to allow that % break, since then the whatsits could end up on page n while the % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. \nobreak % % Output the actual section heading. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright \hangindent=\wd0 % zero if no section number \unhbox0 #1}% }% % Add extra space after the heading -- half of whatever came above it. % Don't allow stretch, though. \kern .5 \csname #2headingskip\endcsname % % Do not let the kern be a potential breakpoint, as it would be if it % was followed by glue. \nobreak % % We'll almost certainly start a paragraph next, so don't let that % glue accumulate. (Not a breakpoint because it's preceded by a % discardable item.) However, when a paragraph is not started next % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out % or the negative glue will cause weirdly wrong output, typically % obscuring the section heading with something else. \vskip-\parskip % % This is so the last item on the main vertical list is a known % \penalty > 10000, so \startdefun, etc., can recognize the situation % and do the needful. \penalty 10001 } \message{toc,} % Table of contents. \newwrite\tocfile % Write an entry to the toc file, opening it if necessary. % Called from @chapter, etc. % % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} % We append the current node name (if any) and page number as additional % arguments for the \{chap,sec,...}entry macros which will eventually % read this. The node name is used in the pdf outlines as the % destination to jump to. % % We open the .toc file for writing here instead of at @setfilename (or % any other fixed time) so that @contents can be anywhere in the document. % But if #1 is `omit', then we don't do anything. This is used for the % table of contents chapter openings themselves. % \newif\iftocfileopened \def\omitkeyword{omit}% % \def\writetocentry#1#2#3{% \edef\writetoctype{#1}% \ifx\writetoctype\omitkeyword \else \iftocfileopened\else \immediate\openout\tocfile = \jobname.toc \global\tocfileopenedtrue \fi % \iflinks {\atdummies \edef\temp{% \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% \temp }% \fi \fi % % Tell \shipout to create a pdf destination on each page, if we're % writing pdf. These are used in the table of contents. We can't % just write one on every page because the title pages are numbered % 1 and 2 (the page numbers aren't printed), and so are the first % two pages of the document. Thus, we'd have two destinations named % `1', and two named `2'. \ifpdf \global\pdfmakepagedesttrue \fi } % These characters do not print properly in the Computer Modern roman % fonts, so we must take special care. This is more or less redundant % with the Texinfo input format setup at the end of this file. % \def\activecatcodes{% \catcode`\"=\active \catcode`\$=\active \catcode`\<=\active \catcode`\>=\active \catcode`\\=\active \catcode`\^=\active \catcode`\_=\active \catcode`\|=\active \catcode`\~=\active } % Read the toc file, which is essentially Texinfo input. \def\readtocfile{% \setupdatafile \activecatcodes \input \tocreadfilename } \newskip\contentsrightmargin \contentsrightmargin=1in \newcount\savepageno \newcount\lastnegativepageno \lastnegativepageno = -1 % Prepare to read what we've written to \tocfile. % \def\startcontents#1{% % If @setchapternewpage on, and @headings double, the contents should % start on an odd page, unlike chapters. Thus, we maintain % \contentsalignmacro in parallel with \pagealignmacro. % From: Torbjorn Granlund \contentsalignmacro \immediate\closeout\tocfile % % Don't need to put `Contents' or `Short Contents' in the headline. % It is abundantly clear what they are. \chapmacro{#1}{Yomitfromtoc}{}% % \savepageno = \pageno \begingroup % Set up to handle contents files properly. \raggedbottom % Worry more about breakpoints than the bottom. \advance\hsize by -\contentsrightmargin % Don't use the full line length. % % Roman numerals for page numbers. \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi } % redefined for the two-volume lispref. We always output on % \jobname.toc even if this is redefined. % \def\tocreadfilename{\jobname.toc} % Normal (long) toc. % \def\contents{% \startcontents{\putwordTOC}% \openin 1 \tocreadfilename\space \ifeof 1 \else \readtocfile \fi \vfill \eject \contentsalignmacro % in case @setchapternewpage odd is in effect \ifeof 1 \else \pdfmakeoutlines \fi \closein 1 \endgroup \lastnegativepageno = \pageno \global\pageno = \savepageno } % And just the chapters. \def\summarycontents{% \startcontents{\putwordShortTOC}% % \let\partentry = \shortpartentry \let\numchapentry = \shortchapentry \let\appentry = \shortchapentry \let\unnchapentry = \shortunnchapentry % We want a true roman here for the page numbers. \secfonts \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl \let\tt=\shortconttt \rm \hyphenpenalty = 10000 \advance\baselineskip by 1pt % Open it up a little. \def\numsecentry##1##2##3##4{} \let\appsecentry = \numsecentry \let\unnsecentry = \numsecentry \let\numsubsecentry = \numsecentry \let\appsubsecentry = \numsecentry \let\unnsubsecentry = \numsecentry \let\numsubsubsecentry = \numsecentry \let\appsubsubsecentry = \numsecentry \let\unnsubsubsecentry = \numsecentry \openin 1 \tocreadfilename\space \ifeof 1 \else \readtocfile \fi \closein 1 \vfill \eject \contentsalignmacro % in case @setchapternewpage odd is in effect \endgroup \lastnegativepageno = \pageno \global\pageno = \savepageno } \let\shortcontents = \summarycontents % Typeset the label for a chapter or appendix for the short contents. % The arg is, e.g., `A' for an appendix, or `3' for a chapter. % \def\shortchaplabel#1{% % This space should be enough, since a single number is .5em, and the % widest letter (M) is 1em, at least in the Computer Modern fonts. % But use \hss just in case. % (This space doesn't include the extra space that gets added after % the label; that gets put in by \shortchapentry above.) % % We'd like to right-justify chapter numbers, but that looks strange % with appendix letters. And right-justifying numbers and % left-justifying letters looks strange when there is less than 10 % chapters. Have to read the whole toc once to know how many chapters % there are before deciding ... \hbox to 1em{#1\hss}% } % These macros generate individual entries in the table of contents. % The first argument is the chapter or section name. % The last argument is the page number. % The arguments in between are the chapter number, section number, ... % Parts, in the main contents. Replace the part number, which doesn't % exist, with an empty box. Let's hope all the numbers have the same width. % Also ignore the page number, which is conventionally not printed. \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}} % % Parts, in the short toc. \def\shortpartentry#1#2#3#4{% \penalty-300 \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip \shortchapentry{{\bf #1}}{\numeralbox}{}{}% } % Chapters, in the main contents. \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} % % Chapters, in the short toc. % See comments in \dochapentry re vbox and related settings. \def\shortchapentry#1#2#3#4{% \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% } % Appendices, in the main contents. % Need the word Appendix, and a fixed-size box. % \def\appendixbox#1{% % We use M since it's probably the widest letter. \setbox0 = \hbox{\putwordAppendix{} M}% \hbox to \wd0{\putwordAppendix{} #1\hss}} % \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}} % Unnumbered chapters. \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} % Sections. \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} \let\appsecentry=\numsecentry \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} % Subsections. \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} \let\appsubsecentry=\numsubsecentry \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} % And subsubsections. \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} \let\appsubsubsecentry=\numsubsubsecentry \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} % This parameter controls the indentation of the various levels. % Same as \defaultparindent. \newdimen\tocindent \tocindent = 15pt % Now for the actual typesetting. In all these, #1 is the text and #2 is the % page number. % % If the toc has to be broken over pages, we want it to be at chapters % if at all possible; hence the \penalty. \def\dochapentry#1#2{% \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip \begingroup \chapentryfonts \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup \nobreak\vskip .25\baselineskip plus.1\baselineskip } \def\dosecentry#1#2{\begingroup \secentryfonts \leftskip=\tocindent \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup} \def\dosubsecentry#1#2{\begingroup \subsecentryfonts \leftskip=2\tocindent \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup} \def\dosubsubsecentry#1#2{\begingroup \subsubsecentryfonts \leftskip=3\tocindent \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup} % We use the same \entry macro as for the index entries. \let\tocentry = \entry % Space between chapter (or whatever) number and the title. \def\labelspace{\hskip1em \relax} \def\dopageno#1{{\rm #1}} \def\doshortpageno#1{{\rm #1}} \def\chapentryfonts{\secfonts \rm} \def\secentryfonts{\textfonts} \def\subsecentryfonts{\textfonts} \def\subsubsecentryfonts{\textfonts} \message{environments,} % @foo ... @end foo. % @tex ... @end tex escapes into raw TeX temporarily. % One exception: @ is still an escape character, so that @end tex works. % But \@ or @@ will get a plain @ character. \envdef\tex{% \setupmarkupstyle{tex}% \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie \catcode `\%=14 \catcode `\+=\other \catcode `\"=\other \catcode `\|=\other \catcode `\<=\other \catcode `\>=\other \catcode`\`=\other \catcode`\'=\other \escapechar=`\\ % % ' is active in math mode (mathcode"8000). So reset it, and all our % other math active characters (just in case), to plain's definitions. \mathactive % \let\b=\ptexb \let\bullet=\ptexbullet \let\c=\ptexc \let\,=\ptexcomma \let\.=\ptexdot \let\dots=\ptexdots \let\equiv=\ptexequiv \let\!=\ptexexclam \let\i=\ptexi \let\indent=\ptexindent \let\noindent=\ptexnoindent \let\{=\ptexlbrace \let\+=\tabalign \let\}=\ptexrbrace \let\/=\ptexslash \let\*=\ptexstar \let\t=\ptext \expandafter \let\csname top\endcsname=\ptextop % outer \let\frenchspacing=\plainfrenchspacing % \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% \def\@{@}% } % There is no need to define \Etex. % Define @lisp ... @end lisp. % @lisp environment forms a group so it can rebind things, % including the definition of @end lisp (which normally is erroneous). % Amount to narrow the margins by for @lisp. \newskip\lispnarrowing \lispnarrowing=0.4in % This is the definition that ^^M gets inside @lisp, @example, and other % such environments. \null is better than a space, since it doesn't % have any width. \def\lisppar{\null\endgraf} % This space is always present above and below environments. \newskip\envskipamount \envskipamount = 0pt % Make spacing and below environment symmetrical. We use \parskip here % to help in doing that, since in @example-like environments \parskip % is reset to zero; thus the \afterenvbreak inserts no space -- but the % start of the next paragraph will insert \parskip. % \def\aboveenvbreak{{% % =10000 instead of <10000 because of a special case in \itemzzz and % \sectionheading, q.v. \ifnum \lastpenalty=10000 \else \advance\envskipamount by \parskip \endgraf \ifdim\lastskip<\envskipamount \removelastskip % it's not a good place to break if the last penalty was \nobreak % or better ... \ifnum\lastpenalty<10000 \penalty-50 \fi \vskip\envskipamount \fi \fi }} \let\afterenvbreak = \aboveenvbreak % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will % also clear it, so that its embedded environments do the narrowing again. \let\nonarrowing=\relax % @cartouche ... @end cartouche: draw rectangle w/rounded corners around % environment contents. \font\circle=lcircle10 \newdimen\circthick \newdimen\cartouter\newdimen\cartinner \newskip\normbskip\newskip\normpskip\newskip\normlskip \circthick=\fontdimen8\circle % \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth \def\ctr{{\hskip 6pt\circle\char'010}} \def\cbl{{\circle\char'012\hskip -6pt}} \def\cbr{{\hskip 6pt\circle\char'011}} \def\carttop{\hbox to \cartouter{\hskip\lskip \ctl\leaders\hrule height\circthick\hfil\ctr \hskip\rskip}} \def\cartbot{\hbox to \cartouter{\hskip\lskip \cbl\leaders\hrule height\circthick\hfil\cbr \hskip\rskip}} % \newskip\lskip\newskip\rskip \envdef\cartouche{% \ifhmode\par\fi % can't be in the midst of a paragraph. \startsavinginserts \lskip=\leftskip \rskip=\rightskip \leftskip=0pt\rightskip=0pt % we want these *outside*. \cartinner=\hsize \advance\cartinner by-\lskip \advance\cartinner by-\rskip \cartouter=\hsize \advance\cartouter by 18.4pt % allow for 3pt kerns on either % side, and for 6pt waste from % each corner char, and rule thickness \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip % Flag to tell @lisp, etc., not to narrow margin. \let\nonarrowing = t% % % If this cartouche directly follows a sectioning command, we need the % \parskip glue (backspaced over by default) or the cartouche can % collide with the section heading. \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi % \vbox\bgroup \baselineskip=0pt\parskip=0pt\lineskip=0pt \carttop \hbox\bgroup \hskip\lskip \vrule\kern3pt \vbox\bgroup \kern3pt \hsize=\cartinner \baselineskip=\normbskip \lineskip=\normlskip \parskip=\normpskip \vskip -\parskip \comment % For explanation, see the end of def\group. } \def\Ecartouche{% \ifhmode\par\fi \kern3pt \egroup \kern3pt\vrule \hskip\rskip \egroup \cartbot \egroup \checkinserts } % This macro is called at the beginning of all the @example variants, % inside a group. \newdimen\nonfillparindent \def\nonfillstart{% \aboveenvbreak \hfuzz = 12pt % Don't be fussy \sepspaces % Make spaces be word-separators rather than space tokens. \let\par = \lisppar % don't ignore blank lines \obeylines % each line of input is a line of output \parskip = 0pt % Turn off paragraph indentation but redefine \indent to emulate % the normal \indent. \nonfillparindent=\parindent \parindent = 0pt \let\indent\nonfillindent % \emergencystretch = 0pt % don't try to avoid overfull boxes \ifx\nonarrowing\relax \advance \leftskip by \lispnarrowing \exdentamount=\lispnarrowing \else \let\nonarrowing = \relax \fi \let\exdent=\nofillexdent } \begingroup \obeyspaces % We want to swallow spaces (but not other tokens) after the fake % @indent in our nonfill-environments, where spaces are normally % active and set to @tie, resulting in them not being ignored after % @indent. \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}% \gdef\nonfillindentcheck{% \ifx\temp % \expandafter\nonfillindentgobble% \else% \leavevmode\nonfillindentbox% \fi% }% \endgroup \def\nonfillindentgobble#1{\nonfillindent} \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}} % If you want all examples etc. small: @set dispenvsize small. % If you want even small examples the full size: @set dispenvsize nosmall. % This affects the following displayed environments: % @example, @display, @format, @lisp % \def\smallword{small} \def\nosmallword{nosmall} \let\SETdispenvsize\relax \def\setnormaldispenv{% \ifx\SETdispenvsize\smallword % end paragraph for sake of leading, in case document has no blank % line. This is redundant with what happens in \aboveenvbreak, but % we need to do it before changing the fonts, and it's inconvenient % to change the fonts afterward. \ifnum \lastpenalty=10000 \else \endgraf \fi \smallexamplefonts \rm \fi } \def\setsmalldispenv{% \ifx\SETdispenvsize\nosmallword \else \ifnum \lastpenalty=10000 \else \endgraf \fi \smallexamplefonts \rm \fi } % We often define two environments, @foo and @smallfoo. % Let's do it in one command. #1 is the env name, #2 the definition. \def\makedispenvdef#1#2{% \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}% \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}% \expandafter\let\csname E#1\endcsname \afterenvbreak \expandafter\let\csname Esmall#1\endcsname \afterenvbreak } % Define two environment synonyms (#1 and #2) for an environment. \def\maketwodispenvdef#1#2#3{% \makedispenvdef{#1}{#3}% \makedispenvdef{#2}{#3}% } % % @lisp: indented, narrowed, typewriter font; % @example: same as @lisp. % % @smallexample and @smalllisp: use smaller fonts. % Originally contributed by Pavel@xerox. % \maketwodispenvdef{lisp}{example}{% \nonfillstart \tt\setupmarkupstyle{example}% \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. \gobble % eat return } % @display/@smalldisplay: same as @lisp except keep current font. % \makedispenvdef{display}{% \nonfillstart \gobble } % @format/@smallformat: same as @display except don't narrow margins. % \makedispenvdef{format}{% \let\nonarrowing = t% \nonfillstart \gobble } % @flushleft: same as @format, but doesn't obey \SETdispenvsize. \envdef\flushleft{% \let\nonarrowing = t% \nonfillstart \gobble } \let\Eflushleft = \afterenvbreak % @flushright. % \envdef\flushright{% \let\nonarrowing = t% \nonfillstart \advance\leftskip by 0pt plus 1fill\relax \gobble } \let\Eflushright = \afterenvbreak % @raggedright does more-or-less normal line breaking but no right % justification. From plain.tex. \envdef\raggedright{% \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax } \let\Eraggedright\par \envdef\raggedleft{% \parindent=0pt \leftskip0pt plus2em \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt \hbadness=10000 % Last line will usually be underfull, so turn off % badness reporting. } \let\Eraggedleft\par \envdef\raggedcenter{% \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt \hbadness=10000 % Last line will usually be underfull, so turn off % badness reporting. } \let\Eraggedcenter\par % @quotation does normal linebreaking (hence we can't use \nonfillstart) % and narrows the margins. We keep \parskip nonzero in general, since % we're doing normal filling. So, when using \aboveenvbreak and % \afterenvbreak, temporarily make \parskip 0. % \makedispenvdef{quotation}{\quotationstart} % \def\quotationstart{% \indentedblockstart % same as \indentedblock, but increase right margin too. \ifx\nonarrowing\relax \advance\rightskip by \lispnarrowing \fi \parsearg\quotationlabel } % We have retained a nonzero parskip for the environment, since we're % doing normal filling. % \def\Equotation{% \par \ifx\quotationauthor\thisisundefined\else % indent a bit. \leftline{\kern 2\leftskip \sl ---\quotationauthor}% \fi {\parskip=0pt \afterenvbreak}% } \def\Esmallquotation{\Equotation} % If we're given an argument, typeset it in bold with a colon after. \def\quotationlabel#1{% \def\temp{#1}% \ifx\temp\empty \else {\bf #1: }% \fi } % @indentedblock is like @quotation, but indents only on the left and % has no optional argument. % \makedispenvdef{indentedblock}{\indentedblockstart} % \def\indentedblockstart{% {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip \parindent=0pt % % @cartouche defines \nonarrowing to inhibit narrowing at next level down. \ifx\nonarrowing\relax \advance\leftskip by \lispnarrowing \exdentamount = \lispnarrowing \else \let\nonarrowing = \relax \fi } % Keep a nonzero parskip for the environment, since we're doing normal filling. % \def\Eindentedblock{% \par {\parskip=0pt \afterenvbreak}% } \def\Esmallindentedblock{\Eindentedblock} % LaTeX-like @verbatim...@end verbatim and @verb{...} % If we want to allow any as delimiter, % we need the curly braces so that makeinfo sees the @verb command, eg: % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org % % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. % % [Knuth] p.344; only we need to do the other characters Texinfo sets % active too. Otherwise, they get lost as the first character on a % verbatim line. \def\dospecials{% \do\ \do\\\do\{\do\}\do\$\do\&% \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% \do\<\do\>\do\|\do\@\do+\do\"% % Don't do the quotes -- if we do, @set txicodequoteundirected and % @set txicodequotebacktick will not have effect on @verb and % @verbatim, and ?` and !` ligatures won't get disabled. %\do\`\do\'% } % % [Knuth] p. 380 \def\uncatcodespecials{% \def\do##1{\catcode`##1=\other}\dospecials} % % Setup for the @verb command. % % Eight spaces for a tab \begingroup \catcode`\^^I=\active \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} \endgroup % \def\setupverb{% \tt % easiest (and conventionally used) font for verbatim \def\par{\leavevmode\endgraf}% \setupmarkupstyle{verb}% \tabeightspaces % Respect line breaks, % print special symbols as themselves, and % make each space count % must do in this order: \obeylines \uncatcodespecials \sepspaces } % Setup for the @verbatim environment % % Real tab expansion. \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount % % We typeset each line of the verbatim in an \hbox, so we can handle % tabs. The \global is in case the verbatim line starts with an accent, % or some other command that starts with a begin-group. Otherwise, the % entire \verbbox would disappear at the corresponding end-group, before % it is typeset. Meanwhile, we can't have nested verbatim commands % (can we?), so the \global won't be overwriting itself. \newbox\verbbox \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup} % \begingroup \catcode`\^^I=\active \gdef\tabexpand{% \catcode`\^^I=\active \def^^I{\leavevmode\egroup \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab \divide\dimen\verbbox by\tabw \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox }% } \endgroup % start the verbatim environment. \def\setupverbatim{% \let\nonarrowing = t% \nonfillstart \tt % easiest (and conventionally used) font for verbatim % The \leavevmode here is for blank lines. Otherwise, we would % never \starttabox and the \egroup would end verbatim mode. \def\par{\leavevmode\egroup\box\verbbox\endgraf}% \tabexpand \setupmarkupstyle{verbatim}% % Respect line breaks, % print special symbols as themselves, and % make each space count. % Must do in this order: \obeylines \uncatcodespecials \sepspaces \everypar{\starttabbox}% } % Do the @verb magic: verbatim text is quoted by unique % delimiter characters. Before first delimiter expect a % right brace, after last delimiter expect closing brace: % % \def\doverb'{'#1'}'{#1} % % [Knuth] p. 382; only eat outer {} \begingroup \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] \endgroup % \def\verb{\begingroup\setupverb\doverb} % % % Do the @verbatim magic: define the macro \doverbatim so that % the (first) argument ends when '@end verbatim' is reached, ie: % % \def\doverbatim#1@end verbatim{#1} % % For Texinfo it's a lot easier than for LaTeX, % because texinfo's \verbatim doesn't stop at '\end{verbatim}': % we need not redefine '\', '{' and '}'. % % Inspired by LaTeX's verbatim command set [latex.ltx] % \begingroup \catcode`\ =\active \obeylines % % ignore everything up to the first ^^M, that's the newline at the end % of the @verbatim input line itself. Otherwise we get an extra blank % line in the output. \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}% % We really want {...\end verbatim} in the body of the macro, but % without the active space; thus we have to use \xdef and \gobble. \endgroup % \envdef\verbatim{% \setupverbatim\doverbatim } \let\Everbatim = \afterenvbreak % @verbatiminclude FILE - insert text of file in verbatim environment. % \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} % \def\doverbatiminclude#1{% {% \makevalueexpandable \setupverbatim \indexnofonts % Allow `@@' and other weird things in file names. \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}% \input #1 \afterenvbreak }% } % @copying ... @end copying. % Save the text away for @insertcopying later. % % We save the uninterpreted tokens, rather than creating a box. % Saving the text in a box would be much easier, but then all the % typesetting commands (@smallbook, font changes, etc.) have to be done % beforehand -- and a) we want @copying to be done first in the source % file; b) letting users define the frontmatter in as flexible order as % possible is very desirable. % \def\copying{\checkenv{}\begingroup\scanargctxt\docopying} \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} % \def\insertcopying{% \begingroup \parindent = 0pt % paragraph indentation looks wrong on title page \scanexp\copyingtext \endgroup } \message{defuns,} % @defun etc. \newskip\defbodyindent \defbodyindent=.4in \newskip\defargsindent \defargsindent=50pt \newskip\deflastargmargin \deflastargmargin=18pt \newcount\defunpenalty % Start the processing of @deffn: \def\startdefun{% \ifnum\lastpenalty<10000 \medbreak \defunpenalty=10003 % Will keep this @deffn together with the % following @def command, see below. \else % If there are two @def commands in a row, we'll have a \nobreak, % which is there to keep the function description together with its % header. But if there's nothing but headers, we need to allow a % break somewhere. Check specifically for penalty 10002, inserted % by \printdefunline, instead of 10000, since the sectioning % commands also insert a nobreak penalty, and we don't want to allow % a break between a section heading and a defun. % % As a further refinement, we avoid "club" headers by signalling % with penalty of 10003 after the very first @deffn in the % sequence (see above), and penalty of 10002 after any following % @def command. \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi % % Similarly, after a section heading, do not allow a break. % But do insert the glue. \medskip % preceded by discardable penalty, so not a breakpoint \fi % \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent } \def\dodefunx#1{% % First, check whether we are in the right environment: \checkenv#1% % % As above, allow line break if we have multiple x headers in a row. % It's not a great place, though. \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi % % And now, it's time to reuse the body of the original defun: \expandafter\gobbledefun#1% } \def\gobbledefun#1\startdefun{} % \printdefunline \deffnheader{text} % \def\printdefunline#1#2{% \begingroup % call \deffnheader: #1#2 \endheader % common ending: \interlinepenalty = 10000 \advance\rightskip by 0pt plus 1fil\relax \endgraf \nobreak\vskip -\parskip \penalty\defunpenalty % signal to \startdefun and \dodefunx % Some of the @defun-type tags do not enable magic parentheses, % rendering the following check redundant. But we don't optimize. \checkparencounts \endgroup } \def\Edefun{\endgraf\medbreak} % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; % the only thing remaining is to define \deffnheader. % \def\makedefun#1{% \expandafter\let\csname E#1\endcsname = \Edefun \edef\temp{\noexpand\domakedefun \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% \temp } % \domakedefun \deffn \deffnx \deffnheader % % Define \deffn and \deffnx, without parameters. % \deffnheader has to be defined explicitly. % \def\domakedefun#1#2#3{% \envdef#1{% \startdefun \doingtypefnfalse % distinguish typed functions from all else \parseargusing\activeparens{\printdefunline#3}% }% \def#2{\dodefunx#1}% \def#3% } \newif\ifdoingtypefn % doing typed function? \newif\ifrettypeownline % typeset return type on its own line? % @deftypefnnewline on|off says whether the return type of typed functions % are printed on their own line. This affects @deftypefn, @deftypefun, % @deftypeop, and @deftypemethod. % \parseargdef\deftypefnnewline{% \def\temp{#1}% \ifx\temp\onword \expandafter\let\csname SETtxideftypefnnl\endcsname = \empty \else\ifx\temp\offword \expandafter\let\csname SETtxideftypefnnl\endcsname = \relax \else \errhelp = \EMsimple \errmessage{Unknown @txideftypefnnl value `\temp', must be on|off}% \fi\fi } % Untyped functions: % @deffn category name args \makedefun{deffn}{\deffngeneral{}} % @deffn category class name args \makedefun{defop}#1 {\defopon{#1\ \putwordon}} % \defopon {category on}class name args \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } % \deffngeneral {subind}category name args % \def\deffngeneral#1#2 #3 #4\endheader{% % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}. \dosubind{fn}{\code{#3}}{#1}% \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% } % Typed functions: % @deftypefn category type name args \makedefun{deftypefn}{\deftypefngeneral{}} % @deftypeop category class type name args \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} % \deftypeopon {category on}class type name args \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } % \deftypefngeneral {subind}category type name args % \def\deftypefngeneral#1#2 #3 #4 #5\endheader{% \dosubind{fn}{\code{#4}}{#1}% \doingtypefntrue \defname{#2}{#3}{#4}\defunargs{#5\unskip}% } % Typed variables: % @deftypevr category type var args \makedefun{deftypevr}{\deftypecvgeneral{}} % @deftypecv category class type var args \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} % \deftypecvof {category of}class type var args \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } % \deftypecvgeneral {subind}category type var args % \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% \dosubind{vr}{\code{#4}}{#1}% \defname{#2}{#3}{#4}\defunargs{#5\unskip}% } % Untyped variables: % @defvr category var args \makedefun{defvr}#1 {\deftypevrheader{#1} {} } % @defcv category class var args \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} % \defcvof {category of}class var args \def\defcvof#1#2 {\deftypecvof{#1}#2 {} } % Types: % @deftp category name args \makedefun{deftp}#1 #2 #3\endheader{% \doind{tp}{\code{#2}}% \defname{#1}{}{#2}\defunargs{#3\unskip}% } % Remaining @defun-like shortcuts: \makedefun{defun}{\deffnheader{\putwordDeffunc} } \makedefun{defmac}{\deffnheader{\putwordDefmac} } \makedefun{defspec}{\deffnheader{\putwordDefspec} } \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } \makedefun{defvar}{\defvrheader{\putwordDefvar} } \makedefun{defopt}{\defvrheader{\putwordDefopt} } \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } \makedefun{defmethod}{\defopon\putwordMethodon} \makedefun{deftypemethod}{\deftypeopon\putwordMethodon} \makedefun{defivar}{\defcvof\putwordInstanceVariableof} \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} % \defname, which formats the name of the @def (not the args). % #1 is the category, such as "Function". % #2 is the return type, if any. % #3 is the function name. % % We are followed by (but not passed) the arguments, if any. % \def\defname#1#2#3{% \par % Get the values of \leftskip and \rightskip as they were outside the @def... \advance\leftskip by -\defbodyindent % % Determine if we are typesetting the return type of a typed function % on a line by itself. \rettypeownlinefalse \ifdoingtypefn % doing a typed function specifically? % then check user option for putting return type on its own line: \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else \rettypeownlinetrue \fi \fi % % How we'll format the category name. Putting it in brackets helps % distinguish it from the body text that may end up on the next line % just below it. \def\temp{#1}% \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} % % Figure out line sizes for the paragraph shape. We'll always have at % least two. \tempnum = 2 % % The first line needs space for \box0; but if \rightskip is nonzero, % we need only space for the part of \box0 which exceeds it: \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip % % If doing a return type on its own line, we'll have another line. \ifrettypeownline \advance\tempnum by 1 \def\maybeshapeline{0in \hsize}% \else \def\maybeshapeline{}% \fi % % The continuations: \dimen2=\hsize \advance\dimen2 by -\defargsindent % % The final paragraph shape: \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2 % % Put the category name at the right margin. \noindent \hbox to 0pt{% \hfil\box0 \kern-\hsize % \hsize has to be shortened this way: \kern\leftskip % Intentionally do not respect \rightskip, since we need the space. }% % % Allow all lines to be underfull without complaint: \tolerance=10000 \hbadness=10000 \exdentamount=\defbodyindent {% % defun fonts. We use typewriter by default (used to be bold) because: % . we're printing identifiers, they should be in tt in principle. % . in languages with many accents, such as Czech or French, it's % common to leave accents off identifiers. The result looks ok in % tt, but exceedingly strange in rm. % . we don't want -- and --- to be treated as ligatures. % . this still does not fix the ?` and !` ligatures, but so far no % one has made identifiers using them :). \df \tt \def\temp{#2}% text of the return type \ifx\temp\empty\else \tclose{\temp}% typeset the return type \ifrettypeownline % put return type on its own line; prohibit line break following: \hfil\vadjust{\nobreak}\break \else \space % type on same line, so just followed by a space \fi \fi % no return type #3% output function name }% {\rm\enskip}% hskip 0.5 em of \tenrm % \boldbrax % arguments will be output next, if any. } % Print arguments in slanted roman (not ttsl), inconsistently with using % tt for the name. This is because literal text is sometimes needed in % the argument list (groff manual), and ttsl and tt are not very % distinguishable. Prevent hyphenation at `-' chars. % \def\defunargs#1{% % use sl by default (not ttsl), % tt for the names. \df \sl \hyphenchar\font=0 % % On the other hand, if an argument has two dashes (for instance), we % want a way to get ttsl. We used to recommend @var for that, so % leave the code in, but it's strange for @var to lead to typewriter. % Nowadays we recommend @code, since the difference between a ttsl hyphen % and a tt hyphen is pretty tiny. @code also disables ?` !`. \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}% #1% \sl\hyphenchar\font=45 } % We want ()&[] to print specially on the defun line. % \def\activeparens{% \catcode`\(=\active \catcode`\)=\active \catcode`\[=\active \catcode`\]=\active \catcode`\&=\active } % Make control sequences which act like normal parenthesis chars. \let\lparen = ( \let\rparen = ) % Be sure that we always have a definition for `(', etc. For example, % if the fn name has parens in it, \boldbrax will not be in effect yet, % so TeX would otherwise complain about undefined control sequence. { \activeparens \global\let(=\lparen \global\let)=\rparen \global\let[=\lbrack \global\let]=\rbrack \global\let& = \& \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} \gdef\magicamp{\let&=\amprm} } \newcount\parencount % If we encounter &foo, then turn on ()-hacking afterwards \newif\ifampseen \def\amprm#1 {\ampseentrue{\bf\ }} \def\parenfont{% \ifampseen % At the first level, print parens in roman, % otherwise use the default font. \ifnum \parencount=1 \rm \fi \else % The \sf parens (in \boldbrax) actually are a little bolder than % the contained text. This is especially needed for [ and ] . \sf \fi } \def\infirstlevel#1{% \ifampseen \ifnum\parencount=1 #1% \fi \fi } \def\bfafterword#1 {#1 \bf} \def\opnr{% \global\advance\parencount by 1 {\parenfont(}% \infirstlevel \bfafterword } \def\clnr{% {\parenfont)}% \infirstlevel \sl \global\advance\parencount by -1 } \newcount\brackcount \def\lbrb{% \global\advance\brackcount by 1 {\bf[}% } \def\rbrb{% {\bf]}% \global\advance\brackcount by -1 } \def\checkparencounts{% \ifnum\parencount=0 \else \badparencount \fi \ifnum\brackcount=0 \else \badbrackcount \fi } % these should not use \errmessage; the glibc manual, at least, actually % has such constructs (when documenting function pointers). \def\badparencount{% \message{Warning: unbalanced parentheses in @def...}% \global\parencount=0 } \def\badbrackcount{% \message{Warning: unbalanced square brackets in @def...}% \global\brackcount=0 } \message{macros,} % @macro. % To do this right we need a feature of e-TeX, \scantokens, % which we arrange to emulate with a temporary file in ordinary TeX. \ifx\eTeXversion\thisisundefined \newwrite\macscribble \def\scantokens#1{% \toks0={#1}% \immediate\openout\macscribble=\jobname.tmp \immediate\write\macscribble{\the\toks0}% \immediate\closeout\macscribble \input \jobname.tmp } \fi \def\scanmacro#1{\begingroup \newlinechar`\^^M \let\xeatspaces\eatspaces % % Undo catcode changes of \startcontents and \doprintindex % When called from @insertcopying or (short)caption, we need active % backslash to get it printed correctly. Previously, we had % \catcode`\\=\other instead. We'll see whether a problem appears % with macro expansion. --kasal, 19aug04 \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ % % ... and for \example: \spaceisspace % % The \empty here causes a following catcode 5 newline to be eaten as % part of reading whitespace after a control sequence. It does not % eat a catcode 13 newline. There's no good way to handle the two % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX % would then have different behavior). See the Macro Details node in % the manual for the workaround we recommend for macros and % line-oriented commands. % \scantokens{#1\empty}% \endgroup} \def\scanexp#1{% \edef\temp{\noexpand\scanmacro{#1}}% \temp } \newcount\paramno % Count of parameters \newtoks\macname % Macro name \newif\ifrecursive % Is it recursive? % List of all defined macros in the form % \definedummyword\macro1\definedummyword\macro2... % Currently is also contains all @aliases; the list can be split % if there is a need. \def\macrolist{} % Add the macro to \macrolist \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} \def\addtomacrolistxxx#1{% \toks0 = \expandafter{\macrolist\definedummyword#1}% \xdef\macrolist{\the\toks0}% } % Utility routines. % This does \let #1 = #2, with \csnames; that is, % \let \csname#1\endcsname = \csname#2\endcsname % (except of course we have to play expansion games). % \def\cslet#1#2{% \expandafter\let \csname#1\expandafter\endcsname \csname#2\endcsname } % Trim leading and trailing spaces off a string. % Concepts from aro-bend problem 15 (see CTAN). {\catcode`\@=11 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} \def\unbrace#1{#1} \unbrace{\gdef\trim@@@ #1 } #2@{#1} } % Trim a single trailing ^^M off a string. {\catcode`\^^M=\other \catcode`\Q=3% \gdef\eatcr #1{\eatcra #1Q^^MQ}% \gdef\eatcra#1^^MQ{\eatcrb#1Q}% \gdef\eatcrb#1Q#2Q{#1}% } % Macro bodies are absorbed as an argument in a context where % all characters are catcode 10, 11 or 12, except \ which is active % (as in normal texinfo). It is necessary to change the definition of \ % to recognize macro arguments; this is the job of \mbodybackslash. % % Non-ASCII encodings make 8-bit characters active, so un-activate % them to avoid their expansion. Must do this non-globally, to % confine the change to the current group. % % It's necessary to have hard CRs when the macro is executed. This is % done by making ^^M (\endlinechar) catcode 12 when reading the macro % body, and then making it the \newlinechar in \scanmacro. % \def\scanctxt{% used as subroutine \catcode`\"=\other \catcode`\+=\other \catcode`\<=\other \catcode`\>=\other \catcode`\@=\other \catcode`\^=\other \catcode`\_=\other \catcode`\|=\other \catcode`\~=\other \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi } \def\scanargctxt{% used for copying and captions, not macros. \scanctxt \catcode`\\=\other \catcode`\^^M=\other } \def\macrobodyctxt{% used for @macro definitions \scanctxt \catcode`\{=\other \catcode`\}=\other \catcode`\^^M=\other \usembodybackslash } \def\macroargctxt{% used when scanning invocations \scanctxt \catcode`\\=0 } % why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes" % for the single characters \ { }. Thus, we end up with the "commands" % that would be written @\ @{ @} in a Texinfo document. % % We already have @{ and @}. For @\, we define it here, and only for % this purpose, to produce a typewriter backslash (so, the @\ that we % define for @math can't be used with @macro calls): % \def\\{\normalbackslash}% % % We would like to do this for \, too, since that is what makeinfo does. % But it is not possible, because Texinfo already has a command @, for a % cedilla accent. Documents must use @comma{} instead. % % \anythingelse will almost certainly be an error of some kind. % \mbodybackslash is the definition of \ in @macro bodies. % It maps \foo\ => \csname macarg.foo\endcsname => #N % where N is the macro parameter number. % We define \csname macarg.\endcsname to be \realbackslash, so % \\ in macro replacement text gets you a backslash. % {\catcode`@=0 @catcode`@\=@active @gdef@usembodybackslash{@let\=@mbodybackslash} @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} } \expandafter\def\csname macarg.\endcsname{\realbackslash} \def\margbackslash#1{\char`\#1 } \def\macro{\recursivefalse\parsearg\macroxxx} \def\rmacro{\recursivetrue\parsearg\macroxxx} \def\macroxxx#1{% \getargs{#1}% now \macname is the macname and \argl the arglist \ifx\argl\empty % no arguments \paramno=0\relax \else \expandafter\parsemargdef \argl;% \if\paramno>256\relax \ifx\eTeXversion\thisisundefined \errhelp = \EMsimple \errmessage{You need eTeX to compile a file with macros with more than 256 arguments} \fi \fi \fi \if1\csname ismacro.\the\macname\endcsname \message{Warning: redefining \the\macname}% \else \expandafter\ifx\csname \the\macname\endcsname \relax \else \errmessage{Macro name \the\macname\space already defined}\fi \global\cslet{macsave.\the\macname}{\the\macname}% \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% \addtomacrolist{\the\macname}% \fi \begingroup \macrobodyctxt \ifrecursive \expandafter\parsermacbody \else \expandafter\parsemacbody \fi} \parseargdef\unmacro{% \if1\csname ismacro.#1\endcsname \global\cslet{#1}{macsave.#1}% \global\expandafter\let \csname ismacro.#1\endcsname=0% % Remove the macro name from \macrolist: \begingroup \expandafter\let\csname#1\endcsname \relax \let\definedummyword\unmacrodo \xdef\macrolist{\macrolist}% \endgroup \else \errmessage{Macro #1 not defined}% \fi } % Called by \do from \dounmacro on each macro. The idea is to omit any % macro definitions that have been changed to \relax. % \def\unmacrodo#1{% \ifx #1\relax % remove this \else \noexpand\definedummyword \noexpand#1% \fi } % This makes use of the obscure feature that if the last token of a % is #, then the preceding argument is delimited by % an opening brace, and that opening brace is not consumed. \def\getargs#1{\getargsxxx#1{}} \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} \def\getmacname#1 #2\relax{\macname={#1}} \def\getmacargs#1{\def\argl{#1}} % For macro processing make @ a letter so that we can make Texinfo private macro names. \edef\texiatcatcode{\the\catcode`\@} \catcode `@=11\relax % Parse the optional {params} list. Set up \paramno and \paramlist % so \defmacro knows what to do. Define \macarg.BLAH for each BLAH % in the params list to some hook where the argument si to be expanded. If % there are less than 10 arguments that hook is to be replaced by ##N where N % is the position in that list, that is to say the macro arguments are to be % defined `a la TeX in the macro body. % % That gets used by \mbodybackslash (above). % % We need to get `macro parameter char #' into several definitions. % The technique used is stolen from LaTeX: let \hash be something % unexpandable, insert that wherever you need a #, and then redefine % it to # just before using the token list produced. % % The same technique is used to protect \eatspaces till just before % the macro is used. % % If there are 10 or more arguments, a different technique is used, where the % hook remains in the body, and when macro is to be expanded the body is % processed again to replace the arguments. % % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the % argument N value and then \edef the body (nothing else will expand because of % the catcode regime underwhich the body was input). % % If you compile with TeX (not eTeX), and you have macros with 10 or more % arguments, you need that no macro has more than 256 arguments, otherwise an % error is produced. \def\parsemargdef#1;{% \paramno=0\def\paramlist{}% \let\hash\relax \let\xeatspaces\relax \parsemargdefxxx#1,;,% % In case that there are 10 or more arguments we parse again the arguments % list to set new definitions for the \macarg.BLAH macros corresponding to % each BLAH argument. It was anyhow needed to parse already once this list % in order to count the arguments, and as macros with at most 9 arguments % are by far more frequent than macro with 10 or more arguments, defining % twice the \macarg.BLAH macros does not cost too much processing power. \ifnum\paramno<10\relax\else \paramno0\relax \parsemmanyargdef@@#1,;,% 10 or more arguments \fi } \def\parsemargdefxxx#1,{% \if#1;\let\next=\relax \else \let\next=\parsemargdefxxx \advance\paramno by 1 \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname {\xeatspaces{\hash\the\paramno}}% \edef\paramlist{\paramlist\hash\the\paramno,}% \fi\next} \def\parsemmanyargdef@@#1,{% \if#1;\let\next=\relax \else \let\next=\parsemmanyargdef@@ \edef\tempb{\eatspaces{#1}}% \expandafter\def\expandafter\tempa \expandafter{\csname macarg.\tempb\endcsname}% % Note that we need some extra \noexpand\noexpand, this is because we % don't want \the to be expanded in the \parsermacbody as it uses an % \xdef . \expandafter\edef\tempa {\noexpand\noexpand\noexpand\the\toks\the\paramno}% \advance\paramno by 1\relax \fi\next} % These two commands read recursive and nonrecursive macro bodies. % (They're different since rec and nonrec macros end differently.) % \catcode `\@\texiatcatcode \long\def\parsemacbody#1@end macro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% \long\def\parsermacbody#1@end rmacro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% \catcode `\@=11\relax \let\endargs@\relax \let\nil@\relax \def\nilm@{\nil@}% \long\def\nillm@{\nil@}% % This macro is expanded during the Texinfo macro expansion, not during its % definition. It gets all the arguments values and assigns them to macros % macarg.ARGNAME % % #1 is the macro name % #2 is the list of argument names % #3 is the list of argument values \def\getargvals@#1#2#3{% \def\macargdeflist@{}% \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion. \def\paramlist{#2,\nil@}% \def\macroname{#1}% \begingroup \macroargctxt \def\argvaluelist{#3,\nil@}% \def\@tempa{#3}% \ifx\@tempa\empty \setemptyargvalues@ \else \getargvals@@ \fi } % \def\getargvals@@{% \ifx\paramlist\nilm@ % Some sanity check needed here that \argvaluelist is also empty. \ifx\argvaluelist\nillm@ \else \errhelp = \EMsimple \errmessage{Too many arguments in macro `\macroname'!}% \fi \let\next\macargexpandinbody@ \else \ifx\argvaluelist\nillm@ % No more arguments values passed to macro. Set remaining named-arg % macros to empty. \let\next\setemptyargvalues@ \else % pop current arg name into \@tempb \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}% \expandafter\@tempa\expandafter{\paramlist}% % pop current argument value into \@tempc \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}% \expandafter\@tempa\expandafter{\argvaluelist}% % Here \@tempb is the current arg name and \@tempc is the current arg value. % First place the new argument macro definition into \@tempd \expandafter\macname\expandafter{\@tempc}% \expandafter\let\csname macarg.\@tempb\endcsname\relax \expandafter\def\expandafter\@tempe\expandafter{% \csname macarg.\@tempb\endcsname}% \edef\@tempd{\long\def\@tempe{\the\macname}}% \push@\@tempd\macargdeflist@ \let\next\getargvals@@ \fi \fi \next } \def\push@#1#2{% \expandafter\expandafter\expandafter\def \expandafter\expandafter\expandafter#2% \expandafter\expandafter\expandafter{% \expandafter#1#2}% } % Replace arguments by their values in the macro body, and place the result % in macro \@tempa \def\macvalstoargs@{% % To do this we use the property that token registers that are \the'ed % within an \edef expand only once. So we are going to place all argument % values into respective token registers. % % First we save the token context, and initialize argument numbering. \begingroup \paramno0\relax % Then, for each argument number #N, we place the corresponding argument % value into a new token list register \toks#N \expandafter\putargsintokens@\saveparamlist@,;,% % Then, we expand the body so that argument are replaced by their % values. The trick for values not to be expanded themselves is that they % are within tokens and that tokens expand only once in an \edef . \edef\@tempc{\csname mac.\macroname .body\endcsname}% % Now we restore the token stack pointer to free the token list registers % which we have used, but we make sure that expanded body is saved after % group. \expandafter \endgroup \expandafter\def\expandafter\@tempa\expandafter{\@tempc}% } \def\macargexpandinbody@{% %% Define the named-macro outside of this group and then close this group. \expandafter \endgroup \macargdeflist@ % First the replace in body the macro arguments by their values, the result % is in \@tempa . \macvalstoargs@ % Then we point at the \norecurse or \gobble (for recursive) macro value % with \@tempb . \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname % Depending on whether it is recursive or not, we need some tailing % \egroup . \ifx\@tempb\gobble \let\@tempc\relax \else \let\@tempc\egroup \fi % And now we do the real job: \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}% \@tempd } \def\putargsintokens@#1,{% \if#1;\let\next\relax \else \let\next\putargsintokens@ % First we allocate the new token list register, and give it a temporary % alias \@tempb . \toksdef\@tempb\the\paramno % Then we place the argument value into that token list register. \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname \expandafter\@tempb\expandafter{\@tempa}% \advance\paramno by 1\relax \fi \next } % Save the token stack pointer into macro #1 \def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}} % Restore the token stack pointer from number in macro #1 \def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax} % newtoks that can be used non \outer . \def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi} % Tailing missing arguments are set to empty \def\setemptyargvalues@{% \ifx\paramlist\nilm@ \let\next\macargexpandinbody@ \else \expandafter\setemptyargvaluesparser@\paramlist\endargs@ \let\next\setemptyargvalues@ \fi \next } \def\setemptyargvaluesparser@#1,#2\endargs@{% \expandafter\def\expandafter\@tempa\expandafter{% \expandafter\def\csname macarg.#1\endcsname{}}% \push@\@tempa\macargdeflist@ \def\paramlist{#2}% } % #1 is the element target macro % #2 is the list macro % #3,#4\endargs@ is the list value \def\pop@#1#2#3,#4\endargs@{% \def#1{#3}% \def#2{#4}% } \long\def\longpop@#1#2#3,#4\endargs@{% \long\def#1{#3}% \long\def#2{#4}% } % This defines a Texinfo @macro. There are eight cases: recursive and % nonrecursive macros of zero, one, up to nine, and many arguments. % Much magic with \expandafter here. % \xdef is used so that macro definitions will survive the file % they're defined in; @include reads the file inside a group. % \def\defmacro{% \let\hash=##% convert placeholders to macro parameter chars \ifrecursive \ifcase\paramno % 0 \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\scanmacro{\temp}}% \or % 1 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\braceorline \expandafter\noexpand\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup\noexpand\scanmacro{\temp}}% \else \ifnum\paramno<10\relax % at most 9 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\csname\the\macname xx\endcsname}% \expandafter\xdef\csname\the\macname xx\endcsname##1{% \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter \csname\the\macname xxx\endcsname \paramlist{\egroup\noexpand\scanmacro{\temp}}% \else % 10 or more \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\getargvals@{\the\macname}{\argl}% }% \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble \fi \fi \else \ifcase\paramno % 0 \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \or % 1 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\braceorline \expandafter\noexpand\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \else % at most 9 \ifnum\paramno<10\relax \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \expandafter\noexpand\csname\the\macname xx\endcsname}% \expandafter\xdef\csname\the\macname xx\endcsname##1{% \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter \csname\the\macname xxx\endcsname \paramlist{% \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \else % 10 or more: \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\getargvals@{\the\macname}{\argl}% }% \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse \fi \fi \fi} \catcode `\@\texiatcatcode\relax \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} % \braceorline decides whether the next nonwhitespace character is a % {. If so it reads up to the closing }, if not, it reads the whole % line. Whatever was read is then fed to the next control sequence % as an argument (by \parsebrace or \parsearg). % \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} \def\braceorlinexxx{% \ifx\nchar\bgroup\else \expandafter\parsearg \fi \macnamexxx} % @alias. % We need some trickery to remove the optional spaces around the equal % sign. Make them active and then expand them all to nothing. % \def\alias{\parseargusing\obeyspaces\aliasxxx} \def\aliasxxx #1{\aliasyyy#1\relax} \def\aliasyyy #1=#2\relax{% {% \expandafter\let\obeyedspace=\empty \addtomacrolist{#1}% \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% }% \next } \message{cross references,} \newwrite\auxfile \newif\ifhavexrefs % True if xref values are known. \newif\ifwarnedxrefs % True if we warned once that they aren't known. % @inforef is relatively simple. \def\inforef #1{\inforefzzz #1,,,,**} \def\inforefzzz #1,#2,#3,#4**{% \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, node \samp{\ignorespaces#1{}}} % @node's only job in TeX is to define \lastnode, which is used in % cross-references. The @node line might or might not have commas, and % might or might not have spaces before the first comma, like: % @node foo , bar , ... % We don't want such trailing spaces in the node name. % \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} % % also remove a trailing comma, in case of something like this: % @node Help-Cross, , , Cross-refs \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} \let\nwnode=\node \let\lastnode=\empty % Write a cross-reference definition for the current node. #1 is the % type (Ynumbered, Yappendix, Ynothing). % \def\donoderef#1{% \ifx\lastnode\empty\else \setref{\lastnode}{#1}% \global\let\lastnode=\empty \fi } % @anchor{NAME} -- define xref target at arbitrary point. % \newcount\savesfregister % \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an % anchor), which consists of three parts: % 1) NAME-title - the current sectioning name taken from \lastsection, % or the anchor name. % 2) NAME-snt - section number and type, passed as the SNT arg, or % empty for anchors. % 3) NAME-pg - the page number. % % This is called from \donoderef, \anchor, and \dofloat. In the case of % floats, there is an additional part, which is not written here: % 4) NAME-lof - the text as it should appear in a @listoffloats. % \def\setref#1#2{% \pdfmkdest{#1}% \iflinks {% \atdummies % preserve commands, but don't expand them \edef\writexrdef##1##2{% \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef ##1}{##2}}% these are parameters of \writexrdef }% \toks0 = \expandafter{\lastsection}% \immediate \writexrdef{title}{\the\toks0 }% \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout }% \fi } % @xrefautosectiontitle on|off says whether @section(ing) names are used % automatically in xrefs, if the third arg is not explicitly specified. % This was provided as a "secret" @set xref-automatic-section-title % variable, now it's official. % \parseargdef\xrefautomaticsectiontitle{% \def\temp{#1}% \ifx\temp\onword \expandafter\let\csname SETxref-automatic-section-title\endcsname = \empty \else\ifx\temp\offword \expandafter\let\csname SETxref-automatic-section-title\endcsname = \relax \else \errhelp = \EMsimple \errmessage{Unknown @xrefautomaticsectiontitle value `\temp', must be on|off}% \fi\fi } % % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is % the node name, #2 the name of the Info cross-reference, #3 the printed % node name, #4 the name of the Info file, #5 the name of the printed % manual. All but the node name can be omitted. % \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} \def\ref#1{\xrefX[#1,,,,,,,]} % \newbox\toprefbox \newbox\printedrefnamebox \newbox\infofilenamebox \newbox\printedmanualbox % \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup \unsepspaces % % Get args without leading/trailing spaces. \def\printedrefname{\ignorespaces #3}% \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% % \def\infofilename{\ignorespaces #4}% \setbox\infofilenamebox = \hbox{\infofilename\unskip}% % \def\printedmanual{\ignorespaces #5}% \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% % % If the printed reference name (arg #3) was not explicitly given in % the @xref, figure out what we want to use. \ifdim \wd\printedrefnamebox = 0pt % No printed node name was explicitly given. \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax % Not auto section-title: use node name inside the square brackets. \def\printedrefname{\ignorespaces #1}% \else % Auto section-title: use chapter/section title inside % the square brackets if we have it. \ifdim \wd\printedmanualbox > 0pt % It is in another manual, so we don't have it; use node name. \def\printedrefname{\ignorespaces #1}% \else \ifhavexrefs % We (should) know the real title if we have the xref values. \def\printedrefname{\refx{#1-title}{}}% \else % Otherwise just copy the Info node name. \def\printedrefname{\ignorespaces #1}% \fi% \fi \fi \fi % % Make link in pdf output. \ifpdf {\indexnofonts \turnoffactive \makevalueexpandable % This expands tokens, so do it after making catcode changes, so _ % etc. don't get their TeX definitions. This ignores all spaces in % #4, including (wrongly) those in the middle of the filename. \getfilename{#4}% % % This (wrongly) does not take account of leading or trailing % spaces in #1, which should be ignored. \edef\pdfxrefdest{#1}% \ifx\pdfxrefdest\empty \def\pdfxrefdest{Top}% no empty targets \else \txiescapepdf\pdfxrefdest % escape PDF special chars \fi % \leavevmode \startlink attr{/Border [0 0 0]}% \ifnum\filenamelength>0 goto file{\the\filename.pdf} name{\pdfxrefdest}% \else goto name{\pdfmkpgn{\pdfxrefdest}}% \fi }% \setcolor{\linkcolor}% \fi % % Float references are printed completely differently: "Figure 1.2" % instead of "[somenode], p.3". We distinguish them by the % LABEL-title being set to a magic string. {% % Have to otherify everything special to allow the \csname to % include an _ in the xref name, etc. \indexnofonts \turnoffactive \expandafter\global\expandafter\let\expandafter\Xthisreftitle \csname XR#1-title\endcsname }% \iffloat\Xthisreftitle % If the user specified the print name (third arg) to the ref, % print it instead of our usual "Figure 1.2". \ifdim\wd\printedrefnamebox = 0pt \refx{#1-snt}{}% \else \printedrefname \fi % % If the user also gave the printed manual name (fifth arg), append % "in MANUALNAME". \ifdim \wd\printedmanualbox > 0pt \space \putwordin{} \cite{\printedmanual}% \fi \else % node/anchor (non-float) references. % % If we use \unhbox to print the node names, TeX does not insert % empty discretionaries after hyphens, which means that it will not % find a line break at a hyphen in a node names. Since some manuals % are best written with fairly long node names, containing hyphens, % this is a loss. Therefore, we give the text of the node name % again, so it is as if TeX is seeing it for the first time. % \ifdim \wd\printedmanualbox > 0pt % Cross-manual reference with a printed manual name. % \crossmanualxref{\cite{\printedmanual\unskip}}% % \else\ifdim \wd\infofilenamebox > 0pt % Cross-manual reference with only an info filename (arg 4), no % printed manual name (arg 5). This is essentially the same as % the case above; we output the filename, since we have nothing else. % \crossmanualxref{\code{\infofilename\unskip}}% % \else % Reference within this manual. % % _ (for example) has to be the character _ for the purposes of the % control sequence corresponding to the node, but it has to expand % into the usual \leavevmode...\vrule stuff for purposes of % printing. So we \turnoffactive for the \refx-snt, back on for the % printing, back off for the \refx-pg. {\turnoffactive % Only output a following space if the -snt ref is nonempty; for % @unnumbered and @anchor, it won't be. \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi }% % output the `[mynode]' via the macro below so it can be overridden. \xrefprintnodename\printedrefname % % But we always want a comma and a space: ,\space % % output the `page 3'. \turnoffactive \putwordpage\tie\refx{#1-pg}{}% \fi\fi \fi \endlink \endgroup} % Output a cross-manual xref to #1. Used just above (twice). % % Only include the text "Section ``foo'' in" if the foo is neither % missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply % "see The Foo Manual", the idea being to refer to the whole manual. % % But, this being TeX, we can't easily compare our node name against the % string "Top" while ignoring the possible spaces before and after in % the input. By adding the arbitrary 7sp below, we make it much less % likely that a real node name would have the same width as "Top" (e.g., % in a monospaced font). Hopefully it will never happen in practice. % % For the same basic reason, we retypeset the "Top" at every % reference, since the current font is indeterminate. % \def\crossmanualxref#1{% \setbox\toprefbox = \hbox{Top\kern7sp}% \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% \ifdim \wd2 > 7sp % nonempty? \ifdim \wd2 = \wd\toprefbox \else % same as Top? \putwordSection{} ``\printedrefname'' \putwordin{}\space \fi \fi #1% } % This macro is called from \xrefX for the `[nodename]' part of xref % output. It's a separate macro only so it can be changed more easily, % since square brackets don't work well in some documents. Particularly % one that Bob is working on :). % \def\xrefprintnodename#1{[#1]} % Things referred to by \setref. % \def\Ynothing{} \def\Yomitfromtoc{} \def\Ynumbered{% \ifnum\secno=0 \putwordChapter@tie \the\chapno \else \ifnum\subsecno=0 \putwordSection@tie \the\chapno.\the\secno \else \ifnum\subsubsecno=0 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno \else \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno \fi\fi\fi } \def\Yappendix{% \ifnum\secno=0 \putwordAppendix@tie @char\the\appendixno{}% \else \ifnum\subsecno=0 \putwordSection@tie @char\the\appendixno.\the\secno \else \ifnum\subsubsecno=0 \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno \else \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno \fi\fi\fi } % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. % If its value is nonempty, SUFFIX is output afterward. % \def\refx#1#2{% {% \indexnofonts \otherbackslash \expandafter\global\expandafter\let\expandafter\thisrefX \csname XR#1\endcsname }% \ifx\thisrefX\relax % If not defined, say something at least. \angleleft un\-de\-fined\angleright \iflinks \ifhavexrefs {\toks0 = {#1}% avoid expansion of possibly-complex value \message{\linenumber Undefined cross reference `\the\toks0'.}}% \else \ifwarnedxrefs\else \global\warnedxrefstrue \message{Cross reference values unknown; you must run TeX again.}% \fi \fi \fi \else % It's defined, so just use it. \thisrefX \fi #2% Output the suffix in any case. } % This is the macro invoked by entries in the aux file. Usually it's % just a \def (we prepend XR to the control sequence name to avoid % collisions). But if this is a float type, we have more work to do. % \def\xrdef#1#2{% {% The node name might contain 8-bit characters, which in our current % implementation are changed to commands like @'e. Don't let these % mess up the control sequence name. \indexnofonts \turnoffactive \xdef\safexrefname{#1}% }% % \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref % % Was that xref control sequence that we just defined for a float? \expandafter\iffloat\csname XR\safexrefname\endcsname % it was a float, and we have the (safe) float type in \iffloattype. \expandafter\let\expandafter\floatlist \csname floatlist\iffloattype\endcsname % % Is this the first time we've seen this float type? \expandafter\ifx\floatlist\relax \toks0 = {\do}% yes, so just \do \else % had it before, so preserve previous elements in list. \toks0 = \expandafter{\floatlist\do}% \fi % % Remember this xref in the control sequence \floatlistFLOATTYPE, % for later use in \listoffloats. \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0 {\safexrefname}}% \fi } % Read the last existing aux file, if any. No error if none exists. % \def\tryauxfile{% \openin 1 \jobname.aux \ifeof 1 \else \readdatafile{aux}% \global\havexrefstrue \fi \closein 1 } \def\setupdatafile{% \catcode`\^^@=\other \catcode`\^^A=\other \catcode`\^^B=\other \catcode`\^^C=\other \catcode`\^^D=\other \catcode`\^^E=\other \catcode`\^^F=\other \catcode`\^^G=\other \catcode`\^^H=\other \catcode`\^^K=\other \catcode`\^^L=\other \catcode`\^^N=\other \catcode`\^^P=\other \catcode`\^^Q=\other \catcode`\^^R=\other \catcode`\^^S=\other \catcode`\^^T=\other \catcode`\^^U=\other \catcode`\^^V=\other \catcode`\^^W=\other \catcode`\^^X=\other \catcode`\^^Z=\other \catcode`\^^[=\other \catcode`\^^\=\other \catcode`\^^]=\other \catcode`\^^^=\other \catcode`\^^_=\other % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. % in xref tags, i.e., node names. But since ^^e4 notation isn't % supported in the main text, it doesn't seem desirable. Furthermore, % that is not enough: for node names that actually contain a ^ % character, we would end up writing a line like this: 'xrdef {'hat % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first % argument, and \hat is not an expandable control sequence. It could % all be worked out, but why? Either we support ^^ or we don't. % % The other change necessary for this was to define \auxhat: % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter % and then to call \auxhat in \setq. % \catcode`\^=\other % % Special characters. Should be turned off anyway, but... \catcode`\~=\other \catcode`\[=\other \catcode`\]=\other \catcode`\"=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode`\$=\other \catcode`\#=\other \catcode`\&=\other \catcode`\%=\other \catcode`+=\other % avoid \+ for paranoia even though we've turned it off % % This is to support \ in node names and titles, since the \ % characters end up in a \csname. It's easier than % leaving it active and making its active definition an actual \ % character. What I don't understand is why it works in the *value* % of the xrdef. Seems like it should be a catcode12 \, and that % should not typeset properly. But it works, so I'm moving on for % now. --karl, 15jan04. \catcode`\\=\other % % Make the characters 128-255 be printing characters. {% \count1=128 \def\loop{% \catcode\count1=\other \advance\count1 by 1 \ifnum \count1<256 \loop \fi }% }% % % @ is our escape character in .aux files, and we need braces. \catcode`\{=1 \catcode`\}=2 \catcode`\@=0 } \def\readdatafile#1{% \begingroup \setupdatafile \input\jobname.#1 \endgroup} \message{insertions,} % including footnotes. \newcount \footnoteno % The trailing space in the following definition for supereject is % vital for proper filling; pages come out unaligned when you do a % pagealignmacro call if that space before the closing brace is % removed. (Generally, numeric constants should always be followed by a % space to prevent strange expansion errors.) \def\supereject{\par\penalty -20000\footnoteno =0 } % @footnotestyle is meaningful for Info output only. \let\footnotestyle=\comment {\catcode `\@=11 % % Auto-number footnotes. Otherwise like plain. \gdef\footnote{% \let\indent=\ptexindent \let\noindent=\ptexnoindent \global\advance\footnoteno by \@ne \edef\thisfootno{$^{\the\footnoteno}$}% % % In case the footnote comes at the end of a sentence, preserve the % extra spacing after we do the footnote number. \let\@sf\empty \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi % % Remove inadvertent blank space before typesetting the footnote number. \unskip \thisfootno\@sf \dofootnote }% % Don't bother with the trickery in plain.tex to not require the % footnote text as a parameter. Our footnotes don't need to be so general. % % Oh yes, they do; otherwise, @ifset (and anything else that uses % \parseargline) fails inside footnotes because the tokens are fixed when % the footnote is read. --karl, 16nov96. % \gdef\dofootnote{% \insert\footins\bgroup % We want to typeset this text as a normal paragraph, even if the % footnote reference occurs in (for example) a display environment. % So reset some parameters. \hsize=\pagewidth \interlinepenalty\interfootnotelinepenalty \splittopskip\ht\strutbox % top baseline for broken footnotes \splitmaxdepth\dp\strutbox \floatingpenalty\@MM \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip \parindent\defaultparindent % \smallfonts \rm % % Because we use hanging indentation in footnotes, a @noindent appears % to exdent this text, so make it be a no-op. makeinfo does not use % hanging indentation so @noindent can still be needed within footnote % text after an @example or the like (not that this is good style). \let\noindent = \relax % % Hang the footnote text off the number. Use \everypar in case the % footnote extends for more than one paragraph. \everypar = {\hang}% \textindent{\thisfootno}% % % Don't crash into the line above the footnote text. Since this % expands into a box, it must come within the paragraph, lest it % provide a place where TeX can split the footnote. \footstrut % % Invoke rest of plain TeX footnote routine. \futurelet\next\fo@t } }%end \catcode `\@=11 % In case a @footnote appears in a vbox, save the footnote text and create % the real \insert just after the vbox finished. Otherwise, the insertion % would be lost. % Similarly, if a @footnote appears inside an alignment, save the footnote % text to a box and make the \insert when a row of the table is finished. % And the same can be done for other insert classes. --kasal, 16nov03. % Replace the \insert primitive by a cheating macro. % Deeper inside, just make sure that the saved insertions are not spilled % out prematurely. % \def\startsavinginserts{% \ifx \insert\ptexinsert \let\insert\saveinsert \else \let\checkinserts\relax \fi } % This \insert replacement works for both \insert\footins{foo} and % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. % \def\saveinsert#1{% \edef\next{\noexpand\savetobox \makeSAVEname#1}% \afterassignment\next % swallow the left brace \let\temp = } \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} \def\placesaveins#1{% \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname {\box#1}% } % eat @SAVE -- beware, all of them have catcode \other: { \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) \gdef\gobblesave @SAVE{} } % initialization: \def\newsaveins #1{% \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% \next } \def\newsaveinsX #1{% \csname newbox\endcsname #1% \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts \checksaveins #1}% } % initialize: \let\checkinserts\empty \newsaveins\footins \newsaveins\margin % @image. We use the macros from epsf.tex to support this. % If epsf.tex is not installed and @image is used, we complain. % % Check for and read epsf.tex up front. If we read it only at @image % time, we might be inside a group, and then its definitions would get % undone and the next image would fail. \openin 1 = epsf.tex \ifeof 1 \else % Do not bother showing banner with epsf.tex v2.7k (available in % doc/epsf.tex and on ctan). \def\epsfannounce{\toks0 = }% \input epsf.tex \fi \closein 1 % % We will only complain once about lack of epsf.tex. \newif\ifwarnednoepsf \newhelp\noepsfhelp{epsf.tex must be installed for images to work. It is also included in the Texinfo distribution, or you can get it from ftp://tug.org/tex/epsf.tex.} % \def\image#1{% \ifx\epsfbox\thisisundefined \ifwarnednoepsf \else \errhelp = \noepsfhelp \errmessage{epsf.tex not found, images will be ignored}% \global\warnednoepsftrue \fi \else \imagexxx #1,,,,,\finish \fi } % % Arguments to @image: % #1 is (mandatory) image filename; we tack on .eps extension. % #2 is (optional) width, #3 is (optional) height. % #4 is (ignored optional) html alt text. % #5 is (ignored optional) extension. % #6 is just the usual extra ignored arg for parsing stuff. \newif\ifimagevmode \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup \catcode`\^^M = 5 % in case we're inside an example \normalturnoffactive % allow _ et al. in names % If the image is by itself, center it. \ifvmode \imagevmodetrue \else \ifx\centersub\centerV % for @center @image, we need a vbox so we can have our vertical space \imagevmodetrue \vbox\bgroup % vbox has better behavior than vtop herev \fi\fi % \ifimagevmode \nobreak\medskip % Usually we'll have text after the image which will insert % \parskip glue, so insert it here too to equalize the space % above and below. \nobreak\vskip\parskip \nobreak \fi % % Leave vertical mode so that indentation from an enclosing % environment such as @quotation is respected. % However, if we're at the top level, we don't want the % normal paragraph indentation. % On the other hand, if we are in the case of @center @image, we don't % want to start a paragraph, which will create a hsize-width box and % eradicate the centering. \ifx\centersub\centerV\else \noindent \fi % % Output the image. \ifpdf \dopdfimage{#1}{#2}{#3}% \else % \epsfbox itself resets \epsf?size at each figure. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi \epsfbox{#1.eps}% \fi % \ifimagevmode \medskip % space after a standalone image \fi \ifx\centersub\centerV \egroup \fi \endgroup} % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, % etc. We don't actually implement floating yet, we always include the % float "here". But it seemed the best name for the future. % \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} % There may be a space before second and/or third parameter; delete it. \def\eatcommaspace#1, {#1,} % #1 is the optional FLOATTYPE, the text label for this float, typically % "Figure", "Table", "Example", etc. Can't contain commas. If omitted, % this float will not be numbered and cannot be referred to. % % #2 is the optional xref label. Also must be present for the float to % be referable. % % #3 is the optional positioning argument; for now, it is ignored. It % will somehow specify the positions allowed to float to (here, top, bottom). % % We keep a separate counter for each FLOATTYPE, which we reset at each % chapter-level command. \let\resetallfloatnos=\empty % \def\dofloat#1,#2,#3,#4\finish{% \let\thiscaption=\empty \let\thisshortcaption=\empty % % don't lose footnotes inside @float. % % BEWARE: when the floats start float, we have to issue warning whenever an % insert appears inside a float which could possibly float. --kasal, 26may04 % \startsavinginserts % % We can't be used inside a paragraph. \par % \vtop\bgroup \def\floattype{#1}% \def\floatlabel{#2}% \def\floatloc{#3}% we do nothing with this yet. % \ifx\floattype\empty \let\safefloattype=\empty \else {% % the floattype might have accents or other special characters, % but we need to use it in a control sequence name. \indexnofonts \turnoffactive \xdef\safefloattype{\floattype}% }% \fi % % If label is given but no type, we handle that as the empty type. \ifx\floatlabel\empty \else % We want each FLOATTYPE to be numbered separately (Figure 1, % Table 1, Figure 2, ...). (And if no label, no number.) % \expandafter\getfloatno\csname\safefloattype floatno\endcsname \global\advance\floatno by 1 % {% % This magic value for \lastsection is output by \setref as the % XREFLABEL-title value. \xrefX uses it to distinguish float % labels (which have a completely different output format) from % node and anchor labels. And \xrdef uses it to construct the % lists of floats. % \edef\lastsection{\floatmagic=\safefloattype}% \setref{\floatlabel}{Yfloat}% }% \fi % % start with \parskip glue, I guess. \vskip\parskip % % Don't suppress indentation if a float happens to start a section. \restorefirstparagraphindent } % we have these possibilities: % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap % @float Foo,lbl & no caption: Foo 1.1 % @float Foo & @caption{Cap}: Foo: Cap % @float Foo & no caption: Foo % @float ,lbl & Caption{Cap}: 1.1: Cap % @float ,lbl & no caption: 1.1 % @float & @caption{Cap}: Cap % @float & no caption: % \def\Efloat{% \let\floatident = \empty % % In all cases, if we have a float type, it comes first. \ifx\floattype\empty \else \def\floatident{\floattype}\fi % % If we have an xref label, the number comes next. \ifx\floatlabel\empty \else \ifx\floattype\empty \else % if also had float type, need tie first. \appendtomacro\floatident{\tie}% \fi % the number. \appendtomacro\floatident{\chaplevelprefix\the\floatno}% \fi % % Start the printed caption with what we've constructed in % \floatident, but keep it separate; we need \floatident again. \let\captionline = \floatident % \ifx\thiscaption\empty \else \ifx\floatident\empty \else \appendtomacro\captionline{: }% had ident, so need a colon between \fi % % caption text. \appendtomacro\captionline{\scanexp\thiscaption}% \fi % % If we have anything to print, print it, with space before. % Eventually this needs to become an \insert. \ifx\captionline\empty \else \vskip.5\parskip \captionline % % Space below caption. \vskip\parskip \fi % % If have an xref label, write the list of floats info. Do this % after the caption, to avoid chance of it being a breakpoint. \ifx\floatlabel\empty \else % Write the text that goes in the lof to the aux file as % \floatlabel-lof. Besides \floatident, we include the short % caption if specified, else the full caption if specified, else nothing. {% \atdummies % % since we read the caption text in the macro world, where ^^M % is turned into a normal character, we have to scan it back, so % we don't write the literal three characters "^^M" into the aux file. \scanexp{% \xdef\noexpand\gtemp{% \ifx\thisshortcaption\empty \thiscaption \else \thisshortcaption \fi }% }% \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident \ifx\gtemp\empty \else : \gtemp \fi}}% }% \fi \egroup % end of \vtop % % place the captured inserts % % BEWARE: when the floats start floating, we have to issue warning % whenever an insert appears inside a float which could possibly % float. --kasal, 26may04 % \checkinserts } % Append the tokens #2 to the definition of macro #1, not expanding either. % \def\appendtomacro#1#2{% \expandafter\def\expandafter#1\expandafter{#1#2}% } % @caption, @shortcaption % \def\caption{\docaption\thiscaption} \def\shortcaption{\docaption\thisshortcaption} \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} \def\defcaption#1#2{\egroup \def#1{#2}} % The parameter is the control sequence identifying the counter we are % going to use. Create it if it doesn't exist and assign it to \floatno. \def\getfloatno#1{% \ifx#1\relax % Haven't seen this figure type before. \csname newcount\endcsname #1% % % Remember to reset this floatno at the next chap. \expandafter\gdef\expandafter\resetallfloatnos \expandafter{\resetallfloatnos #1=0 }% \fi \let\floatno#1% } % \setref calls this to get the XREFLABEL-snt value. We want an @xref % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we % first read the @float command. % \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% % Magic string used for the XREFLABEL-title value, so \xrefX can % distinguish floats from other xref types. \def\floatmagic{!!float!!} % #1 is the control sequence we are passed; we expand into a conditional % which is true if #1 represents a float ref. That is, the magic % \lastsection value which we \setref above. % \def\iffloat#1{\expandafter\doiffloat#1==\finish} % % #1 is (maybe) the \floatmagic string. If so, #2 will be the % (safe) float type for this float. We set \iffloattype to #2. % \def\doiffloat#1=#2=#3\finish{% \def\temp{#1}% \def\iffloattype{#2}% \ifx\temp\floatmagic } % @listoffloats FLOATTYPE - print a list of floats like a table of contents. % \parseargdef\listoffloats{% \def\floattype{#1}% floattype {% % the floattype might have accents or other special characters, % but we need to use it in a control sequence name. \indexnofonts \turnoffactive \xdef\safefloattype{\floattype}% }% % % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax \ifhavexrefs % if the user said @listoffloats foo but never @float foo. \message{\linenumber No `\safefloattype' floats to list.}% \fi \else \begingroup \leftskip=\tocindent % indent these entries like a toc \let\do=\listoffloatsdo \csname floatlist\safefloattype\endcsname \endgroup \fi } % This is called on each entry in a list of floats. We're passed the % xref label, in the form LABEL-title, which is how we save it in the % aux file. We strip off the -title and look up \XRLABEL-lof, which % has the text we're supposed to typeset here. % % Figures without xref labels will not be included in the list (since % they won't appear in the aux file). % \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} \def\listoffloatsdoentry#1-title\finish{{% % Can't fully expand XR#1-lof because it can contain anything. Just % pass the control sequence. On the other hand, XR#1-pg is just the % page number, and we want to fully expand that so we can get a link % in pdf output. \toksA = \expandafter{\csname XR#1-lof\endcsname}% % % use the same \entry macro we use to generate the TOC and index. \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% \writeentry }} \message{localization,} % For single-language documents, @documentlanguage is usually given very % early, just after @documentencoding. Single argument is the language % (de) or locale (de_DE) abbreviation. % { \catcode`\_ = \active \globaldefs=1 \parseargdef\documentlanguage{\begingroup \let_=\normalunderscore % normal _ character for filenames \tex % read txi-??.tex file in plain TeX. % Read the file by the name they passed if it exists. \openin 1 txi-#1.tex \ifeof 1 \documentlanguagetrywithoutunderscore{#1_\finish}% \else \globaldefs = 1 % everything in the txi-LL files needs to persist \input txi-#1.tex \fi \closein 1 \endgroup % end raw TeX \endgroup} % % If they passed de_DE, and txi-de_DE.tex doesn't exist, % try txi-de.tex. % \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{% \openin 1 txi-#1.tex \ifeof 1 \errhelp = \nolanghelp \errmessage{Cannot read language file txi-#1.tex}% \else \globaldefs = 1 % everything in the txi-LL files needs to persist \input txi-#1.tex \fi \closein 1 } }% end of special _ catcode % \newhelp\nolanghelp{The given language definition file cannot be found or is empty. Maybe you need to install it? Putting it in the current directory should work if nowhere else does.} % This macro is called from txi-??.tex files; the first argument is the % \language name to set (without the "\lang@" prefix), the second and % third args are \{left,right}hyphenmin. % % The language names to pass are determined when the format is built. % See the etex.log file created at that time, e.g., % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log. % % With TeX Live 2008, etex now includes hyphenation patterns for all % available languages. This means we can support hyphenation in % Texinfo, at least to some extent. (This still doesn't solve the % accented characters problem.) % \catcode`@=11 \def\txisetlanguage#1#2#3{% % do not set the language if the name is undefined in the current TeX. \expandafter\ifx\csname lang@#1\endcsname \relax \message{no patterns for #1}% \else \global\language = \csname lang@#1\endcsname \fi % but there is no harm in adjusting the hyphenmin values regardless. \global\lefthyphenmin = #2\relax \global\righthyphenmin = #3\relax } % Helpers for encodings. % Set the catcode of characters 128 through 255 to the specified number. % \def\setnonasciicharscatcode#1{% \count255=128 \loop\ifnum\count255<256 \global\catcode\count255=#1\relax \advance\count255 by 1 \repeat } \def\setnonasciicharscatcodenonglobal#1{% \count255=128 \loop\ifnum\count255<256 \catcode\count255=#1\relax \advance\count255 by 1 \repeat } % @documentencoding sets the definition of non-ASCII characters % according to the specified encoding. % \parseargdef\documentencoding{% % Encoding being declared for the document. \def\declaredencoding{\csname #1.enc\endcsname}% % % Supported encodings: names converted to tokens in order to be able % to compare them with \ifx. \def\ascii{\csname US-ASCII.enc\endcsname}% \def\latnine{\csname ISO-8859-15.enc\endcsname}% \def\latone{\csname ISO-8859-1.enc\endcsname}% \def\lattwo{\csname ISO-8859-2.enc\endcsname}% \def\utfeight{\csname UTF-8.enc\endcsname}% % \ifx \declaredencoding \ascii \asciichardefs % \else \ifx \declaredencoding \lattwo \setnonasciicharscatcode\active \lattwochardefs % \else \ifx \declaredencoding \latone \setnonasciicharscatcode\active \latonechardefs % \else \ifx \declaredencoding \latnine \setnonasciicharscatcode\active \latninechardefs % \else \ifx \declaredencoding \utfeight \setnonasciicharscatcode\active \utfeightchardefs % \else \message{Unknown document encoding #1, ignoring.}% % \fi % utfeight \fi % latnine \fi % latone \fi % lattwo \fi % ascii } % A message to be logged when using a character that isn't available % the default font encoding (OT1). % \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} % Take account of \c (plain) vs. \, (Texinfo) difference. \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} % First, make active non-ASCII characters in order for them to be % correctly categorized when TeX reads the replacement text of % macros containing the character definitions. \setnonasciicharscatcode\active % % Latin1 (ISO-8859-1) character definitions. \def\latonechardefs{% \gdef^^a0{\tie} \gdef^^a1{\exclamdown} \gdef^^a2{\missingcharmsg{CENT SIGN}} \gdef^^a3{{\pounds}} \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} \gdef^^a5{\missingcharmsg{YEN SIGN}} \gdef^^a6{\missingcharmsg{BROKEN BAR}} \gdef^^a7{\S} \gdef^^a8{\"{}} \gdef^^a9{\copyright} \gdef^^aa{\ordf} \gdef^^ab{\guillemetleft} \gdef^^ac{$\lnot$} \gdef^^ad{\-} \gdef^^ae{\registeredsymbol} \gdef^^af{\={}} % \gdef^^b0{\textdegree} \gdef^^b1{$\pm$} \gdef^^b2{$^2$} \gdef^^b3{$^3$} \gdef^^b4{\'{}} \gdef^^b5{$\mu$} \gdef^^b6{\P} % \gdef^^b7{$^.$} \gdef^^b8{\cedilla\ } \gdef^^b9{$^1$} \gdef^^ba{\ordm} % \gdef^^bb{\guillemetright} \gdef^^bc{$1\over4$} \gdef^^bd{$1\over2$} \gdef^^be{$3\over4$} \gdef^^bf{\questiondown} % \gdef^^c0{\`A} \gdef^^c1{\'A} \gdef^^c2{\^A} \gdef^^c3{\~A} \gdef^^c4{\"A} \gdef^^c5{\ringaccent A} \gdef^^c6{\AE} \gdef^^c7{\cedilla C} \gdef^^c8{\`E} \gdef^^c9{\'E} \gdef^^ca{\^E} \gdef^^cb{\"E} \gdef^^cc{\`I} \gdef^^cd{\'I} \gdef^^ce{\^I} \gdef^^cf{\"I} % \gdef^^d0{\DH} \gdef^^d1{\~N} \gdef^^d2{\`O} \gdef^^d3{\'O} \gdef^^d4{\^O} \gdef^^d5{\~O} \gdef^^d6{\"O} \gdef^^d7{$\times$} \gdef^^d8{\O} \gdef^^d9{\`U} \gdef^^da{\'U} \gdef^^db{\^U} \gdef^^dc{\"U} \gdef^^dd{\'Y} \gdef^^de{\TH} \gdef^^df{\ss} % \gdef^^e0{\`a} \gdef^^e1{\'a} \gdef^^e2{\^a} \gdef^^e3{\~a} \gdef^^e4{\"a} \gdef^^e5{\ringaccent a} \gdef^^e6{\ae} \gdef^^e7{\cedilla c} \gdef^^e8{\`e} \gdef^^e9{\'e} \gdef^^ea{\^e} \gdef^^eb{\"e} \gdef^^ec{\`{\dotless i}} \gdef^^ed{\'{\dotless i}} \gdef^^ee{\^{\dotless i}} \gdef^^ef{\"{\dotless i}} % \gdef^^f0{\dh} \gdef^^f1{\~n} \gdef^^f2{\`o} \gdef^^f3{\'o} \gdef^^f4{\^o} \gdef^^f5{\~o} \gdef^^f6{\"o} \gdef^^f7{$\div$} \gdef^^f8{\o} \gdef^^f9{\`u} \gdef^^fa{\'u} \gdef^^fb{\^u} \gdef^^fc{\"u} \gdef^^fd{\'y} \gdef^^fe{\th} \gdef^^ff{\"y} } % Latin9 (ISO-8859-15) encoding character definitions. \def\latninechardefs{% % Encoding is almost identical to Latin1. \latonechardefs % \gdef^^a4{\euro} \gdef^^a6{\v S} \gdef^^a8{\v s} \gdef^^b4{\v Z} \gdef^^b8{\v z} \gdef^^bc{\OE} \gdef^^bd{\oe} \gdef^^be{\"Y} } % Latin2 (ISO-8859-2) character definitions. \def\lattwochardefs{% \gdef^^a0{\tie} \gdef^^a1{\ogonek{A}} \gdef^^a2{\u{}} \gdef^^a3{\L} \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} \gdef^^a5{\v L} \gdef^^a6{\'S} \gdef^^a7{\S} \gdef^^a8{\"{}} \gdef^^a9{\v S} \gdef^^aa{\cedilla S} \gdef^^ab{\v T} \gdef^^ac{\'Z} \gdef^^ad{\-} \gdef^^ae{\v Z} \gdef^^af{\dotaccent Z} % \gdef^^b0{\textdegree} \gdef^^b1{\ogonek{a}} \gdef^^b2{\ogonek{ }} \gdef^^b3{\l} \gdef^^b4{\'{}} \gdef^^b5{\v l} \gdef^^b6{\'s} \gdef^^b7{\v{}} \gdef^^b8{\cedilla\ } \gdef^^b9{\v s} \gdef^^ba{\cedilla s} \gdef^^bb{\v t} \gdef^^bc{\'z} \gdef^^bd{\H{}} \gdef^^be{\v z} \gdef^^bf{\dotaccent z} % \gdef^^c0{\'R} \gdef^^c1{\'A} \gdef^^c2{\^A} \gdef^^c3{\u A} \gdef^^c4{\"A} \gdef^^c5{\'L} \gdef^^c6{\'C} \gdef^^c7{\cedilla C} \gdef^^c8{\v C} \gdef^^c9{\'E} \gdef^^ca{\ogonek{E}} \gdef^^cb{\"E} \gdef^^cc{\v E} \gdef^^cd{\'I} \gdef^^ce{\^I} \gdef^^cf{\v D} % \gdef^^d0{\DH} \gdef^^d1{\'N} \gdef^^d2{\v N} \gdef^^d3{\'O} \gdef^^d4{\^O} \gdef^^d5{\H O} \gdef^^d6{\"O} \gdef^^d7{$\times$} \gdef^^d8{\v R} \gdef^^d9{\ringaccent U} \gdef^^da{\'U} \gdef^^db{\H U} \gdef^^dc{\"U} \gdef^^dd{\'Y} \gdef^^de{\cedilla T} \gdef^^df{\ss} % \gdef^^e0{\'r} \gdef^^e1{\'a} \gdef^^e2{\^a} \gdef^^e3{\u a} \gdef^^e4{\"a} \gdef^^e5{\'l} \gdef^^e6{\'c} \gdef^^e7{\cedilla c} \gdef^^e8{\v c} \gdef^^e9{\'e} \gdef^^ea{\ogonek{e}} \gdef^^eb{\"e} \gdef^^ec{\v e} \gdef^^ed{\'{\dotless{i}}} \gdef^^ee{\^{\dotless{i}}} \gdef^^ef{\v d} % \gdef^^f0{\dh} \gdef^^f1{\'n} \gdef^^f2{\v n} \gdef^^f3{\'o} \gdef^^f4{\^o} \gdef^^f5{\H o} \gdef^^f6{\"o} \gdef^^f7{$\div$} \gdef^^f8{\v r} \gdef^^f9{\ringaccent u} \gdef^^fa{\'u} \gdef^^fb{\H u} \gdef^^fc{\"u} \gdef^^fd{\'y} \gdef^^fe{\cedilla t} \gdef^^ff{\dotaccent{}} } % UTF-8 character definitions. % % This code to support UTF-8 is based on LaTeX's utf8.def, with some % changes for Texinfo conventions. It is included here under the GPL by % permission from Frank Mittelbach and the LaTeX team. % \newcount\countUTFx \newcount\countUTFy \newcount\countUTFz \gdef\UTFviiiTwoOctets#1#2{\expandafter \UTFviiiDefined\csname u8:#1\string #2\endcsname} % \gdef\UTFviiiThreeOctets#1#2#3{\expandafter \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname} % \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname} \gdef\UTFviiiDefined#1{% \ifx #1\relax \message{\linenumber Unicode char \string #1 not defined for Texinfo}% \else \expandafter #1% \fi } \begingroup \catcode`\~13 \catcode`\"12 \def\UTFviiiLoop{% \global\catcode\countUTFx\active \uccode`\~\countUTFx \uppercase\expandafter{\UTFviiiTmp}% \advance\countUTFx by 1 \ifnum\countUTFx < \countUTFy \expandafter\UTFviiiLoop \fi} \countUTFx = "C2 \countUTFy = "E0 \def\UTFviiiTmp{% \xdef~{\noexpand\UTFviiiTwoOctets\string~}} \UTFviiiLoop \countUTFx = "E0 \countUTFy = "F0 \def\UTFviiiTmp{% \xdef~{\noexpand\UTFviiiThreeOctets\string~}} \UTFviiiLoop \countUTFx = "F0 \countUTFy = "F4 \def\UTFviiiTmp{% \xdef~{\noexpand\UTFviiiFourOctets\string~}} \UTFviiiLoop \endgroup \begingroup \catcode`\"=12 \catcode`\<=12 \catcode`\.=12 \catcode`\,=12 \catcode`\;=12 \catcode`\!=12 \catcode`\~=13 \gdef\DeclareUnicodeCharacter#1#2{% \countUTFz = "#1\relax %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}% \begingroup \parseXMLCharref \def\UTFviiiTwoOctets##1##2{% \csname u8:##1\string ##2\endcsname}% \def\UTFviiiThreeOctets##1##2##3{% \csname u8:##1\string ##2\string ##3\endcsname}% \def\UTFviiiFourOctets##1##2##3##4{% \csname u8:##1\string ##2\string ##3\string ##4\endcsname}% \expandafter\expandafter\expandafter\expandafter \expandafter\expandafter\expandafter \gdef\UTFviiiTmp{#2}% \endgroup} \gdef\parseXMLCharref{% \ifnum\countUTFz < "A0\relax \errhelp = \EMsimple \errmessage{Cannot define Unicode char value < 00A0}% \else\ifnum\countUTFz < "800\relax \parseUTFviiiA,% \parseUTFviiiB C\UTFviiiTwoOctets.,% \else\ifnum\countUTFz < "10000\relax \parseUTFviiiA;% \parseUTFviiiA,% \parseUTFviiiB E\UTFviiiThreeOctets.{,;}% \else \parseUTFviiiA;% \parseUTFviiiA,% \parseUTFviiiA!% \parseUTFviiiB F\UTFviiiFourOctets.{!,;}% \fi\fi\fi } \gdef\parseUTFviiiA#1{% \countUTFx = \countUTFz \divide\countUTFz by 64 \countUTFy = \countUTFz \multiply\countUTFz by 64 \advance\countUTFx by -\countUTFz \advance\countUTFx by 128 \uccode `#1\countUTFx \countUTFz = \countUTFy} \gdef\parseUTFviiiB#1#2#3#4{% \advance\countUTFz by "#10\relax \uccode `#3\countUTFz \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} \endgroup \def\utfeightchardefs{% \DeclareUnicodeCharacter{00A0}{\tie} \DeclareUnicodeCharacter{00A1}{\exclamdown} \DeclareUnicodeCharacter{00A3}{\pounds} \DeclareUnicodeCharacter{00A8}{\"{ }} \DeclareUnicodeCharacter{00A9}{\copyright} \DeclareUnicodeCharacter{00AA}{\ordf} \DeclareUnicodeCharacter{00AB}{\guillemetleft} \DeclareUnicodeCharacter{00AD}{\-} \DeclareUnicodeCharacter{00AE}{\registeredsymbol} \DeclareUnicodeCharacter{00AF}{\={ }} \DeclareUnicodeCharacter{00B0}{\ringaccent{ }} \DeclareUnicodeCharacter{00B4}{\'{ }} \DeclareUnicodeCharacter{00B8}{\cedilla{ }} \DeclareUnicodeCharacter{00BA}{\ordm} \DeclareUnicodeCharacter{00BB}{\guillemetright} \DeclareUnicodeCharacter{00BF}{\questiondown} \DeclareUnicodeCharacter{00C0}{\`A} \DeclareUnicodeCharacter{00C1}{\'A} \DeclareUnicodeCharacter{00C2}{\^A} \DeclareUnicodeCharacter{00C3}{\~A} \DeclareUnicodeCharacter{00C4}{\"A} \DeclareUnicodeCharacter{00C5}{\AA} \DeclareUnicodeCharacter{00C6}{\AE} \DeclareUnicodeCharacter{00C7}{\cedilla{C}} \DeclareUnicodeCharacter{00C8}{\`E} \DeclareUnicodeCharacter{00C9}{\'E} \DeclareUnicodeCharacter{00CA}{\^E} \DeclareUnicodeCharacter{00CB}{\"E} \DeclareUnicodeCharacter{00CC}{\`I} \DeclareUnicodeCharacter{00CD}{\'I} \DeclareUnicodeCharacter{00CE}{\^I} \DeclareUnicodeCharacter{00CF}{\"I} \DeclareUnicodeCharacter{00D0}{\DH} \DeclareUnicodeCharacter{00D1}{\~N} \DeclareUnicodeCharacter{00D2}{\`O} \DeclareUnicodeCharacter{00D3}{\'O} \DeclareUnicodeCharacter{00D4}{\^O} \DeclareUnicodeCharacter{00D5}{\~O} \DeclareUnicodeCharacter{00D6}{\"O} \DeclareUnicodeCharacter{00D8}{\O} \DeclareUnicodeCharacter{00D9}{\`U} \DeclareUnicodeCharacter{00DA}{\'U} \DeclareUnicodeCharacter{00DB}{\^U} \DeclareUnicodeCharacter{00DC}{\"U} \DeclareUnicodeCharacter{00DD}{\'Y} \DeclareUnicodeCharacter{00DE}{\TH} \DeclareUnicodeCharacter{00DF}{\ss} \DeclareUnicodeCharacter{00E0}{\`a} \DeclareUnicodeCharacter{00E1}{\'a} \DeclareUnicodeCharacter{00E2}{\^a} \DeclareUnicodeCharacter{00E3}{\~a} \DeclareUnicodeCharacter{00E4}{\"a} \DeclareUnicodeCharacter{00E5}{\aa} \DeclareUnicodeCharacter{00E6}{\ae} \DeclareUnicodeCharacter{00E7}{\cedilla{c}} \DeclareUnicodeCharacter{00E8}{\`e} \DeclareUnicodeCharacter{00E9}{\'e} \DeclareUnicodeCharacter{00EA}{\^e} \DeclareUnicodeCharacter{00EB}{\"e} \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}} \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}} \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}} \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}} \DeclareUnicodeCharacter{00F0}{\dh} \DeclareUnicodeCharacter{00F1}{\~n} \DeclareUnicodeCharacter{00F2}{\`o} \DeclareUnicodeCharacter{00F3}{\'o} \DeclareUnicodeCharacter{00F4}{\^o} \DeclareUnicodeCharacter{00F5}{\~o} \DeclareUnicodeCharacter{00F6}{\"o} \DeclareUnicodeCharacter{00F8}{\o} \DeclareUnicodeCharacter{00F9}{\`u} \DeclareUnicodeCharacter{00FA}{\'u} \DeclareUnicodeCharacter{00FB}{\^u} \DeclareUnicodeCharacter{00FC}{\"u} \DeclareUnicodeCharacter{00FD}{\'y} \DeclareUnicodeCharacter{00FE}{\th} \DeclareUnicodeCharacter{00FF}{\"y} \DeclareUnicodeCharacter{0100}{\=A} \DeclareUnicodeCharacter{0101}{\=a} \DeclareUnicodeCharacter{0102}{\u{A}} \DeclareUnicodeCharacter{0103}{\u{a}} \DeclareUnicodeCharacter{0104}{\ogonek{A}} \DeclareUnicodeCharacter{0105}{\ogonek{a}} \DeclareUnicodeCharacter{0106}{\'C} \DeclareUnicodeCharacter{0107}{\'c} \DeclareUnicodeCharacter{0108}{\^C} \DeclareUnicodeCharacter{0109}{\^c} \DeclareUnicodeCharacter{0118}{\ogonek{E}} \DeclareUnicodeCharacter{0119}{\ogonek{e}} \DeclareUnicodeCharacter{010A}{\dotaccent{C}} \DeclareUnicodeCharacter{010B}{\dotaccent{c}} \DeclareUnicodeCharacter{010C}{\v{C}} \DeclareUnicodeCharacter{010D}{\v{c}} \DeclareUnicodeCharacter{010E}{\v{D}} \DeclareUnicodeCharacter{0112}{\=E} \DeclareUnicodeCharacter{0113}{\=e} \DeclareUnicodeCharacter{0114}{\u{E}} \DeclareUnicodeCharacter{0115}{\u{e}} \DeclareUnicodeCharacter{0116}{\dotaccent{E}} \DeclareUnicodeCharacter{0117}{\dotaccent{e}} \DeclareUnicodeCharacter{011A}{\v{E}} \DeclareUnicodeCharacter{011B}{\v{e}} \DeclareUnicodeCharacter{011C}{\^G} \DeclareUnicodeCharacter{011D}{\^g} \DeclareUnicodeCharacter{011E}{\u{G}} \DeclareUnicodeCharacter{011F}{\u{g}} \DeclareUnicodeCharacter{0120}{\dotaccent{G}} \DeclareUnicodeCharacter{0121}{\dotaccent{g}} \DeclareUnicodeCharacter{0124}{\^H} \DeclareUnicodeCharacter{0125}{\^h} \DeclareUnicodeCharacter{0128}{\~I} \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}} \DeclareUnicodeCharacter{012A}{\=I} \DeclareUnicodeCharacter{012B}{\={\dotless{i}}} \DeclareUnicodeCharacter{012C}{\u{I}} \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}} \DeclareUnicodeCharacter{0130}{\dotaccent{I}} \DeclareUnicodeCharacter{0131}{\dotless{i}} \DeclareUnicodeCharacter{0132}{IJ} \DeclareUnicodeCharacter{0133}{ij} \DeclareUnicodeCharacter{0134}{\^J} \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}} \DeclareUnicodeCharacter{0139}{\'L} \DeclareUnicodeCharacter{013A}{\'l} \DeclareUnicodeCharacter{0141}{\L} \DeclareUnicodeCharacter{0142}{\l} \DeclareUnicodeCharacter{0143}{\'N} \DeclareUnicodeCharacter{0144}{\'n} \DeclareUnicodeCharacter{0147}{\v{N}} \DeclareUnicodeCharacter{0148}{\v{n}} \DeclareUnicodeCharacter{014C}{\=O} \DeclareUnicodeCharacter{014D}{\=o} \DeclareUnicodeCharacter{014E}{\u{O}} \DeclareUnicodeCharacter{014F}{\u{o}} \DeclareUnicodeCharacter{0150}{\H{O}} \DeclareUnicodeCharacter{0151}{\H{o}} \DeclareUnicodeCharacter{0152}{\OE} \DeclareUnicodeCharacter{0153}{\oe} \DeclareUnicodeCharacter{0154}{\'R} \DeclareUnicodeCharacter{0155}{\'r} \DeclareUnicodeCharacter{0158}{\v{R}} \DeclareUnicodeCharacter{0159}{\v{r}} \DeclareUnicodeCharacter{015A}{\'S} \DeclareUnicodeCharacter{015B}{\'s} \DeclareUnicodeCharacter{015C}{\^S} \DeclareUnicodeCharacter{015D}{\^s} \DeclareUnicodeCharacter{015E}{\cedilla{S}} \DeclareUnicodeCharacter{015F}{\cedilla{s}} \DeclareUnicodeCharacter{0160}{\v{S}} \DeclareUnicodeCharacter{0161}{\v{s}} \DeclareUnicodeCharacter{0162}{\cedilla{t}} \DeclareUnicodeCharacter{0163}{\cedilla{T}} \DeclareUnicodeCharacter{0164}{\v{T}} \DeclareUnicodeCharacter{0168}{\~U} \DeclareUnicodeCharacter{0169}{\~u} \DeclareUnicodeCharacter{016A}{\=U} \DeclareUnicodeCharacter{016B}{\=u} \DeclareUnicodeCharacter{016C}{\u{U}} \DeclareUnicodeCharacter{016D}{\u{u}} \DeclareUnicodeCharacter{016E}{\ringaccent{U}} \DeclareUnicodeCharacter{016F}{\ringaccent{u}} \DeclareUnicodeCharacter{0170}{\H{U}} \DeclareUnicodeCharacter{0171}{\H{u}} \DeclareUnicodeCharacter{0174}{\^W} \DeclareUnicodeCharacter{0175}{\^w} \DeclareUnicodeCharacter{0176}{\^Y} \DeclareUnicodeCharacter{0177}{\^y} \DeclareUnicodeCharacter{0178}{\"Y} \DeclareUnicodeCharacter{0179}{\'Z} \DeclareUnicodeCharacter{017A}{\'z} \DeclareUnicodeCharacter{017B}{\dotaccent{Z}} \DeclareUnicodeCharacter{017C}{\dotaccent{z}} \DeclareUnicodeCharacter{017D}{\v{Z}} \DeclareUnicodeCharacter{017E}{\v{z}} \DeclareUnicodeCharacter{01C4}{D\v{Z}} \DeclareUnicodeCharacter{01C5}{D\v{z}} \DeclareUnicodeCharacter{01C6}{d\v{z}} \DeclareUnicodeCharacter{01C7}{LJ} \DeclareUnicodeCharacter{01C8}{Lj} \DeclareUnicodeCharacter{01C9}{lj} \DeclareUnicodeCharacter{01CA}{NJ} \DeclareUnicodeCharacter{01CB}{Nj} \DeclareUnicodeCharacter{01CC}{nj} \DeclareUnicodeCharacter{01CD}{\v{A}} \DeclareUnicodeCharacter{01CE}{\v{a}} \DeclareUnicodeCharacter{01CF}{\v{I}} \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}} \DeclareUnicodeCharacter{01D1}{\v{O}} \DeclareUnicodeCharacter{01D2}{\v{o}} \DeclareUnicodeCharacter{01D3}{\v{U}} \DeclareUnicodeCharacter{01D4}{\v{u}} \DeclareUnicodeCharacter{01E2}{\={\AE}} \DeclareUnicodeCharacter{01E3}{\={\ae}} \DeclareUnicodeCharacter{01E6}{\v{G}} \DeclareUnicodeCharacter{01E7}{\v{g}} \DeclareUnicodeCharacter{01E8}{\v{K}} \DeclareUnicodeCharacter{01E9}{\v{k}} \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}} \DeclareUnicodeCharacter{01F1}{DZ} \DeclareUnicodeCharacter{01F2}{Dz} \DeclareUnicodeCharacter{01F3}{dz} \DeclareUnicodeCharacter{01F4}{\'G} \DeclareUnicodeCharacter{01F5}{\'g} \DeclareUnicodeCharacter{01F8}{\`N} \DeclareUnicodeCharacter{01F9}{\`n} \DeclareUnicodeCharacter{01FC}{\'{\AE}} \DeclareUnicodeCharacter{01FD}{\'{\ae}} \DeclareUnicodeCharacter{01FE}{\'{\O}} \DeclareUnicodeCharacter{01FF}{\'{\o}} \DeclareUnicodeCharacter{021E}{\v{H}} \DeclareUnicodeCharacter{021F}{\v{h}} \DeclareUnicodeCharacter{0226}{\dotaccent{A}} \DeclareUnicodeCharacter{0227}{\dotaccent{a}} \DeclareUnicodeCharacter{0228}{\cedilla{E}} \DeclareUnicodeCharacter{0229}{\cedilla{e}} \DeclareUnicodeCharacter{022E}{\dotaccent{O}} \DeclareUnicodeCharacter{022F}{\dotaccent{o}} \DeclareUnicodeCharacter{0232}{\=Y} \DeclareUnicodeCharacter{0233}{\=y} \DeclareUnicodeCharacter{0237}{\dotless{j}} \DeclareUnicodeCharacter{02DB}{\ogonek{ }} \DeclareUnicodeCharacter{1E02}{\dotaccent{B}} \DeclareUnicodeCharacter{1E03}{\dotaccent{b}} \DeclareUnicodeCharacter{1E04}{\udotaccent{B}} \DeclareUnicodeCharacter{1E05}{\udotaccent{b}} \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}} \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}} \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}} \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}} \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}} \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}} \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}} \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}} \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}} \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}} \DeclareUnicodeCharacter{1E20}{\=G} \DeclareUnicodeCharacter{1E21}{\=g} \DeclareUnicodeCharacter{1E22}{\dotaccent{H}} \DeclareUnicodeCharacter{1E23}{\dotaccent{h}} \DeclareUnicodeCharacter{1E24}{\udotaccent{H}} \DeclareUnicodeCharacter{1E25}{\udotaccent{h}} \DeclareUnicodeCharacter{1E26}{\"H} \DeclareUnicodeCharacter{1E27}{\"h} \DeclareUnicodeCharacter{1E30}{\'K} \DeclareUnicodeCharacter{1E31}{\'k} \DeclareUnicodeCharacter{1E32}{\udotaccent{K}} \DeclareUnicodeCharacter{1E33}{\udotaccent{k}} \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}} \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}} \DeclareUnicodeCharacter{1E36}{\udotaccent{L}} \DeclareUnicodeCharacter{1E37}{\udotaccent{l}} \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}} \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}} \DeclareUnicodeCharacter{1E3E}{\'M} \DeclareUnicodeCharacter{1E3F}{\'m} \DeclareUnicodeCharacter{1E40}{\dotaccent{M}} \DeclareUnicodeCharacter{1E41}{\dotaccent{m}} \DeclareUnicodeCharacter{1E42}{\udotaccent{M}} \DeclareUnicodeCharacter{1E43}{\udotaccent{m}} \DeclareUnicodeCharacter{1E44}{\dotaccent{N}} \DeclareUnicodeCharacter{1E45}{\dotaccent{n}} \DeclareUnicodeCharacter{1E46}{\udotaccent{N}} \DeclareUnicodeCharacter{1E47}{\udotaccent{n}} \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}} \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}} \DeclareUnicodeCharacter{1E54}{\'P} \DeclareUnicodeCharacter{1E55}{\'p} \DeclareUnicodeCharacter{1E56}{\dotaccent{P}} \DeclareUnicodeCharacter{1E57}{\dotaccent{p}} \DeclareUnicodeCharacter{1E58}{\dotaccent{R}} \DeclareUnicodeCharacter{1E59}{\dotaccent{r}} \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}} \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}} \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}} \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}} \DeclareUnicodeCharacter{1E60}{\dotaccent{S}} \DeclareUnicodeCharacter{1E61}{\dotaccent{s}} \DeclareUnicodeCharacter{1E62}{\udotaccent{S}} \DeclareUnicodeCharacter{1E63}{\udotaccent{s}} \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}} \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}} \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}} \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}} \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}} \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}} \DeclareUnicodeCharacter{1E7C}{\~V} \DeclareUnicodeCharacter{1E7D}{\~v} \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}} \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}} \DeclareUnicodeCharacter{1E80}{\`W} \DeclareUnicodeCharacter{1E81}{\`w} \DeclareUnicodeCharacter{1E82}{\'W} \DeclareUnicodeCharacter{1E83}{\'w} \DeclareUnicodeCharacter{1E84}{\"W} \DeclareUnicodeCharacter{1E85}{\"w} \DeclareUnicodeCharacter{1E86}{\dotaccent{W}} \DeclareUnicodeCharacter{1E87}{\dotaccent{w}} \DeclareUnicodeCharacter{1E88}{\udotaccent{W}} \DeclareUnicodeCharacter{1E89}{\udotaccent{w}} \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}} \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}} \DeclareUnicodeCharacter{1E8C}{\"X} \DeclareUnicodeCharacter{1E8D}{\"x} \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}} \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}} \DeclareUnicodeCharacter{1E90}{\^Z} \DeclareUnicodeCharacter{1E91}{\^z} \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}} \DeclareUnicodeCharacter{1E93}{\udotaccent{z}} \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}} \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}} \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}} \DeclareUnicodeCharacter{1E97}{\"t} \DeclareUnicodeCharacter{1E98}{\ringaccent{w}} \DeclareUnicodeCharacter{1E99}{\ringaccent{y}} \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}} \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}} \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}} \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}} \DeclareUnicodeCharacter{1EBC}{\~E} \DeclareUnicodeCharacter{1EBD}{\~e} \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}} \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}} \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}} \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}} \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}} \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}} \DeclareUnicodeCharacter{1EF2}{\`Y} \DeclareUnicodeCharacter{1EF3}{\`y} \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}} \DeclareUnicodeCharacter{1EF8}{\~Y} \DeclareUnicodeCharacter{1EF9}{\~y} \DeclareUnicodeCharacter{2013}{--} \DeclareUnicodeCharacter{2014}{---} \DeclareUnicodeCharacter{2018}{\quoteleft} \DeclareUnicodeCharacter{2019}{\quoteright} \DeclareUnicodeCharacter{201A}{\quotesinglbase} \DeclareUnicodeCharacter{201C}{\quotedblleft} \DeclareUnicodeCharacter{201D}{\quotedblright} \DeclareUnicodeCharacter{201E}{\quotedblbase} \DeclareUnicodeCharacter{2022}{\bullet} \DeclareUnicodeCharacter{2026}{\dots} \DeclareUnicodeCharacter{2039}{\guilsinglleft} \DeclareUnicodeCharacter{203A}{\guilsinglright} \DeclareUnicodeCharacter{20AC}{\euro} \DeclareUnicodeCharacter{2192}{\expansion} \DeclareUnicodeCharacter{21D2}{\result} \DeclareUnicodeCharacter{2212}{\minus} \DeclareUnicodeCharacter{2217}{\point} \DeclareUnicodeCharacter{2261}{\equiv} }% end of \utfeightchardefs % US-ASCII character definitions. \def\asciichardefs{% nothing need be done \relax } % Make non-ASCII characters printable again for compatibility with % existing Texinfo documents that may use them, even without declaring a % document encoding. % \setnonasciicharscatcode \other \message{formatting,} \newdimen\defaultparindent \defaultparindent = 15pt \chapheadingskip = 15pt plus 4pt minus 2pt \secheadingskip = 12pt plus 3pt minus 2pt \subsecheadingskip = 9pt plus 2pt minus 2pt % Prevent underfull vbox error messages. \vbadness = 10000 % Don't be very finicky about underfull hboxes, either. \hbadness = 6666 % Following George Bush, get rid of widows and orphans. \widowpenalty=10000 \clubpenalty=10000 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're % using an old version of TeX, don't do anything. We want the amount of % stretch added to depend on the line length, hence the dependence on % \hsize. We call this whenever the paper size is set. % \def\setemergencystretch{% \ifx\emergencystretch\thisisundefined % Allow us to assign to \emergencystretch anyway. \def\emergencystretch{\dimen0}% \else \emergencystretch = .15\hsize \fi } % Parameters in order: 1) textheight; 2) textwidth; % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip; % 7) physical page height; 8) physical page width. % % We also call \setleading{\textleading}, so the caller should define % \textleading. The caller should also set \parskip. % \def\internalpagesizes#1#2#3#4#5#6#7#8{% \voffset = #3\relax \topskip = #6\relax \splittopskip = \topskip % \vsize = #1\relax \advance\vsize by \topskip \outervsize = \vsize \advance\outervsize by 2\topandbottommargin \pageheight = \vsize % \hsize = #2\relax \outerhsize = \hsize \advance\outerhsize by 0.5in \pagewidth = \hsize % \normaloffset = #4\relax \bindingoffset = #5\relax % \ifpdf \pdfpageheight #7\relax \pdfpagewidth #8\relax % if we don't reset these, they will remain at "1 true in" of % whatever layout pdftex was dumped with. \pdfhorigin = 1 true in \pdfvorigin = 1 true in \fi % \setleading{\textleading} % \parindent = \defaultparindent \setemergencystretch } % @letterpaper (the default). \def\letterpaper{{\globaldefs = 1 \parskip = 3pt plus 2pt minus 1pt \textleading = 13.2pt % % If page is nothing but text, make it come out even. \internalpagesizes{607.2pt}{6in}% that's 46 lines {\voffset}{.25in}% {\bindingoffset}{36pt}% {11in}{8.5in}% }} % Use @smallbook to reset parameters for 7x9.25 trim size. \def\smallbook{{\globaldefs = 1 \parskip = 2pt plus 1pt \textleading = 12pt % \internalpagesizes{7.5in}{5in}% {-.2in}{0in}% {\bindingoffset}{16pt}% {9.25in}{7in}% % \lispnarrowing = 0.3in \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = .5cm }} % Use @smallerbook to reset parameters for 6x9 trim size. % (Just testing, parameters still in flux.) \def\smallerbook{{\globaldefs = 1 \parskip = 1.5pt plus 1pt \textleading = 12pt % \internalpagesizes{7.4in}{4.8in}% {-.2in}{-.4in}% {0pt}{14pt}% {9in}{6in}% % \lispnarrowing = 0.25in \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = .4cm }} % Use @afourpaper to print on European A4 paper. \def\afourpaper{{\globaldefs = 1 \parskip = 3pt plus 2pt minus 1pt \textleading = 13.2pt % % Double-side printing via postscript on Laserjet 4050 % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. % To change the settings for a different printer or situation, adjust % \normaloffset until the front-side and back-side texts align. Then % do the same for \bindingoffset. You can set these for testing in % your texinfo source file like this: % @tex % \global\normaloffset = -6mm % \global\bindingoffset = 10mm % @end tex \internalpagesizes{673.2pt}{160mm}% that's 51 lines {\voffset}{\hoffset}% {\bindingoffset}{44pt}% {297mm}{210mm}% % \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = 5mm }} % Use @afivepaper to print on European A5 paper. % From romildo@urano.iceb.ufop.br, 2 July 2000. % He also recommends making @example and @lisp be small. \def\afivepaper{{\globaldefs = 1 \parskip = 2pt plus 1pt minus 0.1pt \textleading = 12.5pt % \internalpagesizes{160mm}{120mm}% {\voffset}{\hoffset}% {\bindingoffset}{8pt}% {210mm}{148mm}% % \lispnarrowing = 0.2in \tolerance = 800 \hfuzz = 1.2pt \contentsrightmargin = 0pt \defbodyindent = 2mm \tableindent = 12mm }} % A specific text layout, 24x15cm overall, intended for A4 paper. \def\afourlatex{{\globaldefs = 1 \afourpaper \internalpagesizes{237mm}{150mm}% {\voffset}{4.6mm}% {\bindingoffset}{7mm}% {297mm}{210mm}% % % Must explicitly reset to 0 because we call \afourpaper. \globaldefs = 0 }} % Use @afourwide to print on A4 paper in landscape format. \def\afourwide{{\globaldefs = 1 \afourpaper \internalpagesizes{241mm}{165mm}% {\voffset}{-2.95mm}% {\bindingoffset}{7mm}% {297mm}{210mm}% \globaldefs = 0 }} % @pagesizes TEXTHEIGHT[,TEXTWIDTH] % Perhaps we should allow setting the margins, \topskip, \parskip, % and/or leading, also. Or perhaps we should compute them somehow. % \parseargdef\pagesizes{\pagesizesyyy #1,,\finish} \def\pagesizesyyy#1,#2,#3\finish{{% \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi \globaldefs = 1 % \parskip = 3pt plus 2pt minus 1pt \setleading{\textleading}% % \dimen0 = #1\relax \advance\dimen0 by \voffset % \dimen2 = \hsize \advance\dimen2 by \normaloffset % \internalpagesizes{#1}{\hsize}% {\voffset}{\normaloffset}% {\bindingoffset}{44pt}% {\dimen0}{\dimen2}% }} % Set default to letter. % \letterpaper \message{and turning on texinfo input format.} \def^^L{\par} % remove \outer, so ^L can appear in an @comment % DEL is a comment character, in case @c does not suffice. \catcode`\^^? = 14 % Define macros to output various characters with catcode for normal text. \catcode`\"=\other \def\normaldoublequote{"} \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix \catcode`\+=\other \def\normalplus{+} \catcode`\<=\other \def\normalless{<} \catcode`\>=\other \def\normalgreater{>} \catcode`\^=\other \def\normalcaret{^} \catcode`\_=\other \def\normalunderscore{_} \catcode`\|=\other \def\normalverticalbar{|} \catcode`\~=\other \def\normaltilde{~} % This macro is used to make a character print one way in \tt % (where it can probably be output as-is), and another way in other fonts, % where something hairier probably needs to be done. % % #1 is what to print if we are indeed using \tt; #2 is what to print % otherwise. Since all the Computer Modern typewriter fonts have zero % interword stretch (and shrink), and it is reasonable to expect all % typewriter fonts to have this, we can check that font parameter. % \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} % Same as above, but check for italic font. Actually this also catches % non-italic slanted fonts since it is impossible to distinguish them from % italic fonts. But since this is only used by $ and it uses \sl anyway % this is not a problem. \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} % Turn off all special characters except @ % (and those which the user can use as if they were ordinary). % Most of these we simply print from the \tt font, but for some, we can % use math or other variants that look better in normal text. \catcode`\"=\active \def\activedoublequote{{\tt\char34}} \let"=\activedoublequote \catcode`\~=\active \def~{{\tt\char126}} \chardef\hat=`\^ \catcode`\^=\active \def^{{\tt \hat}} \catcode`\_=\active \def_{\ifusingtt\normalunderscore\_} \let\realunder=_ % Subroutine for the previous macro. \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } \catcode`\|=\active \def|{{\tt\char124}} \chardef \less=`\< \catcode`\<=\active \def<{{\tt \less}} \chardef \gtr=`\> \catcode`\>=\active \def>{{\tt \gtr}} \catcode`\+=\active \def+{{\tt \char 43}} \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix % If a .fmt file is being used, characters that might appear in a file % name cannot be active until we have parsed the command line. % So turn them off again, and have \everyjob (or @setfilename) turn them on. % \otherifyactive is called near the end of this file. \def\otherifyactive{\catcode`+=\other \catcode`\_=\other} % Used sometimes to turn off (effectively) the active characters even after % parsing them. \def\turnoffactive{% \normalturnoffactive \otherbackslash } \catcode`\@=0 % \backslashcurfont outputs one backslash character in current font, % as in \char`\\. \global\chardef\backslashcurfont=`\\ \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work % \realbackslash is an actual character `\' with catcode other, and % \doublebackslash is two of them (for the pdf outlines). {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} % In texinfo, backslash is an active character; it prints the backslash % in fixed width font. \catcode`\\=\active % @ for escape char from now on. % The story here is that in math mode, the \char of \backslashcurfont % ends up printing the roman \ from the math symbol font (because \char % in math mode uses the \mathcode, and plain.tex sets % \mathcode`\\="026E). It seems better for @backslashchar{} to always % print a typewriter backslash, hence we use an explicit \mathchar, % which is the decimal equivalent of "715c (class 7, e.g., use \fam; % ignored family value; char position "5C). We can't use " for the % usual hex value because it has already been made active. @def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} @let@backslashchar = @normalbackslash % @backslashchar{} is for user documents. % On startup, @fixbackslash assigns: % @let \ = @normalbackslash % \rawbackslash defines an active \ to do \backslashcurfont. % \otherbackslash defines an active \ to be a literal `\' character with % catcode other. We switch back and forth between these. @gdef@rawbackslash{@let\=@backslashcurfont} @gdef@otherbackslash{@let\=@realbackslash} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of % the literal character `\'. Also revert - to its normal character, in % case the active - from code has slipped in. % {@catcode`- = @active @gdef@normalturnoffactive{% @let-=@normaldash @let"=@normaldoublequote @let$=@normaldollar %$ font-lock fix @let+=@normalplus @let<=@normalless @let>=@normalgreater @let\=@normalbackslash @let^=@normalcaret @let_=@normalunderscore @let|=@normalverticalbar @let~=@normaltilde @markupsetuplqdefault @markupsetuprqdefault @unsepspaces } } % Make _ and + \other characters, temporarily. % This is canceled by @fixbackslash. @otherifyactive % If a .fmt file is being used, we don't want the `\input texinfo' to show up. % That is what \eatinput is for; after that, the `\' should revert to printing % a backslash. % @gdef@eatinput input texinfo{@fixbackslash} @global@let\ = @eatinput % On the other hand, perhaps the file did not have a `\input texinfo'. Then % the first `\' in the file would cause an error. This macro tries to fix % that, assuming it is called before the first `\' could plausibly occur. % Also turn back on active characters that might appear in the input % file name, in case not using a pre-dumped format. % @gdef@fixbackslash{% @ifx\@eatinput @let\ = @normalbackslash @fi @catcode`+=@active @catcode`@_=@active } % Say @foo, not \foo, in error messages. @escapechar = `@@ % These (along with & and #) are made active for url-breaking, so need % active definitions as the normal characters. @def@normaldot{.} @def@normalquest{?} @def@normalslash{/} % These look ok in all fonts, so just make them not special. % @hashchar{} gets its own user-level command, because of #line. @catcode`@& = @other @def@normalamp{&} @catcode`@# = @other @def@normalhash{#} @catcode`@% = @other @def@normalpercent{%} @let @hashchar = @normalhash @c Finally, make ` and ' active, so that txicodequoteundirected and @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we @c don't make ` and ' active, @code will not get them as active chars. @c Do this last of all since we use ` in the previous @catcode assignments. @catcode`@'=@active @catcode`@`=@active @markupsetuplqdefault @markupsetuprqdefault @c Local variables: @c eval: (add-hook 'write-file-hooks 'time-stamp) @c page-delimiter: "^\\\\message" @c time-stamp-start: "def\\\\texinfoversion{" @c time-stamp-format: "%:y-%02m-%02d.%02H" @c time-stamp-end: "}" @c End: @c vim:sw=2: @ignore arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 @end ignore avrdude-6.0.1/doc/TODO000644 000153 000000 00000001463 12216240451 013764 0ustar00jwheel000000 000000 - 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 avrdude-6.0.1/doc/avrdude.texi000644 000153 000000 00000262035 12216240451 015625 0ustar00jwheel000000 000000 %% -*-texinfo-*- \input texinfo @c $Id: avrdude.texi 1226 2013-09-13 17:22:38Z joerg_wunsch $ @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 - 2011 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 (both mkI and mkII, the latter 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 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 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. The STK500, JTAG ICE, avr910, and avr109/butterfly use the serial port to communicate with the PC. The STK600, JTAG ICE mkII, AVRISP mkII, USBasp, avrftdi (and derivitives), 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, 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 is supported in PDI mode, provided it has a revision 1 hardware and firmware version of at least 5.37 (decimal). 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. @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. 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 you have a programmer or part that AVRDUDE does not know about, you can add it to the config file (be sure and submit a patch back to the author so that it can be incorporated for the next version). 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 simplicistic 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. @emph{This feature is currently not implemented for Win32 systems.} @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}. 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 @itemx AVR Dragon When using the JTAG ICE mkII 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 compatability 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. This setting is only available in ASCII mode. (The lower limit was chosen so the CPU frequency is at least for four times the SPI frequency which is in ASCII mode 30kHz.) @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 commandline 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 commandline. @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 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 usally 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 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 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 unability 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:: @end menu @c @c Node @c @node Atmel STK600, , 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 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 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 dependant; 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 avrdude-6.0.1/doc/parts_comments.txt000644 000153 000000 00000000116 12216240451 017065 0ustar00jwheel000000 000000 AT90S1200 (****) AT90S2343 (*) ATmega2560 (**) ATmega2561 (**) ATtiny11 (***) avrdude-6.0.1/doc/avrdude.info000644 000153 000000 00000314531 12216243246 015613 0ustar00jwheel000000 000000 INFO-DIR-SECTION AVR Programming & development tools. START-INFO-DIR-ENTRY This is ./avrdude.info, produced by makeinfo version 4.11 from ./avrdude.texi. * AvrDude: (avrdude). AVR program downloader/uploader. END-INFO-DIR-ENTRY This file documents the avrdude program. For avrdude version 6.0.1, 18 September 2013. Copyright (C) 2003, 2005 Brian Dean Copyright (C) 2006 - 2011 Jo"rg 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. 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.  File: avrdude.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) This file documents the avrdude program for downloading/uploading programs to Atmel AVR microcontrollers. For avrdude version 6.0.1, 18 September 2013. Send comments on AVRDUDE to . Use `http://savannah.nongnu.org/bugs/?group=avrdude' to report bugs. Copyright (C) 2003,2005 Brian S. Dean Copyright (C) 2006 Jo"rg Wunsch * Menu: * Introduction:: * Command Line Options:: * Terminal Mode Operation:: * Configuration File:: * Programmer Specific Information:: * Platform Dependent Information:: * Troubleshooting::  File: avrdude.info, Node: Introduction, Next: Command Line Options, Prev: Top, Up: Top 1 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 (both mkI and mkII, the latter 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 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 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. The STK500, JTAG ICE, avr910, and avr109/butterfly use the serial port to communicate with the PC. The STK600, JTAG ICE mkII, AVRISP mkII, USBasp, avrftdi (and derivitives), and USBtinyISP programmers communicate through the USB, using `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, 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 is supported in PDI mode, provided it has a revision 1 hardware and firmware version of at least 5.37 (decimal). 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 `-B 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 _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. * Menu: * History::  File: avrdude.info, Node: History, Prev: Introduction, Up: Introduction 1.1 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 (`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.  File: avrdude.info, Node: Command Line Options, Next: Terminal Mode Operation, Prev: Introduction, Up: Top 2 Command Line Options ********************** * Menu: * Option Descriptions:: * Programmers accepting extended parameters:: * Example Command Line Invocations::  File: avrdude.info, Node: Option Descriptions, Next: Programmers accepting extended parameters, Prev: Command Line Options, Up: Command Line Options 2.1 Option Descriptions ======================= AVRDUDE is a command line tool, used as follows: avrdude -p partno OPTIONS ... Command line options are used to control AVRDUDE's behaviour. The following options are recognized: `-p PARTNO' This is the only mandatory option and it tells AVRDUDE what type of part (MCU) that is connected to the programmer. The 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: `uc3a0512' AT32UC3A0512 `c128' AT90CAN128 `c32' AT90CAN32 `c64' AT90CAN64 `pwm2' AT90PWM2 `pwm2b' AT90PWM2B `pwm3' AT90PWM3 `pwm316' AT90PWM316 `pwm3b' AT90PWM3B `1200' AT90S1200 (****) `2313' AT90S2313 `2333' AT90S2333 `2343' AT90S2343 (*) `4414' AT90S4414 `4433' AT90S4433 `4434' AT90S4434 `8515' AT90S8515 `8535' AT90S8535 `usb1286' AT90USB1286 `usb1287' AT90USB1287 `usb162' AT90USB162 `usb646' AT90USB646 `usb647' AT90USB647 `usb82' AT90USB82 `m103' ATmega103 `m128' ATmega128 `m1280' ATmega1280 `m1281' ATmega1281 `m1284p' ATmega1284P `m1284rfr2'ATmega1284RFR2 `m128rfa1' ATmega128RFA1 `m128rfr2' ATmega128RFR2 `m16' ATmega16 `m161' ATmega161 `m162' ATmega162 `m163' ATmega163 `m164p' ATmega164P `m168' ATmega168 `m168p' ATmega168P `m169' ATmega169 `m16u2' ATmega16U2 `m2560' ATmega2560 (**) `m2561' ATmega2561 (**) `m2564rfr2'ATmega2564RFR2 `m256rfr2' ATmega256RFR2 `m32' ATmega32 `m324p' ATmega324P `m324pa' ATmega324PA `m325' ATmega325 `m3250' ATmega3250 `m328' ATmega328 `m328p' ATmega328P `m329' ATmega329 `m3290' ATmega3290 `m3290p' ATmega3290P `m329p' ATmega329P `m32u2' ATmega32U2 `m32u4' ATmega32U4 `m406' ATMEGA406 `m48' ATmega48 `m48p' ATmega48P `m64' ATmega64 `m640' ATmega640 `m644' ATmega644 `m644p' ATmega644P `m644rfr2' ATmega644RFR2 `m645' ATmega645 `m6450' ATmega6450 `m649' ATmega649 `m6490' ATmega6490 `m64rfr2' ATmega64RFR2 `m8' ATmega8 `m8515' ATmega8515 `m8535' ATmega8535 `m88' ATmega88 `m88p' ATmega88P `m8u2' ATmega8U2 `t10' ATtiny10 `t11' ATtiny11 `t12' ATtiny12 `t13' ATtiny13 `t15' ATtiny15 `t1634' ATtiny1634 `t20' ATtiny20 `t2313' ATtiny2313 `t24' ATtiny24 `t25' ATtiny25 `t26' ATtiny26 `t261' ATtiny261 `t4' ATtiny4 `t40' ATtiny40 `t4313' ATtiny4313 `t43u' ATtiny43u `t44' ATtiny44 `t45' ATtiny45 `t461' ATtiny461 `t5' ATtiny5 `t84' ATtiny84 `t85' ATtiny85 `t861' ATtiny861 `t88' ATtiny88 `t9' ATtiny9 `x128a1' ATxmega128A1 `x128a1d' ATxmega128A1revD `x128a1u' ATxmega128A1U `x128a3' ATxmega128A3 `x128a3u' ATxmega128A3U `x128a4' ATxmega128A4 `x128a4u' ATxmega128A4U `x128b1' ATxmega128B1 `x128b3' ATxmega128B3 `x128c3' ATxmega128C3 `x128d3' ATxmega128D3 `x128d4' ATxmega128D4 `x16a4' ATxmega16A4 `x16a4u' ATxmega16A4U `x16c4' ATxmega16C4 `x16d4' ATxmega16D4 `x16e5' ATxmega16E5 `x192a1' ATxmega192A1 `x192a3' ATxmega192A3 `x192a3u' ATxmega192A3U `x192c3' ATxmega192C3 `x192d3' ATxmega192D3 `x256a1' ATxmega256A1 `x256a3' ATxmega256A3 `x256a3b' ATxmega256A3B `x256a3bu' ATxmega256A3BU `x256a3u' ATxmega256A3U `x256c3' ATxmega256C3 `x256d3' ATxmega256D3 `x32a4' ATxmega32A4 `x32a4u' ATxmega32A4U `x32c4' ATxmega32C4 `x32d4' ATxmega32D4 `x32e5' ATxmega32E5 `x384c3' ATxmega384C3 `x384d3' ATxmega384D3 `x64a1' ATxmega64A1 `x64a1u' ATxmega64A1U `x64a3' ATxmega64A3 `x64a3u' ATxmega64A3U `x64a4' ATxmega64A4 `x64a4u' ATxmega64A4U `x64b1' ATxmega64B1 `x64b3' ATxmega64B3 `x64c3' ATxmega64C3 `x64d3' ATxmega64D3 `x64d4' ATxmega64D4 `x8e5' ATxmega8E5 `ucr2' deprecated, (*) 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. `-b BAUDRATE' Override the RS-232 connection baud rate specified in the respective programmer's entry of the configuration file. `-B 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. 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. `-c PROGRAMMER-ID' Specify the programmer to be used. AVRDUDE knows about several common programmers. Use this option to specify which one to use. The 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: `2232HIO' FT2232H based generic programmer `4232h' FT4232H based generic programmer `89isp' Atmel at89isp cable `abcmini' ABCmini Board, aka Dick Smith HOTCHIP `alf' Nightshade ALF-PgmAVR, http://nightshade.homeip.net/ `arduino' Arduino `arduino-ft232r'Arduino: FT232R connected to ISP `atisp' AT-ISP V1.1 programming cable for AVR-SDK1 from `avr109' Atmel AppNote AVR109 Boot Loader `avr910' Atmel Low Cost Serial Programmer `avr911' Atmel AppNote AVR911 AVROSP `avrftdi' FT2232D based generic programmer `avrisp' Atmel AVR ISP `avrisp2' Atmel AVR ISP mkII `avrispmkII' Atmel AVR ISP mkII `avrispv2' Atmel AVR ISP V2 `bascom' Bascom SAMPLE programming cable `blaster' Altera ByteBlaster `bsd' Brian Dean's Programmer, http://www.bsdhome.com/avrdude/ `buspirate' The Bus Pirate `buspirate_bb'The Bus Pirate (bitbang interface, supports TPI) `butterfly' Atmel Butterfly Development Board `butterfly_mk'Mikrokopter.de Butterfly `bwmega' BitWizard ftdi_atmega builtin programmer `c2n232i' serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts `dapa' Direct AVR Parallel Access cable `dasa' serial port banging, reset=rts sck=dtr mosi=txd miso=cts `dasa3' serial port banging, reset=!dtr sck=rts mosi=txd miso=cts `diecimila' alias for arduino-ft232r `dragon_dw' Atmel AVR Dragon in debugWire mode `dragon_hvsp' Atmel AVR Dragon in HVSP mode `dragon_isp' Atmel AVR Dragon in ISP mode `dragon_jtag' Atmel AVR Dragon in JTAG mode `dragon_pdi' Atmel AVR Dragon in PDI mode `dragon_pp' Atmel AVR Dragon in PP mode `dt006' Dontronics DT006 `ere-isp-avr' ERE ISP-AVR `frank-stk200'Frank STK200 `ft232r' FT232R Synchronous BitBang `ft245r' FT245R Synchronous BitBang `futurlec' Futurlec.com programming cable. `jtag1' Atmel JTAG ICE (mkI) `jtag1slow' Atmel JTAG ICE (mkI) `jtag2' Atmel JTAG ICE mkII `jtag2avr32' Atmel JTAG ICE mkII im AVR32 mode `jtag2dw' Atmel JTAG ICE mkII in debugWire mode `jtag2fast' Atmel JTAG ICE mkII `jtag2isp' Atmel JTAG ICE mkII in ISP mode `jtag2pdi' Atmel JTAG ICE mkII PDI mode `jtag2slow' Atmel JTAG ICE mkII `jtag3' Atmel AVR JTAGICE3 in JTAG mode `jtag3dw' Atmel AVR JTAGICE3 in debugWIRE mode `jtag3isp' Atmel AVR JTAGICE3 in ISP mode `jtag3pdi' Atmel AVR JTAGICE3 in PDI mode `jtagkey' Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2 `jtagmkI' Atmel JTAG ICE (mkI) `jtagmkII' Atmel JTAG ICE mkII `jtagmkII_avr32'Atmel JTAG ICE mkII im AVR32 mode `lm3s811' Luminary Micro LM3S811 Eval Board (Rev. A) `mib510' Crossbow MIB510 programming board `mkbutterfly' Mikrokopter.de Butterfly `nibobee' NIBObee `o-link' O-Link, OpenJTAG from www.100ask.net `openmoko' Openmoko debug board (v3) `pavr' Jason Kyle's pAVR Serial Programmer `pickit2' MicroChip's PICkit2 Programmer `picoweb' Picoweb Programming Cable, http://www.picoweb.net/ `pony-stk200' Pony Prog STK200 `ponyser' design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts `siprog' Lancos SI-Prog `sp12' Steve Bolt's Programmer `stk200' STK200 `stk500' Atmel STK500 `stk500hvsp' Atmel STK500 V2 in high-voltage serial programming mode `stk500pp' Atmel STK500 V2 in parallel programming mode `stk500v1' Atmel STK500 Version 1.x firmware `stk500v2' Atmel STK500 Version 2.x firmware `stk600' Atmel STK600 `stk600hvsp' Atmel STK600 in high-voltage serial programming mode `stk600pp' Atmel STK600 in parallel programming mode `usbasp' USBasp, http://www.fischl.de/usbasp/ `usbasp-clone'Any usbasp clone with correct VID/PID `usbtiny' USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/ `wiring' Wiring `xil' Xilinx JTAG cable `-C CONFIG-FILE' Use the specified config file for configuration data. This file contains all programmer and part definitions that AVRDUDE knows about. If you have a programmer or part that AVRDUDE does not know about, you can add it to the config file (be sure and submit a patch back to the author so that it can be incorporated for the next version). 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 CONFIG-FILE is written as +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. `-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. `-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. `-E EXITSPEC[,...]' 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: `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. `noreset' The `/RESET' line will be deactivated at program exit, thus allowing the MCU target program to run while the programming hardware remains connected. `vcc' This option will leave those parallel port pins active (i. e. high) that can be used to supply `Vcc' power to the MCU. `novcc' This option will pull the `Vcc' pins of the parallel port down at program exit. `d_high' This option will leave the 8 data pins on the parallel port active (i. e. high). `d_low' This option will leave the 8 data pins on the parallel port inactive (i. e. low). Multiple EXITSPEC arguments can be separated with commas. `-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 `-t' to continue in terminal mode. `-i DELAY' For bitbang-type programmers, delay for approximately 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. `-l LOGFILE' Use LOGFILE rather than STDERR for diagnostics output. Note that initial diagnostic messages (during option parsing) are still written to STDERR anyway. `-n' No-write - disables actually writing data to the MCU (useful for debugging AVRDUDE). `-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. `-P 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 0X). For the JTAG ICE mkII, if AVRDUDE has been built with libusb support, PORT may alternatively be specified as `usb'[:SERIALNO]. In that case, the JTAG ICE mkII will be looked up on USB. If 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 *note 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 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'. For the USBtinyISP, which is a simplicistic device not implementing serial numbers, multiple devices can be distinguished by their location in the USB hierarchy. *Note 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), PORT can be specified as `net':HOST:PORT. In this case, instead of trying to open a local device, a TCP network connection to (TCP) PORT on 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. _This feature is currently not implemented for Win32 systems._ `-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. `-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 _safemode_). If one of the configuration files contains a line `default_safemode = no;' safemode is disabled by default. The `-u' option's effect is negated in that case, i. e. it _enables_ safemode. Safemode is always disabled for AVR32, Xmega and TPI devices. `-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. `-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. `-U MEMTYPE:OP:FILENAME[:FORMAT]' Perform a memory operation. Multiple `-U' options can be specified in order to operate on multiple memories on the same command-line invocation. The MEMTYPE field specifies the memory type to operate on. Use the `-v' option on the command line or the `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 `flash' and `eeprom'. All memory types currently known are: `calibration' One or more bytes of RC oscillator calibration data. `eeprom' The EEPROM of the device. `efuse' The extended fuse byte. `flash' The flash ROM of the device. `fuse' The fuse byte in devices that have only a single fuse byte. `hfuse' The high fuse byte. `lfuse' The low fuse byte. `lock' The lock byte. `signature' The three device signature bytes (device ID). `fuse_N_' The fuse bytes of ATxmega devices, _N_ is an integer number for each fuse supported by the device. `application' The application flash area of ATxmega devices. `apptable' The application table flash area of ATxmega devices. `boot' The boot flash area of ATxmega devices. `prodsig' The production signature (calibration) area of ATxmega devices. `usersig' The user signature area of ATxmega devices. The OP field specifies what operation to perform: `r' read the specified device memory and write to the specified file `w' read the specified file and write it to the specified device memory `v' read the specified device memory and the specified file and perform a verify operation The FILENAME field indicates the name of the file to read or write. The FORMAT field is optional and contains the format of the file to read or write. Possible values are: `i' Intel Hex `s' Motorola S-record `r' raw binary; little-endian byte order, in the case of the flash ROM data `e' ELF (Executable and Linkable Format), the final output file from the linker; currently only accepted as an input file `m' immediate mode; actual byte values specified on the command line, separated by commas or spaces in place of the FILENAME field of the `-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 `0x', it is treated as a hex value. If the number otherwise begins with a leading zero (`0') it is treated as octal. Otherwise, the value is treated as decimal. `a' auto detect; valid for input only, and only if the input is not provided at stdin. `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. `h' hexadecimal; each value will get the string _0x_ prepended. `o' octal; each value will get a _0_ prepended unless it is less than 8 in which case it gets no prefix. `b' binary; each value will get the string _0b_ prepended. The default is to use auto detection for input files, and raw binary format for output files. Note that if FILENAME contains a colon, the FORMAT field is no longer optional since the filename part following the colon would otherwise be misinterpreted as FORMAT. As an abbreviation, the form `-U' FILENAME is equivalent to specifying `-U' _flash:w:_FILENAME_:a_. This will only work if FILENAME does not have a colon in it. `-v' Enable verbose output. More `-v' options increase verbosity level. `-V' Disable automatic verify check when uploading data. `-x EXTENDED_PARAM' Pass 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.  File: avrdude.info, Node: Programmers accepting extended parameters, Next: Example Command Line Invocations, Prev: Option Descriptions, Up: Command Line Options 2.2 Programmers accepting extended parameters ============================================= `JTAG ICE mkII' `AVR Dragon' When using the JTAG ICE mkII or AVR Dragon in JTAG mode, the following extended parameter is accepted: ``jtagchain=UB,UA,BB,BA'' Setup the JTAG scan chain for UB units before, UA units after, BB bits before, and 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. `AVR910' The AVR910 programmer type accepts the following extended parameter: ``devcode=VALUE'' Override the device code selection by using VALUE as the device code. The programmer is not queried for the list of supported device codes, and the specified VALUE is not verified but used directly within the `T' command sent to the programmer. VALUE can be specified using the conventional number notation of the C programming language. ``no_blockmode'' Disables the default checking for block transfer capability. Use `no_blockmode' only if your `AVR910' programmer creates errors during initial sequence. `BusPirate' The BusPirate programmer type accepts the following extended parameters: ``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 _CS_ pin, second AVR's RESET connected to BusPirate's _AUX_ pin and if your BusPirate has an _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. ``spifreq=0..7'' `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 ``rawfreq=0..3'' Sets the SPI speed and uses the Bus Pirate's binary "raw-wire" mode instead of the default binary SPI mode: `0' 5 kHz `1' 50 kHz `2' 100 kHz (Firmware v4.2+ only) `3' 400 kHz (v4.2+) The only advantage of the "raw-wire" mode is that different SPI frequencies are available. Paged writing is not implemented in this mode. ``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 `reset=', `spifreq=' and `rawfreq=' parameters unavailable. Be aware that ASCII mode is not guaranteed to work with newer firmware versions, and is retained only to maintain compatability with older firmware versions. ``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. ``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. ``cpufreq=125..4000'' This sets the _AUX_ pin to output a frequency of 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. This setting is only available in ASCII mode. (The lower limit was chosen so the CPU frequency is at least for four times the SPI frequency which is in ASCII mode 30kHz.) ``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. `Wiring' When using the Wiring programmer type, the following optional extended parameter is accepted: ``snooze=0..32767'' After performing the port open phase, AVRDUDE will wait/snooze for SNOOZE milliseconds before continuing to the protocol sync phase. No toggling of DTR/RTS is performed if SNOOZE > 0. `PICkit2' Connection to the PICkit2 programmer: `(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) ' `OSI'`AUX (6) ' Extended commandline parameters: ``clockrate=RATE'' Sets the SPI clocking rate in Hz (default is 100kHz). Alternately the -B or -i options can be used to set the period. ``timeout=USB-TRANSACTION-TIMEOUT'' Sets the timeout for USB reads and writes in milliseconds (default is 1500 ms).  File: avrdude.info, Node: Example Command Line Invocations, Prev: Programmers accepting extended parameters, Up: Command Line Options 2.3 Example Command Line Invocations ==================================== Download the file `diag.hex' to the ATmega128 chip using the STK500 programmer connected to the default serial port: % 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. % Upload the flash memory from the ATmega128 connected to the STK500 programmer and save it in raw binary format in the file named `c:/diag flash.bin': % 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. % Using the default programmer, download the file `diag.hex' to flash, `eeprom.hex' to EEPROM, and set the Extended, High, and Low fuse bytes to 0xff, 0x89, and 0x2e respectively: % 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. % Connect to the JTAG ICE mkII which serial number ends up in 1C37 via USB, and enter terminal mode: % 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. 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. % 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"  File: avrdude.info, Node: Terminal Mode Operation, Next: Configuration File, Prev: Command Line Options, Up: Top 3 Terminal Mode Operation ************************* AVRDUDE has an interactive mode called TERMINAL MODE that is enabled by the `-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::  File: avrdude.info, Node: Terminal Mode Commands, Next: Terminal Mode Examples, Prev: Terminal Mode Operation, Up: Terminal Mode Operation 3.1 Terminal Mode Commands ========================== The following commands are implemented: `dump MEMTYPE ADDR NBYTES' Read NBYTES from the specified memory area, and display them in the usual hexadecimal and ASCII form. `dump' Continue dumping the memory contents for another NBYTES where the previous dump command left off. `write MEMTYPE ADDR BYTE1 ... BYTEN' Manually program the respective memory cells, starting at address addr, using the values BYTE1 through BYTEN. This feature is not implemented for bank-addressed memories such as the flash memory of ATMega devices. `erase' Perform a chip erase. `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 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. `sig' Display the device signature bytes. `spi' Enter direct SPI mode. The _pgmled_ pin acts as slave select. _Only supported on parallel bitbang programmers._ `part' Display the current part settings and parameters. Includes chip specific information including all memory types supported by the device, read/write timing, etc. `pgm' Return to programming mode (from direct SPI mode). `verbose [LEVEL]' Change (when LEVEL is provided), or display the verbosity level. The initial verbosity level is controlled by the number of `-v' options given on the commandline. `?' `help' Give a short on-line summary of the available commands. `quit' Leave terminal mode and thus AVRDUDE. In addition, the following commands are supported on the STK500 and STK600 programmer: `vtarg VOLTAGE' Set the target's supply voltage to VOLTAGE Volts. `varef [CHANNEL] VOLTAGE' Set the adjustable voltage source to VOLTAGE Volts. This voltage is normally used to drive the target's _Aref_ input on the STK500 and STK600. The STK600 offers two reference voltages, which can be selected by the optional parameter CHANNEL (either 0 or 1). `fosc FREQ[`M'|`k']' Set the master oscillator to FREQ Hz. An optional trailing letter `M' multiplies by 1E6, a trailing letter `k' by 1E3. `fosc off' Turn the master oscillator off. `sck PERIOD' _STK500 and STK600 only:_ Set the SCK clock period to PERIOD microseconds. _JTAG ICE only:_ Set the JTAG ICE bit clock period to 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 to specify the ISP clock period when operating the ICE in ISP mode. `parms' _STK500 and STK600 only:_ Display the current voltage and master oscillator parameters. _JTAG ICE only:_ Display the current target supply voltage and JTAG bit clock rate/period.  File: avrdude.info, Node: Terminal Mode Examples, Prev: Terminal Mode Commands, Up: Terminal Mode Operation 3.2 Terminal Mode Examples ========================== Display part parameters, modify eeprom cells, perform a chip erase: % 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> 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: % 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>  File: avrdude.info, Node: Configuration File, Next: Programmer Specific Information, Prev: Terminal Mode Operation, Up: Top 4 Configuration File ******************** 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 `/usr/local/etc/avrdude.conf', while on Windows it is usally in the same location as the executable file. The name of this file can be changed using the `-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 `.avrduderc' within the user's home directory. On Windows, this file is the `avrdude.rc' file located in the same directory as the executable. * Menu: * AVRDUDE Defaults:: * Programmer Definitions:: * Part Definitions:: * Other Notes::  File: avrdude.info, Node: AVRDUDE Defaults, Next: Programmer Definitions, Prev: Configuration File, Up: Configuration File 4.1 AVRDUDE Defaults ==================== `default_parallel = "DEFAULT-PARALLEL-DEVICE";' Assign the default parallel port device. Can be overridden using the `-P' option. `default_serial = "DEFAULT-SERIAL-DEVICE";' Assign the default serial port device. Can be overridden using the `-P' option. `default_programmer = "DEFAULT-PROGRAMMER-ID";' Assign the default programmer id. Can be overridden using the `-c' option. `default_bitclock = "DEFAULT-BITCLOCK";' Assign the default bitclock value. Can be overridden using the `-B' option.  File: avrdude.info, Node: Programmer Definitions, Next: Part Definitions, Prev: AVRDUDE Defaults, Up: Configuration File 4.2 Programmer Definitions ========================== The format of the programmer definition is as follows: 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 ; 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. To invert a bit in the pin definitions, use `= ~ '. Following programmer types are currently implemented: `arduino' Arduino programmer `avr910' Serial programmers using protocol described in application note AVR910 `avrftdi' Interface to the MPSSE Engine of FTDI Chips using libftdi. `buspirate' Using the Bus Pirate's SPI interface for programming `buspirate_bb' Using the Bus Pirate's bitbang interface for programming `butterfly' Atmel Butterfly evaluation board; Atmel AppNotes AVR109, AVR911 `butterfly_mk' Mikrokopter.de Butterfly `dragon_dw' Atmel AVR Dragon in debugWire mode `dragon_hvsp' Atmel AVR Dragon in HVSP mode `dragon_isp' Atmel AVR Dragon in ISP mode `dragon_jtag' Atmel AVR Dragon in JTAG mode `dragon_pdi' Atmel AVR Dragon in PDI mode `dragon_pp' Atmel AVR Dragon in PP mode `ftdi_syncbb' FT245R/FT232R Synchronous BitBangMode Programmer `jtagmki' Atmel JTAG ICE mkI `jtagmkii' Atmel JTAG ICE mkII `jtagmkii_avr32' Atmel JTAG ICE mkII in AVR32 mode `jtagmkii_dw' Atmel JTAG ICE mkII in debugWire mode `jtagmkii_isp' Atmel JTAG ICE mkII in ISP mode `jtagmkii_pdi' Atmel JTAG ICE mkII in PDI mode `jtagice3' Atmel JTAGICE3 `jtagice3_pdi' Atmel JTAGICE3 in PDI mode `jtagice3_dw' Atmel JTAGICE3 in debugWire mode `jtagice3_isp' Atmel JTAGICE3 in ISP mode `linuxgpio' GPIO bitbanging using the Linux sysfs interface (not available) `par' Parallel port bitbanging `pickit2' Microchip's PICkit2 Programmer `serbb' Serial port bitbanging `stk500' Atmel STK500 Version 1.x firmware `stk500generic' Atmel STK500, autodetect firmware version `stk500v2' Atmel STK500 Version 2.x firmware `stk500hvsp' Atmel STK500 V2 in high-voltage serial programming mode `stk500pp' Atmel STK500 V2 in parallel programming mode `stk600' Atmel STK600 `stk600hvsp' Atmel STK600 in high-voltage serial programming mode `stk600pp' Atmel STK600 in parallel programming mode `usbasp' USBasp programmer, see http://www.fischl.de/usbasp/ `usbtiny' Driver for "usbtiny"-type programmers `wiring' http://wiring.org.co/, Basically STK500v2 protocol, with some glue to trigger the bootloader.  File: avrdude.info, Node: Part Definitions, Next: Other Notes, Prev: Programmer Definitions, Up: Configuration File 4.3 Part Definitions ==================== 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 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 = ; ; ; * Menu: * Parent Part:: * Instruction Format::  File: avrdude.info, Node: Parent Part, Next: Instruction Format, Prev: Part Definitions, Up: Part Definitions 4.3.1 Parent Part ----------------- 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 ;  File: avrdude.info, Node: Instruction Format, Prev: Parent Part, Up: Part Definitions 4.3.2 Instruction Format ------------------------ 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: `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. For example, the EEPROM read and write instruction for an AT90S2313 AVR part could be encoded as: 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";  File: avrdude.info, Node: Other Notes, Prev: Part Definitions, Up: Configuration File 4.4 Other Notes =============== * The `devicecode' parameter is the device code used by the STK500 and is obtained from the software section (`avr061.zip') of Atmel's AVR061 application note available from `http://www.atmel.com/dyn/resources/prod_documents/doc2525.pdf'. * 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), `efuse' (extended 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' * 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 unability to write the fuse bits, the safemode functionality does not make sense for these boot loaders.  File: avrdude.info, Node: Programmer Specific Information, Next: Platform Dependent Information, Prev: Configuration File, Up: Top 5 Programmer Specific Information ********************************* * Menu: * Atmel STK600::  File: avrdude.info, Node: Atmel STK600, Prev: Programmer Specific Information, Up: Programmer Specific Information 5.1 Atmel STK600 ================ The following devices are supported by the respective STK600 routing and socket card: Routing card Socket card Devices --------------------------------------------------------------------------- `' `STK600-ATTINY10' ATtiny4 ATtiny5 ATtiny9 ATtiny10 `STK600-RC008T-2' `STK600-DIP' ATtiny11 ATtiny12 ATtiny13 ATtiny13A ATtiny25 ATtiny45 ATtiny85 `STK600-RC008T-7' `STK600-DIP' ATtiny15 `STK600-RC014T-42' `STK600-SOIC' ATtiny20 `STK600-RC020T-1' `STK600-DIP' ATtiny2313 ATtiny2313A ATtiny4313 `' `STK600-TinyX3U' ATtiny43U `STK600-RC014T-12' `STK600-DIP' ATtiny24 ATtiny44 ATtiny84 ATtiny24A ATtiny44A `STK600-RC020T-8' `STK600-DIP' ATtiny26 ATtiny261 ATtiny261A ATtiny461 ATtiny861 ATtiny861A `STK600-RC020T-43' `STK600-SOIC' ATtiny261 ATtiny261A ATtiny461 ATtiny461A ATtiny861 ATtiny861A `STK600-RC020T-23' `STK600-SOIC' ATtiny87 ATtiny167 `STK600-RC028T-3' `STK600-DIP' ATtiny28 `STK600-RC028M-6' `STK600-DIP' ATtiny48 ATtiny88 ATmega8 ATmega8A ATmega48 ATmega88 ATmega168 ATmega48P ATmega48PA ATmega88P ATmega88PA ATmega168P ATmega168PA ATmega328P `' `QT600-ATTINY88-QT8'ATtiny88 `STK600-RC040M-4' `STK600-DIP' ATmega8515 ATmega162 `STK600-RC044M-30' `STK600-TQFP44' ATmega8515 ATmega162 `STK600-RC040M-5' `STK600-DIP' ATmega8535 ATmega16 ATmega16A ATmega32 ATmega32A ATmega164P ATmega164PA ATmega324P ATmega324PA ATmega644 ATmega644P ATmega644PA ATmega1284P `STK600-RC044M-31' `STK600-TQFP44' ATmega8535 ATmega16 ATmega16A ATmega32 ATmega32A ATmega164P ATmega164PA ATmega324P ATmega324PA ATmega644 ATmega644P ATmega644PA ATmega1284P `' `QT600-ATMEGA324-QM64'ATmega324PA `STK600-RC032M-29' `STK600-TQFP32' ATmega8 ATmega8A ATmega48 ATmega88 ATmega168 ATmega48P ATmega48PA ATmega88P ATmega88PA ATmega168P ATmega168PA ATmega328P `STK600-RC064M-9' `STK600-TQFP64' ATmega64 ATmega64A ATmega128 ATmega128A ATmega1281 ATmega2561 AT90CAN32 AT90CAN64 AT90CAN128 `STK600-RC064M-10' `STK600-TQFP64' ATmega165 ATmega165P ATmega169 ATmega169P ATmega169PA ATmega325 ATmega325P ATmega329 ATmega329P ATmega645 ATmega649 ATmega649P `STK600-RC100M-11' `STK600-TQFP100' ATmega640 ATmega1280 ATmega2560 `' `STK600-ATMEGA2560'ATmega2560 `STK600-RC100M-18' `STK600-TQFP100' ATmega3250 ATmega3250P ATmega3290 ATmega3290P ATmega6450 ATmega6490 `STK600-RC032U-20' `STK600-TQFP32' AT90USB82 AT90USB162 ATmega8U2 ATmega16U2 ATmega32U2 `STK600-RC044U-25' `STK600-TQFP44' ATmega16U4 ATmega32U4 `STK600-RC064U-17' `STK600-TQFP64' ATmega32U6 AT90USB646 AT90USB1286 AT90USB647 AT90USB1287 `STK600-RCPWM-22' `STK600-TQFP32' ATmega32C1 ATmega64C1 ATmega16M1 ATmega32M1 ATmega64M1 `STK600-RCPWM-19' `STK600-SOIC' AT90PWM2 AT90PWM3 AT90PWM2B AT90PWM3B AT90PWM216 AT90PWM316 `STK600-RCPWM-26' `STK600-SOIC' AT90PWM81 `STK600-RC044M-24' `STK600-TSSOP44' ATmega16HVB ATmega32HVB `' `STK600-HVE2' ATmega64HVE `' `STK600-ATMEGA128RFA1'ATmega128RFA1 `STK600-RC100X-13' `STK600-TQFP100' ATxmega64A1 ATxmega128A1 ATxmega128A1_revD ATxmega128A1U `' `STK600-ATXMEGA1281A1'ATxmega128A1 `' `QT600-ATXMEGA128A1-QT16'ATxmega128A1 `STK600-RC064X-14' `STK600-TQFP64' ATxmega64A3 ATxmega128A3 ATxmega256A3 ATxmega64D3 ATxmega128D3 ATxmega192D3 ATxmega256D3 `STK600-RC064X-14' `STK600-MLF64' ATxmega256A3B `STK600-RC044X-15' `STK600-TQFP44' ATxmega32A4 ATxmega16A4 ATxmega16D4 ATxmega32D4 `' `STK600-ATXMEGAT0' ATxmega32T0 `' `STK600-uC3-144' AT32UC3A0512 AT32UC3A0256 AT32UC3A0128 `STK600-RCUC3A144-33'`STK600-TQFP144' AT32UC3A0512 AT32UC3A0256 AT32UC3A0128 `STK600-RCuC3A100-28'`STK600-TQFP100' AT32UC3A1512 AT32UC3A1256 AT32UC3A1128 `STK600-RCuC3B0-21'`STK600-TQFP64-2' AT32UC3B0256 AT32UC3B0512RevC AT32UC3B0512 AT32UC3B0128 AT32UC3B064 AT32UC3D1128 `STK600-RCuC3B48-27'`STK600-TQFP48' AT32UC3B1256 AT32UC3B164 `STK600-RCUC3A144-32'`STK600-TQFP144' AT32UC3A3512 AT32UC3A3256 AT32UC3A3128 AT32UC3A364 AT32UC3A3256S AT32UC3A3128S AT32UC3A364S `STK600-RCUC3C0-36'`STK600-TQFP144' AT32UC3C0512 AT32UC3C0256 AT32UC3C0128 AT32UC3C064 `STK600-RCUC3C1-38'`STK600-TQFP100' AT32UC3C1512 AT32UC3C1256 AT32UC3C1128 AT32UC3C164 `STK600-RCUC3C2-40'`STK600-TQFP64-2' AT32UC3C2512 AT32UC3C2256 AT32UC3C2128 AT32UC3C264 `STK600-RCUC3C0-37'`STK600-TQFP144' AT32UC3C0512 AT32UC3C0256 AT32UC3C0128 AT32UC3C064 `STK600-RCUC3C1-39'`STK600-TQFP100' AT32UC3C1512 AT32UC3C1256 AT32UC3C1128 AT32UC3C164 `STK600-RCUC3C2-41'`STK600-TQFP64-2' AT32UC3C2512 AT32UC3C2256 AT32UC3C2128 AT32UC3C264 `STK600-RCUC3L0-34'`STK600-TQFP48' AT32UC3L064 AT32UC3L032 AT32UC3L016 `' `QT600-AT32UC3L-QM64'AT32UC3L064 Ensure the correct socket and routing card are mounted _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 `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 `STK600-RC008T-2', in order to use ISP mode, the jumper for `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 _Terminal Mode_, see *note Terminal Mode Operation::.  File: avrdude.info, Node: Platform Dependent Information, Next: Troubleshooting, Prev: Programmer Specific Information, Up: Top Appendix A Platform Dependent Information ***************************************** * Menu: * Unix:: * Windows::  File: avrdude.info, Node: Unix, Next: Windows, Prev: Platform Dependent Information, Up: Platform Dependent Information A.1 Unix ======== * Menu: * Unix Installation:: * Unix Configuration Files:: * Unix Port Names:: * Unix Documentation::  File: avrdude.info, Node: Unix Installation, Next: Unix Configuration Files, Prev: Unix, Up: Unix A.1.1 Unix Installation ----------------------- To build and install from the source tarball on Unix like systems: $ gunzip -c avrdude-6.0.1.tar.gz | tar xf - $ cd avrdude-6.0.1 $ ./configure $ make $ su root -c 'make install' The default location of the install is into `/usr/local' so you will need to be sure that `/usr/local/bin' is in your `PATH' environment variable. If you do not have root access to your system, you can do the the following instead: $ gunzip -c avrdude-6.0.1.tar.gz | tar xf - $ cd avrdude-6.0.1 $ ./configure --prefix=$HOME/local $ make $ make install * Menu: * FreeBSD Installation:: * Linux Installation::  File: avrdude.info, Node: FreeBSD Installation, Next: Linux Installation, Prev: Unix Installation, Up: Unix Installation A.1.1.1 FreeBSD Installation ............................ AVRDUDE is installed via the FreeBSD Ports Tree as follows: % su - root # cd /usr/ports/devel/avrdude # make install If you wish to install from a pre-built package instead of the source, you can use the following instead: % su - root # pkg_add -r avrdude 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.  File: avrdude.info, Node: Linux Installation, Prev: FreeBSD Installation, Up: Unix Installation A.1.1.2 Linux Installation .......................... On rpm based Linux systems (such as RedHat, SUSE, Mandrake, etc), you can build and install the rpm binaries directly from the tarball: $ su - root # rpmbuild -tb avrdude-6.0.1.tar.gz # rpm -Uvh /usr/src/redhat/RPMS/i386/avrdude-6.0.1-1.i386.rpm Note that the path to the resulting rpm package, differs from system to system. The above example is specific to RedHat.  File: avrdude.info, Node: Unix Configuration Files, Next: Unix Port Names, Prev: Unix Installation, Up: Unix A.1.2 Unix Configuration Files ------------------------------ When AVRDUDE is build using the default `--prefix' configure option, the default configuration file for a Unix system is located at `/usr/local/etc/avrdude.conf'. This can be overridden by using the `-C' command line option. Additionally, the user's home directory is searched for a file named `.avrduderc', and if found, is used to augment the system default configuration file. * Menu: * FreeBSD Configuration Files:: * Linux Configuration Files::  File: avrdude.info, Node: FreeBSD Configuration Files, Next: Linux Configuration Files, Prev: Unix Configuration Files, Up: Unix Configuration Files A.1.2.1 FreeBSD Configuration Files ................................... When AVRDUDE is installed using the FreeBSD ports system, the system configuration file is always `/usr/local/etc/avrdude.conf'.  File: avrdude.info, Node: Linux Configuration Files, Prev: FreeBSD Configuration Files, Up: Unix Configuration Files A.1.2.2 Linux Configuration Files ................................. When AVRDUDE is installed using from an rpm package, the system configuration file will be always be `/etc/avrdude.conf'.  File: avrdude.info, Node: Unix Port Names, Next: Unix Documentation, Prev: Unix Configuration Files, Up: Unix A.1.3 Unix Port Names --------------------- The parallel and serial port device file names are system specific. The following table lists the default names for a given system. *System* *Default Parallel *Default Serial Port* Port* FreeBSD `/dev/ppi0' `/dev/cuad0' Linux `/dev/parport0' `/dev/ttyS0' Solaris `/dev/printers/0' `/dev/term/a' 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.  File: avrdude.info, Node: Unix Documentation, Prev: Unix Port Names, Up: Unix A.1.4 Unix Documentation ------------------------ AVRDUDE installs a manual page as well as info, HTML and PDF documentation. The manual page is installed in `/usr/local/man/man1' area, while the HTML and PDF documentation is installed in `/usr/local/share/doc/avrdude' directory. The info manual is installed in `/usr/local/info/avrdude.info'. Note that these locations can be altered by various configure options such as `--prefix'.  File: avrdude.info, Node: Windows, Prev: Unix, Up: Platform Dependent Information A.2 Windows =========== * Menu: * Windows Installation:: * Windows Configuration Files:: * Windows Port Names:: * Using the parallel port:: * Documentation:: * Credits.::  File: avrdude.info, Node: Windows Installation, Next: Windows Configuration Files, Prev: Windows, Up: Windows A.2.1 Installation ------------------ A Windows executable of avrdude is included in WinAVR which can be found at `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 (`http://www.cygwin.com/'). To build and install from the source tarball for Windows (using Cygwin): $ set PREFIX= $ export PREFIX $ gunzip -c avrdude-6.0.1.tar.gz | tar xf - $ cd avrdude-6.0.1 $ ./configure LDFLAGS="-static" --prefix=$PREFIX --datadir=$PREFIX --sysconfdir=$PREFIX/bin --enable-versioned-doc=no $ make $ make install 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 `cygwin1.dll' at run-time. Either try using an older compiler version that still supports MinGW builds, or use MinGW (`http://www.mingw.org/') directly.  File: avrdude.info, Node: Windows Configuration Files, Next: Windows Port Names, Prev: Windows Installation, Up: Windows A.2.2 Configuration Files ------------------------- * Menu: * Configuration file names:: * How AVRDUDE finds the configuration files.::  File: avrdude.info, Node: Configuration file names, Next: How AVRDUDE finds the configuration files., Prev: Windows Configuration Files, Up: Windows Configuration Files A.2.2.1 Configuration file names ................................ AVRDUDE on Windows looks for a system configuration file name of `avrdude.conf' and looks for a user override configuration file of `avrdude.rc'.  File: avrdude.info, Node: How AVRDUDE finds the configuration files., Prev: Configuration file names, Up: Windows Configuration Files A.2.2.2 How AVRDUDE finds the configuration files. .................................................. 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: 1. The directory from which the application loaded. 2. The current directory. 3. The Windows system directory. On Windows NT, the name of this directory is `SYSTEM32'. 4. Windows NT: The 16-bit Windows system directory. The name of this directory is `SYSTEM'. 5. The Windows directory. 6. The directories that are listed in the PATH environment variable.  File: avrdude.info, Node: Windows Port Names, Next: Using the parallel port, Prev: Windows Configuration Files, Up: Windows A.2.3 Port Names ---------------- * Menu: * Serial Ports:: * Parallel Ports::  File: avrdude.info, Node: Serial Ports, Next: Parallel Ports, Prev: Windows Port Names, Up: Windows Port Names A.2.3.1 Serial Ports .................... When you select a serial port (i.e. when using an STK500) use the Windows serial port device names such as: com1, com2, etc.  File: avrdude.info, Node: Parallel Ports, Prev: Serial Ports, Up: Windows Port Names A.2.3.2 Parallel Ports ...................... AVRDUDE will accept 3 Windows parallel port names: lpt1, lpt2, or lpt3. Each of these names corresponds to a fixed parallel port base address: `lpt1' 0x378 `lpt2' 0x278 `lpt3' 0x3BC 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 `0x').  File: avrdude.info, Node: Using the parallel port, Next: Documentation, Prev: Windows Port Names, Up: Windows A.2.4 Using the parallel port ----------------------------- * Menu: * Windows NT/2K/XP:: * Windows 95/98::  File: avrdude.info, Node: Windows NT/2K/XP, Next: Windows 95/98, Prev: Using the parallel port, Up: Using the parallel port A.2.4.1 Windows NT/2K/XP ........................ 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: 1. install_giveio.bat Install and start the giveio driver. 2. status_giveio.bat Check on the status of the giveio driver. 3. remove_giveio.bat Stop and remove the giveio driver from memory. 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.  File: avrdude.info, Node: Windows 95/98, Prev: Windows NT/2K/XP, Up: Using the parallel port A.2.4.2 Windows 95/98 ..................... On Windows 95 and 98 the giveio.sys driver is not needed.  File: avrdude.info, Node: Documentation, Next: Credits., Prev: Using the parallel port, Up: Windows A.2.5 Documentation ------------------- AVRDUDE installs a manual page as well as info, HTML and PDF documentation. The manual page is installed in `/usr/local/man/man1' area, while the HTML and PDF documentation is installed in `/usr/local/share/doc/avrdude' directory. The info manual is installed in `/usr/local/info/avrdude.info'. Note that these locations can be altered by various configure options such as `--prefix' and `--datadir'.  File: avrdude.info, Node: Credits., Prev: Documentation, Up: Windows A.2.6 Credits. -------------- Thanks to: * Dale Roberts for the giveio driver. * Paula Tomlinson for the loaddrv sources. * Chris Liechti for modifying loaddrv to be command line driven and for writing the batch files.  File: avrdude.info, Node: Troubleshooting, Prev: Platform Dependent Information, Up: Top Appendix B Troubleshooting ************************** In general, please report any bugs encountered via `http://savannah.nongnu.org/bugs/?group=avrdude'. * Problem: I'm using a serial programmer under Windows and get the following error: `avrdude: serial_open(): can't set attributes for device "com1"', Solution: This problem seems to appear with certain versions of Cygwin. Specifying `"/dev/com1"' instead of `"com1"' should help. * Problem: I'm using Linux and my AVR910 programmer is really slow. Solution (short): `setserial 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). `setserial 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 `drivers/char/serial.c'. Search the file for `UART_FCR_TRIGGER_8' and replace it with `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. * 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. * 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. * 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. * Problem: How do I turn off the DWEN fuse? Solution: If the DWEN (debugWire enable) fuse is activated, the /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 /RESET pin is activated initially using a 12 V pulse (thus the name _high voltage_), so the target AVR can subsequently be reprogrammed, and the 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 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 DWEN fuse can be cleared. The pin mapping for the JTAG-to-ISP adapter is: *JTAG pin* *ISP pin* 1 3 2 6 3 1 4 2 6 5 9 4 * 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 -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 dependant; AVRDUDE will print out what it found on the bus when running it with (at least) one -V option. By specifying a string that cannot match any existing device (for example, -P USB:XXX), the scan will list all possible candidate devices found on the bus. Examples: 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) * Problem: I cannot do ... 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 /RESET line. DebugWire mode is initiated by activating the 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 _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. * Problem: I want to use my JTAG ICE mkII to program an Xmega device through PDI. The documentation tells me to use the _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: *JTAGICE* *Target* *Squid cab-* *PDI* *mkII probe* *pins* *le colors* *header* 1 (TCK) Black 2 (GND) GND White 6 3 (TDO) Grey 4 (VTref) VTref Purple 2 5 (TMS) Blue 6 (nSRST) PDI_CLK Green 5 7 (N.C.) Yellow 8 (nTRST) Orange 9 (TDI) PDI_DATA Red 1 10 (GND) Brown * 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: *Dragon* *Target* *ISP Header* *pins* 1 (MISO) PDI_DATA 2 (VCC) VCC 3 (SCK) 4 (MOSI) 5 (RESET) PDI_CLK / RST 6 (GND) GND * 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: *AVRISP* *Target* *ATtiny* *connector* *pins* *pin #* 1 (MISO) TPIDATA 1 2 (VTref) Vcc 5 3 (SCK) TPICLK 3 4 (MOSI) 5 (RESET) /RESET 6 6 (GND) GND 2 * 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 MISO and MOSI pins should be connected to the TPIDATA pin on the ATtiny device. However, a 1K resistor should be placed between the MOSI and TPIDATA. The MISO pin connects to TPIDATA directly. The SCK pin is connected to TPICLK. In addition, the VCC, /RESET and GND pins should be connected to their respective ports on the ATtiny device. * 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 `programmer' definition should be inverted by prefixing a tilde. For example, the DASA programmer would look like this when connected via a FT232R device (notice the tildes in front of pins 7, 4, 3 and 8): 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; ; Note that this uses the FT232 device as a normal serial port, not using the FTDI drivers in the special bitbang mode. * 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. * Problem: My ATxmega...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. * 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: `http://www.libusb.org/ticket/6' * Problem: after flashing a firmware that reduces the target's clock speed (e.g. through the `CLKPR' register), further ISP connection attempts fail. Solution: Even though ISP starts with pulling /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 _chip erase_ using the slow ISP clock (option `-e'), and then start a new session at higher speed. Option `-D' might be used there, to prevent another unneeded erase cycle.  Tag Table: Node: Top1235 Node: Introduction1879 Node: History8405 Node: Command Line Options9638 Node: Option Descriptions9916 Node: Programmers accepting extended parameters36663 Node: Example Command Line Invocations42966 Node: Terminal Mode Operation47671 Node: Terminal Mode Commands48408 Node: Terminal Mode Examples51672 Node: Configuration File54856 Node: AVRDUDE Defaults56275 Node: Programmer Definitions56991 Node: Part Definitions61553 Node: Parent Part66404 Node: Instruction Format67042 Node: Other Notes68424 Node: Programmer Specific Information70632 Node: Atmel STK60070866 Node: Platform Dependent Information78922 Node: Unix79173 Node: Unix Installation79423 Node: FreeBSD Installation80227 Node: Linux Installation80859 Node: Unix Configuration Files81404 Node: FreeBSD Configuration Files82038 Node: Linux Configuration Files82397 Node: Unix Port Names82712 Node: Unix Documentation83703 Node: Windows84230 Node: Windows Installation84492 Node: Windows Configuration Files85755 Node: Configuration file names86022 Node: How AVRDUDE finds the configuration files.86412 Node: Windows Port Names87202 Node: Serial Ports87414 Node: Parallel Ports87701 Node: Using the parallel port88470 Node: Windows NT/2K/XP88697 Node: Windows 95/9890203 Node: Documentation90406 Node: Credits.90962 Node: Troubleshooting91295  End Tag Table