📄 avrdude-usb-v2.patch
字号:
- avrdude.toc avrdude.tp avrdude.tps avrdude.vr avrdude.vrs \- avrdude.dvi avrdude.pdf avrdude.ps+ -rm -f avrdude.aux avrdude.cp avrdude.cps avrdude.dvi avrdude.fn avrdude.ky \+ avrdude.log avrdude.pg avrdude.ps avrdude.tmp avrdude.toc \+ avrdude.tp avrdude.vr maintainer-clean-aminfo:- @list='$(INFO_DEPS)'; for i in $$list; do \- i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \- echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \- rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \+ cd $(srcdir) && \+ list='$(INFO_DEPS)'; for i in $$list; do \+ rm -f $$i; \+ if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \+ rm -f $$i-[0-9]*; \+ fi; \ done tags: TAGS TAGS: -ctags: CTAGS-CTAGS:- DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = .. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES)- @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \- list='$(DISTFILES)'; for file in $$list; do \- case $$file in \- $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \- $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \- esac; \+ @list='$(DISTFILES)'; for file in $$list; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \@@ -304,7 +253,7 @@ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \- top_distdir="$(top_distdir)" distdir="$(distdir)" \+ top_distdir="${top_distdir}" distdir="$(distdir)" \ dist-info check-am: all-am check: check-am@@ -365,12 +314,10 @@ $(mkinstalldirs) $(DESTDIR)$(infodir) @list='$(INFO_DEPS)'; \ for file in $$list; do \- if test -f $$file; then d=.; else d=$(srcdir); fi; \- file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \- for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \- $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \+ d=$(srcdir); \+ for ifile in echo $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9]; do \ if test -f $$ifile; then \- relfile=`echo "$$ifile" | sed 's|^.*/||'`; \+ relfile=`expr "$$ifile" : "$$d/\(.*\)"`; \ echo " $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile"; \ $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile; \ else : ; fi; \@@ -378,12 +325,11 @@ done @$(POST_INSTALL) @if (install-info --version && \- install-info --version | grep -i -v debian) >/dev/null 2>&1; then \+ install-info --version | fgrep -i -v debian) >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; \ for file in $$list; do \- relfile=`echo "$$file" | sed 's|^.*/||'`; \- echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$relfile";\- install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$relfile || :;\+ echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\+ install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;\ done; \ else : ; fi install-man:@@ -399,14 +345,6 @@ mostlyclean-am: mostlyclean-aminfo mostlyclean-generic mostlyclean-vti -pdf: pdf-am--pdf-am: $(PDFS)--ps: ps-am--ps-am: $(PSS)- uninstall-am: uninstall-info-am uninstall-local .PHONY: all all-am all-local check check-am clean clean-generic \@@ -417,8 +355,8 @@ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-aminfo maintainer-clean-generic \ maintainer-clean-vti mostlyclean mostlyclean-aminfo \- mostlyclean-generic mostlyclean-vti pdf pdf-am ps ps-am \- uninstall uninstall-am uninstall-info-am uninstall-local+ mostlyclean-generic mostlyclean-vti uninstall uninstall-am \+ uninstall-info-am uninstall-local all-local: info html ps pdfdiff -ruN avrdude-4.0.0-orig/hostlib.c avrdude-4.0.0/hostlib.c--- avrdude-4.0.0-orig/hostlib.c 1969-12-31 18:00:00.000000000 -0600+++ avrdude-4.0.0/hostlib.c 2003-12-10 10:29:50.000000000 -0600@@ -0,0 +1,101 @@+#include "hostlib.h"++#include <usb.h>+#include <stdio.h>+#include <time.h>++#define DO_DEBUG 0 +++#if DO_DEBUG+static struct timeval t0, t1; +#define DEBUG(x) (printf x)+#define TB() gettimeofday(&t0)+#define TE(s) gettimeofday(&t1); DEBUG(( s ": %f\n", t1.tv_sec - t0.tv_sec + (t1.tv_usec - t0.tv_usec) * 1e-6 ))+#else+#define TB() (void)0+#define TE(s) (void)0+#define DEBUG(x) (void)0+#endif+struct usb_device *find_on_bus(struct usb_bus *bus, u_int16_t v, u_int16_t p) {+ struct usb_device *dev = bus->devices;++ for(; dev; dev = dev->next) {+ if(dev->descriptor.idVendor == v && dev->descriptor.idProduct == p) {+ return dev;+ }+ }+ return NULL;+}++struct usb_device *find_dev(u_int16_t v, u_int16_t p) {+ struct usb_bus *bus = usb_get_busses();+ struct usb_device *dev = NULL;++ for(; bus; bus = bus->next) {+ dev = find_on_bus(bus, v, p);+ if(dev) return dev;+ }+ return NULL;+}++void send_command(avr_device *dev, int cmd, int val) {+ DEBUG(("send_command %d %02x\n", cmd, val));+ TB();+ usb_control_msg((usb_dev_handle *)dev, USB_TYPE_VENDOR, cmd, val,+ 0, NULL, 0, 1000);+ TE("send_command");+}++void send_command_idx(avr_device *dev, int cmd, int val, int idx) {+ DEBUG(("send_command %d %02x\n", cmd, val));+ TB();+ usb_control_msg((usb_dev_handle *)dev, USB_TYPE_VENDOR, cmd, val,+ idx, NULL, 0, 1000);+ TE("send_command");+}+++int get_response(avr_device *dev, int cmd, int val, char *buf, int len) {+ DEBUG(("get_response %d %02x", cmd, val));+ TB();+ int ret = usb_control_msg((usb_dev_handle *)dev,+ USB_TYPE_VENDOR | USB_ENDPOINT_IN, cmd, val,+ 0, buf, len, 1000);+ TE("get_response");+ DEBUG((" -> %d (buf[0] = %02x)\n", ret, (unsigned char)buf[0]));+ return ret;+}+++int get_response_idx(avr_device *dev, int cmd, int val, int idx,+ char *buf, int len) {+ DEBUG(("get_response %d %02x", cmd, val));+ TB();+ int ret = usb_control_msg((usb_dev_handle *)dev,+ USB_TYPE_VENDOR | USB_ENDPOINT_IN, cmd, val,+ idx, buf, len, 1000);+ TE("get_response");+ DEBUG((" -> %d (buf[0] = %02x)\n", ret, (unsigned char)buf[0]));+ return ret;+}++avr_device get_avr(void) {+ struct usb_device *dev;+ usb_dev_handle *devh;++ usb_init();+ usb_set_debug(0xff);+ usb_find_busses();+ usb_find_devices();++ dev = find_dev(0x3eb, 0x2);+ if(!dev) return NULL;++ devh = usb_open(dev);++ usb_claim_interface(devh, 0);+ return (avr_device)devh;+}++// vim:sts=4:sw=4:etdiff -ruN avrdude-4.0.0-orig/hostlib.h avrdude-4.0.0/hostlib.h--- avrdude-4.0.0-orig/hostlib.h 1969-12-31 18:00:00.000000000 -0600+++ avrdude-4.0.0/hostlib.h 2003-12-10 10:29:50.000000000 -0600@@ -0,0 +1,27 @@+#ifndef AVR_HOSTLIB_H+#define AVR_HOSTLIB_H++#define AVR_INFRA_BUFFER_EMPTY 1+#define AVR_INFRA_GET_CODE 2+#define AVR_DDR_SET 3+#define AVR_DDR_GET 4+#define AVR_PORT_SET 5+#define AVR_PORT_GET 6+#define AVR_PIN_GET 7+#define AVR_EEPROM_READ 8+#define AVR_EEPROM_WRITE 9+#define AVR_RS232_WRITE 10+#define AVR_RS232_READ 11+#define AVR_RS232_BAUD_SET 12+#define AVR_RS232_BAUD_GET 13+#define AVR_SPI4 15++typedef void* avr_device;++avr_device get_avr();+void send_command(avr_device *dev, int cmd, int val);+void send_command_idx(avr_device *dev, int cmd, int val, int idx);+int get_response(avr_device *dev, int cmd, int val, char *buf, int len);+int get_response_idx(avr_device *dev, int cmd, int idx, int val,+ char *buf, int len);+#endifdiff -ruN avrdude-4.0.0-orig/lexer.l avrdude-4.0.0/lexer.l--- avrdude-4.0.0-orig/lexer.l 2003-02-27 10:42:56.000000000 -0600+++ avrdude-4.0.0/lexer.l 2003-12-10 10:29:50.000000000 -0600@@ -153,6 +153,7 @@ size { yylval=NULL; return K_SIZE; } stk500 { yylval=NULL; return K_STK500; } type { yylval=NULL; return K_TYPE; }+usb { yylval=NULL; return K_USB; } vcc { yylval=NULL; return K_VCC; } vfyled { yylval=NULL; return K_VFYLED; } diff -ruN avrdude-4.0.0-orig/pgm.h avrdude-4.0.0/pgm.h--- avrdude-4.0.0-orig/pgm.h 2003-02-22 10:45:13.000000000 -0600+++ avrdude-4.0.0/pgm.h 2003-12-10 10:29:50.000000000 -0600@@ -27,7 +27,7 @@ #include "avrpart.h" #include "lists.h" #include "pindefs.h"-+#include "hostlib.h" #define ON 1 #define OFF 0@@ -43,6 +43,7 @@ unsigned int pinno[N_PINS]; int ppidata; int fd;+ avr_device dev; int page_size; /* page size if the programmer supports paged write/load */ int (*rdy_led) (struct programmer_t * pgm, int value); int (*err_led) (struct programmer_t * pgm, int value);diff -ruN avrdude-4.0.0-orig/usb.c avrdude-4.0.0/usb.c--- avrdude-4.0.0-orig/usb.c 1969-12-31 18:00:00.000000000 -0600+++ avrdude-4.0.0/usb.c 2003-12-10 10:29:50.000000000 -0600@@ -0,0 +1,431 @@+/*+ * avrdude - A Downloader/Uploader for AVR device programmers+ * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@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+ */++/* $Id: usb.c,v 1.2 2003/11/26 22:24:50 jepler Exp jepler $ */++#include "ac_cfg.h"++#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include <fcntl.h>+#include <unistd.h>+#include <errno.h>++#include <usb.h>++#include "avr.h"+#include "pindefs.h"+#include "pgm.h"+#include "avr_usb.h"+#include "hostlib.h"++#define SLOW_TOGGLE 0++extern char * progname;+extern int do_cycles;+extern int verbose;+++static int ausb_setpin (PROGRAMMER *pgm, int pin, int value);++static int ausb_getpin (PROGRAMMER *pgm, int pin);++static int ausb_pulsepin (PROGRAMMER *pgm, int pin);+++static int ausb_rdy_led (PROGRAMMER * pgm, int value);++static int ausb_err_led (PROGRAMMER * pgm, int value);++static int ausb_pgm_led (PROGRAMMER * pgm, int value);++static int ausb_vfy_led (PROGRAMMER * pgm, int value);++static int ausb_cmd (PROGRAMMER * pgm, unsigned char cmd[4], + unsigned char res[4]);++static int ausb_chip_erase (PROGRAMMER * pgm, AVRPART * p);++static int ausb_program_enable (PROGRAMMER * pgm, AVRPART * p);++static void ausb_powerup (PROGRAMMER * pgm);++static void ausb_powerdown (PROGRAMMER * pgm);++static int ausb_initialize (PROGRAMMER * pgm, AVRPART * p);++static int ausb_save (PROGRAMMER * pgm);++static void ausb_restore (PROGRAMMER * pgm);++static void ausb_disable (PROGRAMMER * pgm);++static void ausb_enable (PROGRAMMER * pgm);++static void ausb_open (PROGRAMMER * pgm, char * port);++static void ausb_close (PROGRAMMER * pgm);+++#define USB_RESET 4+#define USB_MOSI 5+#define USB_MISO 6+#define USB_SCK 7++static unsigned pins = 0;++static int ausb_setpin(PROGRAMMER *pgm, int pin, int value)+{+ unsigned char c = pins;++ if (pin < 0 || pin > 7)+ return -1;++ if(value)+ c |= (1<<pin);+ else+ c &= ~(1<<pin)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -