-
Notifications
You must be signed in to change notification settings - Fork 25
/
avrdude.patch
319 lines (311 loc) · 10.1 KB
/
avrdude.patch
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
diff --git a/avrdude.conf.in b/avrdude.conf.in
index 0485e5b..813ff4c 100644
--- a/avrdude.conf.in
+++ b/avrdude.conf.in
@@ -718,6 +718,27 @@ programmer
;
programmer
+ id = "scratchmonkey";
+ desc = "ScratchMonkey";
+ type = "scratchmonkey";
+ connection_type = serial;
+;
+
+programmer
+ id = "scratchmonkey_pp";
+ desc = "ScratchMonkey in parallel programming mode";
+ type = "scratchmonkey_pp";
+ connection_type = serial;
+;
+
+programmer
+ id = "scratchmonkey_hvsp";
+ desc = "ScratchMonkey in high-voltage serial programming mode";
+ type = "scratchmonkey_hvsp";
+ connection_type = serial;
+;
+
+programmer
id = "avr910";
desc = "Atmel Low Cost Serial Programmer";
type = "avr910";
diff --git a/pgm_type.c b/pgm_type.c
index 7724987..cce963b 100644
--- a/pgm_type.c
+++ b/pgm_type.c
@@ -82,6 +82,9 @@ const PROGRAMMER_TYPE programmers_types[] = {
{"linuxgpio", linuxgpio_initpgm, linuxgpio_desc},
{"par", par_initpgm, par_desc},
{"pickit2", pickit2_initpgm, pickit2_desc},
+ {"scratchmonkey", stk500v2_scratchmonkey_initpgm, stk500v2_scratchmonkey_desc},
+ {"scratchmonkey_hvsp", stk500v2_scratchmonkey_hvsp_initpgm, stk500v2_scratchmonkey_hvsp_desc},
+ {"scratchmonkey_pp", stk500v2_scratchmonkey_pp_initpgm, stk500v2_scratchmonkey_pp_desc},
{"serbb", serbb_initpgm, serbb_desc},
{"stk500", stk500_initpgm, stk500_desc},
{"stk500generic", stk500generic_initpgm, stk500generic_desc},
diff --git a/stk500v2.c b/stk500v2.c
index 5f1f79e..cd504bb 100644
--- a/stk500v2.c
+++ b/stk500v2.c
@@ -117,6 +117,7 @@ static const char *pgmname[] =
"JTAG ICE mkII",
"STK600",
"JTAGICE3",
+ "ScratchMonkey",
};
struct jtagispentry
@@ -776,6 +777,9 @@ retry:
} else if (siglen >= strlen("STK600") &&
memcmp(resp + 3, "STK600", strlen("STK600")) == 0) {
PDATA(pgm)->pgmtype = PGMTYPE_STK600;
+ } else if (siglen >= strlen("SCRATCHMONKEY") &&
+ memcmp(resp + 3, "SCRATCHMONKEY", strlen("SCRATCHMONKEY")) == 0) {
+ PDATA(pgm)->pgmtype = PGMTYPE_SCRATCHMONKEY;
} else {
resp[siglen + 3] = 0;
avrdude_message(MSG_NOTICE, "%s: stk500v2_getsync(): got response from unknown "
@@ -1259,7 +1263,8 @@ 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
+ PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII ||
+ PDATA(pgm)->pgmtype == PGMTYPE_SCRATCHMONKEY) != 0
&& (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_TPI)) != 0) {
/*
* This is an ATxmega device, must use XPROG protocol for the
@@ -2327,7 +2332,7 @@ static int stk500v2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
commandbuf[6] = cmds[0];
// otherwise, we need to load different commands in
- }
+ }
else {
commandbuf[3] = m->mode | 0x80; // yes, write the words to flash
@@ -4300,6 +4305,58 @@ static int stk600_xprog_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return 0;
}
+enum {
+ PARAM_SCRATCHMONKEY_STATUS_LEDS = 0x2A,
+ SCRATCHMONKEY_RDY_LED = 1<<0,
+ SCRATCHMONKEY_PGM_LED = 1<<1,
+ SCRATCHMONKEY_VFY_LED = 1<<2,
+ SCRATCHMONKEY_ERR_LED = 1<<3,
+};
+
+static int scratchmonkey_leds = 0;
+
+static void scratchmonkey_led_state(PROGRAMMER * pgm, int flag, int value)
+{
+ int new_leds = scratchmonkey_leds;
+ if (value)
+ new_leds |= flag;
+ else
+ new_leds &= ~flag;
+
+ if (new_leds != scratchmonkey_leds) {
+ scratchmonkey_leds = new_leds;
+ stk500v2_setparm_real(pgm, PARAM_SCRATCHMONKEY_STATUS_LEDS, scratchmonkey_leds);
+ }
+}
+
+static int scratchmonkey_rdy_led(struct programmer_t * pgm, int value)
+{
+ scratchmonkey_led_state(pgm, SCRATCHMONKEY_RDY_LED, value);
+
+ return 0;
+}
+
+static int scratchmonkey_pgm_led(struct programmer_t * pgm, int value)
+{
+ scratchmonkey_led_state(pgm, SCRATCHMONKEY_PGM_LED, value);
+
+ return 0;
+}
+
+static int scratchmonkey_vfy_led(struct programmer_t * pgm, int value)
+{
+ scratchmonkey_led_state(pgm, SCRATCHMONKEY_VFY_LED, value);
+
+ return 0;
+}
+
+static int scratchmonkey_err_led(struct programmer_t * pgm, int value)
+{
+ scratchmonkey_led_state(pgm, SCRATCHMONKEY_ERR_LED, value);
+
+ return 0;
+}
+
/*
* Modify pgm's methods for XPROG operation.
*/
@@ -4721,3 +4778,134 @@ void stk500v2_jtag3_initpgm(PROGRAMMER * pgm)
pgm->page_size = 256;
}
+const char stk500v2_scratchmonkey_desc[] = "ScratchMonkey V2 in ISP/TPI/PDI mode";
+
+void stk500v2_scratchmonkey_initpgm(PROGRAMMER * pgm)
+{
+ strcpy(pgm->type, "SCRATCHMONKEY");
+
+ /*
+ * 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;
+
+ /*
+ * We provide LEDs if we have enough pins available
+ */
+ pgm->rdy_led = scratchmonkey_rdy_led;
+ pgm->err_led = scratchmonkey_err_led;
+ pgm->pgm_led = scratchmonkey_pgm_led;
+ pgm->vfy_led = scratchmonkey_vfy_led;
+}
+
+const char stk500v2_scratchmonkey_pp_desc[] = "ScratchMonkey V2 in parallel programming mode";
+
+void stk500v2_scratchmonkey_pp_initpgm(PROGRAMMER * pgm)
+{
+ strcpy(pgm->type, "SCRATCHMONKEY_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_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;
+
+ /*
+ * We provide LEDs if we have enough pins available
+ */
+ pgm->rdy_led = scratchmonkey_rdy_led;
+ pgm->err_led = scratchmonkey_err_led;
+ pgm->pgm_led = scratchmonkey_pgm_led;
+ pgm->vfy_led = scratchmonkey_vfy_led;
+}
+
+const char stk500v2_scratchmonkey_hvsp_desc[] = "ScratchMonkey V2 in high-voltage serial programming mode";
+
+void stk500v2_scratchmonkey_hvsp_initpgm(PROGRAMMER * pgm)
+{
+ strcpy(pgm->type, "SCRATCHMONKEY_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_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;
+
+ /*
+ * We provide LEDs if we have enough pins available
+ */
+ pgm->rdy_led = scratchmonkey_rdy_led;
+ pgm->err_led = scratchmonkey_err_led;
+ pgm->pgm_led = scratchmonkey_pgm_led;
+ pgm->vfy_led = scratchmonkey_vfy_led;
+}
diff --git a/stk500v2.h b/stk500v2.h
index c56056b..c591b55 100644
--- a/stk500v2.h
+++ b/stk500v2.h
@@ -34,6 +34,9 @@ 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 stk500v2_scratchmonkey_desc[];
+extern const char stk500v2_scratchmonkey_pp_desc[];
+extern const char stk500v2_scratchmonkey_hvsp_desc[];
extern const char stk600_desc[];
extern const char stk600hvsp_desc[];
extern const char stk600pp_desc[];
@@ -45,6 +48,9 @@ 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 stk500v2_scratchmonkey_initpgm(PROGRAMMER * pgm);
+void stk500v2_scratchmonkey_hvsp_initpgm(PROGRAMMER * pgm);
+void stk500v2_scratchmonkey_pp_initpgm(PROGRAMMER * pgm);
void stk600_initpgm (PROGRAMMER * pgm);
void stk600hvsp_initpgm (PROGRAMMER * pgm);
void stk600pp_initpgm (PROGRAMMER * pgm);
diff --git a/stk500v2_private.h b/stk500v2_private.h
index 2ac0d05..ed37f78 100644
--- a/stk500v2_private.h
+++ b/stk500v2_private.h
@@ -308,7 +308,8 @@ struct pdata
PGMTYPE_AVRISP_MKII,
PGMTYPE_JTAGICE_MKII,
PGMTYPE_STK600,
- PGMTYPE_JTAGICE3
+ PGMTYPE_JTAGICE3,
+ PGMTYPE_SCRATCHMONKEY,
}
pgmtype;