From 07ef7149bc9ef6c8b1759b92b1ff7d0bd7ca5d3d Mon Sep 17 00:00:00 2001 From: ckuethe Date: Sat, 23 Aug 2008 07:20:17 +0000 Subject: [PATCH] merge patches from arduino. add a note on how to load code into an arduino. tested with a diecimilia. ok ajacoutot --- devel/avrdude/Makefile | 4 +- devel/avrdude/patches/patch-stk500_c | 60 ++++++++++++++++++++++++++ devel/avrdude/patches/patch-stk500v2_c | 14 ++++++ devel/avrdude/pkg/DESCR | 5 +++ 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 devel/avrdude/patches/patch-stk500_c create mode 100644 devel/avrdude/patches/patch-stk500v2_c diff --git a/devel/avrdude/Makefile b/devel/avrdude/Makefile index 0a093929de4..f327d218bc7 100644 --- a/devel/avrdude/Makefile +++ b/devel/avrdude/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.2 2008/08/21 14:20:12 ckuethe Exp $ +# $OpenBSD: Makefile,v 1.3 2008/08/23 07:20:17 ckuethe Exp $ COMMENT= AVR microcontroller hardware in-system programmer V= 5.5 DISTNAME= avrdude-${V} DISTFILES+= avrdude-doc-${V}.pdf -PKGNAME= ${DISTNAME}p0 +PKGNAME= ${DISTNAME}p1 CATEGORIES= devel HOMEPAGE= http://www.nongnu.org/avrdude/ diff --git a/devel/avrdude/patches/patch-stk500_c b/devel/avrdude/patches/patch-stk500_c new file mode 100644 index 00000000000..860819ec14c --- /dev/null +++ b/devel/avrdude/patches/patch-stk500_c @@ -0,0 +1,60 @@ +$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; + } diff --git a/devel/avrdude/patches/patch-stk500v2_c b/devel/avrdude/patches/patch-stk500v2_c new file mode 100644 index 00000000000..be8f2e23e7d --- /dev/null +++ b/devel/avrdude/patches/patch-stk500v2_c @@ -0,0 +1,14 @@ +$OpenBSD: patch-stk500v2_c,v 1.1 2008/08/23 07:20:17 ckuethe Exp $ +--- stk500v2.c.orig Tue Jan 30 05:41:53 2007 ++++ stk500v2.c Fri Aug 22 20:52:56 2008 +@@ -483,6 +483,10 @@ static int stk500v2_getsync(PROGRAMMER * pgm) { + if (pgmtype == PGMTYPE_JTAGICE_MKII) + return 0; + ++ // my avrispmkii doesn't respond to the sync --dam@mellis.org ++ if (pgmtype == PGMTYPE_AVRISP_MKII) ++ return 0; ++ + retry: + tries++; + diff --git a/devel/avrdude/pkg/DESCR b/devel/avrdude/pkg/DESCR index fcf8cb2ffde..a3f0ec285a8 100644 --- a/devel/avrdude/pkg/DESCR +++ b/devel/avrdude/pkg/DESCR @@ -4,3 +4,8 @@ serial programming protocol, it can program fuse and lock bits. AVRDUDE also supplies a direct instruction mode allowing one to issue any programming instruction to the AVR chip regardless of whether AVRDUDE implements that specific feature of a particular chip. + +If you're planning on programming *duino devices with avrdude, you'll want +to invoke it something like this: + + avrdude -b19200 -P /dev/cuaU0 -c avrisp -p m169 -U flash:w:blink.hex