flm01/mote/v2/openwrt/package/avrdude/patches/110-gpio_dev.patch

390 lines
13 KiB
Diff
Raw Normal View History

diff -urNad /tmp/avrdude-5.10/avrdude.conf.in avrdude-5.10/avrdude.conf.in
--- /tmp/avrdude-5.10/avrdude.conf.in 2010-08-06 13:53:20.883965102 +0200
+++ avrdude-5.10/avrdude.conf.in 2010-08-06 13:11:12.803965267 +0200
@@ -833,6 +833,16 @@
miso = 8;
;
+programmer
+ id = "gpio";
+ desc = "Use gpio_dev to bitbang GPIO lines";
+ type = gpio;
+ reset = 0;
+ sck = 3;
+ mosi = 1;
+ miso = 2;
+;
+
# Same as above, different name
# reset=!txd sck=rts mosi=dtr miso=cts
diff -urNad /tmp/avrdude-5.10/config_gram.y avrdude-5.10/config_gram.y
--- /tmp/avrdude-5.10/config_gram.y 2010-08-06 13:53:20.891969681 +0200
+++ avrdude-5.10/config_gram.y 2010-08-06 13:11:12.827964827 +0200
@@ -39,6 +39,7 @@
#include "stk500.h"
#include "arduino.h"
#include "buspirate.h"
+#include "gpio.h"
#include "stk500v2.h"
#include "stk500generic.h"
#include "avr910.h"
@@ -99,6 +100,7 @@
%token K_DRAGON_JTAG
%token K_DRAGON_PDI
%token K_DRAGON_PP
+%token K_GPIO
%token K_STK500_DEVCODE
%token K_AVR910_DEVCODE
%token K_EEPROM
@@ -437,6 +439,12 @@
buspirate_initpgm(current_prog);
}
} |
+
+ K_TYPE TKN_EQUAL K_GPIO {
+ {
+ gpio_initpgm(current_prog);
+ }
+ } |
K_TYPE TKN_EQUAL K_STK600 {
{
diff -urNad /tmp/avrdude-5.10/gpio.c avrdude-5.10/gpio.c
--- /tmp/avrdude-5.10/gpio.c 1970-01-01 01:00:00.000000000 +0100
+++ avrdude-5.10/gpio.c 2010-08-06 13:11:12.823989322 +0200
@@ -0,0 +1,181 @@
+/*
+ * avrdude - A Downloader/Uploader for AVR device programmers
+ * Support for a bitbanged GPIO programmer using gpio_dev
+ *
+ * copyright (c) 2010 flukso.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "ac_cfg.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "avrdude.h"
+#include "avr.h"
+#include "pindefs.h"
+#include "pgm.h"
+#include "bitbang.h"
+
+#include <linux/gpio_dev.h>
+#include <sys/ioctl.h>
+
+#define AVRDUDE_GPIO_DIR_IN 0
+#define AVRDUDE_GPIO_DIR_OUT 1
+
+static int gpio_fd;
+
+static void _gpio_dir(int pin, int dir)
+{
+ pin &= PIN_MASK;
+
+ if (dir == AVRDUDE_GPIO_DIR_OUT)
+ ioctl(gpio_fd, GPIO_DIR_OUT, pin);
+ else
+ ioctl(gpio_fd, GPIO_DIR_IN, pin);
+
+ return;
+}
+
+static int gpio_setpin(PROGRAMMER * pgm, int pin, int value)
+{
+ if (pin & PIN_INVERSE) {
+ value = !value;
+ pin &= PIN_MASK;
+ }
+
+ if (value)
+ ioctl(gpio_fd, GPIO_SET, pin);
+ else
+ ioctl(gpio_fd, GPIO_CLEAR, pin);
+
+ if (pgm->ispdelay > 1)
+ bitbang_delay(pgm->ispdelay);
+
+ return 0;
+}
+
+static int gpio_getpin(PROGRAMMER * pgm, int pin)
+{
+ char input, inv = 0;
+
+ if (pin & PIN_INVERSE) {
+ inv = 1;
+ pin &= PIN_MASK;
+ }
+
+ input = ioctl(gpio_fd, GPIO_GET, pin);
+
+ if (inv) {
+ return input ^ 1;
+ }
+ else {
+ return input;
+ }
+}
+
+static int gpio_highpulsepin(PROGRAMMER * pgm, int pin)
+{
+ gpio_setpin(pgm, pin, 1);
+ gpio_setpin(pgm, pin, 0);
+
+ return 0;
+}
+
+
+
+static void gpio_display(PROGRAMMER *pgm, const char *p)
+{
+ /* nothing */
+}
+
+static void gpio_enable(PROGRAMMER *pgm)
+{
+ /* nothing */
+}
+
+static void gpio_disable(PROGRAMMER *pgm)
+{
+ /* nothing */
+}
+
+static void gpio_powerup(PROGRAMMER *pgm)
+{
+ /* nothing */
+}
+
+static void gpio_powerdown(PROGRAMMER *pgm)
+{
+ /* nothing */
+}
+
+static int gpio_open(PROGRAMMER *pgm, char *port)
+{
+ int i;
+
+ bitbang_check_prerequisites(pgm);
+
+ if ((gpio_fd = open("/dev/gpio", O_RDWR)) < 0) {
+ perror("cannot open /dev/gpio");
+ return -1;
+ }
+
+ for (i = 0; i < N_PINS; i++) {
+ if (i == PIN_AVR_MISO)
+ _gpio_dir(pgm->pinno[i], AVRDUDE_GPIO_DIR_IN);
+ else
+ _gpio_dir(pgm->pinno[i], AVRDUDE_GPIO_DIR_OUT);
+ }
+
+ return(0);
+}
+
+static void gpio_close(PROGRAMMER *pgm)
+{
+ gpio_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 1);
+ close(gpio_fd);
+ return;
+}
+
+void gpio_initpgm(PROGRAMMER *pgm)
+{
+ strcpy(pgm->type, "GPIO");
+
+ pgm->rdy_led = bitbang_rdy_led;
+ pgm->err_led = bitbang_err_led;
+ pgm->pgm_led = bitbang_pgm_led;
+ pgm->vfy_led = bitbang_vfy_led;
+ pgm->initialize = bitbang_initialize;
+ pgm->display = gpio_display;
+ pgm->enable = gpio_enable;
+ pgm->disable = gpio_disable;
+ pgm->powerup = gpio_powerup;
+ pgm->powerdown = gpio_powerdown;
+ pgm->program_enable = bitbang_program_enable;
+ pgm->chip_erase = bitbang_chip_erase;
+ pgm->cmd = bitbang_cmd;
+ pgm->open = gpio_open;
+ pgm->close = gpio_close;
+ pgm->setpin = gpio_setpin;
+ pgm->getpin = gpio_getpin;
+ pgm->highpulsepin = gpio_highpulsepin;
+ pgm->read_byte = avr_read_byte_default;
+ pgm->write_byte = avr_write_byte_default;
+}
diff -urNad /tmp/avrdude-5.10/gpio.h avrdude-5.10/gpio.h
--- /tmp/avrdude-5.10/gpio.h 1970-01-01 01:00:00.000000000 +0100
+++ avrdude-5.10/gpio.h 2010-08-06 13:37:40.479767917 +0200
@@ -0,0 +1,33 @@
+/*
+ * avrdude - A Downloader/Uploader for AVR device programmers
+ * Copyright (C) 2000-2004 Brian S. Dean <b...@bsdhome.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef gpio_h
+#define gpio_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void gpio_initpgm (PROGRAMMER * pgm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff -urNad /tmp/avrdude-5.10/lexer.l avrdude-5.10/lexer.l
--- /tmp/avrdude-5.10/lexer.l 2010-08-06 13:53:20.883965102 +0200
+++ avrdude-5.10/lexer.l 2010-08-06 13:11:12.803965267 +0200
@@ -146,6 +146,7 @@
enablepageprogramming { yylval=NULL; return K_ENABLEPAGEPROGRAMMING; }
errled { yylval=NULL; return K_ERRLED; }
flash { yylval=NULL; return K_FLASH; }
+gpio { yylval=NULL; return K_GPIO; }
has_jtag { yylval=NULL; return K_HAS_JTAG; }
has_debugwire { yylval=NULL; return K_HAS_DW; }
has_pdi { yylval=NULL; return K_HAS_PDI; }
diff -urNad /tmp/avrdude-5.10/Makefile.am avrdude-5.10/Makefile.am
--- /tmp/avrdude-5.10/Makefile.am 2010-08-06 13:53:20.891969681 +0200
+++ avrdude-5.10/Makefile.am 2010-08-06 13:11:12.827964827 +0200
@@ -101,6 +101,8 @@
fileio.c \
fileio.h \
freebsd_ppi.h \
+ gpio.c \
+ gpio.h \
jtagmkI.c \
jtagmkI.h \
jtagmkI_private.h \
diff -urNad /tmp/avrdude-5.10/Makefile.in avrdude-5.10/Makefile.in
--- /tmp/avrdude-5.10/Makefile.in 2010-08-06 13:53:20.887965471 +0200
+++ avrdude-5.10/Makefile.in 2010-08-06 13:11:12.811964888 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -87,11 +87,11 @@
libavrdude_a-buspirate.$(OBJEXT) \
libavrdude_a-butterfly.$(OBJEXT) libavrdude_a-config.$(OBJEXT) \
libavrdude_a-confwin.$(OBJEXT) libavrdude_a-crc16.$(OBJEXT) \
- libavrdude_a-fileio.$(OBJEXT) libavrdude_a-jtagmkI.$(OBJEXT) \
- libavrdude_a-jtagmkII.$(OBJEXT) libavrdude_a-lists.$(OBJEXT) \
- libavrdude_a-par.$(OBJEXT) libavrdude_a-pgm.$(OBJEXT) \
- libavrdude_a-ppi.$(OBJEXT) libavrdude_a-ppiwin.$(OBJEXT) \
- libavrdude_a-safemode.$(OBJEXT) \
+ libavrdude_a-fileio.$(OBJEXT) libavrdude_a-gpio.$(OBJEXT) \
+ libavrdude_a-jtagmkI.$(OBJEXT) libavrdude_a-jtagmkII.$(OBJEXT) \
+ libavrdude_a-lists.$(OBJEXT) libavrdude_a-par.$(OBJEXT) \
+ libavrdude_a-pgm.$(OBJEXT) libavrdude_a-ppi.$(OBJEXT) \
+ libavrdude_a-ppiwin.$(OBJEXT) libavrdude_a-safemode.$(OBJEXT) \
libavrdude_a-serbb_posix.$(OBJEXT) \
libavrdude_a-serbb_win32.$(OBJEXT) \
libavrdude_a-ser_avrdoper.$(OBJEXT) \
@@ -204,6 +204,7 @@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
@@ -323,6 +324,8 @@
fileio.c \
fileio.h \
freebsd_ppi.h \
+ gpio.c \
+ gpio.h \
jtagmkI.c \
jtagmkI.h \
jtagmkI_private.h \
@@ -493,6 +496,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-confwin.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-crc16.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-fileio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-gpio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-jtagmkI.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-jtagmkII.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libavrdude_a-lexer.Po@am__quote@
@@ -711,6 +715,20 @@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-fileio.obj `if test -f 'fileio.c'; then $(CYGPATH_W) 'fileio.c'; else $(CYGPATH_W) '$(srcdir)/fileio.c'; fi`
+libavrdude_a-gpio.o: gpio.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-gpio.o -MD -MP -MF $(DEPDIR)/libavrdude_a-gpio.Tpo -c -o libavrdude_a-gpio.o `test -f 'gpio.c' || echo '$(srcdir)/'`gpio.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libavrdude_a-gpio.Tpo $(DEPDIR)/libavrdude_a-gpio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gpio.c' object='libavrdude_a-gpio.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-gpio.o `test -f 'gpio.c' || echo '$(srcdir)/'`gpio.c
+
+libavrdude_a-gpio.obj: gpio.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-gpio.obj -MD -MP -MF $(DEPDIR)/libavrdude_a-gpio.Tpo -c -o libavrdude_a-gpio.obj `if test -f 'gpio.c'; then $(CYGPATH_W) 'gpio.c'; else $(CYGPATH_W) '$(srcdir)/gpio.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libavrdude_a-gpio.Tpo $(DEPDIR)/libavrdude_a-gpio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gpio.c' object='libavrdude_a-gpio.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -c -o libavrdude_a-gpio.obj `if test -f 'gpio.c'; then $(CYGPATH_W) 'gpio.c'; else $(CYGPATH_W) '$(srcdir)/gpio.c'; fi`
+
libavrdude_a-jtagmkI.o: jtagmkI.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavrdude_a_CPPFLAGS) $(CPPFLAGS) $(libavrdude_a_CFLAGS) $(CFLAGS) -MT libavrdude_a-jtagmkI.o -MD -MP -MF $(DEPDIR)/libavrdude_a-jtagmkI.Tpo -c -o libavrdude_a-jtagmkI.o `test -f 'jtagmkI.c' || echo '$(srcdir)/'`jtagmkI.c
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libavrdude_a-jtagmkI.Tpo $(DEPDIR)/libavrdude_a-jtagmkI.Po
@@ -1035,8 +1053,8 @@
esac; \
done; \
for i in $$list; do \
- if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
- else file=$$i; fi; \
+ if test -f $$i; then file=$$i; \
+ else file=$(srcdir)/$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
@@ -1162,7 +1180,7 @@
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS