07ef7149bc
arduino. tested with a diecimilia. ok ajacoutot
61 lines
1.7 KiB
Plaintext
61 lines
1.7 KiB
Plaintext
$OpenBSD: patch-stk500_c,v 1.1 2008/08/23 07:20:17 ckuethe Exp $
|
|
--- stk500.c.orig Sun Mar 25 22:14:35 2007
|
|
+++ stk500.c Fri Aug 22 20:52:56 2008
|
|
@@ -1220,7 +1220,49 @@ static void stk500_print_parms(PROGRAMMER * pgm)
|
|
stk500_print_parms1(pgm, "");
|
|
}
|
|
|
|
+/* Signature byte reads are always 3 bytes. */
|
|
+static int stk500_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
|
|
+{
|
|
+ unsigned char buf[32];
|
|
+ unsigned char tmp;
|
|
|
|
+ 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;
|
|
+
|
|
+ stk500_send(pgm, buf, 2);
|
|
+
|
|
+ if (stk500_recv(pgm, 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: stk500_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: stk500_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;
|
|
+}
|
|
+
|
|
void stk500_initpgm(PROGRAMMER * pgm)
|
|
{
|
|
strcpy(pgm->type, "STK500");
|
|
@@ -1250,5 +1292,6 @@ void stk500_initpgm(PROGRAMMER * pgm)
|
|
pgm->set_varef = stk500_set_varef;
|
|
pgm->set_fosc = stk500_set_fosc;
|
|
pgm->set_sck_period = stk500_set_sck_period;
|
|
+ pgm->read_sig_bytes = stk500_read_sig_bytes;
|
|
pgm->page_size = 256;
|
|
}
|