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

View: New views
14 Messages — Rating Filter:   Alert me  

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


URL:
  <http://savannah.nongnu.org/patch/?6866>

                 Summary: bug #26703: [Feature Request] Support device reset
for 'arduino' programmer type
                 Project: AVR Downloader/UploaDEr
            Submitted by: nospam2000
            Submitted on: Do 16 Jul 2009 01:46:25 GMT
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email:
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

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





    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Do 16 Jul 2009 01:46:25 GMT  Name: avrdude_5.8_dtr4.diff  Size: 18kB  
By: nospam2000

<http://savannah.nongnu.org/patch/download.php?file_id=18424>

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6866>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #1, patch #6866 (project avrdude):

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)
    _______________________________________________________

Additional Item Attachment:

File name: avrdude-5.8-dtr-rts-arduino-reset.patch Size:13 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6866>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #2, patch #6866 (project avrdude):

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)
    _______________________________________________________

Additional Item Attachment:

File name: avrdude-5.8-dtr-rts-arduino-reset-2.patch Size:15 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6866>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of patch #6866 (project avrdude):

                  Status:                    None => Ready For Test        
             Assigned to:                    None => mludvig                

    _______________________________________________________

Follow-up 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)
    _______________________________________________________

Additional Item Attachment:

File name: arduino-reset-3.patch          Size:5 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?6866>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #4, patch #6866 (project avrdude):

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.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?6866>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #5, patch #6866 (project avrdude):

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

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6866>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #6, patch #6866 (project avrdude):

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



    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6866>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #7, patch #6866 (project avrdude):

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.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6866>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

avr32 now partially supported

by David Hoerl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I just checked additions to support avr32. Its quite shakey right now,
as it uses many undocumented jtagice-mkii commands with unknown return
codes. Essentially, it mimics what avr32program 4.0.0 does - to the best
of my ability.

At this time, you can burn the flash. It has only been tested with
48,000 byte loads, but the code was modified to handle the full 500,000+
part.

It does not yet support read (or verify).

The syntax for the single hex file I have tested with is:

   avrdude -cjtagmkII_avr32 -Pusb -pucr2 -V -Uflash:w:firmware.hex

Occasionally it fails to fully burn the flash - rerun it and it normally
succeeds the next run.

You can also do a chip_erase:

   avrdude -cjtagmkII_avr32 -Pusb -pucr2 -e

It cannot do a chip_erase AND a burn on the same line - code needs to
prevent the attempt but does not yet.

---

To try it out, you will need to pull source, then bootstrap + configure
+ make - you don't need to install if you put the following in your
.avrduderc file (if you do install it will be in the standard config file)

programmer
   id    = "jtagmkII_avr32";
   desc  = "Atmel JTAG ICE mkII";
   baudrate = 115200;
   type  = jtagmkii_avr32;
;

#------------------------------------------------------------
# AVR32UC3A0512
#------------------------------------------------------------

part
     id = "ucr2";
     desc = "32UC3A0512";
     signature = 0xED 0xC0 0x3F;
     has_jtag = yes;
     is_avr32    = yes;

     memory "flash"
         paged           = yes;
         page_size       = 512;               # bytes
         num_pages       = 1024 ;             # numeric
         size = 0x00080000;
         offset = 0x80000000;
         readsize = 512;
     ;
;


_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #8, patch #6866 (project avrdude):

> 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

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6866>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #9, patch #6866 (project avrdude):

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


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6866>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of patch #6866 (project avrdude):

                  Status:          Ready For Test => Done                  

    _______________________________________________________

Follow-up 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.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6866>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by Sylvain Beucler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #11, patch #6866 (project avrdude):

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


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6866>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

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

by mrtangent :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 6, 2009, at 2:17 PM, Michael Dreher wrote:

> Follow-up Comment #11, patch #6866 (project avrdude):
> ...
> 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);

If it still intended to be 1 second, shouldn't there be three more zeroes (1 million microseconds)?

Cheers,

--Dave

_______________________________________________
avrdude-dev mailing list
avrdude-dev@...
http://lists.nongnu.org/mailman/listinfo/avrdude-dev