Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Jan 2012 05:15:50 GMT
From:      bob frazier <bobf@mrp3.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/163749: devel/avrdude fails to reset RTS/DTR properly for Arduino Uno in 8-STABLE/amd64
Message-ID:  <201201010515.q015Fogn073222@red.freebsd.org>
Resent-Message-ID: <201201010520.q015KCd7061559@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         163749
>Category:       ports
>Synopsis:       devel/avrdude fails to reset RTS/DTR properly for Arduino Uno in 8-STABLE/amd64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 01 05:20:11 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     bob frazier
>Release:        8.2-STABLE amd64
>Organization:
S.F.T. Inc.
>Environment:
FreeBSD hack.SFT.local 8.2-STABLE FreeBSD 8.2-STABLE #0: Wed Dec 28 03:04:48 PST 2011     root@hack.SFT.local:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
when attempting to program an Arduino Uno (using comms/uarduno driver) in 8.2-STABLE with the latest avrdude and Arduino 1.0 environment the Arduino Uno does not properly reset, resulting in an inability to program the device.

This problem does NOT occur in 7.2 (which uses libusb), nor does it occur when I flash an 'arduino clone' board using a different board setting and driver.

A patch to avrdude corrects the problem by setting the RTS/DTR lines high BEFORE setting them low, then back to high again.  This guarantees a proper high to low transition that is apparently needed to discharge the reset capacitor properly.


>How-To-Repeat:
attempt to program an Arduino Uno using the Arduino 1.0 development environment

>Fix:
the patch file (attached) modifies arduino.c to force the RTS and DTR lines _HIGH_ before setting them to low (guaranteeing you get the high to low transition that is needed to discharge the reset capacitor).  Otherwise the code appears to rely on the lines being set high on open.  For some reason this problem did not occur in the earlier development environment, nor when the libusb port is being used (as it is on 7.2-STABLE)



Patch attached with submission follows:

--- arduino.c.orig	2011-12-31 21:00:47.000000000 -0800
+++ arduino.c	2011-12-31 21:01:09.000000000 -0800
@@ -88,10 +88,13 @@
   strcpy(pgm->port, port);
   if (serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &pgm->fd)==-1) {
     return -1;
   }
 
+  /* Set DTR and RTS to high before I do anything else (BBB mod) */
+  serial_set_dtr_rts(&pgm->fd, 1);
+  usleep(50*1000);
   /* Clear DTR and RTS to unload the RESET capacitor 
    * (for example in Arduino) */
   serial_set_dtr_rts(&pgm->fd, 0);
   usleep(50*1000);
   /* Set DTR and RTS back to high */


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201010515.q015Fogn073222>