NAME SP12: A serial programmer for working with Atmel AVR uCs. Copyright (C) 1997-2003 Ken Huntington, Kevin Towers, Pitronics. This 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. Pitronics can be reached by email: sbolt@xs4all.nl Kevin Towers can be reached by email: ktowers@omnexcontrols.com Ken Huntington can be reached by email: kenh@compmore.net URL The home page for sp12 is http://www.xs4all.nl/~sbolt/e-spider_prog.html DESCRIPTION Sp12 version 2.0 is a serial mode (in-circuit) programmer for the AVR family of microcontrollers. When new AVR uCs arrive, you can easily add support for them yourself, by adding a plain text entry to the runtime configuration file _sp12dev. Editing this file also allows you to customize the way sp12 deals with existing uCs. Customization means, among other things, that you can define the write (high, extended) fuses commands so they won't touch the bits that can lock you out of your uC. For instance, the Mega8 and the Tiny15 both allow serial mode access to RSTDISBL, which can take away the resetpin - thus ending serial mode programming access. The Tiny15 also permits writing to SPIEN. If you use the _sp12dev entries as provided, these fuses will never be altered by user errors. Sp12 is one of the few programmers capable of uploading new software to several uCs on a single target, in one go. Yet it is a small and simple command line tool, easy to use in scripts and batch files. Depending on your PC and target, the hardware can be as simple as a nearly plain cable between your target and a parallel port. A special `dongle' design is available to improve the signal quality and make the programming lines high-Z unless sp12 is active. Sp12 can also adapt its use of the paralel port to the cable/dongles supplied with the Kanda STK200/300 starter kits. INSTALLATION This package contains an executable which depends on libc.so.6 and ld-linux.so.2. If it doesn't work on your system, symply compile your own binary by entering the SP12/Source directory and typing `make'. (There used to be a statically linked sp12 binary package, but that's no good anymore, because older kernels need a different binary format.) If you do have to compile sp12, be sure to run the timing check when the installation is completed (see below). Note: To run sp12 you must have i/o permission on your system, so run as root (not a good idea) or set sp12 permissions and ownership like this: -r-sr-xr-x 1 root root 53208 Jan 17 16:35 /usr/local/bin/sp12* Which can be achieved by becoming root and using these commands: chown root.root sp12 chmod 4555 sp12 Note that sp12 drops root permissions before accessing the file system, so it should be secure enough for general use. Put the sp12 executable somewhere in your $PATH, for instance in /usr/local/bin Next, add a line like export SP12=/home// to your .bash_profile or similar file. After restarting the shell (normally by opening a new terminal window) this creates the environment variable SP12, which should point to the directory where you want to keep the runtime configuration files _sp12dev and _sp12rc. Copy _sp12dev into that directory, and run sp12 -i To make sp12 create an _sp12rc for your system. Depending on your computer it may take a few seconds or somewhat longer to calibrate the timing loop. Note: If heavy multitasking is going on, the autocalibration will produce time constants which are too small. Therefore _sp12rc should be created on a lightly loaded system. When you are actually programming an uC, heavy background loads may slow down the job, but they won't really hurt; the AVR serial mode programming time constraints are minimum values. _sp12rc is in plain language and may be edited (with care), for instance to make SP12 use a different parallel port (read _sp12rc and sp12rc.txt for details). NOTE: Be sure to erase any previous runtime configuration file (_sp12rc) and let this version make a new one. Finally, run sp12 -t The command presents a progress bar, which should take about 10 seconds to complete, counting from the moment when you hit the return on the command line. (There may a brief pause before the bar appears, which nevertheless is part of the ten seconds.) I wouldn't worry if it's eight or 15 seconds. But the deviation is large, read `bugs & bother' below. BUGS & BOTHER Certain time constants necessary for proper upload of flash and eeprom data (serial clock sck low & high, write delay) are realized by autocalibration based on timing nearly empty loops. So for starters, you should let sp12 generate its runtime configuration file (_sp12rc) while your computer is lightly loaded. If heavy multitasking is going on, the autocalibration will produce time constants which are too small. When you are actually programming an uC, heavy background loads may slow down the job, but they won't really hurt; the AVR serial mode programming time constraints are minimum values. There is no obvious alternative for these loops, as for instance the usleep() function is often limited by the timer resolution of the system (to about 10ms). And this method usually works fine. However, trouble may occur when recompiling sp12 with compilers other than gcc. If all else fails, you might edit the line LOOPCOUNT= in your _sp12rc, referring to the command "sp12 -t" and your watch to get it right.