Bug#819328: avrdude: arduino pro mini reset problem

2016-05-06 Thread Milan Kupcevic
Control: severity -1 wishlist


Hi Michal,


On 03/28/2016 12:44 PM, Michal Suchanek wrote:

[...]

> 
> I fixed the reset problem with pro mini by inverting the DTR handling in
> arduino.c
> 

[...]

> Ideally an extra argument would be added to switch which method is tried
> first.


This looks like a new feature. Please file a bug report at:

http://savannah.nongnu.org/bugs/?func=additem=avrdude

and work with the upstream on the issue.


Milan




signature.asc
Description: OpenPGP digital signature


Bug#819328: avrdude: arduino pro mini reset problem

2016-03-28 Thread Michal Suchanek
Package: avrdude
Version: 6.2-5
Followup-For: Bug #819328

Hello,

I fixed the reset problem with pro mini by inverting the DTR handling in
arduino.c

Since the UNO works with the unmodified avrdude it probably has
different reset circuit.

Tried to put together a patch that makes both boards work.

Ideally an extra argument would be added to switch which method is tried
first.

Thanks

Michal

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (990, 'stable'), (500, 'oldstable'), (171, 
'unstable'), (151, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armhf

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages avrdude depends on:
ii  libc6 2.21-7
ii  libelf1   0.163-5.1
ii  libftdi1  0.20-4
ii  libncurses5   6.0+20151024-2
ii  libreadline6  6.3-8+b4
ii  libtinfo5 6.0+20151024-2
ii  libusb-0.1-4  2:0.1.12-28

avrdude recommends no packages.

Versions of packages avrdude suggests:
pn  avrdude-doc  

-- no debconf information
Index: avrdude-6.2/arduino.c
===
--- avrdude-6.2.orig/arduino.c	2016-03-28 18:25:31.648762178 +0200
+++ avrdude-6.2/arduino.c	2016-03-28 18:31:02.925108185 +0200
@@ -80,6 +80,22 @@
   return 3;
 }
 
+static void arduino_frob_reset(PROGRAMMER * pgm)
+{
+  static bool dtr = 1;
+
+avrdude_message(MSG_INFO, "%s: arduino_open(): DTR is %sset\n",
+		progname, dtr ? "" : "not ");
+  /* Clear DTR and RTS to unload the RESET capacitor 
+   * (for example in Arduino) */
+  serial_set_dtr_rts(>fd, 1 ^ dtr);
+  usleep(250*1000);
+  /* Set DTR and RTS back to high */
+  serial_set_dtr_rts(>fd, 0 ^ dtr);
+  usleep(50*1000);
+  dtr = dtr ^ 1;
+}
+
 static int arduino_open(PROGRAMMER * pgm, char * port)
 {
   union pinfo pinfo;
@@ -89,13 +105,7 @@
 return -1;
   }
 
-  /* Clear DTR and RTS to unload the RESET capacitor 
-   * (for example in Arduino) */
-  serial_set_dtr_rts(>fd, 0);
-  usleep(250*1000);
-  /* Set DTR and RTS back to high */
-  serial_set_dtr_rts(>fd, 1);
-  usleep(50*1000);
+  arduino_frob_reset(pgm);
 
   /*
* drain any extraneous input
@@ -129,4 +139,5 @@
   pgm->read_sig_bytes = arduino_read_sig_bytes;
   pgm->open = arduino_open;
   pgm->close = arduino_close;
+  pgm->frob_reset = arduino_frob_reset;
 }
Index: avrdude-6.2/doc/Makefile.in
===
--- avrdude-6.2.orig/doc/Makefile.in	2016-03-28 18:25:31.648762178 +0200
+++ avrdude-6.2/doc/Makefile.in	2016-03-28 18:25:31.620762488 +0200
@@ -339,6 +339,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -472,9 +473,6 @@
 
 maintainer-clean-vti:
 	-rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi
-.dvi.ps:
-	$(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
-	$(DVIPS) $(AM_V_texinfo) -o $@ $<
 
 uninstall-dvi-am:
 	@$(NORMAL_UNINSTALL)
@@ -826,11 +824,11 @@
 
 all-local: info html ps pdf
 
-html: avrdude-html/avrdude.html
+html: avrdude-html/index.html
 
-avrdude-html/avrdude.html: $(srcdir)/$(info_TEXINFOS) $(GENERATED_TEXINFOS)
-	texi2html -split_node $(srcdir)/$(info_TEXINFOS)
-	if [ -e ./avrdude.html -o -e ./avrdude_1.html ]; then \
+avrdude-html/index.html: $(srcdir)/$(info_TEXINFOS) $(GENERATED_TEXINFOS)
+	makeinfo --html --split=node $(srcdir)/$(info_TEXINFOS)
+	if [ -e ./index.html -o -e ./avrdude_1.html ]; then \
 	 mkdir -p avrdude-html ; \
 	 mv -f *.html avrdude-html ; \
 	else \
@@ -841,6 +839,13 @@
 $(builddir)/avrdude.dvi: $(GENERATED_TEXINFOS)
 $(builddir)/avrdude.pdf: $(GENERATED_TEXINFOS)
 
+.dvi.ps:
+	$(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+	$(DVIPS) $(AM_V_texinfo) -o $@.tmp $<
+	printf "[ /CreationDate (%s)\n/DOCINFO pdfmark\n" "`date -u -r ../debian/changelog +%Y-%m-%dT%H:%M:%SZ`" > $@.mark
+	gs -q -dBATCH -dNOPAUSE -sDEVICE=ps2write -sOutputFile=$@ $@.tmp $@.mark
+	rm -f $@.mark $@.tmp
+
 # if it does not exist make this first
 ../avrdude$(EXEEXT):
 	$(MAKE) -C .. avrdude$(EXEEXT)
Index: avrdude-6.2/libavrdude.h
===
--- avrdude-6.2.orig/libavrdude.h	2016-03-28 18:25:31.648762178 +0200
+++ avrdude-6.2/libavrdude.h	2016-03-28 18:25:31.624762443 +0200
@@ -649,6 +649,7 @@
   unsigned char *res, int count);
   int  (*open)   (struct programmer_t * pgm, char * port);
   void (*close)  (struct programmer_t * pgm);
+  void (*frob_reset) (struct programmer_t * pgm);
   int  (*paged_write)(struct programmer_t * pgm, AVRPART * p, AVRMEM * m, 
   unsigned int page_size, unsigned int 

Bug#819328: avrdude: arduino pro mini reset problem

2016-03-26 Thread Michal Suchanek
Package: avrdude
Version: 6.2-5
Severity: normal

Hello,

I tried to flash an arduino pro mini clone over an USB TTL cable.

Some wiring guide on the internet suggests to wire DTR to RST so the ARV
resets automagically. Since I had Blink on the AVR I could tell it
indeed resets. However, it stays in reset the whole time avrdude tries
to communicate with the AVR and hence avrdude reports there is no
response.

Unwiring DTR and resetting board by hand solves the problem.

Can this be handled in avrdude? It seems whatever it does works for UNO
but not Pro Mini. Or is the wiring of the reset supposed to be
different?

Thanks

Michal

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (990, 'stable'), (500, 'oldstable'), (171, 
'unstable'), (151, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armhf

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages avrdude depends on:
ii  libc6 2.21-7
ii  libelf1   0.163-5.1
ii  libftdi1  0.20-4
ii  libncurses5   6.0+20151024-2
ii  libreadline6  6.3-8+b4
ii  libtinfo5 6.0+20151024-2
ii  libusb-0.1-4  2:0.1.12-28

avrdude recommends no packages.

Versions of packages avrdude suggests:
pn  avrdude-doc  

-- no debconf information