File: README.stk500

package info (click to toggle)
uisp 20050207-4.3
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 916 kB
  • sloc: cpp: 4,606; sh: 872; ansic: 429; makefile: 140
file content (294 lines) | stat: -rw-r--r-- 7,097 bytes parent folder | download | duplicates (5)
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
$Id: README.stk500,v 1.2 2002/10/02 16:14:08 troth Exp $

NOTE: Atmel has finally released the specs for the protocol for talking to the
stk500 over a serial line. Here's where to get the files:

    ftp://www.atmel.com/pub/atmel/avr061.zip
    http://www.atmel.com/atmel/acrobat/doc2525.pdf

STK500 Commands  **preliminary information**
---------------

Extracted by Jason Kyle 20010701
Updated 200201

The latest version of this document can be found at www.avr1.org.

Notes:
- Incomplete but sufficient to make progress on free tools.
- All commands are terminated by 0x20
- All successful responses are framed 0x14 data 0x10 (i.e. NULL response is 
  0x14 0x10)
- Commands invalid in current mode (i.e not in pgm mode, pgm page) give 
  0x14 0x13 response.


STK500 BOARD COMMANDS
---------------------

** ?STK500
Command		0x30 0x20
Response	0x14 0x10
Use		Establish STK500 presence and UART sync. Re-send n times until
		response.
Notes		STK500 won't respond to other commands unless this has been
		sent.

** BoardID
Command		0x31 0x20
Response	0x14 "AVR STK" 0x10
Use		Identify board.
Notes

** VTargetSet
Command		0x40 0x84 VTarget 0x20
Response	0x14 0x10
Use		Set VTarget voltage.
Notes		0x33 = 5.1V , 0x34 = 5.2V , 0x32 = 5.0V

** ARefSet
Command		0x40 0x85 ARef 0x20
Response	0x14 0x10
Use		Set ARef voltage.
Notes		Same count/V relationship as VTargetRead

** POscSet
Command		0x40 0x86 POsc 0x20
Response	0x14 0x10
Use		Set P parameter.
Notes

** NOscSet
Command		0x40 0x87 NOsc 0x20
Response	0x14 0x10
Use		Set N parameter.
Notes

** SDOscSet
Command		0x40 0x89 SDOsc 0x20
Response	0x14 0x10
Use		Set SD parameter.
Notes

** HWver
Command		0x41 0x80 0x20
Response	0x14 0x02 0x10
Use		Hardware version identification.
Notes

** SWmajor
Command		0x41 0x81 0x20
Response	0x14 0x01 0x10
Use		Software major version identification.
Notes

** SWminor
Command		0x41 0x82 0x20
Response	0x14 0x07 0x10
Use		Software minor version identification.
Notes

** VTargetRead
Command		0x41 0x84 0x20
Response	0x14 0x33 0x10
Use		Query present VTarget voltage.
Notes		0x33 = 5.1V , 0x34 = 5.2V , 0x32 = 5.0V

** ARefRead
Command		0x41 0x85 0x20
Response	0x14 0x33 0x10
Use		Query present ARef voltage.
Notes		Same count/V relationship as VTargetRead

** POscRead
Command		0x41 0x86 0x20
Response	0x14 0x01 0x10
Use		Query present P parameter.
Notes

** NOscRead
Command		0x41 0x87 0x20
Response	0x14 0x00 0x10
Use		Query present N parameter.
Notes

** SDOscRead
Command		0x41 0x89 0x20
Response	0x14 0x01 0x10
Use		Query present SD parameter.
Notes

** DeviceParam
Command		0x42 (20 device specific bytes) 0x20
Response	0x14 0x10
Use		Tell programmer how to program device, i.e data polling byte
		returns.
Notes		See table for more details

** MagicNumber
Command		0x45 0x03 0x00 0xD7 0xA0 0x20
Response	0x14 0x10
Use		Ask Atmel.  Sent before entering programming mode.
Notes		This may well be a code checksum, software version requested
		first.


STK500 PROGRAMMING COMMANDS
---------------------------

** EnterPgmMode
Command		0x50 0x20
Response	0x14 0x10
Use		Enter programming mode, nRESET = low.
Notes

** LeavePgmMode
Command		0x51 0x20
Response	0x14 0x10
Use		Leave programming mode, nRESET = high.
Notes

** EraseDevice
Command		0x52 0x20
Response	0x14 0x10
Use		Erase device.
Notes

** SetAddress
Command		0x55 AddrL AddrH 0x20
Response	0x14 0x10
Use		Set address for read/write operation
Notes		Word address FLASH, Byte address EEPROM

** UniversalCmd
Command		0x56 0xAC 0xFD 0x00 0xFF 0x20
Response	0x14 0x00 0x10
Use		Sending lock and fuse bits.
Notes		Could probably be used for byte by byte programming of devices.
		The 0x00 returned is read from byte 4 SPI return value, i.e. if
		read program memory SPI command sent then this is the byte
		returned.

** WriteMemory
Command		0x64 LenH LenL 0x46 DataBytes 0x20
Response	0x14 0x10
Use		Programming FLASH/EEPROM/PageBuffer
Notes		Change 0x46 ("F") to 0x45 ("E") for EEPROM. Length in bytes.
		Written in 0x0100 chunks for 8515


** ReadMemory
Command		0x74 LenH LenL 0x46 0x20
Response	0x14 DataBytes 0x10
Use		Reading FLASH/EEPROM
Notes		Change 0x46 ("F") to 0x45 ("E") for EEPROM. Length in bytes.
		Read in 0x0100 chunks for 8515.

** GetSignature
Command		0x75 0x20
Response	0x14 0x1E 0x93 0x01 0x10
Use		Requesting device signature bytes
Notes		Response shown for 8515

** ReadOscCal
Command		0x76 0x20
Response	0x14 0x42 0x10
Use		Read current oscillator calibration value
Notes		Varies between devices, 0x42 in an ATmega163L-4PI 0035



COMMAND SEQUENCES
-----------------

Startup:
?STK500 , BoardID , HWver , SWmajor , SWminor

ReadSignature:
?STK500 , DeviceParam , SWminor , SWmajor, MagicNumber , EnterPgmMode ,
GetSignature , LeavePgmMode

WriteLockBits:
?STK500 , DeviceParam , SWminor , SWmajor , MagicNumber , EnterPgmMode ,
UniversalCmd , LeavePgmMode

WriteMemory:
?STK500 , DeviceParam , SWminor , SWmajor , MagicNumber , EnterPgmMode ,
EraseDevice , SetAddress 0x0000 , PgmBlockMode n bytes , SetAddress 0x0000 ,
ReadBlockMode n bytes , LeavePgmMode

ReadMemory:
?STK500 , DeviceParam , SWminor , SWmajor , MagicNumber , EnterPgmMode ,
SetAddress 0x0000 , ReadBlockMode n bytes , LeavePgmMode

Normally memory is programmed or read in 0x0100 byte chunks, obviously if a
program doesn't align to an 0x0100 length then there will be a < 0x0100 chunk
at the end.


Writing mega163.  Set address to 0x0000, write 0x0100 bytes, set address to
0x0080, write 0x0100 bytes etc...  STK500 must auto detect end of page boundry
and write current page to address specified in last setaddress cmd.


Set device paramters and programming mode command for STK500

8515
42 60 00 00 01 01 00 01 01 7f 7f 80 7f 00 00 02 00 00 00 20 00 20

4414
42 50 00 00 01 01 00 01 01 7f 7f 80 7f 00 00 01 00 00 00 10 00 20

2313
42 40 00 00 01 01 00 01 01 7f 7f 80 7f 00 00 00 80 00 00 08 00 20

1200
42 33 00 00 01 01 00 01 01 ff ff 00 ff 00 00 00 40 00 00 04 00 20

2323
42 41 00 00 00 01 00 01 01 ff ff 00 ff 00 00 00 80 00 00 08 00 20

2343
42 43 00 00 00 01 00 01 01 ff ff 00 ff 00 00 00 80 00 00 08 00 20

2233
42 42 00 00 01 01 00 01 01 ff ff 00 ff 00 00 00 80 00 00 08 00 20

4433
42 51 00 00 01 01 00 01 01 ff ff 00 ff 00 00 01 00 00 00 10 00 20

4434
42 52 00 00 01 01 00 01 01 ff ff 00 ff 00 00 01 00 00 00 10 00 20

8535
42 61 00 00 01 01 00 01 01 ff ff 00 ff 00 00 02 00 00 00 20 00 20

tiny11
42 11 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 04 00 20

tiny12
42 12 00 00 00 01 01 01 01 ff ff ff ff 00 00 00 40 00 00 04 00 20

tiny15
42 13 00 00 00 01 01 01 01 ff ff ff ff 00 00 00 40 00 00 04 00 20

tiny22
42 20 00 00 00 01 00 01 01 ff ff 00 ff 00 00 00 80 00 00 08 00 20

tiny28
42 22 00 00 01 00 01 01 01 00 00 00 00 00 00 00 00 00 00 08 00 20

mega32
42 90 00 00 01 01 01 01 02 ff ff ff ff 00 80 04 00 00 00 80 00 20

mega161
42 80 00 00 01 01 01 01 01 ff ff ff ff 00 80 02 00 00 00 40 00 20

mega163
42 81 00 00 01 01 01 01 02 ff ff ff ff 00 80 02 00 00 00 40 00 20

mega103
42 b1 00 00 01 00 00 01 01 00 00 00 00 01 00 10 00 00 02 00 00 20

mega128
42 b2 00 00 01 01 01 01 03 ff ff ff ff 01 00 10 00 00 02 00 00 20