summaryrefslogtreecommitdiff
path: root/changes.txt
blob: e591a3caac18a9501231e1f8dd36e665d95829b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
     CHANGES FROM VERSION 2.1.1 TO 2.1.2

     Bug fixed in checksum calculation, which sometimes altered     
     content of a buffer used elsewhere. Unless you used the 'query
     function' - query=1 in _sp12rc, to get sp12log.txt lines like:

     ATtiny2313  -wpf  RX433.hex  checksum 37a7  Tue Aug 26 15:48:30 2014
     ATtiny2313  -wef  RX433.eep  checksum f075  Tue Aug 26 15:48:30 2014

     You won't have noticed. Other than that, this version is BSD-compatible
     thanks to Dimitri Sokolyuk, who wrote:

     Hallo Steven,
     
     I have just ported your SP12 programmer to OpenBSD platform and would 
     like to contribute my changes back at you.
     The essential part is just a few lines long, but I have also done some 
     code cleanup to keep the compiler quite by replacing strcat() a.o. with 
     strlcat() versions and by renaming `struct logging log' with `struct 
     logging logging' due to collision with math's log() as suggested by 
     compiler.
     The final code compiles and works fine both at Linux and OpenBSD.
     
     Have a nice day,
     Dima

     CHANGES FROM VERSION 2.1.0 TO 2.1.1

     Artur Pundsack added support for the extended addressing
     demanded by big AVR uCs like the Mega2561. The new "load
     extended address byte" command is `hard-wired' (not part
     of _sp12dev), so the change should be transparent even to
     those who write their own _sp12dev entries.
     
     
     CHANGES FROM VERSION 2.0.7 TO 2.1.0

     Corrected a minor bug which prevented sp12 from dealing with the
     ATtiny2313 - the hexadecimal part of the device code (0A91)
     wasn't recognised.
     Added the new programming command `poll rdy/bsy', introduced in
     the Tiny2313. When this command is part of an _sp12dev entry (see
     sp12dev.txt), the -o option is ignored. And for devices which obey
     this new programming command, -o must be ignored, as -o1 would cause
     programming errors.

     Btw, you'll find that programming the Tiny2313 is a zippy process.
     It took about 14 seconds to completely fill the flash of the old
     AT90S2313, or nearly half a minute without optimization. Uploading the
     same stuff to the Tiny takes just a little more than 1 second! (Or 5
     seconds without optimization.)

     A few other improvements were made:

     1) When they can't find a working parallel port, previous versions
        tend to segfault and leave a corrupt _sp12rc behind. 
        Version 2.1 exits gracefully.
        
     2) Speedier blank check, thanks to Petr Slansky.

     3) Because several users put things like -rc2 and -rc3 on the 
        command line (instead of -rc10 -rc11), and were flummoxed by 
        the result, sp12 now accepts decimal calibration byte addresses.

     
     CHANGES FROM VERSION 2.0.6 TO 2.0.7

     Added support for Windows NT/XP.  Note, the MingW (www.mingw.org)
     compiler is used to build the Windows version.
     
     
     CHANGES FROM VERSION 2.0.5 TO 2.0.6

     Timing optimization is now available when programming page mode
     uCs (ATmega's). In previous versions, pages were allowed to
     settle for 64ms, as demanded by the old Mega103. Optimization
     allows you to fully program a Mega8 in about 3 seconds instead
     of 11 seconds.
     However, there are combinations of target and program cable
     (without `dongle') which cause optimization to fail; a few
     locations which have been programmed and verified may revert to
     0xff while programming another page. So it was decided to keep
     `no optimization' as the default behaviour. To increase speed,
     use  -o1. For example:

         sp12 -M4 -o1 -wpf foo.hex

     To make sure that optimization is alright for your hardware,
     it should be tested with QUERY=1 in _sp12rc, or a command like

         sp12 -M4 -o1 -wpfC foo.hex -Cpf foo.hex

     The checksums should be equal.
     

     CHANGES FROM VERSION 2.0.4 TO 2.0.5

     The `read calibration byte' command is now addressable,
     so you can read the four bytes inside for instance the ATmega8.
     Byte 0:   sp12 -rc   or   sp12 -rc00
     Byte 1:   sp12 -rc01
     Byte 2:   sp12 -rc10
     Byte 3:   sp12 -rc11
     
     `CALIB_MESSAGE' has been added to _sp12dev

     In the -i[nnn] command line option, nnn may now be equal to
     either the device code (with or without leading zeroes) or the
     device name, which can be something like AT90S1200, AT90LS1200,
     AT90LS1200A or abbreviations like S1200, Mega128 and M8L. See
     sp12dev.txt for more information about device names.  


     CHANGES FROM VERSION 2.0.3 TO 2.0.4

     Steve broke -T and -P; repaired.
     Increased buffer space for locks and fuses messages in _sp12dev;
     Check on buffer overrun for same;
     Trailing spaces quietly removed from commands in _sp12dev,
     before checking string length.

     
     CHANGES FROM VERSION 2.0.2 TO 2.0.3

     Page mode now properly deals with overlays. 
     Timing now less dependent on compiler optimization setting.

     
     CHANGES FROM VERSION 1.0.3 TO 2.0.2

     The entire locks and fuses command set has been replaced;
     a compatibility jump made inevitable by the proliferation of
     fuses in the AVR family.
     
     A plain text runtime configuration file (_sp12dev) now contains
     the locks and fuses command definitions as well as parameters
     like flash and eeprom size. Maintenance will hopefully be a
     matter of adding entries to and editing this file. Have a look
     at sp12dev.txt.

     The -H is now reserved for reading and writing the `high
     fuses'. Its old function (hex dump with ascii translation
     modifier for the -r(ead) option) is available as -h.

     Other new commands are -rc (to read the calibration byte of uCs
     like the Tiny15, Mega8 and Mega163, command defined in _sp12dev),
     -s (reads the list of supported uCs from _sp12dev and shows
     them on screen) and -t, which shows a progress bar lasting
     about ten seconds, for checking the autocalibrated timing.

     The -i[nnn] option now uses the device codes:

             AT90S1200(A)           -i190  
             AT90S2313              -i191 
             AT90S8515              -i193 
             AT90S4414              -i192 
             AT90S2323              -i291 
             AT90S4434              -i292 
             AT90S8535              -i393 
             AT90S2343 or Tiny22    -i391 
             Tiny22L                -i691 
             AT90S2333              -i591 
             AT90S4433              -i392 
             ATtiny15L              -i690 
             ATmega103              -i197 
             ATmega603              -i196 
             ATmega161              -i194 
             ATmega163              -i294 
             ATmega8                -i793 
             ATmega128              -i297 

     And when 'KANDA' in _sp12rc is removed or set to 3, sp12 will look 
     at the name by which the program is called (sp12 or sp12.kanda,
     sp12.exe or sp12k.exe in Dos/Windows), and adapt its parallel
     port pinout accordingly.

     No version 2.0 younger than patch level 2 has been published;
     1.0.3 is the final instance of version 1.0.


     CHANGES FROM VERSION 1.0.2 TO 1.0.3
     
     Were made according to a patch mailed to us by Eric Norum.
     His way of dealing with root permissions is safer, because
     sp12 now drops root permissions before accessing the file
     system.

     CHANGES FROM VERSION 1.0.1 TO 1.0.2

     While making sp12 compatible with both the sp12 cable/dongle
     and the cable/dongles supplied with the Kanda STK200/300 starter
     kits, Steve partly broke the `port control' option (-P[nnn]).
     Corrected.
     
     CHANGES FROM VERSION 1.0 TO 1.0.1

     A few bugs were squashed in the Intel Hex code, which caused
     records type 2 to be misinterpreted.
     
     CHANGES FROM VERSION 0.9 TO 1.0

     The improved Intel Hex file support and multiple uC programming 
     were conceived by Kevin Towers, who also provided a large part of
     the new code.
     NOTE: Be sure to erase any previous runtime configuration file
     (_sp12rc) and let this version make a new one.

     NEW _sp12rc SETTINGS

     You can set KANDA=1 (default is 0). SP12 1.0 is compatible with
     three programming cables; the one as used with previous
     versions - with or without Ken Huntington's `dongle' - and the
     cable/dongles supplied with the Kanda STK200/300 starter kits.
     The latter two are functionally equivalent. When `Kanda' is
     set, the parallel port pin usage is then adapted to Kanda's,
     which means that the port control option (see below) is of
     limited use.
     
     You can set a log path/file, where SP12 will log its write and
     lock operations. The default is "sp12log.txt" in the current 
     directory. 
     
     You can set LOGGING=1 (Default is 0.) When `logging' is set,
     every write and lock operation will cause a single line to be
     appended to the log.
     
     You can also set QUERY=1 (Default is 0). SP12 normally checks
     each location (or ATmega page) right after writing; if the
     content doesn't match what was written, SP12 retries a couple
     of times before giving up. This procedure achieves correct
     programming when conditions or memory cells are marginal, and
     also catches the large majority of hard errors. But defects and
     averse conditions may sometimes cause the content of one
     address to change, while another is being written to. You can
     catch these (extremely rare) errors by setting both `logging'
     and `query'. After writing a file content into the designated
     memory area, the flash or eeprom will then be read back and
     compared with the file, address by address. When all is well, a
     checksum is calculated and added to the log; else "readback
     ERROR" is reported. For instance:

AT90S2313    -wpf   diz_2.hex        checksum cb46   Sat Sep 23 18:43:49 2000
AT90S2313    -wef   diz_2.eep        checksum 0f37   Sat Sep 23 18:43:53 2000
AT90S2313    -wea   00000052:0xaa    verified        Sat Sep 23 18:43:54 2000 
AT90S2313    -wpa   00000006:0x5679  readback ERROR  Sat Sep 23 19:30:24 2000
AT90S2313    -wpf   diz_2.hex        readback ERROR  Fri Sep 23 19:33:02 2000

     NOTE: The overlay option modifies the `query' behaviour; see
     below.
     Lock operations are preceded by memory checksum calculations,
     and results are logged like this:
     
AT90S1200(A) -L3    flash cb46       eeprom 11cf     Sat Sep 23 18:47:08 2000

     When logging is set but query is not, the address by address 
     comparison is not performed, and writes are logged like this:

AT90S2313    -wpf   diz_2.hex        not queried     Fri Sep 29 14:42:21 2000
AT90S2313    -wef   diz_2.eep        not queried     Fri Sep 29 14:42:22 2000

     ERROR CODES RETURNED ON PROGRAM EXIT

     0 - accomplished writing/reading task - "life is wonderful :)"
     1 - no device present - "nothing to do"
     2 - bad command line options, corrupt _sp12rc, file not found,
         unable to write to file - "don't know what to do"
     3 - verification or blank check error - "device doesn't respond
         as expected"

     PROGRESS BARS

     During area read and write operations, you will see a
     progress bar like this: 
     oooooooooooooooooooooooo.......................................

     NEW AND CHANGED OPTIONS

     -A   EESAVE fuse bit
          The command -A0 programs the EESAVE fuse on an ATmega103
          or 603, causing the eeprom NOT to be erased when a `chip
          erase' is executed (by -E or -wpf). Command -A1 unprograms
          the fuse.
          This option can be used on its own or in combination with
          option U, forming a word like -A0U10.
          NOTE: When a device is locked, this fuse bit can't be
          programmed or unprogrammed.

     -H   Hex dump with ascii translation modifier for the -r (read)
          option, see below.

     -I   Intel Hex modifier for the -r (read) option, see below.

 -i[NNN]  init
          As before, except for a few additions to the list:

                       Force recognition 
                       with:
          AT90S1200           -i12
          AT90S2313           -i13
          AT90S2323           -i23
          AT90S2333           -i233
          AT90S2343           -i43
          AT90S4414           -i14
          AT90S4433           -i433
          AT90S4434           -i34
          AT90S8515           -i15
          AT90S8535           -i35
          ATTiny22            -i22
          ATmega103           -i103
          ATmega603           -i603

 -M[n.n]  uC clock frequency
          n.n is the uCs clock speed in MHz, not lower than 0.1. 
          _sp12rc contains autocalibrated timing data (delay caused
          by outportb(), loop count/s), from which an Sck frequency is
          calculated, fitting the uC's clock speed as indicated by 
          -Mn.n. You can safely set -Mn.n lower than the default (also
          in _sp12rc), but only if the command precedes all others
          except -i<nn>. For instance:

            sp12 -M4 -wpf foo.hex
            sp12 -i103 -M4 -wpf foo.hex
          
          When this option is not on the command line, the default
          is used. Unless you change it (in _sp12rc), the default
          makes sp12 version 1.0 behave like previous versions, which
          means that the Sck frequency and wave form will be suitable
          for uCs running on an internal RC clock, at fairly low Vcc.
          WARNING: When -Mn.n is set too high, the uC will misread
          commands and fill its memory with garbage.
          NOTE: In practice, the outportb() function needs a certain
          amount of time to actually change a parallel port data bit.
          Depending on the hardware, this is likely to limit the
          shortest timing to about 1.3us for an Sck half cycle. Most
          AVR uCs need the Sck low and high phases to be at least two
          clock cycles long; the AT89S1200 is an exception, needing an
          Sck high phase of at least four clock cycles.
          So while SP12 works correctly with very fast uCs, the time
          needed to execute a command line is not likely to decrease
          for Mnn settings above 3MHz for the 1200, and 1.5MHz for
          the other family members. SP12 reports the timing achieved.

     -O   overlay
          The commands -wpf and -wef cause SP12 to read files into
          0xFFFF or 0xFF padded buffers, and to make sure that the
          flash or eeprom area contains the buffer image after
          programming is done. -wpf is automatically preceded by a
          `chip erase', and -wef writes 0xFF into all addresses which
          don't have their content specified by the file (addresses
          which already contain 0xFF are skipped). This guarantees
          that programming is actually possible (new uploads to
          flash could easily conflict with `leftovers' from previous
          work). It also results in equal checksums for uC content
          and file.
          However, You may sometimes want to add calibration
          constants, configuration data and/or serial numbers to
          what's already in flash or eeprom. To overlay files on
          data already in the uC's memory, you'd do:

            sp12 -Owpf foo.hex -Owef foo.eep

          In combination with -wpf, the -O precludes chip erase. 
          If there is a conflict, the flash overlay will stop with an
          error report - it isn't possible to write a 1 over a 0 in an
          AVR flash location. However, foo.eep is always written, even
          if it (partially) replaces earlier data.
          Both -Owpf and -Owef only upload the file (as opposed to
          the buffer) and cause a query (performed when `logging' and
          `query' are set in _sp12rc) to also be limited to the
          file, or where the flash area is concerned, to addresses
          which according to the file should contain something other
          than 0xffff.
          Checksums are always calculated for the entire area, as the
          commands -Cp and -Ce refer to the entire uC areas. So
          after an -Owpf or -Owef, the log will show a checksum
          which only matches area content. The overlayed files each
          have their own checksum.

 -P[nnn]  Port control
          When used as the final option on the command line, this
          option leaves the parallel port data pins in the state
          determined by NNN, which can be a decimal or hexadecimal
          number: For instance, -P124 and -P0x7C both leave the
          port in 01111100 state. When used like this: 
             
             SP12 -P4 -wpf uC1.hex -P8 -wpf uC2.hex -P2

          The first two -P's are limited to controlling pins 2-6
          (those not used for the programming interface itself).
          Kevin invented this usage for programming two AVR uCs
          on a single board, using a single connector and a single
          command. There is a 10ms delay after each -P, to give
          analog switches on the target board some time to do their
          job.
          NOTE: You can't use Ken Huntington's `dongle' together
          with option -P, since buffers inside it are powered as well
          as high-Z/enabled using the data 2-6 pins. So only the exit
          state of the parallel port can be set, as with the old -T
          option (see below).
          NOTE: it is possible to set different communication speeds
          for each uC, using the -Mn.n command, but you have to put
          the -P first on the command line:
             
             SP12 -P4 -M0.2 -wpf uC1.hex -P8 -M4 -wpf uC2.hex -P2

          NOTE: -P has immediate control over data pins 2-6 only 
          when it's the first option on the command line. In this
          case:
                  SP12 -iNNN -P4 -wpf ...

          Pins 2-6 will all be high during init, which takes about a
          quarter of a second, depending on settings in _sp12rc and
          the possible need for resynchronization of the uC's
          programming interface.
          
          NOTE: When sp12 is used with the Kanda STK200 cable/dongle,
          a -P which is not the final option on the command line will
          control only data bits 0, 1 and 6. Bits 2 and 3 have to be
          used to high-Z/enable buffers inside the Kanda dongle; bits
          4 and 7 are programming lines, and bit 7 handles reset. 

     -r   read
          To read from either program or eeprom area, a single address
          (-rpa address, or -rea address) or the whole area. In the
          latter case output can be directed to a file using the -f
          option: -rpf foo.rom reads the program area and writes an
          image into foo.rom. Use of the `I' modifier (-rpfI foo.hex)
          changes the format from `native' avrasm to Intel Hex, while 
          use of `H' (-rpH to screen or -rpfH foo.dmp to file)
          results in a hex dump with ascii translation, ending with 
          a checksum:

            000078  95 08 24 ee 24 ff 27 cc 77 d7   ..$.$.'.w.......
            000080  bf 02 2f 4d 70 47 30 45 f0 10   ../MpG0E..=...h.
            000088  e0 00 16 e0 f0 89 16 f0 f0 79   .........y...i..
            000090  f4 18 16 fc f4 08 c0 04 14 fe   ...........0... 
            Checksum: cb46

          The above is just a sample of (shortened) lines taken from
          actual output. 
          NOTE: 16-bit word addresses are used when displaying the
          program space, and words are shown hi byte first.
          By default, data read from the eeprom area is presented in
          this format:

               Address:  Data in hex,  dec, oct,  bin
                  0000:          0xc0  192  0300  11000000
                  0x01:          0x99  153  0231  10011001
          
          Or in this format when a single address is read to the screen
          (stdout):

               The byte 0x99 (153, 0231, B10011001) was read from 
               eeprom address 0x0001

          But you can also use the commands -reH, -refH or -refI
          with appropriate effect. Byte addressing is used for the
          hex dump display.


     -T   This option was retained to remain compatible with older
          versions, but option -P offers much more control over the
          parallel port.
          By default, SP12 will leave the Centronics parallel port
          databits all zero on exit. Command -T1 leaves the reset 
          pin high, so a connected device will start running immediately
          after SP12 has finished, assuming it uses an external power
          source. Command -T2 also leaves the `powerbits' (2-6, as 
          shown by progrmmr.gif) high, to run a device without external 
          power.

  -U[nn]  SUT fuse bits
          The command -U[nn] programs the SUT fuses on an ATmega103
          or 603, thus enabling various reset delays as detailed in
          the datasheet (page 23/24, tables 5 and 6, 11/1999). 
          This option can be used on its own or in combination with
          option A, forming words like -A0U10 (see `examples' below).

     EXAMPLES OF THE NEW OPTIONS

     When an ATmega103 or 603 is connected, the command
         SP12 -rF
     Will result in something like:

         The following information was read from the
         lock and fuse bits:
            Start-up time code selected is 3 (16K WDT cycles)
            EEPROM is NOT preserved thru chip erase
            Device is not protected

     When an AT90S2333 or 4433 is connected, the command
         SP12 -rF
     Will result in something like:
     
        The following information was read from the
        lock and fuse bits:
           Brown-out detection enabled.
           Brown-out trigger set at 4.0V.
           CKSEL = 100 (datasheet page 20, table 5)
           Device is not protected
        Writing 0 to all Centronics data bits.
     
     But when an AT90S2343 is connected, you might see
     
         The following information was read from the
         lock and fuse bits:
            Internal RC clock enabled.
            Device is write-protected.
            
     And when an AT90S4434 or 8535 is connected, the report might be:

         The following information was read from the
         lock and fuse bits:
            Short start-up time selected.
            Device is write-protected.    

     The command:
         SP12 -A0U10   
     Will cause the eeprom NOT to be erased when a `chip erase' is
     executed (by -E or -wpf). The reset delay is set at 4K WDT
     cycles. SP12 will report:
     
         The following information was read back from
         the fuse bits:
            Start-up time code selected is 2 (4K WDT cycles)
            EEPROM is preserved thru chip erase
     
     The command:
         SP12 -M4 -wpf foo.hex
     Will attempt to set communication timing to match a device
     clock speed of 4MHz. Hardware will usually limit the achievable
     com speed, so while SP12 works correctly with very fast uCs, the
     time needed to execute a command line is not likely to decrease
     for Mnn settings above 1.5MHz. SP12 will report the speed
     actually achieved. For instance:
        
         Sck timing set for 1.5MHz or higher.

     The command:
         SP12 -Owpf foo.hex -Owef foo.eep
     Will NOT erase the device before writing in the new data. 
     The files foo.hex and foo.eep are added to what is already in the
     flash and eeprom area's. If there is a conflict, the flash
     overlay will stop with an error report - it isn't possible to
     write a 1 over a 0 in an AVR flash location. However, foo.eep is
     always written, even if it (partially) replaces earlier data.

     With suitable hardware, this command:
         SP12 -P4 -wpf uC1.hex -P8 -wpf uC2.hex -P2
     will program two uCs on a single target board, using a single
     command line. The first -P would make parallel port data bit 3
     high, making a set of analog switches route the programming lines
     to the first uC. The second -P disconnects the first and connects
     the second uC. Finally, the third -P leaves reset high when SP12
     exits, allowing the new software to run. There is a 10ms delay
     after each -P, to give analog switches on the target board some
     time to do their job.

     The command:
         SP12 -rpfH foo.dmp
     Reads the program area and writes a `hex dump with ascii
     translation' into the file foo.dmp. If you type just -rpH, the
     output is directed to the screen (stdout). You can dump the 
     eeprom area using -refH.

     The command:
         SP12 -rpfI foo.hex
     Reads the program area and writes it into the Intel HEX file
     foo.hex. -rpI (without the f) is not a valid command. You can
     dump the eeprom area using -refI.


     CHANGES FROM VERSION 0.8 TO 0.9

     NOTE: Be sure to erase any previous runtime conifiguration file
     (_sp12rc) and let this version make a new one.
   
     SP12 0.8 works reliably with most AVR uCs, parallel ports and
     target boards. But some hardware combinations can be
     recalcitrant. To deal with start-up transients, SP12 0.9
     implements the automatic SPI resynchronization procedure as
     recommended by Atmel. And to increase programming speed as well
     as reliability at marginal voltages, the Bytewrite time constant
     is dynamically adjusted (details below).
     The signal provided by some parallel ports just isn't good
     enough, no matter what the software does. The new `dongle'
     designed by Ken Huntington (dongle.gif) takes care of that.
     It also has the advantage of being high-Z except when SP12
     is active, and you don't need Sck termination (as shown in
     progrmmr.gif and icp_intr.gif) when using it.
     
     NOTE: The dongle is perfectly transparent to the software, so
     you can still use a plain cable without any changes whatsoever.
     Power for the dongle is provided by the parallel port, which is
     still able to provide power for a small target board as well
     (Icc up to about 5mA).
     NOTE: when using the dongle, your target board should have a
     reset circuit - at the very least a 10K resistor between the
     uC's reset pin and Vcc.

     The software changes in detail:
   
  1) All supported AVR uCs except the AT90S1200(A) should answer 
     the programming enable command by echoing 0x53 on Miso, while
     the third byte of the command is being transmitted. If they
     don't, the SPI shift register may be desynchronized. This
     version of SP12 will try to resynchronize in such cases.

  2) The high pulse on the reset line (part of the power-on sequence)
     now has a width which can be altered by editing the RESETPULS
     value in _sp12rc. The default is long enough (100us) to make
     SP12 live with a 100N cap on the reset line, as shown in
     icp_intr.gif.

     NEW AND CHANGED OPTIONS

     -o   optimization
          Default (option not on command line): the Bytewrite time
          constant - which determines how much time a flash or eeprom
          address gets to settle, after it has been written to - is
          dynamically adjusted, with the value in _sp12rc as upper limit.
          This makes SP12 0.9 program significantly faster than the older
          versions when conditions allow, and should cause less trouble
          at low Vcc. As older versions of the AT90S1200 were found to
          react unreliably when a flash address is polled during
          programming, default behaviour is to not optimize when a
          1200(A) is detected, or when its recognition is forced using
          option -i12.
          Level 0 (-o0): No optimization for any uC.
          Level 1 (-o1): forces optimization for all uCs, including the
          1200(A).
          NOTE: If used, this option must be the first option on the
          command line, or the first after -i[NNN]
          NOTE: Allow this version to make a new _sp12rc, because it
          should have 12ms as default.
     
     Faster performance is achieved only when the program and/or
     eeprom data file being uploaded to the uC have a certain
     length, as the algorithm adjusts towards shorter values in
     steps of default/12, one step per address. Once the time
     constant appears too short, the algorithm backs up a step and
     sets a flag. If a survivable verify error occurs after this,
     the adjustment is restarted at the default value.
     
     Polling (as mentioned in the AVR datasheets) is used to
     determine whether the time constant is long enough. So why not
     just use polling? Because there are values for which polling
     can't be used, which vary with the uC. An adjusted time
     constant also prevents quite a bit of PC/uC communication.

     As you can see below, the wait period required before a value
     written to flash or eeprom `settles' is closely related to Vcc.
     I tried programming at 2.5 < Vcc < 5V on two 2313-10PCs, a
     2313-4PC and a 4433-8PC. Here are the results (fixed pitch font
     table):

                2313-10PC       2313-4PC        4433-8PC
                % of 12ms       % of 12ms       % of 12ms
      Vcc      -wpf   -wef     -wpf   -wef     -wpf   -wef
      
      5.0      16     16       16     16       16     16
      4.5      16     16       16     16       16     16
      4.0      25     25       25     25       25     25
      3.5      33     33       33     33       33     33
      3.0      50     50       50     50       41     41
      2.5      83     83       75     75       75     75

     NOTE: All programming runs were perfect; no verify errors,
     always the same checksums. Nevertheless, 2.5V should be
     considered to be too low for comfort.
  
     EXAMPLES OF THE NEW OPTION

     To force byteWrite optimization for a 1200:
        SP12 -o1 -wpfC foo.hex -Cpf foo.hex
     Or:
        SP12 -i12 -o1 -wpfC foo.hex -Cpf foo.hex
     Compare the two checksums to make sure that the upload was
     correct.
     To force a fixed byteWrite equal to the value in _sp12rc
     (behaviour equal to previous versions):
        SP12 -o0 -wpf foo.hex


     CHANGES FROM VERSION 0.7 TO 0.8

  1) Support for the AT90S2333 and 4433 has been added, and the 
     FSTRT-bit of the 2323 is now accessible:

                Read, set/clear:
                Lock  RCEN  FSTRT  BODEN  BODLEVEL  CKSEL
     AT90S1200
     AT90S2313
     AT90S2323  YES         YES
     AT90S2333  YES                YES    YES       YES
     AT90S2343  YES   YES(*)
     AT90S4414
     AT90S4433  YES                YES    YES       YES
     AT90S4434  YES         YES
     AT90S8515
     AT90S8535  YES         YES
     ATTiny22   YES   YES(*)

     (*)  The 2343 is still treated as if it has an RCEN-bit, which
          may not be true for the series now being sold - the 02/2000
          errata sheet for the Tiny22 says "If external oscillator is
          required, use the 100% pin- and code-compatible
          AT90S/LS2343 which has external clock option only."
          It appears that the RCEN fuse proved recalcitrant in some
          cases, and Atmel felt this to be the quick and safe
          solution.
     (**) The same errata sheet says that only the Tiny22L is now 
          available, with the internal RC oscillator as the single 
          clock option. However, I have several Tiny22s with a
          switchable RCEN fuse, making them fully compatible with a
          number of clock-switchable 2343s I have lying around.
          Moreover, my Tiny22 (8PC) chips even have the same
          signature bytes (device code) as my 2343s...
          To make all versions as useful as possible, it was decided
          to make SP12 version 0.8 treat all Tiny22s and 2343s as if
          they are identical, and have a switchable RCEN fuse. It's
          up to the user to determine or find out the use of of the
          -R0/R1 option.

 -K[NNN]  CKSEL fuse bits
          The command -Knnn programs the CKSEL fuses on an AT90S2333
          or 4433, thus enabling various reset delays as detailed in
          the datasheet (page 20, table 5, 04/1999). This option can
          be used on its own or in combination with options D and V.
          NOTE: This option must be the final one on your command
          line. If options -D and/or -V are also used, you must 
          combine them with -K to form a single command word. (See
          `examples' below.)

     -D   BODEN fuse bit
          The command -D0 programs the BODEN fuse on an AT90S2333
          or 4433, enabling brown-out detection. Command -D1
          unprograms the fuse, switching brown-out detection off.
          This option can be used on its own or in combination with
          options K and V.
          NOTE: This option must be the final one on your command
          line. If options -K and/or -V are also used, you must 
          combine them with -D to form a single command word. (See
          `examples' below.)
     
     -V   BODLEVEL fuse bit
          The command -V0 programs the BODLEVEL fuse on an AT90S2333
          or 4433, setting the brown-out detection level to 4.0V. 
          Command -V1 unprograms the fuse, setting the lever to 2.7V.
          This option can be used on its own or in combination with
          options K and D.
          NOTE: This option must be the final one on your command
          line. If options -K and/or -D are also used, you must 
          combine them with -V to form a single command word. (See
          `examples' below.)

 -i[NNN]  init
          As before, except for a few additions to the list:

                       Force recognition 
                       with:
          AT90S1200           -i12
          AT90S2313           -i13
          AT90S2323           -i23
          AT90S2333           -i233
          AT90S2343           -i43
          AT90S4414           -i14
          AT90S4433           -i433
          AT90S4434           -i34
          AT90S8515           -i15
          AT90S8535           -i35
          ATTiny22            -i22

     EXAMPLES OF THE (NEW) OPTIONS 

     When an AT90S2333 or 4433 is connected, the command
         SP12 -rF
     Will result in something like:
     
        The following information was read from the
        lock and fuse bits:
           Brown-out detection enabled.
           Brown-out trigger set at 4.0V.
           CKSEL = 100 (datasheet page 20, table 5)
           Device is not protected
        Writing 0 to all Centronics data bits.
     
     But when an AT90S2343 is connected, you might see
     
         The following information was read from the
         lock and fuse bits:
            Internal RC clock enabled.
            Device is write-protected.
            
     And when an AT90S4434 or 8535 is connected, the report might be:

         The following information was read from the
         lock and fuse bits:
            Short start-up time selected.
            Device is write-protected.    

     The command:
         SP12 -D0V0K100
     Will switch on the brown-out detection of an AT90S2333 or 4433,
     set the detection level to 4.0V and provides a start-up delay
     of 16K CK (datasheet 04/1999, page 20, table 5). SP12 will
     report:

            Brown-out detection enabled.
            Brown-out trigger set at 4.0V.
            CKSEL = 100 (datasheet page 20, table 5)
         (Re)enabling brown-out detection usually causes the
         AT90(L)S2333/4433 to hang, so there is nothing further
         to do for SP12. Before programming can continue, power
         to the 2333/4433 must be switched off and back on again.
         Writing 0 to all Centronics data bits.
     
     Atmel had this to say about the `hangup' mentioned above:
     
     "This is a known problem with the current revision of the 
      AT90S4433. There is no other workaround than to program the
      BODEN bit after you have programmed the flash and the EEPROM."
      (Communication via Mark Korsloot of Alcom, the Dutch
      distributor of Atmel products, on 27 Apr 2000.)

     When this version of SP12 was prepared, the AT90(L)S2333 was
     not available. (Re)enabling BOD may or may not cause this uC to
     hang, but it seems best to make fuse programming the final
     word on your command line. So if you want to write to eeprom
     and flash, lock the device and program the fuses in one go,
     this is the correct order of the command words:

         SP12 -wpf prog.hex -wef data.epr -L3 -D0V0K100

     The flash must be written to first, because that command first 
     erases the device. The fuses can be programmed after locking
     the device, because in serial programming mode, you have access
     to the fuse bits even when a device is locked mode 3.

     Using one of the fuse programming options on its own is of
     course possible. The command:
         SP12 -V1
     Sets the brown-out detection level of an AT90S2333 or 4433 to
     2.7V.
 

     CHANGES FROM VERSION 0.6 TO 0.7

  1) Kevin Towers reported:
     --------------------------------------------------------------------
     I just downloaded your SP12 programmer source the other day and
     tried to get it to work.  After a few hours, I figured out the
     timing was inaccurate. I'm running a 400Mhz Celeron A processor.
     I read your doc files and noted that someone had bumped the numbers
     by 40%. I found this was not enough.  
     --------------------------------------------------------------------
     
     The autocalibration of the timing loops has been rewritten and
     tested in cooperation with Kevin Towers and Ken Huntington. It is
     now more accurate as well as faster than it used to be.

     NOTE: The timing has been split into autocalibrated loops for the 
     constants which should be shorter than 10 milliseconds (sckLO, 
     sckHI and byteWrite) and delay() calls for the other three. So when
     upgrading from a previous SP12 version, you MUST erase your old
     _sp12rc(s), to let version 0.7 write new ones.
     
  2) Kevin Towers improved the code for reading Intel HEX files, to be
     compatible with flash data as generated by the IAR C compiler.

  3) Atmels AT90S2323 datasheet specifies the wrong signature bytes,
     which caused SP12 version 0.6 not to recognize this device. Atmel
     has since confirmed the correct signature, which been compiled into
     version 0.7.

  4) An option like this has been demanded by many. It has the 
     disadvantage of leaving the Centronics parallel port in a state
     other than zero, which may conflict with the next device you
     connect. Use with care.
  
     -T   By default, SP12 will leave the Centronics parallel port
          databits all zero on exit. Command -T1 leaves the reset 
          pin high, so a connected device will start running immediately
          after SP12 has finished, assuming it uses an external power
          source. Command -T2 also leaves the `powerbits' (2-6, as 
          shown by progrmmr.gif) high, to run a device without external 
          power.

  5) There is now a single source for the Dos and Linux versions of
     SP12, as initiated by Jean-Jacques Michel (see linux.doc in the 
     SP12v0_7-linux.tgz or SP12v0_7-linux-static.tgz).

     
     CHANGES FROM VERSION 0.5 TO 0.6

     Chris Jackson reported:
     --------------------------------------------------------------------
     I've recently built your SP12 programmer for the Atmel AVR
     microcontroller. In the documentation you mention that the
     software apparently doesn't work in a Windows98 DOS box. I'm happy
     to report that this isn't the case, as it works quite happily in
     both WIndows95 and Windows98 for me.

     I have had a couple of problems though:

     1. One of the machines that I tried it on had a Parallel Port
     PCMCIA adapter installed. Unless the machine was powered up with
     this device fully disconnected, the driver for it was loaded by
     Windows. This meant that whenever SP12 set the port lines high,
     the driver would kick in and set them back low again. Depending on
     the speed of the driver's response, the programmer would sometimes
     work, and sometimes not - which caused a bit of confusion at first.
     
     2. The software doesn't work reliably on any computer with a
     PentiumII processor running at >=350MHz. The problem is in the
     initialization of the timing loop, which doesn't have the
     resolution to cope with such high speed processors. You can work
     around this by manually editing the _sp12rc file until the values
     are large enough to make it work.
     
     I have recompiled the software using MS VisualC++, using the
     system's high resolution timer. This gives me reliable software
     without tweaking the _sp12rc file, but it is more tied to Windows
     than it was before. Also, Microsoft have removed support for the
     outportb() and inportb() functions, so I had to use inline
     assembler for those. It looks as though it will be impossible to
     access the parallel port in this way when WindowsNT takes over,
     which will be unfortunate.
     --------------------------------------------------------------------

     Chris later recompiled SP12 using Borland C++ 4.5 with no changes
     to the source code. It worked without problems on all machines he
     tried it on up to a processor speed of 400MHz. When he tried
     it on a 450MHz machine, it didn't work but increasing the SCKLO and
     SCKHI values in _sp12rc by just 40% made it work OK. He supposes
     that this could be accounted for by inaccuracies in the timing
     initialisation. It now looks as if programs compiled with Turbo C
     may have problems with newer high speed Pentiums.

     The present 32-bit protected mode version 0.6 was compiled with gcc
     (Free Software Foundation, as found in the djgpp package). It does
     a better job of calibrating its timing, which takes care of problem
     number 2 above, as Chris confirmed. His other remarks remain valid;
     SP12 has no way to deal with MS Windows related port conflicts and
     access problems. It isn't Windows software and probably never will
     be. And Windows-NT does not provide the parallel port access 
     required by SP12.
     

CHANGES FROM VERSION 0.4 TO 0.5

     Support has been added for seven other AVR uCs.  On all of them,
     you have read and write access to the flash and eeprom memory
     (from/to file or single address), and you can set the lock bits.
     Some of them offer extra functions as shown in the table:
     
                  Read access to       set/clear   set/clear
                  lock & fuse bits     RCEN        FSTRT
     AT90S1200
     AT90S2313
     AT90S2323    YES
     AT90S2343    YES                  YES
     AT90S4414
     AT90S4434    YES                              YES
     AT90S8515
     AT90S8535    YES                              YES
     
     Note that on `YES' marked devices, you have access to the fuse
     bits even if the device is locked. For instance, you can switch
     the 2343 from internal to external clock oscillator and back
     even if you can't read the program inside.

     NEW AND CHANGED OPTIONS

     -C   calculate checksum
          Unchanged, but note the support for files in Intel HEX format:
          Using files in Intel HEX format makes no difference to the
          checksum. If foo.rom is the same program as foo.hex, then -Cpf
          foo.rom and -Cpf foo.hex result in the same checksum.
          And mark the following note:
          NOTE: The checksum value depends on what's in the buffer and
          also on the total size of the buffer. So if you move a file
          from an AT90S2313 to an AT90S8515, the checksum changes.
          -i12 -Cpf foo.rom and -i15 -Cpf foo.rom show different
          checksums for the same file, matching those calculated when
          doing -Cp with a 1200 or an 8515 connected.
     
     -E   chip erase
          A blank check no longer follows automatically. Imho there is
          something to be said for checking results if they can be
          checked, but it does take time and is in this case necessary
          only if you suspect trouble. 
          Using options -w, -p and -f together (to write a file
          from disk to program area) is still automatically preceded by
          an erase, but not by a blank check. So -wpf foo.rom is now
          equivalent to -Ewpf foo.rom. -Bwpf foo.rom causes a blank
          check between the automatic erase and the upload of foo.rom.
          -E merely does an erase, -EB means erase and blank check.

     -f   filename next
          The upload of files in Intel HEX format is now supported:
          Program files must be either in the Atmel `generic' format or
          in Intel HEX format, both as provided by the Atmel assembler
          (w)avrasm.exe version 1.03 or higher. SP12 recognizes the file
          by content, so you don't need to use specific extensions; 
          but .rom and .hex do seem logical.
          The generic format contains only lines like 00000c:99e1 (both
          address and data in hexadecimal notation without prefix; six
          digits for the address, four for the data).
          Eeprom files must be either in SP12 `native' format, or Intel
          HEX format as provided by (w)avrasm.exe version 1.21 or
          higher. To conform to SP12 format, the file must contain only
          lines like 0x0d:0xcf (Address in hexadecimal, decimal or octal
          notation, data in hexadecimal, decimal, octal or binary
          notation, all with appropriate prefix. So the lines 0x0d:153,
          13:0231 and 015:B10011001 have the same meaning.)

     -F   Lock and fuse bits
          Use in combination with -r to make the command -rF, for
          reading the lock and fuse bits. Valid only if an AT90S2323,
          2343, 4434 or 8535 is connected.

  -i[NN]  init
          As before, except the following:
          ...Next the device code of your device (contained in the
          signature bytes) will be read to determine which member of
          the AVR family has been connected. This enables SP12 to use
          the correct programming command subset and to know the size
          of the flash and eeprom memory. When a device has been
          locked mode 3, the device code (signature bits) will be
          unreadable. To regain access, you must put a two-ddigit number
          behind the -i, thus forcing SP12 to assume that a certain
          device is connected. Here is a table of supported uCs and init
          numbers:
                       Force recognition 
                       with:
          AT90S1200           -i12
          AT90S2313           -i13
          AT90S2323           -i23
          AT90S2343           -i43
          AT90S4414           -i14
          AT90S4434           -i34
          AT90S8515           -i15
          AT90S8535           -i35

          -i0, -i or no use of this option (when there are others on
          the command line) results in automatic init and device check.
          NOTE: option -iNN must be the first on the command line.
          NOTE: init is the only valid option if no device is connected,
          though you might for instance check a file checksum using 
          -i15 -Cpf foo.hex, if foo.hex is intended for the 8515.
          
     -R   RCEN fuse bit
          The command -R0 programs the RCEN bit on an AT90S2343, thus
          enabling the internal RC clock oscillator. Command -R1
          unprograms the bit, switching the internal clock off.
          While RCEN is available on other AT90S uCs, it can only be
          accessed by a serial programmer (like SP12) on the 2343.
          
     -S   FSTRT fuse bit
          The command -S0 programs the FSTRT bit on the AT90S4434 and
          8535, thus selecting the fast start-up time. Command -S1
          unprograms the bit, selecting the default (long) start-up
          time.

     -w   write 
          As before, except:
          NOTE: All writes are automatically verified; SP12 immediately
          reads back from the current address and compares the response 
          with the data that was written. If the response is not
          correct, SP12 tries to write to the same address two more
          times before coming back with "ERROR: Verify has failed."
          
     EXAMPLES OF THE NEW OPTIONS

     When an AT90S2343 is connected, the command
         SP12 -rF
     Will result in something like:
         The following information was read from the
         lock and fuse bits:
            Internal RC clock enabled.
            Device is write-protected.
     But when an AT90S4434 or 8535 is connected, you might see:
         The following information was read from the
         lock and fuse bits:
            Short start-up time selected.
            Device is write-protected.    
 
     The command:
         SP12 -R0
     Will program the RCEN fuse bit on an AT90S2343, enabling the
     internal RC clock oscillator.
     On an AT90S4434 or 8535, the command:
         SP12 -S0
     programs the FSTRT fuse bit, to select the short start-up time. 
     
INTERACTIVE USE
     The interactive human interface is still on the `to do' list.
     It will probably appear in version 0.7.


CHANGES FROM EARLIER VERSIONS:

     Version 0.3 and before needed free access to the Reset pin as well
     as MOSI, MISO and SCK. As of 0.4, the timing has been altered to
     cater for the use of a 10K resistor and a 100N (100 nano-farad)
     capacitor, which make power-on reset more reliable. That
     combination allows SP12 sufficient access to Reset. Check
     icp_intr.gif for details.

     No operational changes before this.