Reset function for arduino

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

Reset function for arduino

by Josef Wolf :: Rate this Message:

| View Threaded | Show Only this Message

Hello,

The reset function for the arduino board seems not to be quite correct, IMHO.

The arduino_open() function, as implemented, leaves the *DTR and *RTS lines on
the TTL side in low level, causing the board to be in reset state permanently
if the board contains only the resistor without a capacitor (for example
arduino NG or Diecimila)

  http://arduino.cc/en/uploads/Main/arduino_NG_schematic.png
  http://arduino.cc/en/uploads/Main/Arduino-Diecimila-schematic.pdf

I would suggest to let the *RTS and *DTR lines go to high again after reset,
so the chip can actually run regardless whether there is a capacitor or a
resistor used to attach to the *RESET input.

The attached patch works for me with both types of boards, no matter whether a
resistor is used or a capacitor.

Opinions?

Index: arduino.c
===================================================================
--- arduino.c   (Revision 947)
+++ arduino.c   (Arbeitskopie)
@@ -92,8 +92,15 @@
    * (for example in Arduino) */
   serial_set_dtr_rts(&pgm->fd, 0);
   usleep(50*1000);
-  /* Set DTR and RTS back to high */
+
+  /* Set DTR and RTS back to high to assert RESET */
   serial_set_dtr_rts(&pgm->fd, 1);
+  usleep(5*1000);
+
+  /* Clear DTR and RTS again, so the chip can run even when a resistor is
+     used instead of a capacitor
+  */
+  serial_set_dtr_rts(&pgm->fd, 0);
   usleep(50*1000);

   /*

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

Re: Reset function for arduino

by mellis :: Rate this Message:

| View Threaded | Show Only this Message

Hi,

All of the Arduino boards we've shipped with auto-reset have used a
capacitor, not a resistor, to connect RTS/DTR to the microcontroller's
reset pin, so I'm not sure this is necessary.

Also, which operating systems have you tested this on?  Do they all
allow raising and lowering of the line once the serial device is open?

David

On Tue, Aug 24, 2010 at 5:17 PM, Josef Wolf <jw@...> wrote:

> Hello,
>
> The reset function for the arduino board seems not to be quite correct, IMHO.
>
> The arduino_open() function, as implemented, leaves the *DTR and *RTS lines on
> the TTL side in low level, causing the board to be in reset state permanently
> if the board contains only the resistor without a capacitor (for example
> arduino NG or Diecimila)
>
>  http://arduino.cc/en/uploads/Main/arduino_NG_schematic.png
>  http://arduino.cc/en/uploads/Main/Arduino-Diecimila-schematic.pdf
>
> I would suggest to let the *RTS and *DTR lines go to high again after reset,
> so the chip can actually run regardless whether there is a capacitor or a
> resistor used to attach to the *RESET input.
>
> The attached patch works for me with both types of boards, no matter whether a
> resistor is used or a capacitor.
>
> Opinions?
>
> Index: arduino.c
> ===================================================================
> --- arduino.c   (Revision 947)
> +++ arduino.c   (Arbeitskopie)
> @@ -92,8 +92,15 @@
>    * (for example in Arduino) */
>   serial_set_dtr_rts(&pgm->fd, 0);
>   usleep(50*1000);
> -  /* Set DTR and RTS back to high */
> +
> +  /* Set DTR and RTS back to high to assert RESET */
>   serial_set_dtr_rts(&pgm->fd, 1);
> +  usleep(5*1000);
> +
> +  /* Clear DTR and RTS again, so the chip can run even when a resistor is
> +     used instead of a capacitor
> +  */
> +  serial_set_dtr_rts(&pgm->fd, 0);
>   usleep(50*1000);
>
>   /*
>
> _______________________________________________
> avrdude-dev mailing list
> avrdude-dev@...
> http://lists.nongnu.org/mailman/listinfo/avrdude-dev
>

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

Re: Reset function for arduino

by Josef Wolf :: Rate this Message:

| View Threaded | Show Only this Message

On Tue, Aug 24, 2010 at 05:17:39PM +0200, Josef Wolf wrote:

> The reset function for the arduino board seems not to be quite correct, IMHO.
>
> The arduino_open() function, as implemented, leaves the *DTR and *RTS lines on
> the TTL side in low level, causing the board to be in reset state permanently
> if the board contains only the resistor without a capacitor (for example
> arduino NG or Diecimila)
>
>   http://arduino.cc/en/uploads/Main/arduino_NG_schematic.png
>   http://arduino.cc/en/uploads/Main/Arduino-Diecimila-schematic.pdf
>
> I would suggest to let the *RTS and *DTR lines go to high again after reset,
> so the chip can actually run regardless whether there is a capacitor or a
> resistor used to attach to the *RESET input.
>
> The attached patch works for me with both types of boards, no matter
> whether a resistor is used or a capacitor.

I get much more reliable results when I shorten the reset pulse to 50us.

With a pulse width of more than 3*1000us, the upload procedure gets very
unreliable. That's probably because the charge curve starts rising quite
fast and (in the worst case) 0.2Vcc (that is, 1V when Vcc==5V) is enough
to end the reset cycle. Thus, the chip can start running long before the
50*1000us have passed.

The data sheet says 2.5us is the minimum pulse width, so 50us should have
enough reserve to accomplish for USB delays.

Below is the updated patch. Please comment.

Index: avrdude/arduino.c
===================================================================
--- avrdude/arduino.c   (Revision 947)
+++ avrdude/arduino.c   (Arbeitskopie)
@@ -92,10 +92,17 @@
    * (for example in Arduino) */
   serial_set_dtr_rts(&pgm->fd, 0);
   usleep(50*1000);
-  /* Set DTR and RTS back to high */
+
+  /* Set DTR and RTS back to high to assert RESET */
   serial_set_dtr_rts(&pgm->fd, 1);
-  usleep(50*1000);
+  usleep(50);
 
+  /* Clear DTR and RTS again, so the chip can run even when a resistor is
+     used instead of a capacitor
+  */
+  serial_set_dtr_rts(&pgm->fd, 0);
+  usleep(50);
+
   /*
    * drain any extraneous input
    */

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

Parent Message unknown Re: Reset function for arduino

by Josef Wolf :: Rate this Message:

| View Threaded | Show Only this Message

On Tue, Aug 24, 2010 at 08:38:13PM +0200, David A. Mellis wrote:

> All of the Arduino boards we've shipped with auto-reset have used a
> capacitor, not a resistor, to connect RTS/DTR to the microcontroller's reset
> pin, so I'm not sure this is necessary.

Well, I see lots of schematics (e.g. the NG, the Diecimila) with a resistor
instead of a capacitor. And people keep having problems. One of the recent
examples is http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1280814595
I have purchased such a cable, and indeed, I had similar problems.

> Also, which operating systems have you tested this on?

I tested on opensuse and ubuntu. Same results.

> Do they all allow
> raising and lowering of the line once the serial device is open?

If an OS does not allow this, current code will not work anyway on that OS.

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

Re: Reset function for arduino

by uracolix :: Rate this Message:

| View Threaded | Show Only this Message


Am Dienstag, 24. August 2010 20:40:18 schrieb David A. Mellis:
> All of the Arduino boards we've shipped with auto-reset have used a
> capacitor, not a resistor, to connect RTS/DTR to the microcontroller's
> reset pin, so I'm not sure this is necessary.

I recently stumbled across this effect too. I have an
arduino-2009 clone with capacitor for auto reset. The reset
signal looks reasonable at the scope.

For one trial after plugin I'm able to programm the target, for
the next trial, the handshake lines seems to be left in a wrong state.

A little Python snippet helps me to overcome this issue, but thats
not the intented use of Arduino.

===========
import sys, serial
try:
    PORT = sys.argv[1]
except:
    PORT = "/dev/ttyUSB2"
s = serial.Serial(PORT)
s.setDTR(0)
s.setRTS(0)
===========

This happens with avrdude: Version 5.8, compiled on Dec 23 2009 at 21:39:05

Cheers, Axel

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

Re: Reset function for arduino

by Joerg Wunsch :: Rate this Message:

| View Threaded | Show Only this Message

As uracolix@... wrote:

> For one trial after plugin I'm able to programm the target, for
> the next trial, the handshake lines seems to be left in a wrong state.

Would the suggested patch fix your issue as well?

--
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

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

Re: Reset function for arduino

by mellis :: Rate this Message:

| View Threaded | Show Only this Message

The schematics may have a resistor, but the boards shipped with a
capacitor or nothing at all.  We've never used a resistor to connect
RTS/DTR and RESET.

The problems that people have been having are because the Arduino IDE
currently uses the "stk500v1" protocol in avrdude, which doesn't
handle reset of RTS and DTR, not the "arduino" protocol that does.
These problems should go away in Arduino 0019, in which the IDE will
toggle both lines before doing uploading.  This is the same problem,
I'm guessing, that Axel is having, which should go away with recent
versions of avrdude that assert the lines on opening the port and
deassert them on closing.

All of which is to say that this patch might not hurt, but I don't
think it's necessary for any of the situations I've encountered.

David

On Tue, Aug 24, 2010 at 9:07 PM, Josef Wolf <jw@...> wrote:

> On Tue, Aug 24, 2010 at 08:38:13PM +0200, David A. Mellis wrote:
>
>> All of the Arduino boards we've shipped with auto-reset have used a
>> capacitor, not a resistor, to connect RTS/DTR to the microcontroller's reset
>> pin, so I'm not sure this is necessary.
>
> Well, I see lots of schematics (e.g. the NG, the Diecimila) with a resistor
> instead of a capacitor. And people keep having problems. One of the recent
> examples is http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1280814595
> I have purchased such a cable, and indeed, I had similar problems.
>
>> Also, which operating systems have you tested this on?
>
> I tested on opensuse and ubuntu. Same results.
>
>> Do they all allow
>> raising and lowering of the line once the serial device is open?
>
> If an OS does not allow this, current code will not work anyway on that OS.
>
> _______________________________________________
> avrdude-dev mailing list
> avrdude-dev@...
> http://lists.nongnu.org/mailman/listinfo/avrdude-dev
>

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

Re: Reset function for arduino

by Josef Wolf :: Rate this Message:

| View Threaded | Show Only this Message

On Wed, Aug 25, 2010 at 09:13:08AM +0200, David A. Mellis wrote:
> The schematics may have a resistor, but the boards shipped with a
> capacitor or nothing at all.  We've never used a resistor to connect
> RTS/DTR and RESET.

What about the people who have built their own HW based on those schematics?

> The problems that people have been having are because the Arduino IDE
> currently uses the "stk500v1" protocol in avrdude, which doesn't
> handle reset of RTS and DTR, not the "arduino" protocol that does.
> These problems should go away in Arduino 0019, in which the IDE will
> toggle both lines before doing uploading.

I have 0019 and I tried "arduino" protocol from avrdude/trunk _with_
a capacitor.

But there seem to be problems with the timing, too. I get pretty reliable
results with a delay of 3..3000 us. Starting from 3000us up to 80000us, it
gets unreliable in such a way that it works only once after I plug in the
USB port. Above 80000us, it starts getting reliable again.

Unfortunately, I don't have a scope to check what exactly is going on here.

Please see my other post on this thread.

> This is the same problem,
> I'm guessing, that Axel is having, which should go away with recent
> versions of avrdude that assert the lines on opening the port and
> deassert them on closing.

As I wrote above, I _have_ recent avrdude (checked out yesterday). This is
what my patch is based on.

> All of which is to say that this patch might not hurt, but I don't
> think it's necessary for any of the situations I've encountered.

So looks like I have a very special situation here... But nevertheless,
I'd like to know what might so special about my situation.

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

Re: Reset function for arduino

by uracolix :: Rate this Message:

| View Threaded | Show Only this Message

Am Mittwoch, 25. August 2010 07:37:33 schrieb Joerg Wunsch:
>> For one trial after plugin I'm able to programm the target, for
>> the next trial, the handshake lines seems to be left in a wrong state.
> Would the suggested patch fix your issue as well?

I tested it the following way:

  - using avrdude 5.8. the previously described issue exists.
  - using avrdude 5.10svn the issue disapaeread.
  - avrdude 5.10svn + Josefs Patch the issue stays away.

This was tested on SuSE 11.0, 2.6.25.5-1.1-pae, both on
command line (-carduino) and within the arduino gui,
with "stk500v1" replaced by "arduino" in boards.txt.

So after the upgrade to the latest avrdude everything is
fine for me with and without Josefs Patch.

Regards, Axel

PS: With avrdude 5.9 on centos 4.? there is also no such issue.


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

Re: Reset function for arduino

by mellis :: Rate this Message:

| View Threaded | Show Only this Message

Hmm, what hardware are you using?

On Wed, Aug 25, 2010 at 9:45 AM, Josef Wolf <jw@...> wrote:

> On Wed, Aug 25, 2010 at 09:13:08AM +0200, David A. Mellis wrote:
>> The schematics may have a resistor, but the boards shipped with a
>> capacitor or nothing at all.  We've never used a resistor to connect
>> RTS/DTR and RESET.
>
> What about the people who have built their own HW based on those schematics?
>
>> The problems that people have been having are because the Arduino IDE
>> currently uses the "stk500v1" protocol in avrdude, which doesn't
>> handle reset of RTS and DTR, not the "arduino" protocol that does.
>> These problems should go away in Arduino 0019, in which the IDE will
>> toggle both lines before doing uploading.
>
> I have 0019 and I tried "arduino" protocol from avrdude/trunk _with_
> a capacitor.
>
> But there seem to be problems with the timing, too. I get pretty reliable
> results with a delay of 3..3000 us. Starting from 3000us up to 80000us, it
> gets unreliable in such a way that it works only once after I plug in the
> USB port. Above 80000us, it starts getting reliable again.
>
> Unfortunately, I don't have a scope to check what exactly is going on here.
>
> Please see my other post on this thread.
>
>> This is the same problem,
>> I'm guessing, that Axel is having, which should go away with recent
>> versions of avrdude that assert the lines on opening the port and
>> deassert them on closing.
>
> As I wrote above, I _have_ recent avrdude (checked out yesterday). This is
> what my patch is based on.
>
>> All of which is to say that this patch might not hurt, but I don't
>> think it's necessary for any of the situations I've encountered.
>
> So looks like I have a very special situation here... But nevertheless,
> I'd like to know what might so special about my situation.
>
> _______________________________________________
> avrdude-dev mailing list
> avrdude-dev@...
> http://lists.nongnu.org/mailman/listinfo/avrdude-dev
>

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