From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Jul 9 02:10:15 2005 Return-Path: X-Original-To: freebsd-ports-bugs@hub.freebsd.org Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AE62B16A41C for ; Sat, 9 Jul 2005 02:10:15 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2991C43D46 for ; Sat, 9 Jul 2005 02:10:15 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j692AEJg084573 for ; Sat, 9 Jul 2005 02:10:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j692AETg084572; Sat, 9 Jul 2005 02:10:14 GMT (envelope-from gnats) Resent-Date: Sat, 9 Jul 2005 02:10:14 GMT Resent-Message-Id: <200507090210.j692AETg084572@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Erik Greenwald Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6D0EC16A41C for ; Sat, 9 Jul 2005 02:07:14 +0000 (GMT) (envelope-from erik@smluc.org) Received: from phoenix.smluc.org (phoenix.smluc.org [12.28.48.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE75043D45 for ; Sat, 9 Jul 2005 02:07:13 +0000 (GMT) (envelope-from erik@smluc.org) Received: by phoenix.smluc.org (Postfix, from userid 1000) id 88F651CE67; Fri, 8 Jul 2005 21:10:27 -0500 (CDT) Message-Id: <20050709021027.88F651CE67@phoenix.smluc.org> Date: Fri, 8 Jul 2005 21:10:27 -0500 (CDT) From: Erik Greenwald To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: erik@math.smsu.edu Subject: ports/83174: [Maintainer Update] devel/picprog "Werner Almesberger" patch, dev fix X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Erik Greenwald List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2005 02:10:15 -0000 >Number: 83174 >Category: ports >Synopsis: [Maintainer Update] devel/picprog "Werner Almesberger" patch, dev fix >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: maintainer-update >Submitter-Id: current-users >Arrival-Date: Sat Jul 09 02:10:14 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Erik Greenwald >Release: FreeBSD 5.4-RELEASE-p2 i386 >Organization: >Environment: System: FreeBSD fenris 5.4-RELEASE-p2 FreeBSD 5.4-RELEASE-p2 #2: Fri Jun 10 23:00:35 EDT 2005 root@fenris:/usr/obj/usr/src/sys/FENRIS i386 >Description: "Werner Almesberger" patch, which adds a "--slow" argument. Long serial cables and/or JDM programmers seem to need this, my gear (olimex, 6' serial, 16f88's) refuses to work right without it... this is the blurb from the picprog webpage Long cables, different values on capacitors and resistors, and differences on sertial ports can cause very long signal rise and fall times. The JDM device is sensitive to that, and mostly is designed to be connected directly to computer or with very short cable. The sensitivity also depends on the PIC chip type. It may help to stretch the delays in Picprog to allow for longer signal settling times. For example this patch by Werner Almesberger, picprog-1.7-werner-almesberger.diff, gives good example on how to accomodate longer delays. Larger delays are needed also for the uJDM programmer device. additionally, I changed the default device from ttyS0 to cuaa0 (seems to be the first serial on my 5.4 box, tho my 6 box says cuad0) >How-To-Repeat: >Fix: --- devel-picprog.patch begins here --- Index: devel/picprog/Makefile =================================================================== RCS file: /home/ncvs/ports/devel/picprog/Makefile,v retrieving revision 1.12 diff -u -r1.12 Makefile --- devel/picprog/Makefile 25 May 2005 09:21:12 -0000 1.12 +++ devel/picprog/Makefile 9 Jul 2005 02:05:49 -0000 @@ -7,6 +7,7 @@ PORTNAME= picprog PORTVERSION= 1.7 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= http://hyvatti.iki.fi/~jaakko/pic/ Index: devel/picprog/files/patch-main.cc =================================================================== RCS file: /home/ncvs/ports/devel/picprog/files/patch-main.cc,v retrieving revision 1.2 diff -u -r1.2 patch-main.cc --- devel/picprog/files/patch-main.cc 19 Nov 2002 01:59:27 -0000 1.2 +++ devel/picprog/files/patch-main.cc 9 Jul 2005 02:05:49 -0000 @@ -1,10 +1,49 @@ ---- main.cc.orig Tue Nov 19 12:50:51 2002 -+++ main.cc Tue Nov 19 12:51:11 2002 -@@ -32,6 +32,7 @@ +--- main.cc.orig Thu Apr 29 00:41:25 2004 ++++ main.cc Fri Jul 8 22:02:29 2005 +@@ -31,6 +31,7 @@ #include #include +#define HAVE_DECL_GETOPT 1 #include + #include - #include "hexfile.h" +@@ -41,7 +42,7 @@ + + program prog; + +-char short_opts [] = "d:p:i:o:c:qh?"; ++char short_opts [] = "d:p:i:o:c:qsh?"; + + int + main (int argc, char **argv) +@@ -52,7 +53,7 @@ + int opt_usage = 0; + + int opt_format = hexfile::unknown; +- char *opt_port = (char *)"/dev/ttyS0"; ++ char *opt_port = (char *)"/dev/cuaa0"; + char *opt_input = NULL; + char *opt_output = NULL; + char *opt_cc = NULL; +@@ -81,6 +82,7 @@ + {"erase", no_argument, &opt_erase, 1}, + {"burn", no_argument, &opt_burn, 1}, + {"force-calibration", no_argument, &opt_calibration, 1}, ++ {"slow", no_argument, NULL, 's'}, + {0, 0, 0, 0} + }; + +@@ -113,6 +115,12 @@ + case 'q': + opt_quiet = 1; + break; ++ case 's': ++ // Add extra delays for capacity added by very long cable ++ picport::t_edge = 10; // 10 us ++ picport::t_on = 200000; // 200 ms ++ picport::t_off = 700000; // 700 ms - I'm not kidding ! ++ break; + default: // -? -h --help unknown flag + opt_usage = 1; + } Index: devel/picprog/files/patch-picport.cc =================================================================== RCS file: /home/ncvs/ports/devel/picprog/files/patch-picport.cc,v retrieving revision 1.4 diff -u -r1.4 patch-picport.cc --- devel/picprog/files/patch-picport.cc 25 May 2005 09:21:12 -0000 1.4 +++ devel/picprog/files/patch-picport.cc 9 Jul 2005 02:05:49 -0000 @@ -1,5 +1,5 @@ ---- picport.cc.orig Thu Apr 29 06:08:10 2004 -+++ picport.cc Wed May 25 11:09:06 2005 +--- picport.cc.orig Thu Apr 29 00:08:10 2004 ++++ picport.cc Fri Jul 8 21:46:07 2005 @@ -40,7 +40,7 @@ #include #include @@ -9,3 +9,81 @@ #include #include "picport.h" +@@ -54,6 +54,11 @@ + unsigned int picport::tsc_1000ns = 0; + int picport::use_nanosleep = -1; + ++// Extra delays for long cables, in us ++int picport::t_on = 0; ++int picport::t_off = 0; ++int picport::t_edge = 0; ++ + void + picport::set_clock_data (int rts, int dtr) + { +@@ -102,7 +107,7 @@ + // Before first call to set_clock_data, read the modem status. + ioctl (fd, TIOCMGET, &modembits); + set_clock_data (0, 0); +- usleep (50); ++ usleep (50+t_edge); + // Check the CTS. If it is up, even when we just lowered DTR, + // we probably are not talking to a JDM type programmer. + int i; +@@ -200,13 +205,13 @@ + cerr << "Unable to start break on tty " << tty << ":" << strerror (e) << endl; + exit (EX_IOERR); + } +- usleep (10); ++ usleep (10+t_off); + } + + picport::~picport () + { + ioctl (fd, TIOCCBRK, 0); +- usleep (1); ++ usleep (1+t_off); + tcsetattr (fd, TCSANOW, &saved); + close (fd); + delete [] portname; +@@ -216,15 +221,15 @@ + { + set_clock_data (0, 0); + ioctl (fd, TIOCCBRK, 0); +- usleep (50); ++ usleep (50+t_off); + ioctl (fd, TIOCSBRK, 0); +- usleep (10); ++ usleep (10+t_on); + addr = 0; + } + + void picport::delay (long ns) + { +- if (1 == use_nanosleep) { ++ if (1 == use_nanosleep && !t_edge) { + timespec ts = {ns / 1000000000, ns % 1000000000}, ts2; + while (nanosleep (&ts, &ts2) && EINTR == errno) + ts = ts2; +@@ -232,7 +237,7 @@ + } + + #ifdef RDTSC_WORKS +- if (tsc_1000ns > 1) { ++ if (tsc_1000ns > 1 && !t_edge) { + unsigned long a1, d1, a2, d2; + asm volatile("rdtsc":"=a" (a1), "=d" (d1)); + d2 = d1; +@@ -259,10 +264,10 @@ + volatile int i; + gettimeofday (&tv1, 0); + tv2.tv_sec = tv1.tv_sec; +- tv2.tv_usec = 0xffffffff & (tv1.tv_usec + 1 + (ns + 999)/1000); ++ tv2.tv_usec = 0xffffffff & (tv1.tv_usec + 1 + (ns + 999)/1000+t_edge); + if (tv2.tv_usec < tv1.tv_usec) + tv2.tv_sec++; +- for (i = 0; i < 10000; i++) { ++ for (i = 0; i < 10000 || t_edge; i++) { + gettimeofday (&tv1, 0); + if (tv1.tv_sec > tv2.tv_sec + || tv1.tv_sec == tv2.tv_sec && tv1.tv_usec >= tv2.tv_usec) Index: devel/picprog/files/patch-picport.h =================================================================== RCS file: devel/picprog/files/patch-picport.h diff -N devel/picprog/files/patch-picport.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ devel/picprog/files/patch-picport.h 9 Jul 2005 02:05:49 -0000 @@ -0,0 +1,13 @@ +--- picport.h.orig Thu Apr 29 00:09:38 2004 ++++ picport.h Fri Jul 8 21:46:07 2005 +@@ -59,6 +59,10 @@ + + public: + ++ static int t_on; ++ static int t_off; ++ static int t_edge; ++ + static void delay (long ns); + + enum commands { Index: devel/picprog/files/patch-program.h =================================================================== RCS file: /home/ncvs/ports/devel/picprog/files/patch-program.h,v retrieving revision 1.2 diff -u -r1.2 patch-program.h --- devel/picprog/files/patch-program.h 19 Nov 2002 01:59:27 -0000 1.2 +++ devel/picprog/files/patch-program.h 9 Jul 2005 02:05:49 -0000 @@ -1,6 +1,6 @@ ---- program.h.orig Tue Nov 19 12:53:12 2002 -+++ program.h Tue Nov 19 12:53:20 2002 -@@ -31,6 +31,7 @@ +--- program.h.orig Thu Jan 1 20:35:09 2004 ++++ program.h Fri Jul 8 21:44:23 2005 +@@ -30,6 +30,7 @@ #ifndef H_PROGRAM #define H_PROGRAM --- devel-picprog.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: