avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avrdude-dev] Wiring programmer on serial port with no DTR/RTS


From: Rodolfo Giometti
Subject: [avrdude-dev] Wiring programmer on serial port with no DTR/RTS
Date: Fri, 2 Aug 2013 10:33:08 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Hello,

I need using wiring programmer on a serial port who has no DTR/RTS so
I supposed I can use a CPU's gpio pin in order to reset the uC before
reprogrammation.

Currently I use the following script:

   echo 1 > /sys/class/gpio/pioB14/value
   sleep 1
   echo 0 > /sys/class/gpio/pioB14/value

   avrdude -V -F -c wiring -x snooze=1 -b 115200 -p atmega2560 -P /dev/ttyS3 -U 
fla sh:w:prg.hex

but I'd like to add gpio managing into avrdude.

I think I can add an extra option to the wiring programmer in order to
force avrdude in using a gpio insted of DTR/RTS signal as follow:

diff --git a/wiring.orig b/wiring.c
index ce048a2..0a015f8 100644
--- a/wiring.orig
+++ b/wiring.c
@@ -57,10 +57,8 @@
  */
 struct wiringpdata
 {
-  /*
-   * We just have the single snooze integer to carry around for now.
-   */
-  int snoozetime;
+  int snoozetime;      /* snooze integer */
+  int reset_gpio;      /* reset gpio instead of DTR/RTS (-1 none) */
 };


@@ -92,6 +90,7 @@ static void wiring_setup(PROGRAMMER * pgm)
   }
   memset(mycookie, 0, sizeof(struct wiringpdata));
   WIRINGPDATA(mycookie)->snoozetime = 0;
+  WIRINGPDATA(mycookie)->reset_gpio = -1;

   /*
    * Store our own cookie in a safe place for the time being.
@@ -140,6 +139,26 @@ static int wiring_parseextparms(PROGRAMMER * pgm,
LISTID extparms)
       continue;
     }

+    if (strncmp(extended_param, "gpio=", strlen("gpio=")) == 0) {
+      int gpio;
+      if (sscanf(extended_param, "gpio=%i", &gpio) != 1 ||
+          gpio < 0) {
+        fprintf(stderr,
+                "%s: wiring_parseextparms(): invalid gpio '%s'\n",
+                progname, extended_param);
+        rv = -1;
+        continue;
+      }
+      if (verbose >= 2) {
+        fprintf(stderr,
+                "%s: wiring_parseextparms(): reset gpio set to %d
ms\n",
+                progname, gpio);
+      }
+      WIRINGPDATA(mycookie)->gpio = gpio;
+
+      continue;
+    }
+
     fprintf(stderr,
             "%s: wiring_parseextparms(): invalid extended parameter
             '%s'\n",
             progname, extended_param);
@@ -187,7 +206,10 @@ static int wiring_open(PROGRAMMER * pgm, char *
port)
               progname);
     }

-    serial_set_dtr_rts(&pgm->fd, 0);
+    if (WIRINGPDATA(mycookie)->gpio) > -1)
+       gpio_set(gpio);
+    else
+       serial_set_dtr_rts(&pgm->fd, 0);
     usleep(50*1000);

     /* After releasing for 50 milliseconds, DTR and RTS */
@@ -199,7 +221,10 @@ static int wiring_open(PROGRAMMER * pgm, char *
port)
               progname);
     }

-    serial_set_dtr_rts(&pgm->fd, 1);
+    if (WIRINGPDATA(mycookie)->gpio) > -1)
+       gpio_clear(gpio);
+    else
+       serial_set_dtr_rts(&pgm->fd, 1);
     usleep(50*1000);
   }

But How I can implement gpio_set/gpio_clear functions? I found several
patches regarding GPIOs around the net but all of them are related to
a specific programmer, while I think I should add GPIO management as a
"library".

Waiting for any advices... :-)

Thanks,

Rodolfo

-- 

GNU/Linux Solutions                  e-mail: address@hidden
Linux Device Driver                          address@hidden
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it



reply via email to

[Prev in Thread] Current Thread [Next in Thread]