patchAVR Downloader/UploaDEr - Patches: patch #6866, bug #26703: [Feature Request]...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #6866: bug #26703: [Feature Request] Support device reset for 'arduino' programmer type

Submitter:  Michael Dreher <nospam2000>
Submitted:  Thu 16 Jul 2009 01:46:25 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  mludvig Open/Closed:  Closed

Jump to the original submission

Sun 13 Dec 2009 12:09:34 PM UTC, comment #12: 

Can I add this feature (I created patches diffing directly the svn files and 5.8 release) to the avrdude macport as a variant?

Massimo <runaway>
Fri 06 Nov 2009 10:17:16 PM UTC, comment #11: 

Hi Michal,

I successfully tested svn revision 878 on Windows with the following devices:

  • Arduino-BT (with DIY auto-reset)
  • Arduino Duemilanove with ATmega168
  • Arduino Duemilanove with ATmega328


To compile this version, I had to make the following change, because sleep() is not available on the Win32 platform:

Index: jtagmkII.c
===================================================================
--- jtagmkII.c (revision 878)
+++ jtagmkII.c (working copy)
@@ -2847,7 +2847,7 @@
   status = jtagmkII_write_SABaddr(pgm, 0xffff0c00, 0x05, 0x0000004); if(status < 0) {lineno = _LINE_; goto eRR;} // Power Manager
   status = jtagmkII_write_SABaddr(pgm, 0xffff0c00, 0x05, 0x0000005); if(status < 0) {lineno = _LINE_; goto eRR;}
 
-  sleep(1);
+  usleep(1*1000);
  
   val = jtagmkII_read_SABaddr(pgm, 0xfffe1408, 0x05); if(val != 0x0000a001) {lineno = _LINE_; goto eRR;} // PLL 0
 

   Michael

Michael Dreher <nospam2000>
Mon 02 Nov 2009 11:58:52 PM UTC, comment #10: 

Hi Michael,

your last patch is in SVN now. Works for me with Duemilanove on Linux. Hope it won't break things for other arduino users.

Michal Ludvig <mludvig>
Mon 12 Oct 2009 06:53:47 PM UTC, comment #9: 

Hi Michal,

 > Is it safe to do it like this?

No, it has to be done when closing the port, not in the open() function:

--- arduino.c.orig      2009-10-10 10:26:40 +0200
+++ arduino.c   2009-10-12 20:35:33 +0200
@@ -107,6 +107,14 @@
 }


+static void arduino_close(PROGRAMMER * pgm)
+{
+  serial_set_dtr_rts(&pgm->fd, 0);
+  serial_close(&pgm->fd);
+  pgm->fd.ifd = -1;
+}
+
+
 void arduino_initpgm(PROGRAMMER * pgm)
 {
        /* This is mostly a STK500; just the signature is read
@@ -118,4 +126,7 @@
   strcpy(pgm->type, "Arduino");
   pgm->read_sig_bytes = arduino_read_sig_bytes;
   pgm->open = arduino_open;
+  pgm->close = arduino_close;
 }
+

  Michael

Michael Dreher <nospam2000>
Mon 12 Oct 2009 08:30:36 AM UTC, comment #8: 


> there is a little typo in ser_win32.c


Fixed in SVN.

> Please add a CLEARDTR and CLEARRTS when closing the port.


Is it safe to do it like this?

--- arduino.c   (revision 864)
+++ arduino.c   (working copy)
@@ -92,8 +92,11 @@ static int arduino_open(PROGRAMMER pgm, char p
   serial_set_dtr_rts(&pgm->fd, 0);
   usleep(50*1000);
   /* Set DTR and RTS high to trigger reset */
   serial_set_dtr_rts(&pgm->fd, 1);
   usleep(50*1000);
+  /* Bring DTR and RTS back low */
+  serial_set_dtr_rts(&pgm->fd, 0);
+  usleep(50*1000);

I.e. First of all CLRRTS|CLRDTR, then SETDTR|SETRTS and then back to CLRRTS|CLRDTR, all in arduino_open()?

Michal

Michal Ludvig <mludvig>
Sat 10 Oct 2009 03:14:25 PM UTC, comment #7: 

Once I corrected the typo (fdp -> fd), the version in SVN (r. 845) worked fine for me on Windows Vista and Mac OS X 10.6 (Snow Leopard).  I tried both with boards that use DTR and ones that use RTS for reset.

David A. Mellis <mellis>
Sat 10 Oct 2009 12:45:21 PM UTC, comment #6: 

Hi Michal,

there is a little typo in ser_win32.c. The filedescriptor parameter is named "fdp" instead of "fd" which prohibts compiling it.

original:
static int ser_set_dtr_rts(union filedescriptor *fdp, int is_on)

changed:
static int ser_set_dtr_rts(union filedescriptor *fd, int is_on)

The current CVS version (845) does not reset DTR when closing the serial port under Windows. This leaves the DTR signal at the WT-11 bluetooth chip at a high level. Other serial port hardware+drivers+OS combinations like the FTDI chip on the Duemilanove behave differently.

Please add a CLEARDTR and CLEARRTS when closing the port.

Another potential problem is, that ser_setspeed() will always reset DTR and RTS, but it should keep their values. So the result depends on the order between calling ser_setspeed() and set_set_dtr_rts(). That was something I also forgot in my patch.

  Michael


Michael Dreher <nospam2000>
Sat 10 Oct 2009 01:48:07 AM UTC, comment #5: 

DTR/RTS reset support is in SVN now (r845). Please test it on Windows.

Michal Ludvig <mludvig>
Thu 08 Oct 2009 12:59:43 PM UTC, comment #4: 

It didn't work here because I managed to destroy the bootloader on my Arduino. Now it's flashed back (using BusPirate programmer ;-) and all is good again.

avrdude -c arduino works for me with the proposed arduino-reset-3.patch. Tested in Linux with Arduino Duemilanove. Can someone test it on Windows please?

N.

Michal Ludvig <mludvig>
Thu 08 Oct 2009 12:15:00 PM UTC, comment #3: 

David, can you give the attached patch (arduino-reset-3.patch) a try please? I cleaned up your patch a little bit and want to make sure that it still works.

(it doesn't work on my Arduino board but neither does Arduino IDE so I suspect there's something wrong with my board).

(file #18832)

Michal Ludvig <mludvig>
Sun 16 Aug 2009 11:22:57 AM UTC, comment #2: 

Here's an updated patch with the RTS constant and function name changed to correspond to the new function (set instead of pulse).  I also tested on Linux and this seems to work well with all the Arduino boards I tried.

(file #18582)

David A. Mellis <mellis>
Sat 15 Aug 2009 10:18:50 PM UTC, comment #1: 

This didn't work for me with an Arduino Pro (ATmega168 at 3.3V / 8 MHz) and an FTDI USB-TTL Serial cable (which should use RTS for reset) on Mac OS X (10.5.7) or Windows Vista Home Premium.  Setups involving DTR were fine (e.g. the Arduino Pro w/ a SparkFun FTDI Basic Breakout or an Arduino Duemilanove).  I believe that RTS should be treated the same way as DTR, i.e. set on the start of the upload.  Attached is a revised patch.  I'll try to test on Linux soon.

(file #18579)

David A. Mellis <mellis>
Thu 16 Jul 2009 01:46:25 AM UTC, original submission:  

Supports Auto-Reset for Arduino board. Both strategies (DTR and RTS) are supported under Win32 and posix platform. When you use the programmer type "arduino" this feature is activated, otherwise it is switched off.

A special version for the Arduino is no longer needed.

The patch has been made for avrdude V5.8


Michael Dreher <nospam2000>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #18832:  arduino-reset-3.patch added by mludvig (5KiB - text/x-patch)
file #18582:  avrdude-5.8-dtr-rts-arduino-reset-2.patch added by mellis (15KiB - application/octet-stream)
file #18579:  avrdude-5.8-dtr-rts-arduino-reset.patch added by mellis (13KiB - application/octet-stream)
file #18424:  avrdude_5.8_dtr4.diff added by nospam2000 (18KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by joerg_wunsch (Updated the item)
  • -email is unavailable- added by runaway (Posted a comment)
  • -email is unavailable- added by mludvig (Updated the item)
  • -email is unavailable- added by mellis (Updated the item)
  • -email is unavailable- added by nospam2000 (Submitted the item)
  • -email is unavailable- added by nospam2000
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-01-08 joerg_wunsch Open/ClosedOpen Closed
    2009-11-02 mludvig StatusReady For Test Done
    2009-10-08 mludvig Attached File- Added arduino-reset-3.patch, #18832
        StatusNone Ready For Test
        Assigned toNone mludvig
    2009-08-16 mellis Attached File- Added avrdude-5.8-dtr-rts-arduino-reset-2.patch, #18582
    2009-08-15 mellis Attached File- Added avrdude-5.8-dtr-rts-arduino-reset.patch, #18579
    2009-07-16 nospam2000 Attached File- Added avrdude_5.8_dtr4.diff, #18424
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code