├── 0001-CH341A-Programmer.patch ├── AUTHORS ├── CH341DLL.H ├── COPYING ├── ChangeLog ├── ChangeLog-2001 ├── ChangeLog-2002 ├── ChangeLog-2003 ├── ChangeLog-2004-2006 ├── ChangeLog-2007 ├── ChangeLog-2008 ├── ChangeLog-2009 ├── ChangeLog-2010 ├── ChangeLog-2011 ├── ChangeLog-2012 ├── ChangeLog-2013 ├── INSTALL ├── LICENSE ├── Makefile ├── Makefile.am ├── Makefile.am.orig ├── Makefile.in ├── Makefile_OK ├── NEWS ├── README.md ├── README_avrdude ├── ac_cfg.h ├── ac_cfg.h.in ├── aclocal.m4 ├── aclocal.m4.bak ├── arduino.c ├── arduino.h ├── avr.c ├── avr910.c ├── avr910.h ├── avrdude.1 ├── avrdude.conf ├── avrdude.conf.bak ├── avrdude.conf.in ├── avrdude.conf.tmp ├── avrdude.h ├── avrdude.spec ├── avrdude.spec.in ├── avrdude_wch_index_USBASPmod.exe ├── avrftdi.c ├── avrftdi.h ├── avrftdi_private.h ├── avrftdi_tpi.c ├── avrftdi_tpi.h ├── avrpart.c ├── bitbang.c ├── bitbang.h ├── bootstrap ├── buspirate.c ├── buspirate.h ├── butterfly.c ├── butterfly.h ├── ch341a.c ├── ch341a.c.bak ├── ch341a.h ├── ch341a_OK_bitbang.c ├── ch341a_bitbang.c ├── ch341a_bitbang.h ├── ch341a_bitbang_wch.c ├── ch341a_bitbang_wch.c.bak ├── ch341a_bitbang_wch.h ├── ch341a_bitbang_wch_dirty.c ├── ch341a_by_symbol.c ├── ch341a_fullbuff.c ├── compile ├── config.c ├── config.guess ├── config.h ├── config.log ├── config.status ├── config.sub ├── config_gram.c ├── config_gram.h ├── config_gram.y ├── configure ├── configure.ac ├── confwin.c ├── crc16.c ├── crc16.h ├── depcomp ├── dfu.c ├── dfu.h ├── doc ├── Makefile ├── Makefile.am ├── Makefile.in ├── TODO ├── avrdude.texi ├── mdate-sh ├── parts_comments.txt └── texinfo.tex ├── fileio.c ├── flip1.c ├── flip1.h ├── flip2.c ├── flip2.h ├── freebsd_ppi.h ├── ft245r.c ├── ft245r.h ├── install-sh ├── jtag3.c ├── jtag3.h ├── jtag3_private.h ├── jtagmkI.c ├── jtagmkI.h ├── jtagmkII.c ├── jtagmkII.h ├── jtagmkII_private.h ├── jtagmkI_private.h ├── lexer.c ├── lexer.l ├── libavrdude.a ├── libavrdude.h ├── libch341dll_1_modtxt.a ├── libtool ├── linux_ppdev.h ├── linuxgpio.c ├── linuxgpio.h ├── lists.c ├── ltmain.sh ├── main.c ├── missing ├── my_ddk_hidsdi.h ├── par.c ├── par.h ├── pgm.c ├── pgm_type.c ├── pickit2.c ├── pickit2.h ├── pindefs.c ├── ppi.c ├── ppi.h ├── ppiwin.c ├── safemode.c ├── ser_avrdoper.c ├── ser_posix.c ├── ser_win32.c ├── serbb.h ├── serbb_posix.c ├── serbb_win32.c ├── solaris_ecpp.h ├── stamp-h1 ├── static_link.txt ├── stk500.c ├── stk500.h ├── stk500_private.h ├── stk500generic.c ├── stk500generic.h ├── stk500v2.c ├── stk500v2.h ├── stk500v2_private.h ├── term.c ├── term.h ├── tpi.h ├── update.c ├── usb_libusb.c ├── usbasp.c ├── usbasp.h ├── usbdevs.h ├── usbtiny.c ├── usbtiny.h ├── windows ├── Makefile ├── Makefile.am ├── Makefile.in ├── giveio.c ├── giveio.sys ├── install_giveio.bat ├── loaddrv.c ├── loaddrv.h ├── remove_giveio.bat └── status_giveio.bat ├── wiring.c ├── wiring.h └── ylwrap /AUTHORS: -------------------------------------------------------------------------------- 1 | AVRDUDE was written by: 2 | 3 | Brian S. Dean 4 | 5 | Contributors: 6 | 7 | Joerg Wunsch 8 | Eric Weddington 9 | Jan-Hinnerk Reichert 10 | Alex Shepherd 11 | Martin Thomas 12 | Theodore A. Roth 13 | Michael Holzt 14 | Colin O'Flynn 15 | Thomas Fischl 16 | David Hoerl 17 | Michal Ludvig 18 | Darell Tan 19 | Wolfgang Moser 20 | Ville Voipio 21 | Hannes Weisbach 22 | Doug Springer 23 | Brett Hagman 24 | Rene Liebscher 25 | Jim Paris 26 | 27 | For minor contributions, please see the ChangeLog files. 28 | 29 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2016-02-16 Joerg Wunsch 2 | 3 | * configure.ac: Released version 6.3. 4 | 5 | 2016-02-15 Joerg Wunsch 6 | 7 | patch #8894: Spelling in 6.2 doc 8 | * doc/avrdude.texi: Various spelling fixes. 9 | 10 | 2016-02-15 Joerg Wunsch 11 | 12 | patch #8895: Spelling in 6.2 code 13 | * avrftdi.c (avrftdi_open): Spell fix. 14 | 15 | 2016-02-15 Joerg Wunsch 16 | 17 | patch #8896: Silence cppcheck warnings in 6.2 code 18 | * linuxgpio.c: Use %ud to print GPIO values. 19 | 20 | 2016-02-15 Joerg Wunsch 21 | 22 | patch #8735: ATtiny28 support in avrdude.conf 23 | * avrdude.conf.in (ATtiny28): New device. 24 | 25 | 2016-02-15 Joerg Wunsch 26 | 27 | * avrdude.conf.in (ATmega48PB, ATmega88PB, ATmega168PB): New 28 | devices. 29 | 30 | 2016-02-15 Joerg Wunsch 31 | 32 | patch #8435: Implementing mEDBG CMSIS-DAP protocol 33 | * usb_libusb.c: Add endpoint IDs for Xplained Mini, correctly 34 | transfer trailing ZLP when needed 35 | * avrdude.conf.in (xplainedmini, xplainedmini_dw): New entries. 36 | * jtag3.c (jtag3_edbg_send, jtag3_edbg_recv_frame): Implement 37 | fragmentation needed for the 64-byte EP size of the Xplained Mini 38 | * avrdude.1: Document the change 39 | * doc/avrdude.texi: (Dito.) 40 | 41 | 42 | -------------------------------------------------------------------------------- /ChangeLog-2002: -------------------------------------------------------------------------------- 1 | 2002-12-12 Brian S. Dean 2 | 3 | * main.c: minor cleanup 4 | 5 | 2002-12-07 Brian S. Dean 6 | 7 | * avrdude.1, main.c: 8 | If the stk500 is being used, default to using the first serial port. 9 | 10 | 2002-12-03 Brian S. Dean 11 | 12 | * avrdude.1: Mention STK500 support. 13 | 14 | 2002-12-01 Brian S. Dean 15 | 16 | * stk500.c: Remove unused code. 17 | 18 | * CHANGELOG, stk500.c: 19 | Document changes since the previous version in the CHANGELOG. 20 | 21 | Cleanup stk500.c a bit. 22 | 23 | * stk500.c: Fix cut and paste braino. 24 | 25 | * avr.c, avrdude.conf.sample, main.c, pgm.h, stk500.c: 26 | The STK500 can perform paged read/write operations even on standard 27 | "non-paged" parts. Take advantage of that and use the faster internal 28 | routines of the STK500 for those parts as well. 29 | 30 | * avr.c, avr.h, avrpart.h, main.c, pgm.c, pgm.h, stk500.c: 31 | Optimize reading and writing for the STK500 programmer if the part 32 | supports paged reads and writes. This greatly decreases the 33 | program/verify time from about 4.5 minutes down to about 10 seconds in 34 | a 12K program size test case. 35 | 36 | Print out the hardware and firmware version for the STK500 if verbose 37 | is enabled. 38 | 39 | * avrdude.conf.sample, avrpart.h, config_gram.y, lexer.l, pgm.h: 40 | * ppi.c, ppi.h, stk500.c, stk500.h, stk500_private.h: 41 | Add basic support for STK500. 42 | 43 | 2002-11-30 Brian S. Dean 44 | 45 | * avrdude.conf.sample, config.c, config.h, config_gram.y, lexer.l: 46 | * main.c, pgm.c, pgm.h, ppi.c, ppi.h, term.c, term.h, Makefile: 47 | * avr.c, avr.h: 48 | Seperate programmer operations out into a driver-like interface so 49 | that programmers other than the direct parallel port connection can be 50 | supported. 51 | 52 | 2002-11-23 Brian S. Dean 53 | 54 | * CHANGELOG, main.c, term.c: 55 | term.c - when in interactive terminal mode and dumping memory using 56 | the 'dump ' command without any address information, 57 | and the end of memory is reached, wrap back around to zero on 58 | the next invocation. 59 | 60 | CHANGELOG - describe changes 61 | 62 | main.c - update version number 63 | 64 | * main.c: 65 | When getting ready to initiate communications with the AVR device, 66 | first pull /RESET low for a short period of time before enabling the 67 | buffer chip. This sequence allows the AVR to be reset before the 68 | buffer is enabled to avoid a short period of time where the AVR may be 69 | driving the programming lines at the same time the programmer tries 70 | to. Of course, if a buffer is being used, then the /RESET line from 71 | the programmer needs to be directly connected to the AVR /RESET line 72 | and not via the buffer chip. 73 | 74 | 2002-11-06 Brian S. Dean 75 | 76 | * CHANGELOG: Update changelog. 77 | 78 | * avr.c, avr.h, main.c: Fix -Y option. Reported by Joerg Wunsch. 79 | 80 | 2002-11-01 Brian S. Dean 81 | 82 | * CHANGELOG, main.c: Version update and CHANGELOG entry. 83 | 84 | * avr.c: 85 | Be backward compatible with the 2-byte rewrite cycle counter which 86 | appeared in version 2.1.0, but was changed to a 4 byte counter in 87 | version 2.1.1. Reminded by Joerg Wunsch. 88 | 89 | 2002-10-29 Brian S. Dean 90 | 91 | * CHANGELOG, avrdude.1, main.c: 92 | Add '-V' (no verify) flag requested by Joerg Wunsch. Update the man 93 | page. 94 | 95 | 2002-10-13 Brian S. Dean 96 | 97 | * CHANGELOG, avrdude.1: Update man page and changelog. 98 | 99 | * main.c: Update version number. 100 | 101 | 2002-10-12 Brian S. Dean 102 | 103 | * Makefile: Remove --pedantic and -g from the compiler options. 104 | 105 | 2002-10-11 Brian S. Dean 106 | 107 | * avr.c, term.c: 108 | Use a four byte value instead of a two byte value for the programming 109 | cycle count stored at the end of EEPROM. It seems as though Atmel was 110 | greatly conservative in claiming a 1000 count reliability for the 111 | FLASH. I current have a part that has been reprogrammed 173330 times, 112 | and counting. 113 | 114 | Fix a compiler warning. 115 | 116 | * avrdude.conf.sample: 117 | Fix ATMega128 instruction encoding for reading the low and high fuse 118 | bits. Thanks to Joerg Wunsch for tripping over this. 119 | 120 | 2002-08-01 Brian S. Dean 121 | 122 | * avr.c, avrdude.1, main.c: 123 | Move erase-rewrite cycle increment to within the chip erase routine so 124 | that it is tracked no matter where the erase was initiated: command 125 | line mode or interactive mode, without code duplicaiton. 126 | 127 | * CHANGELOG: Recent updates. 128 | 129 | * avr.c: Eliminate unused variables. 130 | 131 | * avr.c, avr.h, avrdude.1, fileio.c, main.c: 132 | Implement a way of tracking how many erase-rewrite cycles a part has 133 | undergone. This utilizes the last two bytes of EEPROM to maintain a 134 | counter that is incremented each time the part is erased. 135 | 136 | 2002-07-27 Brian S. Dean 137 | 138 | * avr.c, main.c: 139 | Fix a typo in a comment. Display the size of memory being written. 140 | Display the correct memory name in an error message (previously 141 | hardcoded). 142 | 143 | 2002-06-22 Brian S. Dean 144 | 145 | * CHANGELOG, avrdude.conf.sample: 146 | Add support for ATtiny15 - contributed by Asher Hoskins 147 | 148 | 149 | 2002-04-23 Brian S. Dean 150 | 151 | * CHANGELOG: Say what changed. 152 | 153 | 2002-04-07 Brian S. Dean 154 | 155 | * Makefile, avrdude.conf.sample: 156 | Backup the config file to a timestamped name to keep from possibly 157 | overwriting user-modified configs. 158 | 159 | Add read/write instructions for all memory types for ATMEGA103, 160 | ATMEGA128, ATMEGA16, and ATMEGA8. 161 | 162 | 2002-04-05 Brian S. Dean 163 | 164 | * avrdude.conf.sample: 165 | Add support for ATMEGA128; untested; requested by Jeff Gardner 166 | . 167 | 168 | 2002-02-15 Brian S. Dean 169 | 170 | * avrdude.conf.sample: Minor ordering. 171 | 172 | * CHANGELOG, main.c: Update version numbers. 173 | 174 | 2002-02-14 Brian S. Dean 175 | 176 | * CHANGELOG: Summarize latest updates. 177 | 178 | * avrdude.conf.sample, config_gram.y: 179 | Make pwroff_after_write a yes/no field instead of a numeric. 180 | 181 | * avrdude.conf.sample: Document the pwroff_after_write flag. 182 | 183 | * avr.c: Enable the extra part verbosity when verbosity >= 3. 184 | 185 | * avr.c, avr.h, avrdude.conf.sample, config_gram.y, lexer.l: 186 | * main.c, term.c: 187 | Fix error reporting by avr_write_byte(). 188 | 189 | Fix setting of status LEDs under various write-fail conditions. 190 | 191 | Add a flag to indicate that a memory type requires the device to 192 | possibly be powered off and back on after a write to it. This is due 193 | to a hardware problem on some Atmel devices, see: 194 | 195 | http://www.atmel.com/atmel/acrobat/doc1280.pdf 196 | 197 | Add greater verbosity to the part-display code when verbose>1 to 198 | display avrprog's encoding of the defined programming instructions. 199 | This is primarily for debugging purposes. 200 | 201 | 202 | Part updates: 203 | 204 | * add the AT90S4414 part 205 | 206 | * add fuse and lock bit access instructions for the AT90S1200, 207 | AT90S4434, and AT90S8515. 208 | 209 | * add the pwroff_after_write flag to the fuse bits for the AT90S2333 210 | and AT90S4433 parts 211 | 212 | 2002-02-09 Brian S. Dean 213 | 214 | * avrdude.conf.sample: 215 | Updates to the 2333 and 4433 parts, contributed by Joerg Wunsh. 216 | 217 | 2002-01-18 Brian S. Dean 218 | 219 | * CHANGELOG: Add changelog. 220 | 221 | 2002-01-12 Brian S. Dean 222 | 223 | * main.c: Add (c) to copyright. 224 | 225 | * fileio.c, fileio.h, lexer.l, lists.c, lists.h, main.c: 226 | * pindefs.h, ppi.c, ppi.h, term.c, term.h, avr.c, avr.h: 227 | * config.c, config.h, config_gram.y: 228 | Update version number. Update copyright. 229 | 230 | * avrdude.1: Update copyright and add description of "default". 231 | 232 | Submitted by: Joerg Wunsch 233 | 234 | * avr.c, term.c: 235 | Fix programming of write-only memories (such as lock bits on the 236 | 2313). 237 | 238 | -------------------------------------------------------------------------------- /ChangeLog-2003: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxproff/avrdude-ch341/d2e962355fc6281f7fe50b1b82ec3f6a44bf065a/ChangeLog-2003 -------------------------------------------------------------------------------- /ChangeLog-2008: -------------------------------------------------------------------------------- 1 | 2008-11-20 Joerg Wunsch 2 | 3 | * avrdude.h: Change the prototype for usleep() to be more Cygwin- 4 | friendly. 5 | * ppiwin.c: (Ditto.) 6 | 7 | 2008-11-06 Joerg Wunsch 8 | 9 | Submitted by limor 10 | * usbtiny.c (usbtiny_cmd): Replace sizeof() by a fixed constant 11 | 4 for the result array, because otherwise it would take the size 12 | of a pointer which miserably fails on 64-bit machines. 13 | 14 | 2008-11-05 Joerg Wunsch 15 | 16 | patch #6609: Using PCI parallel port cards on Windows 17 | * ppiwin.c (ppi_open): If the port parameter passed from the 18 | -p option is neither lpt1/2/3, try interpreting it directly as 19 | a base address. 20 | * avrdude.1: Document the change. 21 | * doc/avrdude.texi: (Ditto.) 22 | 23 | 2008-11-04 Joerg Wunsch 24 | 25 | bug #22882: Erase Cycle Counter does not work for stk500v2 26 | * stk500v2.c (stk500v2_chip_erase,stk500hv_chip_erase): Return 27 | the expected 0 for success rather than a protocol-dependant 28 | number. 29 | 30 | 2008-11-04 Joerg Wunsch 31 | 32 | bug #22883: Chip Erase performed even with no-write flag (-n) 33 | * main.c: Do not erase the chip if both, -e and -n options have 34 | been specified. 35 | 36 | 2008-11-04 Joerg Wunsch 37 | 38 | bug #24589: AT90USB64* have wrong signature 39 | * avrdude.conf.in: Uncomment the correct, and delete the wrong 40 | signature for AT90USB646/647. Alas, the datasheet has never been 41 | corrected for years. 42 | 43 | 2008-10-31 Joerg Wunsch 44 | 45 | * jtagmkII.c: Fix a serious memory corruption that happened when 46 | using the JTAG ICE mkII (or AVR Dragon) in ISP mode. The wrong 47 | set of per-programmer private data had been allocated (stk500v2 48 | vs. jtagmkII) which was too small to hold the actual data. 49 | * jtagmkII.h: (Ditto.) 50 | * stk500v2.c: (Ditto.) 51 | 52 | 2008-07-29 Joerg Wunsch 53 | 54 | * jtagmkII.c: Implement Xmega JTAG support. 55 | * jtagmkII_private.h: Add EMULATOR_MODE_JTAG_XMEGA. 56 | 57 | 2008-07-29 Joerg Wunsch 58 | 59 | * main.c: Remember whether the device initialization worked, and 60 | allow to continue with -F if it failed yet do not attempt to 61 | perform anything on the device itself. That way, -tF could be 62 | specified for programmers like the STK500/STK600 even without a 63 | device connected, just in order to allow changing parameters on 64 | the programmer itself. 65 | * avrdude.1: Document that possible use of the -F option. 66 | * doc/avrdude.texi: (Ditto.) 67 | 68 | 2008-07-29 Joerg Wunsch 69 | 70 | * stk500v2.c (stk600_xprog_paged_write): Fix a fatal miscalculation 71 | of the number of bytes to be written which caused a malloc chunk 72 | corruption. 73 | 74 | 2008-07-27 Joerg Wunsch 75 | 76 | First implementation of ATxmega support. By now, only the 77 | PDI mode of the STK600 is supported. Single-byte EEPROM 78 | (and flash) updates do not work yet. 79 | * avr.c: "boot" memory is a candidate memory region for paged 80 | operations, besides "flash" and "eeprom". 81 | * avrdude.conf.in: add ATxmega128A1 and ATxmega128A1revD 82 | * avrpart.h: add the AVRPART_HAS_PDI flag (used to distinguish 83 | ATxmega parts from classic AVRs), the nvm_base part field, and 84 | the offset field for a memory region. 85 | * config_gram.y: add "has_pdi", "nvm_base", and "offset" 86 | * lexer.l: (Ditto.) 87 | * main.c: disable auto_erase for ATxmega parts 88 | * stk500v2.c: implement the XPROG functionality, and divert to 89 | this for ATxmega parts 90 | * avrdude.1: Document the changes. 91 | * doc/avrdude.texi: (Ditto.) 92 | 93 | 2008-07-25 Joerg Wunsch 94 | 95 | Fix a bunch of warnings. 96 | * avr910.c (avr910_paged_load): possible unitialized use of 97 | rd_size 98 | * jtagmkI.c (jtagmkI_initialize): pointer signedness mixup 99 | * jtagmkII.c (jtagmkII_print_parms1): propagate const'ness 100 | of parameter 101 | * usbasp.c (usbasp_transmit): pointer signedness mixup 102 | * ser_avrdoper.c (usbGetReport): remove useless pointer deref 103 | 104 | 2008-07-25 Joerg Wunsch 105 | 106 | Contributed by Ville Voipio: 107 | patch #6501: New autotools support for avrdude 108 | * Makefile.am: add @WINDOWS_DIRS@ to SUBDIR 109 | * bootstrap: allow for autconf-2.61 and automake-1.10, too 110 | * configure.ac: fix @WINDOWS_DIRS@ recursion, replace 111 | AC_PROG_CC by AM_PROG_CC_C_O, for esoteric reasons 112 | 113 | 2008-06-13 Joerg Wunsch 114 | 115 | Contributed by Janos Sallai : 116 | patch #6074: added support for crossbow's MIB510 programmer 117 | * avrdude.conf.in: Add entry for mib510. 118 | * stk500.c: Add special hooks to handle the MIB510 programmer. 119 | It mostly talks STK500v1 protocol but has a special hello and 120 | goodbye sequence, and uses a fixed block size of 256 bytes. 121 | * doc/avrdude.texi: Document support for mib510. 122 | 123 | 2008-06-07 Joerg Wunsch 124 | 125 | Contributed by Klaus Leidinger : 126 | * main.c: Realign verbose messages. 127 | * avrpart.c: (Ditto.) 128 | * avr910.c: Print the device code selected in verbose mode. 129 | * butterfly.c: (Ditto.) 130 | 131 | 2008-06-07 Joerg Wunsch 132 | 133 | Contributed by Klaus Leidinger : 134 | Add check for buffermode feature, and use it if present. Can be 135 | turned off using -x no_blockmode. 136 | * avr910.c: Implement buffermode test and usage. 137 | * avrdude.1: Document -x no_blockmode. 138 | * doc/avrdude.texi: (Ditto.) 139 | 140 | 2008-03-24 Joerg Wunsch 141 | 142 | * usb_libusb.c: #undef interface for Win32 143 | 144 | 2008-03-24 Joerg Wunsch 145 | 146 | * avr910.c: Add support for the -x devcode option. 147 | * avrdude.1: Document -x devcode for avr910. 148 | * doc/avrdude.texi: (Ditto.) 149 | 150 | 2008-03-14 Joerg Wunsch 151 | 152 | Add initial support for the Atmel STK600, for 153 | "classic" AVRs (AT90, ATtiny, ATmega) in both, 154 | ISP and high-voltage programming modes. 155 | * Makefile.am: Add -lm. 156 | * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. 157 | * config_gram.y: Add support for the stk600* keywords. 158 | * lexer.l: (Ditto.) 159 | * pgm.h: Add the "chan" parameter to set_varef(). 160 | * stk500.c: (Ditto.) 161 | * serial.h: Add USB endpoint support to struct filedescriptor. 162 | * stk500v2.c: Implement the meat of the STK600 support. 163 | * stk500v2.h: Add new prototypes for stk600*() programmers. 164 | * stk500v2_private.h: Add new constants used in the STK600. 165 | * term.c: Add AREF channel support. 166 | * usb_libusb.c: Automatically determine the correct write 167 | endpoint ID, the STK600 uses 0x83 while all other tools use 168 | 0x82. Propagate the EP to use through struct filedescriptor. 169 | * usbdevs.h: Add the STK600 USB product ID. 170 | * tools/get-stk600-cards.xsl: XSL transformation for 171 | targetboards.xml to obtain the list of socket and routing 172 | card IDs, to be used in stk500v2.c (for displaying the 173 | names). 174 | * tools/get-stk600-devices.xsl: XSL transformation for 175 | targetboards.xml to obtain the table of socket/routing cards 176 | and their respective AVR device support for doc/avrdude.texi. 177 | * avrdude.1: Document all the STK600 stuff. 178 | * doc/avrdude.texi: Ditto. Added a new chapter for 179 | Programmer Specific Information. 180 | 181 | 2008-01-26 Joerg Wunsch 182 | 183 | * stk500v2.c (stk500v2_recv): Make length computation unsigned so 184 | it cannot accidentally become negative. 185 | 186 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # avrdude - A Downloader/Uploader for AVR device programmers 3 | # Copyright (C) 2003, 2004 Theodore A. Roth 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | # 20 | # $Id$ 21 | # 22 | 23 | EXTRA_DIST = \ 24 | ChangeLog \ 25 | ChangeLog-2001 \ 26 | ChangeLog-2002 \ 27 | ChangeLog-2003 \ 28 | ChangeLog-2004-2006 \ 29 | ChangeLog-2007 \ 30 | ChangeLog-2008 \ 31 | ChangeLog-2009 \ 32 | ChangeLog-2010 \ 33 | ChangeLog-2011 \ 34 | ChangeLog-2012 \ 35 | ChangeLog-2013 \ 36 | avrdude.1 \ 37 | avrdude.spec \ 38 | bootstrap 39 | 40 | CLEANFILES = \ 41 | config_gram.c \ 42 | config_gram.h \ 43 | lexer.c 44 | 45 | BUILT_SOURCES = $(CLEANFILES) 46 | 47 | #SUBDIRS = doc @WINDOWS_DIRS@ 48 | #DIST_SUBDIRS = doc windows 49 | 50 | # . lets build this directory before the following in SUBDIRS 51 | SUBDIRS = . 52 | # doc comes here, and we want to use the built avrdude to generate the parts list 53 | SUBDIRS += @SUBDIRS_AC@ 54 | SUBDIRS += @WINDOWS_DIRS@ 55 | DIST_SUBDIRS = @DIST_SUBDIRS_AC@ 56 | 57 | AM_YFLAGS = -d 58 | 59 | avrdude_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" 60 | 61 | libavrdude_a_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" 62 | libavrdude_la_CPPFLAGS = $(libavrdude_a_CPPFLAGS) 63 | 64 | avrdude_CFLAGS = @ENABLE_WARNINGS@ 65 | 66 | libavrdude_a_CFLAGS = @ENABLE_WARNINGS@ 67 | libavrdude_la_CFLAGS = $(libavrdude_a_CFLAGS) 68 | 69 | avrdude_LDADD = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB_1_0@ @LIBUSB@ @LIBFTDI1@ @LIBFTDI@ @LIBHID@ @LIBELF@ @LIBPTHREAD@ -lm -lch341dll_1_modtxt 70 | 71 | bin_PROGRAMS = avrdude 72 | 73 | noinst_LIBRARIES = libavrdude.a 74 | lib_LTLIBRARIES = libavrdude.la 75 | 76 | # automake thinks these generated files should be in the distribution, 77 | # but this might cause trouble for some users, so we rather don't want 78 | # to have them there. 79 | # 80 | # See 81 | # 82 | # https://savannah.nongnu.org/bugs/index.php?func=detailitem&item_id=15536 83 | # 84 | # for why we don't want to have them. 85 | dist-hook: 86 | rm -f \ 87 | $(distdir)/lexer.c \ 88 | $(distdir)/config_gram.c \ 89 | $(distdir)/config_gram.h 90 | 91 | libavrdude_a_SOURCES = \ 92 | config_gram.y \ 93 | lexer.l \ 94 | arduino.h \ 95 | arduino.c \ 96 | avr.c \ 97 | avr910.c \ 98 | avr910.h \ 99 | avrdude.h \ 100 | avrftdi.c \ 101 | avrftdi.h \ 102 | avrftdi_private.h \ 103 | avrftdi_tpi.c \ 104 | avrftdi_tpi.h \ 105 | avrpart.c \ 106 | bitbang.c \ 107 | bitbang.h \ 108 | buspirate.c \ 109 | buspirate.h \ 110 | butterfly.c \ 111 | butterfly.h \ 112 | config.c \ 113 | config.h \ 114 | confwin.c \ 115 | crc16.c \ 116 | crc16.h \ 117 | dfu.c \ 118 | dfu.h \ 119 | fileio.c \ 120 | flip1.c \ 121 | flip1.h \ 122 | flip2.c \ 123 | flip2.h \ 124 | freebsd_ppi.h \ 125 | ft245r.c \ 126 | ft245r.h \ 127 | jtagmkI.c \ 128 | jtagmkI.h \ 129 | jtagmkI_private.h \ 130 | jtagmkII.c \ 131 | jtagmkII.h \ 132 | jtagmkII_private.h \ 133 | jtag3.c \ 134 | jtag3.h \ 135 | jtag3_private.h \ 136 | libavrdude.h \ 137 | linuxgpio.c \ 138 | linuxgpio.h \ 139 | linux_ppdev.h \ 140 | lists.c \ 141 | my_ddk_hidsdi.h \ 142 | par.c \ 143 | par.h \ 144 | pgm.c \ 145 | pgm_type.c \ 146 | pickit2.c \ 147 | pickit2.h \ 148 | pindefs.c \ 149 | ppi.c \ 150 | ppi.h \ 151 | ppiwin.c \ 152 | safemode.c \ 153 | serbb.h \ 154 | serbb_posix.c \ 155 | serbb_win32.c \ 156 | ser_avrdoper.c \ 157 | ser_posix.c \ 158 | ser_win32.c \ 159 | solaris_ecpp.h \ 160 | stk500.c \ 161 | stk500.h \ 162 | stk500_private.h \ 163 | stk500v2.c \ 164 | stk500v2.h \ 165 | stk500v2_private.h \ 166 | stk500generic.c \ 167 | stk500generic.h \ 168 | tpi.h \ 169 | usbasp.c \ 170 | usbasp.h \ 171 | ch341a.c \ 172 | ch341a.h \ 173 | ch341a_bitbang.c \ 174 | ch341a_bitbang.h \ 175 | ch341a_bitbang_wch.c \ 176 | ch341a_bitbang_wch.h \ 177 | usbdevs.h \ 178 | usb_libusb.c \ 179 | usbtiny.h \ 180 | usbtiny.c \ 181 | update.c \ 182 | wiring.h \ 183 | wiring.c 184 | libavrdude_la_SOURCES = $(libavrdude_a_SOURCES) 185 | libavrdude_la_LDFLAGS = -version-info 1:0 186 | 187 | include_HEADERS = libavrdude.h 188 | 189 | avrdude_SOURCES = \ 190 | main.c \ 191 | term.c \ 192 | term.h 193 | 194 | man_MANS = avrdude.1 195 | 196 | sysconf_DATA = avrdude.conf 197 | 198 | install-exec-local: backup-avrdude-conf 199 | 200 | distclean-local: 201 | rm -f avrdude.conf 202 | 203 | # This will get run before the config file is installed. 204 | backup-avrdude-conf: 205 | @echo "Backing up avrdude.conf in ${DESTDIR}${sysconfdir}" 206 | @if test -e ${DESTDIR}${sysconfdir}/avrdude.conf; then \ 207 | cp -pR ${DESTDIR}${sysconfdir}/avrdude.conf \ 208 | ${DESTDIR}${sysconfdir}/avrdude.conf.bak; \ 209 | fi 210 | 211 | ACLOCAL_AMFLAGS = -I m4 212 | -------------------------------------------------------------------------------- /Makefile.am.orig: -------------------------------------------------------------------------------- 1 | # 2 | # avrdude - A Downloader/Uploader for AVR device programmers 3 | # Copyright (C) 2003, 2004 Theodore A. Roth 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | # 20 | # $Id: Makefile.am 1357 2015-10-30 23:11:22Z joerg_wunsch $ 21 | # 22 | 23 | EXTRA_DIST = \ 24 | ChangeLog \ 25 | ChangeLog-2001 \ 26 | ChangeLog-2002 \ 27 | ChangeLog-2003 \ 28 | ChangeLog-2004-2006 \ 29 | ChangeLog-2007 \ 30 | ChangeLog-2008 \ 31 | ChangeLog-2009 \ 32 | ChangeLog-2010 \ 33 | ChangeLog-2011 \ 34 | ChangeLog-2012 \ 35 | ChangeLog-2013 \ 36 | avrdude.1 \ 37 | avrdude.spec \ 38 | bootstrap 39 | 40 | CLEANFILES = \ 41 | config_gram.c \ 42 | config_gram.h \ 43 | lexer.c 44 | 45 | BUILT_SOURCES = $(CLEANFILES) 46 | 47 | #SUBDIRS = doc @WINDOWS_DIRS@ 48 | #DIST_SUBDIRS = doc windows 49 | 50 | # . lets build this directory before the following in SUBDIRS 51 | SUBDIRS = . 52 | # doc comes here, and we want to use the built avrdude to generate the parts list 53 | SUBDIRS += @SUBDIRS_AC@ 54 | SUBDIRS += @WINDOWS_DIRS@ 55 | DIST_SUBDIRS = @DIST_SUBDIRS_AC@ 56 | 57 | AM_YFLAGS = -d 58 | 59 | avrdude_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" 60 | 61 | libavrdude_a_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" 62 | libavrdude_la_CPPFLAGS = $(libavrdude_a_CPPFLAGS) 63 | 64 | avrdude_CFLAGS = @ENABLE_WARNINGS@ 65 | 66 | libavrdude_a_CFLAGS = @ENABLE_WARNINGS@ 67 | libavrdude_la_CFLAGS = $(libavrdude_a_CFLAGS) 68 | 69 | avrdude_LDADD = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB_1_0@ @LIBUSB@ @LIBFTDI1@ @LIBFTDI@ @LIBHID@ @LIBELF@ @LIBPTHREAD@ -lm 70 | 71 | bin_PROGRAMS = avrdude 72 | 73 | noinst_LIBRARIES = libavrdude.a 74 | lib_LTLIBRARIES = libavrdude.la 75 | 76 | # automake thinks these generated files should be in the distribution, 77 | # but this might cause trouble for some users, so we rather don't want 78 | # to have them there. 79 | # 80 | # See 81 | # 82 | # https://savannah.nongnu.org/bugs/index.php?func=detailitem&item_id=15536 83 | # 84 | # for why we don't want to have them. 85 | dist-hook: 86 | rm -f \ 87 | $(distdir)/lexer.c \ 88 | $(distdir)/config_gram.c \ 89 | $(distdir)/config_gram.h 90 | 91 | libavrdude_a_SOURCES = \ 92 | config_gram.y \ 93 | lexer.l \ 94 | arduino.h \ 95 | arduino.c \ 96 | avr.c \ 97 | avr910.c \ 98 | avr910.h \ 99 | avrdude.h \ 100 | avrftdi.c \ 101 | avrftdi.h \ 102 | avrftdi_private.h \ 103 | avrftdi_tpi.c \ 104 | avrftdi_tpi.h \ 105 | avrpart.c \ 106 | bitbang.c \ 107 | bitbang.h \ 108 | buspirate.c \ 109 | buspirate.h \ 110 | butterfly.c \ 111 | butterfly.h \ 112 | config.c \ 113 | config.h \ 114 | confwin.c \ 115 | crc16.c \ 116 | crc16.h \ 117 | dfu.c \ 118 | dfu.h \ 119 | fileio.c \ 120 | flip1.c \ 121 | flip1.h \ 122 | flip2.c \ 123 | flip2.h \ 124 | freebsd_ppi.h \ 125 | ft245r.c \ 126 | ft245r.h \ 127 | jtagmkI.c \ 128 | jtagmkI.h \ 129 | jtagmkI_private.h \ 130 | jtagmkII.c \ 131 | jtagmkII.h \ 132 | jtagmkII_private.h \ 133 | jtag3.c \ 134 | jtag3.h \ 135 | jtag3_private.h \ 136 | libavrdude.h \ 137 | linuxgpio.c \ 138 | linuxgpio.h \ 139 | linux_ppdev.h \ 140 | lists.c \ 141 | my_ddk_hidsdi.h \ 142 | par.c \ 143 | par.h \ 144 | pgm.c \ 145 | pgm_type.c \ 146 | pickit2.c \ 147 | pickit2.h \ 148 | pindefs.c \ 149 | ppi.c \ 150 | ppi.h \ 151 | ppiwin.c \ 152 | safemode.c \ 153 | serbb.h \ 154 | serbb_posix.c \ 155 | serbb_win32.c \ 156 | ser_avrdoper.c \ 157 | ser_posix.c \ 158 | ser_win32.c \ 159 | solaris_ecpp.h \ 160 | stk500.c \ 161 | stk500.h \ 162 | stk500_private.h \ 163 | stk500v2.c \ 164 | stk500v2.h \ 165 | stk500v2_private.h \ 166 | stk500generic.c \ 167 | stk500generic.h \ 168 | tpi.h \ 169 | usbasp.c \ 170 | usbasp.h \ 171 | usbdevs.h \ 172 | usb_libusb.c \ 173 | usbtiny.h \ 174 | usbtiny.c \ 175 | update.c \ 176 | wiring.h \ 177 | wiring.c 178 | libavrdude_la_SOURCES = $(libavrdude_a_SOURCES) 179 | libavrdude_la_LDFLAGS = -version-info 1:0 180 | 181 | include_HEADERS = libavrdude.h 182 | 183 | avrdude_SOURCES = \ 184 | main.c \ 185 | term.c \ 186 | term.h 187 | 188 | man_MANS = avrdude.1 189 | 190 | sysconf_DATA = avrdude.conf 191 | 192 | install-exec-local: backup-avrdude-conf 193 | 194 | distclean-local: 195 | rm -f avrdude.conf 196 | 197 | # This will get run before the config file is installed. 198 | backup-avrdude-conf: 199 | @echo "Backing up avrdude.conf in ${DESTDIR}${sysconfdir}" 200 | @if test -e ${DESTDIR}${sysconfdir}/avrdude.conf; then \ 201 | cp -pR ${DESTDIR}${sysconfdir}/avrdude.conf \ 202 | ${DESTDIR}${sysconfdir}/avrdude.conf.bak; \ 203 | fi 204 | 205 | ACLOCAL_AMFLAGS = -I m4 206 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxproff/avrdude-ch341/d2e962355fc6281f7fe50b1b82ec3f6a44bf065a/NEWS -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # avrdude-ch341 2 | avrdude with ch341a programmer support (fullspeed and bitbang) for Windows WCH official driver and Linux (based on Alexey Sadkov patch and WinChipHead sources). 3 | 4 | Very VERY VERY DIRTY coding. I'm not programmer, I'm dirty-coder in the past. 5 | But it works! 6 | 7 | avrdude с поддержкой программатора ch341a (fullspeed и bitbang) для официального драйвера Windows WCH и Linux (на основе патча Алексея Садкова и исходников WinChipHead). 8 | 9 | Очень ОЧЕНЬ ОЧЕНЬ грязный код. Я не программист, я просто попробовал, и у меня получилось! 10 | 11 | (I build with i686-w64-mingw32-gcc (GCC) 4.9.1 on raspbian-jessie) 12 | 13 | TODO: 14 | 15 | It is hardcoded for use CS0 (D0, pin 15 of CH341A) chip select pin as reset RST pin of AVR. 16 | 17 | If your programmer is made for use CS1 (D1, pin 16 of CH341A), you can change code ("CH341A_CMD_UIO_STM_DIR | 0x2A; CH341A_CMD_UIO_STM_OUT |0x02" for example, etc...) 18 | 19 | or resolder CS0 pin instead CS1 on your programmer. (AT YOUR OWN RISK, For example, Maker39 uses coupling CS0+CS1 after 100 ohm resistors 20 | 21 | http://forum.easyelectronics.ru/viewtopic.php?p=514203&sid=a6d35d21cdeb16a76044c32e8fc11987#p514203 ) 22 | 23 | Edit DELAY_US for tune bitbang speed. 24 | 25 | Last stage of linking may be fail (I did it several years ago. I'm too lazy to test it right now again). 26 | 27 | I linked with libch341dll_1_modtxt.a and some other dependencies manually. 28 | 29 | You can edit Makefile for clean linking. 30 | 31 | Windows fullspeed SPI (fastSPI) mode available with LibUSB-alternative-driver only, 32 | 33 | but for WCH-driver this mode didn't released (It isn't need for me). 34 | 35 | You can simply release this mode by comparing "ch341a.c" and "ch341a_bitbang_wch.c". 36 | 37 | Захардкожено на CS0 (D0, 15-й пин CH341A) в для подключения к RST на AVR. 38 | 39 | Если Ваш программатор распаян для использования CS1 (D1, 16-й пин CH341A), вы можете изменить код (например, «CH341A_CMD_UIO_STM_DIR | 0x2A; CH341A_CMD_UIO_STM_OUT |0x02» и т. д.) 40 | 41 | или перепаяйте пин CS0 вместо CS1 на вашем программаторе. (НА СВОЙ РИСК, например, Maker39 использует перемычку CS0+CS1 после резисторов 100 Ом 42 | 43 | http://forum.easyelectronics.ru/viewtopic.php?p=514203&sid=a6d35d21cdeb16a76044c32e8fc11987#p514203 ) 44 | 45 | Отредактируйте DELAY_US для настройки скорости в режиме bitbang. 46 | 47 | На последнем этапе при линковке может вылететь с ошибкой (Давно это было, мне сейчас не досуг снова проверять). 48 | 49 | Я линковал вручную с libch341dll_1_modtxt.a и некоторыми другими либами. 50 | 51 | Вы можете поправить Makefile для корректной автоматической сборки. 52 | 53 | Под Windows режим быстрого SPI доступен только с альтернативным LibUSB драйвером. 54 | 55 | Для драйвера WCH я такой режим не делал за ненадобностью. 56 | 57 | Вы можете сделать его по аналогии, опираясь на "ch341a.c" и "ch341a_bitbang_wch.c". 58 | 59 | CREDITS: 60 | 61 | http://www.nongnu.org/avrdude/ 62 | 63 | https://github.com/Alx2000y/avrdude_ch341a 64 | 65 | http://savannah.nongnu.org/patch/?9127 66 | 67 | http://forum.easyelectronics.ru/viewtopic.php?f=13&t=32626 68 | 69 | https://yourdevice.net/forum/viewtopic.php?f=26&t=1812#p3517 70 | 71 | http://www.wch-ic.com/downloads/category/30.html 72 | 73 | https://disk.yandex.ru/d/oBIy7HXc3MJgSg 74 | 75 | https://github.com/Trel725/chavrprog 76 | 77 | http://forum.easyelectronics.ru/viewtopic.php?p=503664#p503664 78 | 79 | http://docs.expressvl.ru/index.html 80 | 81 | -------------------------------------------------------------------------------- /README_avrdude: -------------------------------------------------------------------------------- 1 | See the documentation file for the details. 2 | 3 | The latest version of AVRDUDE is always available here: 4 | 5 | http://savannah.nongnu.org/projects/avrdude 6 | 7 | 8 | Important environment variables for ./configure: 9 | ================================================ 10 | 11 | CPPFLAGS: C preprocessor flags (*not* "C++") 12 | 13 | This is the place to put additional (non-standard) -I options into. 14 | For example, if your Windows system has LibUSB-Win32 installed into 15 | \\WINDOWS\ProgramFiles\LibUSB-Win32, use 16 | 17 | CPPFLAGS=-I/WINDOWS/ProgramFiles/LibUSB-Win32/include 18 | 19 | to tell configure where to search for the header files. (The use of 20 | forward slashes rather than backslashes can often simplify things. 21 | Note that the Windows system services internally treat both the same. 22 | It's only cmd.exe which requires backslashes as the directory 23 | separator.) 24 | 25 | LDFLAGS: Linker options 26 | 27 | This is the place to make additional library locations known to the 28 | linker. To continue the above example, use 29 | 30 | LDFLAGS=-L/WINDOWS/ProgramFiles/LibUSB-Win32/lib/gcc 31 | 32 | to make the linker search for "libusb.a" in that directory. 33 | 34 | 35 | Linux users: make sure the header files are installed 36 | ===================================================== 37 | 38 | While many Linux distributions install the libraries needed by AVRDUDE 39 | (libusb, libelf) by default, they leave out the corresponding header 40 | files. Consequently, the configure script won't find them, so these 41 | libraries could not be used. 42 | 43 | Usually, the packages with the header files (and static libraries) are 44 | derived from the regular package name by appending "-devel". Thus, 45 | make sure you have "libusb-devel" and "libelf-devel" installed before 46 | running the configure script. (Same goes for libftdi.) 47 | -------------------------------------------------------------------------------- /ac_cfg.h: -------------------------------------------------------------------------------- 1 | /* ac_cfg.h. Generated from ac_cfg.h.in by configure. */ 2 | /* ac_cfg.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to 1 if you have the header file. */ 5 | #define HAVE_DDK_HIDSDI_H 1 6 | 7 | /* Define to 1 if you have the header file. */ 8 | /* #undef HAVE_DLFCN_H */ 9 | 10 | /* Define to 1 if you have the header file. */ 11 | #define HAVE_FCNTL_H 1 12 | 13 | /* Define to 1 if you have the `gettimeofday' function. */ 14 | #define HAVE_GETTIMEOFDAY 1 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_INTTYPES_H 1 18 | 19 | /* Define if ELF support is enabled via libelf */ 20 | #define HAVE_LIBELF 1 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_LIBELF_H 1 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #define HAVE_LIBELF_LIBELF_H 1 27 | 28 | /* Define if FTDI support is enabled via libftdi */ 29 | /* #undef HAVE_LIBFTDI */ 30 | 31 | /* Define if FTDI support is enabled via libftdi1 */ 32 | #define HAVE_LIBFTDI1 1 33 | 34 | /* Define if libftdi supports FT232H, libftdi version >= 0.20 */ 35 | /* #undef HAVE_LIBFTDI_TYPE_232H */ 36 | 37 | /* Define if HID support is enabled via the Win32 DDK */ 38 | #define HAVE_LIBHID 1 39 | 40 | /* Define to 1 if you have the `ncurses' library (-lncurses). */ 41 | /* #undef HAVE_LIBNCURSES */ 42 | 43 | /* Define to 1 if you have the `readline' library (-lreadline). */ 44 | /* #undef HAVE_LIBREADLINE */ 45 | 46 | /* Define to 1 if you have the `termcap' library (-ltermcap). */ 47 | /* #undef HAVE_LIBTERMCAP */ 48 | 49 | /* Define if USB support is enabled via libusb */ 50 | #define HAVE_LIBUSB 1 51 | 52 | /* Define if USB support is enabled via a libusb-1.0 compatible libusb */ 53 | #define HAVE_LIBUSB_1_0 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #define HAVE_LIBUSB_1_0_LIBUSB_H 1 57 | 58 | /* Define to 1 if you have the header file. */ 59 | #define HAVE_LIBUSB_H 1 60 | 61 | /* Define to 1 if you have the `ws2_32' library (-lws2_32). */ 62 | #define HAVE_LIBWS2_32 1 63 | 64 | /* Define to 1 if you have the header file. */ 65 | #define HAVE_LIMITS_H 1 66 | 67 | /* Linux sysfs GPIO support enabled */ 68 | /* #undef HAVE_LINUXGPIO */ 69 | 70 | /* Define to 1 if you have the header file. */ 71 | #define HAVE_LUSB0_USB_H 1 72 | 73 | /* Define to 1 if you have the header file. */ 74 | #define HAVE_MEMORY_H 1 75 | 76 | /* Define to 1 if you have the `memset' function. */ 77 | #define HAVE_MEMSET 1 78 | 79 | /* parallel port access enabled */ 80 | #define HAVE_PARPORT 1 81 | 82 | /* Define to 1 if you have the header file. */ 83 | #define HAVE_PTHREAD_H 1 84 | 85 | /* Define to 1 if you have the `select' function. */ 86 | /* #undef HAVE_SELECT */ 87 | 88 | /* Define to 1 if you have the header file. */ 89 | #define HAVE_STDINT_H 1 90 | 91 | /* Define to 1 if you have the header file. */ 92 | #define HAVE_STDLIB_H 1 93 | 94 | /* Define to 1 if you have the `strcasecmp' function. */ 95 | #define HAVE_STRCASECMP 1 96 | 97 | /* Define to 1 if you have the `strdup' function. */ 98 | #define HAVE_STRDUP 1 99 | 100 | /* Define to 1 if you have the `strerror' function. */ 101 | #define HAVE_STRERROR 1 102 | 103 | /* Define to 1 if you have the header file. */ 104 | #define HAVE_STRINGS_H 1 105 | 106 | /* Define to 1 if you have the header file. */ 107 | #define HAVE_STRING_H 1 108 | 109 | /* Define to 1 if you have the `strncasecmp' function. */ 110 | #define HAVE_STRNCASECMP 1 111 | 112 | /* Define to 1 if you have the `strtol' function. */ 113 | #define HAVE_STRTOL 1 114 | 115 | /* Define to 1 if you have the `strtoul' function. */ 116 | #define HAVE_STRTOUL 1 117 | 118 | /* Define to 1 if you have the header file. */ 119 | /* #undef HAVE_SYS_IOCTL_H */ 120 | 121 | /* Define to 1 if you have the header file. */ 122 | #define HAVE_SYS_STAT_H 1 123 | 124 | /* Define to 1 if you have the header file. */ 125 | #define HAVE_SYS_TIME_H 1 126 | 127 | /* Define to 1 if you have the header file. */ 128 | #define HAVE_SYS_TYPES_H 1 129 | 130 | /* Define to 1 if you have the header file. */ 131 | /* #undef HAVE_TERMIOS_H */ 132 | 133 | /* Define to 1 if the system has the type `uint_t'. */ 134 | /* #undef HAVE_UINT_T */ 135 | 136 | /* Define to 1 if the system has the type `ulong_t'. */ 137 | /* #undef HAVE_ULONG_T */ 138 | 139 | /* Define to 1 if you have the header file. */ 140 | #define HAVE_UNISTD_H 1 141 | 142 | /* Define to 1 if you have the header file. */ 143 | #define HAVE_USB_H 1 144 | 145 | /* Define to 1 if you have the `usleep' function. */ 146 | #define HAVE_USLEEP 1 147 | 148 | /* Define if lex/flex has yylex_destroy */ 149 | #define HAVE_YYLEX_DESTROY 1 150 | 151 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 152 | */ 153 | #define LT_OBJDIR ".libs/" 154 | 155 | /* Name of package */ 156 | #define PACKAGE "avrdude" 157 | 158 | /* Define to the address where bug reports for this package should be sent. */ 159 | #define PACKAGE_BUGREPORT "avrdude-dev@nongnu.org" 160 | 161 | /* Define to the full name of this package. */ 162 | #define PACKAGE_NAME "avrdude" 163 | 164 | /* Define to the full name and version of this package. */ 165 | #define PACKAGE_STRING "avrdude 6.3" 166 | 167 | /* Define to the one symbol short name of this package. */ 168 | #define PACKAGE_TARNAME "avrdude" 169 | 170 | /* Define to the home page for this package. */ 171 | #define PACKAGE_URL "" 172 | 173 | /* Define to the version of this package. */ 174 | #define PACKAGE_VERSION "6.3" 175 | 176 | /* Define to 1 if you have the ANSI C header files. */ 177 | #define STDC_HEADERS 1 178 | 179 | /* Define to 1 if you can safely include both and . */ 180 | #define TIME_WITH_SYS_TIME 1 181 | 182 | /* Version number of package */ 183 | #define VERSION "6.3" 184 | 185 | /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a 186 | `char[]'. */ 187 | /* #undef YYTEXT_POINTER */ 188 | 189 | /* Define to empty if `const' does not conform to ANSI C. */ 190 | /* #undef const */ 191 | -------------------------------------------------------------------------------- /ac_cfg.h.in: -------------------------------------------------------------------------------- 1 | /* ac_cfg.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DDK_HIDSDI_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_DLFCN_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_FCNTL_H 11 | 12 | /* Define to 1 if you have the `gettimeofday' function. */ 13 | #undef HAVE_GETTIMEOFDAY 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_INTTYPES_H 17 | 18 | /* Define if ELF support is enabled via libelf */ 19 | #undef HAVE_LIBELF 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_LIBELF_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_LIBELF_LIBELF_H 26 | 27 | /* Define if FTDI support is enabled via libftdi */ 28 | #undef HAVE_LIBFTDI 29 | 30 | /* Define if FTDI support is enabled via libftdi1 */ 31 | #undef HAVE_LIBFTDI1 32 | 33 | /* Define if libftdi supports FT232H, libftdi version >= 0.20 */ 34 | #undef HAVE_LIBFTDI_TYPE_232H 35 | 36 | /* Define if HID support is enabled via the Win32 DDK */ 37 | #undef HAVE_LIBHID 38 | 39 | /* Define to 1 if you have the `ncurses' library (-lncurses). */ 40 | #undef HAVE_LIBNCURSES 41 | 42 | /* Define to 1 if you have the `readline' library (-lreadline). */ 43 | #undef HAVE_LIBREADLINE 44 | 45 | /* Define to 1 if you have the `termcap' library (-ltermcap). */ 46 | #undef HAVE_LIBTERMCAP 47 | 48 | /* Define if USB support is enabled via libusb */ 49 | #undef HAVE_LIBUSB 50 | 51 | /* Define if USB support is enabled via a libusb-1.0 compatible libusb */ 52 | #undef HAVE_LIBUSB_1_0 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #undef HAVE_LIBUSB_1_0_LIBUSB_H 56 | 57 | /* Define to 1 if you have the header file. */ 58 | #undef HAVE_LIBUSB_H 59 | 60 | /* Define to 1 if you have the `ws2_32' library (-lws2_32). */ 61 | #undef HAVE_LIBWS2_32 62 | 63 | /* Define to 1 if you have the header file. */ 64 | #undef HAVE_LIMITS_H 65 | 66 | /* Linux sysfs GPIO support enabled */ 67 | #undef HAVE_LINUXGPIO 68 | 69 | /* Define to 1 if you have the header file. */ 70 | #undef HAVE_LUSB0_USB_H 71 | 72 | /* Define to 1 if you have the header file. */ 73 | #undef HAVE_MEMORY_H 74 | 75 | /* Define to 1 if you have the `memset' function. */ 76 | #undef HAVE_MEMSET 77 | 78 | /* parallel port access enabled */ 79 | #undef HAVE_PARPORT 80 | 81 | /* Define to 1 if you have the header file. */ 82 | #undef HAVE_PTHREAD_H 83 | 84 | /* Define to 1 if you have the `select' function. */ 85 | #undef HAVE_SELECT 86 | 87 | /* Define to 1 if you have the header file. */ 88 | #undef HAVE_STDINT_H 89 | 90 | /* Define to 1 if you have the header file. */ 91 | #undef HAVE_STDLIB_H 92 | 93 | /* Define to 1 if you have the `strcasecmp' function. */ 94 | #undef HAVE_STRCASECMP 95 | 96 | /* Define to 1 if you have the `strdup' function. */ 97 | #undef HAVE_STRDUP 98 | 99 | /* Define to 1 if you have the `strerror' function. */ 100 | #undef HAVE_STRERROR 101 | 102 | /* Define to 1 if you have the header file. */ 103 | #undef HAVE_STRINGS_H 104 | 105 | /* Define to 1 if you have the header file. */ 106 | #undef HAVE_STRING_H 107 | 108 | /* Define to 1 if you have the `strncasecmp' function. */ 109 | #undef HAVE_STRNCASECMP 110 | 111 | /* Define to 1 if you have the `strtol' function. */ 112 | #undef HAVE_STRTOL 113 | 114 | /* Define to 1 if you have the `strtoul' function. */ 115 | #undef HAVE_STRTOUL 116 | 117 | /* Define to 1 if you have the header file. */ 118 | #undef HAVE_SYS_IOCTL_H 119 | 120 | /* Define to 1 if you have the header file. */ 121 | #undef HAVE_SYS_STAT_H 122 | 123 | /* Define to 1 if you have the header file. */ 124 | #undef HAVE_SYS_TIME_H 125 | 126 | /* Define to 1 if you have the header file. */ 127 | #undef HAVE_SYS_TYPES_H 128 | 129 | /* Define to 1 if you have the header file. */ 130 | #undef HAVE_TERMIOS_H 131 | 132 | /* Define to 1 if the system has the type `uint_t'. */ 133 | #undef HAVE_UINT_T 134 | 135 | /* Define to 1 if the system has the type `ulong_t'. */ 136 | #undef HAVE_ULONG_T 137 | 138 | /* Define to 1 if you have the header file. */ 139 | #undef HAVE_UNISTD_H 140 | 141 | /* Define to 1 if you have the header file. */ 142 | #undef HAVE_USB_H 143 | 144 | /* Define to 1 if you have the `usleep' function. */ 145 | #undef HAVE_USLEEP 146 | 147 | /* Define if lex/flex has yylex_destroy */ 148 | #undef HAVE_YYLEX_DESTROY 149 | 150 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 151 | */ 152 | #undef LT_OBJDIR 153 | 154 | /* Name of package */ 155 | #undef PACKAGE 156 | 157 | /* Define to the address where bug reports for this package should be sent. */ 158 | #undef PACKAGE_BUGREPORT 159 | 160 | /* Define to the full name of this package. */ 161 | #undef PACKAGE_NAME 162 | 163 | /* Define to the full name and version of this package. */ 164 | #undef PACKAGE_STRING 165 | 166 | /* Define to the one symbol short name of this package. */ 167 | #undef PACKAGE_TARNAME 168 | 169 | /* Define to the home page for this package. */ 170 | #undef PACKAGE_URL 171 | 172 | /* Define to the version of this package. */ 173 | #undef PACKAGE_VERSION 174 | 175 | /* Define to 1 if you have the ANSI C header files. */ 176 | #undef STDC_HEADERS 177 | 178 | /* Define to 1 if you can safely include both and . */ 179 | #undef TIME_WITH_SYS_TIME 180 | 181 | /* Version number of package */ 182 | #undef VERSION 183 | 184 | /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a 185 | `char[]'. */ 186 | #undef YYTEXT_POINTER 187 | 188 | /* Define to empty if `const' does not conform to ANSI C. */ 189 | #undef const 190 | -------------------------------------------------------------------------------- /arduino.c: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2009 Lars Immisch 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: arduino.c 1321 2014-06-13 20:07:40Z awachtler $ */ 20 | 21 | /* 22 | * avrdude interface for Arduino programmer 23 | * 24 | * The Arduino programmer is mostly a STK500v1, just the signature bytes 25 | * are read differently. 26 | */ 27 | 28 | #include "ac_cfg.h" 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include "avrdude.h" 35 | #include "libavrdude.h" 36 | #include "stk500_private.h" 37 | #include "stk500.h" 38 | #include "arduino.h" 39 | 40 | /* read signature bytes - arduino version */ 41 | static int arduino_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m) 42 | { 43 | unsigned char buf[32]; 44 | 45 | /* Signature byte reads are always 3 bytes. */ 46 | 47 | if (m->size < 3) { 48 | avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read", progname); 49 | return -1; 50 | } 51 | 52 | buf[0] = Cmnd_STK_READ_SIGN; 53 | buf[1] = Sync_CRC_EOP; 54 | 55 | serial_send(&pgm->fd, buf, 2); 56 | 57 | if (serial_recv(&pgm->fd, buf, 5) < 0) 58 | return -1; 59 | if (buf[0] == Resp_STK_NOSYNC) { 60 | avrdude_message(MSG_INFO, "%s: stk500_cmd(): programmer is out of sync\n", 61 | progname); 62 | return -1; 63 | } else if (buf[0] != Resp_STK_INSYNC) { 64 | avrdude_message(MSG_INFO, "\n%s: arduino_read_sig_bytes(): (a) protocol error, " 65 | "expect=0x%02x, resp=0x%02x\n", 66 | progname, Resp_STK_INSYNC, buf[0]); 67 | return -2; 68 | } 69 | if (buf[4] != Resp_STK_OK) { 70 | avrdude_message(MSG_INFO, "\n%s: arduino_read_sig_bytes(): (a) protocol error, " 71 | "expect=0x%02x, resp=0x%02x\n", 72 | progname, Resp_STK_OK, buf[4]); 73 | return -3; 74 | } 75 | 76 | m->buf[0] = buf[1]; 77 | m->buf[1] = buf[2]; 78 | m->buf[2] = buf[3]; 79 | 80 | return 3; 81 | } 82 | 83 | static int arduino_open(PROGRAMMER * pgm, char * port) 84 | { 85 | union pinfo pinfo; 86 | strcpy(pgm->port, port); 87 | pinfo.baud = pgm->baudrate? pgm->baudrate: 115200; 88 | if (serial_open(port, pinfo, &pgm->fd)==-1) { 89 | return -1; 90 | } 91 | 92 | /* Clear DTR and RTS to unload the RESET capacitor 93 | * (for example in Arduino) */ 94 | serial_set_dtr_rts(&pgm->fd, 0); 95 | usleep(250*1000); 96 | /* Set DTR and RTS back to high */ 97 | serial_set_dtr_rts(&pgm->fd, 1); 98 | usleep(50*1000); 99 | 100 | /* 101 | * drain any extraneous input 102 | */ 103 | stk500_drain(pgm, 0); 104 | 105 | if (stk500_getsync(pgm) < 0) 106 | return -1; 107 | 108 | return 0; 109 | } 110 | 111 | static void arduino_close(PROGRAMMER * pgm) 112 | { 113 | serial_set_dtr_rts(&pgm->fd, 0); 114 | serial_close(&pgm->fd); 115 | pgm->fd.ifd = -1; 116 | } 117 | 118 | const char arduino_desc[] = "Arduino programmer"; 119 | 120 | void arduino_initpgm(PROGRAMMER * pgm) 121 | { 122 | /* This is mostly a STK500; just the signature is read 123 | differently than on real STK500v1 124 | and the DTR signal is set when opening the serial port 125 | for the Auto-Reset feature */ 126 | stk500_initpgm(pgm); 127 | 128 | strcpy(pgm->type, "Arduino"); 129 | pgm->read_sig_bytes = arduino_read_sig_bytes; 130 | pgm->open = arduino_open; 131 | pgm->close = arduino_close; 132 | } 133 | -------------------------------------------------------------------------------- /arduino.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2009 Lars Immisch 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: arduino.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef arduino_h__ 22 | #define arduino_h__ 23 | 24 | extern const char arduino_desc[]; 25 | void arduino_initpgm (PROGRAMMER * pgm); 26 | 27 | #endif 28 | 29 | 30 | -------------------------------------------------------------------------------- /avr910.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2003-2004 Theodore A. Roth 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: avr910.h 1311 2014-05-19 10:01:59Z joerg_wunsch $ */ 20 | 21 | #ifndef avr910_h 22 | #define avr910_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern const char avr910_desc[]; 29 | void avr910_initpgm (PROGRAMMER * pgm); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* avr910_h */ 36 | -------------------------------------------------------------------------------- /avrdude.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2007 Joerg Wunsch 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: avrdude.h 1321 2014-06-13 20:07:40Z awachtler $ */ 20 | 21 | #ifndef avrdude_h 22 | #define avrdude_h 23 | 24 | extern char * progname; /* name of program, for messages */ 25 | extern char progbuf[]; /* spaces same length as progname */ 26 | 27 | extern int ovsigck; /* override signature check (-F) */ 28 | extern int verbose; /* verbosity level (-v, -vv, ...) */ 29 | extern int quell_progress; /* quiteness level (-q, -qq) */ 30 | 31 | int avrdude_message(const int msglvl, const char *format, ...); 32 | 33 | #define MSG_INFO (0) /* no -v option, can be supressed with -qq */ 34 | #define MSG_NOTICE (1) /* displayed with -v */ 35 | #define MSG_NOTICE2 (2) /* displayed with -vv, used rarely */ 36 | #define MSG_DEBUG (3) /* displayed with -vvv */ 37 | #define MSG_TRACE (4) /* displayed with -vvvv, show trace commuication */ 38 | #define MSG_TRACE2 (5) /* displayed with -vvvvv */ 39 | 40 | #if defined(WIN32NATIVE) 41 | 42 | #include "ac_cfg.h" 43 | #include 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | #if !defined(HAVE_USLEEP) 50 | int usleep(unsigned int us); 51 | #endif 52 | 53 | #if !defined(HAVE_GETTIMEOFDAY) 54 | struct timezone; 55 | int gettimeofday(struct timeval *tv, struct timezone *tz); 56 | #endif /* HAVE_GETTIMEOFDAY */ 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #endif /* defined(WIN32NATIVE) */ 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /avrdude.spec: -------------------------------------------------------------------------------- 1 | ## -*- mode: rpm-spec; -*- 2 | ## 3 | ## $Id: avrdude.spec.in 558 2005-11-29 20:28:51Z joerg_wunsch $ 4 | ## 5 | ## avrdude.spec. Generated from avrdude.spec.in by configure. 6 | ## 7 | 8 | %define debug_package %{nil} 9 | 10 | %define _with_docs 1 11 | %{?_without_docs: %define _with_docs 0} 12 | 13 | Summary: AVRDUDE is software for programming Atmel AVR Microcontrollers. 14 | Name: avrdude 15 | Version: 6.3 16 | Release: 1 17 | URL: http://savannah.nongnu.org/projects/avrdude 18 | Source0: %{name}-%{version}.tar.gz 19 | License: GPL 20 | Group: Development/Tools 21 | BuildRoot: %{_tmppath}/%{name}-%{version}-root 22 | 23 | %description 24 | AVRDUDE is software for programming Atmel AVR Microcontrollers. 25 | 26 | %if %{_with_docs} 27 | ## The avrdude-docs subpackage 28 | %package docs 29 | Summary: Documentation for AVRDUDE. 30 | Group: Documentation 31 | %description docs 32 | Documentation for avrdude in info, html, postscript and pdf formats. 33 | %endif 34 | 35 | %prep 36 | %setup -q 37 | 38 | %build 39 | 40 | ./configure --prefix=%{_prefix} --sysconfdir=/etc --mandir=%{_mandir} \ 41 | --infodir=%{_infodir} \ 42 | %if %{_with_docs} 43 | --enable-doc=yes 44 | %else 45 | --enable-doc=no 46 | %endif 47 | 48 | make 49 | 50 | %install 51 | rm -rf $RPM_BUILD_ROOT 52 | make prefix=$RPM_BUILD_ROOT%{_prefix} \ 53 | sysconfdir=$RPM_BUILD_ROOT/etc \ 54 | mandir=$RPM_BUILD_ROOT%{_mandir} \ 55 | infodir=$RPM_BUILD_ROOT%{_infodir} \ 56 | install 57 | 58 | rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/%{name}-%{version} 59 | rm -f $RPM_BUILD_ROOT%{_infodir}/dir 60 | 61 | %clean 62 | rm -rf $RPM_BUILD_ROOT 63 | 64 | %if %{_with_docs} 65 | %post docs 66 | [ -f %{_infodir}/avrdude.info ] && \ 67 | /sbin/install-info %{_infodir}/avrdude.info %{_infodir}/dir || : 68 | [ -f %{_infodir}/avrdude.info.gz ] && \ 69 | /sbin/install-info %{_infodir}/avrdude.info.gz %{_infodir}/dir || : 70 | 71 | %preun docs 72 | if [ $1 = 0 ]; then 73 | [ -f %{_infodir}/avrdude.info ] && \ 74 | /sbin/install-info --delete %{_infodir}/avrdude.info %{_infodir}/dir || : 75 | [ -f %{_infodir}/avrdude.info.gz ] && \ 76 | /sbin/install-info --delete %{_infodir}/avrdude.info.gz %{_infodir}/dir || : 77 | fi 78 | %endif 79 | 80 | %files 81 | %defattr(-,root,root) 82 | %{_prefix}/bin/avrdude 83 | %{_mandir}/man1/avrdude.1.gz 84 | %attr(0644,root,root) %config /etc/avrdude.conf 85 | 86 | %if %{_with_docs} 87 | %files docs 88 | %doc %{_infodir}/*info* 89 | %doc doc/avrdude-html/*.html 90 | %doc doc/TODO 91 | %doc doc/avrdude.ps 92 | %doc doc/avrdude.pdf 93 | %endif 94 | 95 | %changelog 96 | * Fri Sep 23 2005 Galen Seitz 97 | - Default to enable-doc=yes during configure. 98 | - Move info file to docs package. 99 | - Make building of docs package conditional. Basic idea copied from avr-gcc. 100 | 101 | * Wed Aug 27 2003 Theodore A. Roth 102 | [Thanks to Artur Lipowski ] 103 | - Do not build debug package. 104 | - Remove files not packaged to quell RH9 rpmbuild complaints. 105 | 106 | * Wed Mar 05 2003 Theodore A. Roth 107 | - Add docs sub-package. 108 | - Add %post and %preun scriptlets for handling info files. 109 | 110 | * Wed Feb 26 2003 Theodore A. Roth 111 | - Initial build. 112 | 113 | 114 | -------------------------------------------------------------------------------- /avrdude.spec.in: -------------------------------------------------------------------------------- 1 | ## -*- mode: rpm-spec; -*- 2 | ## 3 | ## $Id: avrdude.spec.in 558 2005-11-29 20:28:51Z joerg_wunsch $ 4 | ## 5 | ## @configure_input@ 6 | ## 7 | 8 | %define debug_package %{nil} 9 | 10 | %define _with_docs 1 11 | %{?_without_docs: %define _with_docs 0} 12 | 13 | Summary: AVRDUDE is software for programming Atmel AVR Microcontrollers. 14 | Name: avrdude 15 | Version: @VERSION@ 16 | Release: 1 17 | URL: http://savannah.nongnu.org/projects/avrdude 18 | Source0: %{name}-%{version}.tar.gz 19 | License: GPL 20 | Group: Development/Tools 21 | BuildRoot: %{_tmppath}/%{name}-%{version}-root 22 | 23 | %description 24 | AVRDUDE is software for programming Atmel AVR Microcontrollers. 25 | 26 | %if %{_with_docs} 27 | ## The avrdude-docs subpackage 28 | %package docs 29 | Summary: Documentation for AVRDUDE. 30 | Group: Documentation 31 | %description docs 32 | Documentation for avrdude in info, html, postscript and pdf formats. 33 | %endif 34 | 35 | %prep 36 | %setup -q 37 | 38 | %build 39 | 40 | ./configure --prefix=%{_prefix} --sysconfdir=/etc --mandir=%{_mandir} \ 41 | --infodir=%{_infodir} \ 42 | %if %{_with_docs} 43 | --enable-doc=yes 44 | %else 45 | --enable-doc=no 46 | %endif 47 | 48 | make 49 | 50 | %install 51 | rm -rf $RPM_BUILD_ROOT 52 | make prefix=$RPM_BUILD_ROOT%{_prefix} \ 53 | sysconfdir=$RPM_BUILD_ROOT/etc \ 54 | mandir=$RPM_BUILD_ROOT%{_mandir} \ 55 | infodir=$RPM_BUILD_ROOT%{_infodir} \ 56 | install 57 | 58 | rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/%{name}-%{version} 59 | rm -f $RPM_BUILD_ROOT%{_infodir}/dir 60 | 61 | %clean 62 | rm -rf $RPM_BUILD_ROOT 63 | 64 | %if %{_with_docs} 65 | %post docs 66 | [ -f %{_infodir}/avrdude.info ] && \ 67 | /sbin/install-info %{_infodir}/avrdude.info %{_infodir}/dir || : 68 | [ -f %{_infodir}/avrdude.info.gz ] && \ 69 | /sbin/install-info %{_infodir}/avrdude.info.gz %{_infodir}/dir || : 70 | 71 | %preun docs 72 | if [ $1 = 0 ]; then 73 | [ -f %{_infodir}/avrdude.info ] && \ 74 | /sbin/install-info --delete %{_infodir}/avrdude.info %{_infodir}/dir || : 75 | [ -f %{_infodir}/avrdude.info.gz ] && \ 76 | /sbin/install-info --delete %{_infodir}/avrdude.info.gz %{_infodir}/dir || : 77 | fi 78 | %endif 79 | 80 | %files 81 | %defattr(-,root,root) 82 | %{_prefix}/bin/avrdude 83 | %{_mandir}/man1/avrdude.1.gz 84 | %attr(0644,root,root) %config /etc/avrdude.conf 85 | 86 | %if %{_with_docs} 87 | %files docs 88 | %doc %{_infodir}/*info* 89 | %doc doc/avrdude-html/*.html 90 | %doc doc/TODO 91 | %doc doc/avrdude.ps 92 | %doc doc/avrdude.pdf 93 | %endif 94 | 95 | %changelog 96 | * Fri Sep 23 2005 Galen Seitz 97 | - Default to enable-doc=yes during configure. 98 | - Move info file to docs package. 99 | - Make building of docs package conditional. Basic idea copied from avr-gcc. 100 | 101 | * Wed Aug 27 2003 Theodore A. Roth 102 | [Thanks to Artur Lipowski ] 103 | - Do not build debug package. 104 | - Remove files not packaged to quell RH9 rpmbuild complaints. 105 | 106 | * Wed Mar 05 2003 Theodore A. Roth 107 | - Add docs sub-package. 108 | - Add %post and %preun scriptlets for handling info files. 109 | 110 | * Wed Feb 26 2003 Theodore A. Roth 111 | - Initial build. 112 | 113 | 114 | -------------------------------------------------------------------------------- /avrdude_wch_index_USBASPmod.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxproff/avrdude-ch341/d2e962355fc6281f7fe50b1b82ec3f6a44bf065a/avrdude_wch_index_USBASPmod.exe -------------------------------------------------------------------------------- /avrftdi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrftdi - extension for avrdude, Wolfgang Moser, Ville Voipio 3 | * Copyright (C) 2011 Hannes Weisbach, Doug Springer 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: avrftdi.h 1329 2014-07-16 20:38:52Z joerg_wunsch $ */ 20 | 21 | #ifndef avrftdi_h 22 | #define avrftdi_h 23 | 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | 31 | extern const char avrftdi_desc[]; 32 | void avrftdi_initpgm (PROGRAMMER * pgm); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | 40 | 41 | -------------------------------------------------------------------------------- /avrftdi_private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ac_cfg.h" 3 | 4 | #include 5 | 6 | #if defined(HAVE_LIBFTDI1) && defined(HAVE_LIBUSB_1_0) 7 | # if defined(HAVE_LIBUSB_1_0_LIBUSB_H) 8 | # include 9 | # else 10 | # include 11 | # endif 12 | # include 13 | # undef HAVE_LIBFTDI_TYPE_232H 14 | # define HAVE_LIBFTDI_TYPE_232H 1 15 | #elif defined(HAVE_LIBFTDI) && defined(HAVE_USB_H) 16 | /* ftdi.h includes usb.h */ 17 | #include 18 | #else 19 | #warning No libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again. 20 | #define DO_NOT_BUILD_AVRFTDI 21 | #endif 22 | 23 | #ifndef DO_NOT_BUILD_AVRFTDI 24 | 25 | enum { ERR, WARN, INFO, DEBUG, TRACE }; 26 | 27 | #define __log(lvl, fmt, ...) \ 28 | do { \ 29 | avrftdi_log(lvl, __func__, __LINE__, fmt, ##__VA_ARGS__); \ 30 | } while(0) 31 | 32 | 33 | #define log_err(fmt, ...) __log(ERR, fmt, ##__VA_ARGS__) 34 | #define log_warn(fmt, ...) __log(WARN, fmt, ##__VA_ARGS__) 35 | #define log_info(fmt, ...) __log(INFO, fmt, ##__VA_ARGS__) 36 | #define log_debug(fmt, ...) __log(DEBUG, fmt, ##__VA_ARGS__) 37 | #define log_trace(fmt, ...) __log(TRACE, fmt, ##__VA_ARGS__) 38 | 39 | #define E(x, ftdi) \ 40 | do { \ 41 | if ((x)) \ 42 | { \ 43 | avrdude_message(MSG_INFO, "%s:%d %s() %s: %s (%d)\n\t%s\n", \ 44 | __FILE__, __LINE__, __FUNCTION__, \ 45 | #x, strerror(errno), errno, ftdi_get_error_string(ftdi)); \ 46 | return -1; \ 47 | } \ 48 | } while(0) 49 | 50 | #define E_VOID(x, ftdi) \ 51 | do { \ 52 | if ((x)) \ 53 | { \ 54 | avrdude_message(MSG_INFO, "%s:%d %s() %s: %s (%d)\n\t%s\n", \ 55 | __FILE__, __LINE__, __FUNCTION__, \ 56 | #x, strerror(errno), errno, ftdi_get_error_string(ftdi)); \ 57 | } \ 58 | } while(0) 59 | 60 | 61 | #define to_pdata(pgm) \ 62 | ((avrftdi_t *)((pgm)->cookie)) 63 | 64 | typedef struct avrftdi_s { 65 | /* pointer to struct maintained by libftdi to identify the device */ 66 | struct ftdi_context* ftdic; 67 | /* bitmask of values for pins. bit 0 represents pin 0 ([A|B]DBUS0) */ 68 | uint16_t pin_value; 69 | /* bitmask of pin direction. a '1' make a pin an output. 70 | * bit 0 corresponds to pin 0. */ 71 | uint16_t pin_direction; 72 | /* don't know. not useful. someone put it in. */ 73 | uint16_t led_mask; 74 | /* total number of pins supported by a programmer. varies with FTDI chips */ 75 | int pin_limit; 76 | /* internal RX buffer of the device. needed for INOUT transfers */ 77 | int rx_buffer_size; 78 | int tx_buffer_size; 79 | /* use bitbanging instead of mpsse spi */ 80 | bool use_bitbanging; 81 | } avrftdi_t; 82 | 83 | void avrftdi_log(int level, const char * func, int line, const char * fmt, ...); 84 | 85 | #endif /* DO_NOT_BUILD_AVRFDTI */ 86 | 87 | -------------------------------------------------------------------------------- /avrftdi_tpi.c: -------------------------------------------------------------------------------- 1 | #include "ac_cfg.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "avrdude.h" 9 | #include "libavrdude.h" 10 | 11 | #include "usbasp.h" 12 | 13 | #include "avrftdi_tpi.h" 14 | #include "avrftdi_private.h" 15 | 16 | #ifndef DO_NOT_BUILD_AVRFTDI 17 | 18 | static void avrftdi_tpi_disable(PROGRAMMER *); 19 | static int avrftdi_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p); 20 | 21 | #ifdef notyet 22 | static void 23 | avrftdi_debug_frame(uint16_t frame) 24 | { 25 | static char bit_name[] = "IDLES01234567PSS"; 26 | //static char bit_name[] = "SSP76543210SELDI"; 27 | char line0[34], line1[34], line2[34]; 28 | int bit, pos; 29 | 30 | for(bit = 0; bit < 16; bit++) 31 | { 32 | pos = 16 - bit - 1; 33 | if(frame & (1 << pos)) 34 | { 35 | line0[2*pos] = '_'; 36 | line0[2*pos+1] = ' '; 37 | 38 | line2[2*pos] = ' '; 39 | line2[2*pos+1] = ' '; 40 | } 41 | else 42 | { 43 | line0[2*pos] = ' '; 44 | line0[2*pos+1] = ' '; 45 | 46 | line2[2*pos] = '-'; 47 | line2[2*pos+1] = ' '; 48 | } 49 | 50 | line1[2*pos] = bit_name[pos]; 51 | line1[2*pos+1] = ' '; 52 | 53 | } 54 | 55 | line0[32] = 0; 56 | line1[32] = 0; 57 | line2[32] = 0; 58 | 59 | log_debug("%s\n", line0); 60 | log_debug("%s\n", line1); 61 | //log_debug("%s\n", line2); 62 | } 63 | #endif /* notyet */ 64 | 65 | int 66 | avrftdi_tpi_initialize(PROGRAMMER * pgm, AVRPART * p) 67 | { 68 | int ret; 69 | 70 | avrftdi_t* pdata = to_pdata(pgm); 71 | unsigned char buf[] = { MPSSE_DO_WRITE | MPSSE_WRITE_NEG | MPSSE_LSB, 0x01, 0x00, 0xff, 0xff }; 72 | 73 | log_info("Using TPI interface\n"); 74 | 75 | pgm->program_enable = avrftdi_tpi_program_enable; 76 | pgm->cmd_tpi = avrftdi_cmd_tpi; 77 | pgm->chip_erase = avr_tpi_chip_erase; 78 | pgm->disable = avrftdi_tpi_disable; 79 | 80 | pgm->paged_load = NULL; 81 | pgm->paged_write = NULL; 82 | 83 | log_info("Setting /Reset pin low\n"); 84 | pgm->setpin(pgm, PIN_AVR_RESET, OFF); 85 | pgm->setpin(pgm, PIN_AVR_SCK, OFF); 86 | pgm->setpin(pgm, PIN_AVR_MOSI, ON); 87 | usleep(20 * 1000); 88 | 89 | pgm->setpin(pgm, PIN_AVR_RESET, ON); 90 | /* worst case 128ms */ 91 | usleep(2 * 128 * 1000); 92 | 93 | /*setting rst back to 0 */ 94 | pgm->setpin(pgm, PIN_AVR_RESET, OFF); 95 | /*wait at least 20ms bevor issuing spi commands to avr */ 96 | usleep(20 * 1000); 97 | 98 | log_info("Sending 16 init clock cycles ...\n"); 99 | ret = ftdi_write_data(pdata->ftdic, buf, sizeof(buf)); 100 | 101 | return ret; 102 | } 103 | 104 | #define TPI_PARITY_MASK 0x2000 105 | 106 | static uint16_t 107 | tpi_byte2frame(uint8_t byte) 108 | { 109 | uint16_t frame = 0xc00f; 110 | int parity = __builtin_popcount(byte) & 1; 111 | 112 | frame |= ((byte << 5) & 0x1fe0); 113 | 114 | if(parity) 115 | frame |= TPI_PARITY_MASK; 116 | 117 | return frame; 118 | } 119 | 120 | static int 121 | tpi_frame2byte(uint16_t frame, uint8_t * byte) 122 | { 123 | /* drop idle and start bit(s) */ 124 | *byte = (frame >> 5) & 0xff; 125 | 126 | int parity = __builtin_popcount(*byte) & 1; 127 | int parity_rcvd = (frame & TPI_PARITY_MASK) ? 1 : 0; 128 | 129 | return parity != parity_rcvd; 130 | } 131 | 132 | #ifdef notyet 133 | static int 134 | avrftdi_tpi_break(PROGRAMMER * pgm) 135 | { 136 | unsigned char buffer[] = { MPSSE_DO_WRITE | MPSSE_WRITE_NEG | MPSSE_LSB, 1, 0, 0, 0 }; 137 | E(ftdi_write_data(to_pdata(pgm)->ftdic, buffer, sizeof(buffer)) != sizeof(buffer), to_pdata(pgm)->ftdic); 138 | 139 | return 0; 140 | } 141 | #endif /* notyet */ 142 | 143 | static int 144 | avrftdi_tpi_write_byte(PROGRAMMER * pgm, unsigned char byte) 145 | { 146 | uint16_t frame; 147 | 148 | struct ftdi_context* ftdic = to_pdata(pgm)->ftdic; 149 | 150 | unsigned char buffer[] = { MPSSE_DO_WRITE | MPSSE_WRITE_NEG | MPSSE_LSB, 1, 0, 0, 0 }; 151 | 152 | frame = tpi_byte2frame(byte); 153 | 154 | buffer[3] = frame & 0xff; 155 | buffer[4] = frame >> 8; 156 | 157 | log_trace("Byte %02x, frame: %04x, MPSSE: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", 158 | byte, frame, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4]); 159 | 160 | //avrftdi_debug_frame(frame); 161 | 162 | E(ftdi_write_data(ftdic, buffer, sizeof(buffer)) != sizeof(buffer), ftdic); 163 | 164 | return 0; 165 | } 166 | 167 | #define TPI_FRAME_SIZE 12 168 | #define TPI_IDLE_BITS 2 169 | 170 | static int 171 | avrftdi_tpi_read_byte(PROGRAMMER * pgm, unsigned char * byte) 172 | { 173 | uint16_t frame; 174 | 175 | /* use 2 guard bits, 2 default idle bits + 12 frame bits = 16 bits total */ 176 | const int bytes = 3; 177 | int err, i = 0; 178 | 179 | unsigned char buffer[4]; 180 | 181 | buffer[0] = MPSSE_DO_READ | MPSSE_LSB; 182 | buffer[1] = (bytes-1) & 0xff; 183 | buffer[2] = ((bytes-1) >> 8) & 0xff; 184 | buffer[3] = SEND_IMMEDIATE; 185 | 186 | log_trace("MPSSE: 0x%02x 0x%02x 0x%02x 0x%02x (Read frame)\n", 187 | buffer[0], buffer[1], buffer[2], buffer[3]); 188 | 189 | ftdi_write_data(to_pdata(pgm)->ftdic, buffer, 4); 190 | 191 | memset(buffer, 0, sizeof(buffer)); 192 | 193 | i = 0; 194 | do { 195 | int err = ftdi_read_data(to_pdata(pgm)->ftdic, &buffer[i], bytes - i); 196 | E(err < 0, to_pdata(pgm)->ftdic); 197 | i += err; 198 | } while(i < bytes); 199 | 200 | 201 | log_trace("MPSSE: 0x%02x 0x%02x 0x%02x 0x%02x (Read frame)\n", 202 | buffer[0], buffer[1], buffer[2], buffer[3]); 203 | 204 | 205 | frame = buffer[0] | (buffer[1] << 8); 206 | 207 | err = tpi_frame2byte(frame, byte); 208 | log_trace("Frame: 0x%04x, byte: 0x%02x\n", frame, *byte); 209 | 210 | //avrftdi_debug_frame(frame); 211 | 212 | return err; 213 | } 214 | 215 | static int 216 | avrftdi_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p) 217 | { 218 | return avr_tpi_program_enable(pgm, p, TPIPCR_GT_2b); 219 | } 220 | 221 | int 222 | avrftdi_cmd_tpi(PROGRAMMER * pgm, const unsigned char *cmd, int cmd_len, 223 | unsigned char *res, int res_len) 224 | { 225 | int i, err = 0; 226 | 227 | for(i = 0; i < cmd_len; i++) 228 | { 229 | err = avrftdi_tpi_write_byte(pgm, cmd[i]); 230 | if(err) 231 | return err; 232 | } 233 | 234 | for(i = 0; i < res_len; i++) 235 | { 236 | err = avrftdi_tpi_read_byte(pgm, &res[i]); 237 | if(err) 238 | return err; 239 | } 240 | 241 | return 0; 242 | } 243 | 244 | static void 245 | avrftdi_tpi_disable(PROGRAMMER * pgm) 246 | { 247 | unsigned char cmd[] = {TPI_OP_SSTCS(TPIPCR), 0}; 248 | pgm->cmd_tpi(pgm, cmd, sizeof(cmd), NULL, 0); 249 | 250 | log_info("Leaving Programming mode.\n"); 251 | } 252 | 253 | #endif /* DO_NOT_BUILD_AVRFTDI */ 254 | 255 | -------------------------------------------------------------------------------- /avrftdi_tpi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //int avrftdi_tpi_write_byte(PROGRAMMER * pgm, unsigned char byte); 4 | //int avrftdi_tpi_read_byte(PROGRAMMER * pgm, unsigned char * byte); 5 | int avrftdi_cmd_tpi(PROGRAMMER * pgm, const unsigned char *cmd, int cmd_len, 6 | unsigned char *res, int res_len); 7 | int avrftdi_tpi_initialize(PROGRAMMER * pgm, AVRPART * p); 8 | 9 | 10 | -------------------------------------------------------------------------------- /bitbang.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean 4 | * Copyright (C) 2005 Michael Holzt 5 | * Copyright (C) 2011 Darell Tan 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | /* $Id: bitbang.h 1301 2014-05-16 15:52:25Z joerg_wunsch $ */ 21 | 22 | #ifndef bitbang_h 23 | #define bitbang_h 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | int bitbang_setpin(int fd, int pin, int value); 30 | int bitbang_getpin(int fd, int pin); 31 | int bitbang_highpulsepin(int fd, int pin); 32 | void bitbang_delay(unsigned int us); 33 | 34 | int bitbang_check_prerequisites(PROGRAMMER *pgm); 35 | 36 | int bitbang_rdy_led (PROGRAMMER * pgm, int value); 37 | int bitbang_err_led (PROGRAMMER * pgm, int value); 38 | int bitbang_pgm_led (PROGRAMMER * pgm, int value); 39 | int bitbang_vfy_led (PROGRAMMER * pgm, int value); 40 | int bitbang_cmd (PROGRAMMER * pgm, const unsigned char *cmd, 41 | unsigned char *res); 42 | int bitbang_cmd_tpi (PROGRAMMER * pgm, const unsigned char *cmd, 43 | int cmd_len, unsigned char *res, int res_len); 44 | int bitbang_spi (PROGRAMMER * pgm, const unsigned char *cmd, 45 | unsigned char *res, int count); 46 | int bitbang_chip_erase (PROGRAMMER * pgm, AVRPART * p); 47 | int bitbang_program_enable (PROGRAMMER * pgm, AVRPART * p); 48 | void bitbang_powerup (PROGRAMMER * pgm); 49 | void bitbang_powerdown (PROGRAMMER * pgm); 50 | int bitbang_initialize (PROGRAMMER * pgm, AVRPART * p); 51 | void bitbang_disable (PROGRAMMER * pgm); 52 | void bitbang_enable (PROGRAMMER * pgm); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /bootstrap: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | : ${AUTOHEADER="autoheader${AC_VER}"} 4 | : ${AUTOCONF="autoconf${AC_VER}"} 5 | : ${ACLOCAL="aclocal${AM_VER}"} 6 | : ${AUTOMAKE="automake${AM_VER}"} 7 | 8 | export ACLOCAL AUTOHEADER AUTOCONF AUTOMAKE 9 | 10 | # Bootstrap the build system. 11 | 12 | set -x 13 | 14 | rm -rf autom4te.cache 15 | 16 | libtoolize 17 | 18 | ${ACLOCAL} 19 | ${AUTOHEADER} 20 | ${AUTOCONF} 21 | ${AUTOMAKE} -a -c 22 | -------------------------------------------------------------------------------- /buspirate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * 4 | * avrdude support for The Bus Pirate - universal serial interface 5 | * 6 | * Copyright (C) 2009 Michal Ludvig 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | /* $Id: buspirate.h 1138 2013-01-30 21:15:39Z rliebscher $ */ 23 | 24 | #ifndef buspirate_h 25 | #define buspirate_h 26 | 27 | extern const char buspirate_desc[]; 28 | extern const char buspirate_bb_desc[]; 29 | void buspirate_initpgm (struct programmer_t *pgm); 30 | void buspirate_bb_initpgm (struct programmer_t *pgm); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /butterfly.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2003-2004 Theodore A. Roth 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: butterfly.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef butterfly_h 22 | #define butterfly_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern const char butterfly_desc[]; 29 | extern const char butterfly_mk_desc[]; 30 | void butterfly_initpgm (PROGRAMMER * pgm); 31 | void butterfly_mk_initpgm (PROGRAMMER * pgm); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* butterfly_h */ 38 | -------------------------------------------------------------------------------- /ch341a.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * 4 | * avrdude support for CH341 5 | * Copyright (C) 2016 Alexey Sadkov 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | 22 | #ifndef ch341a_h 23 | #define ch341a_h 24 | 25 | #define CH341A_VID 0x1A86 26 | #define CH341A_PID 0x5512 27 | 28 | #define CH341A_PACKET_LENGTH 0x20 29 | 30 | #define CH341A_USB_BULK_ENDPOINT 0x02 31 | #define CH341A_PACKET_LENGTH 0x20 32 | 33 | #define CH341A_USB_TIMEOUT 15000 34 | 35 | #define CH341A_CMD_SPI_STREAM 0xA8 //SPI command 36 | #define CH341A_CMD_UIO_STREAM 0xAB //UIO command 37 | 38 | #define CH341A_CMD_UIO_STM_IN 0x00 // UIO Interface In ( D0 ~ D7 ) 39 | #define CH341A_CMD_UIO_STM_DIR 0x40 // UIO interface Dir( set dir of D0~D5 ) 40 | #define CH341A_CMD_UIO_STM_OUT 0x80 // UIO Interface Output(D0~D5) 41 | #define CH341A_CMD_UIO_STM_END 0x20 // UIO Interface End Command 42 | #define CH341A_CMD_UIO_STM_US 0xC0 43 | 44 | #define CH341A_CMD_I2C_STREAM 0xAA 45 | #define CH341A_CMD_I2C_STM_SET 0x60 // bit 2: SPI with two data pairs D5,D4=out, D7,D6=in 46 | #define CH341A_CMD_I2C_STM_END 0x00 47 | 48 | 49 | /* USB error identifiers */ 50 | #define USB_ERROR_NOTFOUND 1 51 | #define USB_ERROR_ACCESS 2 52 | #define USB_ERROR_IO 3 53 | 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | extern const char ch341a_desc[]; 60 | void ch341a_initpgm (PROGRAMMER * pgm); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* ch341a_h */ 67 | -------------------------------------------------------------------------------- /ch341a_bitbang.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * 4 | * avrdude support for CH341 5 | * Copyright (C) 2016 Alexey Sadkov 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | 22 | #ifndef ch341a_bitbang_h 23 | #define ch341a_bitbang_h 24 | 25 | #define CH341A_VID 0x1A86 26 | #define CH341A_PID 0x5512 27 | 28 | #define CH341A_PACKET_LENGTH 0x20 29 | 30 | #define CH341A_USB_BULK_ENDPOINT 0x02 31 | #define CH341A_PACKET_LENGTH 0x20 32 | 33 | #define CH341A_USB_TIMEOUT 15000 34 | 35 | #define CH341A_CMD_SPI_STREAM 0xA8 //SPI command 36 | #define CH341A_CMD_UIO_STREAM 0xAB //UIO command 37 | 38 | #define CH341A_CMD_UIO_STM_IN 0x00 // UIO Interface In ( D0 ~ D7 ) 39 | #define CH341A_CMD_UIO_STM_DIR 0x40 // UIO interface Dir( set dir of D0~D5 ) 40 | #define CH341A_CMD_UIO_STM_OUT 0x80 // UIO Interface Output(D0~D5) 41 | #define CH341A_CMD_UIO_STM_END 0x20 // UIO Interface End Command 42 | #define CH341A_CMD_UIO_STM_US 0xC0 43 | 44 | #define CH341A_CMD_I2C_STREAM 0xAA 45 | #define CH341A_CMD_I2C_STM_SET 0x60 // bit 2: SPI with two data pairs D5,D4=out, D7,D6=in 46 | #define CH341A_CMD_I2C_STM_END 0x00 47 | 48 | 49 | /* USB error identifiers */ 50 | #define USB_ERROR_NOTFOUND 1 51 | #define USB_ERROR_ACCESS 2 52 | #define USB_ERROR_IO 3 53 | 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | extern const char ch341a_bitbang_desc[]; 60 | void ch341a_bitbang_initpgm (PROGRAMMER * pgm); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* ch341a_bitbang_h */ 67 | -------------------------------------------------------------------------------- /ch341a_bitbang_wch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * 4 | * avrdude support for CH341 5 | * Copyright (C) 2016 Alexey Sadkov 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | 22 | #ifndef ch341a_bitbang_wch_h 23 | #define ch341a_bitbang_wch_h 24 | 25 | #if defined(WIN32NATIVE) 26 | #define CH341A_VID 0x1A86 27 | #define CH341A_PID 0x5512 28 | 29 | #define CH341A_PACKET_LENGTH 0x20 30 | 31 | #define CH341A_USB_BULK_ENDPOINT 0x02 32 | #define CH341A_PACKET_LENGTH 0x20 33 | 34 | #define CH341A_USB_TIMEOUT 15000 35 | 36 | #define CH341A_CMD_SPI_STREAM 0xA8 //SPI command 37 | #define CH341A_CMD_UIO_STREAM 0xAB //UIO command 38 | 39 | #define CH341A_CMD_UIO_STM_IN 0x00 // UIO Interface In ( D0 ~ D7 ) 40 | #define CH341A_CMD_UIO_STM_DIR 0x40 // UIO interface Dir( set dir of D0~D5 ) 41 | #define CH341A_CMD_UIO_STM_OUT 0x80 // UIO Interface Output(D0~D5) 42 | #define CH341A_CMD_UIO_STM_END 0x20 // UIO Interface End Command 43 | #define CH341A_CMD_UIO_STM_US 0xC0 44 | 45 | #define CH341A_CMD_I2C_STREAM 0xAA 46 | #define CH341A_CMD_I2C_STM_SET 0x60 // bit 2: SPI with two data pairs D5,D4=out, D7,D6=in 47 | #define CH341A_CMD_I2C_STM_END 0x00 48 | 49 | 50 | /* USB error identifiers */ 51 | #define USB_ERROR_NOTFOUND 1 52 | #define USB_ERROR_ACCESS 2 53 | #define USB_ERROR_IO 3 54 | 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | extern const char ch341a_bitbang_wch_desc[]; 61 | void ch341a_bitbang_wch_initpgm (PROGRAMMER * pgm); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | #endif /* ch341a_bitbang_wch_h */ 69 | -------------------------------------------------------------------------------- /compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Wrapper for compilers which do not understand `-c -o'. 3 | 4 | scriptversion=2005-05-14.22 5 | 6 | # Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7 | # Written by Tom Tromey . 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | # This file is maintained in Automake, please report 29 | # bugs to or send patches to 30 | # . 31 | 32 | case $1 in 33 | '') 34 | echo "$0: No command. Try \`$0 --help' for more information." 1>&2 35 | exit 1; 36 | ;; 37 | -h | --h*) 38 | cat <<\EOF 39 | Usage: compile [--help] [--version] PROGRAM [ARGS] 40 | 41 | Wrapper for compilers which do not understand `-c -o'. 42 | Remove `-o dest.o' from ARGS, run PROGRAM with the remaining 43 | arguments, and rename the output as expected. 44 | 45 | If you are trying to build a whole package this is not the 46 | right script to run: please start by reading the file `INSTALL'. 47 | 48 | Report bugs to . 49 | EOF 50 | exit $? 51 | ;; 52 | -v | --v*) 53 | echo "compile $scriptversion" 54 | exit $? 55 | ;; 56 | esac 57 | 58 | ofile= 59 | cfile= 60 | eat= 61 | 62 | for arg 63 | do 64 | if test -n "$eat"; then 65 | eat= 66 | else 67 | case $1 in 68 | -o) 69 | # configure might choose to run compile as `compile cc -o foo foo.c'. 70 | # So we strip `-o arg' only if arg is an object. 71 | eat=1 72 | case $2 in 73 | *.o | *.obj) 74 | ofile=$2 75 | ;; 76 | *) 77 | set x "$@" -o "$2" 78 | shift 79 | ;; 80 | esac 81 | ;; 82 | *.c) 83 | cfile=$1 84 | set x "$@" "$1" 85 | shift 86 | ;; 87 | *) 88 | set x "$@" "$1" 89 | shift 90 | ;; 91 | esac 92 | fi 93 | shift 94 | done 95 | 96 | if test -z "$ofile" || test -z "$cfile"; then 97 | # If no `-o' option was seen then we might have been invoked from a 98 | # pattern rule where we don't need one. That is ok -- this is a 99 | # normal compilation that the losing compiler can handle. If no 100 | # `.c' file was seen then we are probably linking. That is also 101 | # ok. 102 | exec "$@" 103 | fi 104 | 105 | # Name of file we expect compiler to create. 106 | cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` 107 | 108 | # Create the lock directory. 109 | # Note: use `[/.-]' here to ensure that we don't use the same name 110 | # that we are using for the .o file. Also, base the name on the expected 111 | # object file name, since that is what matters with a parallel build. 112 | lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d 113 | while true; do 114 | if mkdir "$lockdir" >/dev/null 2>&1; then 115 | break 116 | fi 117 | sleep 1 118 | done 119 | # FIXME: race condition here if user kills between mkdir and trap. 120 | trap "rmdir '$lockdir'; exit 1" 1 2 15 121 | 122 | # Run the compile. 123 | "$@" 124 | ret=$? 125 | 126 | if test -f "$cofile"; then 127 | mv "$cofile" "$ofile" 128 | elif test -f "${cofile}bj"; then 129 | mv "${cofile}bj" "$ofile" 130 | fi 131 | 132 | rmdir "$lockdir" 133 | exit $ret 134 | 135 | # Local Variables: 136 | # mode: shell-script 137 | # sh-indentation: 2 138 | # eval: (add-hook 'write-file-hooks 'time-stamp) 139 | # time-stamp-start: "scriptversion=" 140 | # time-stamp-format: "%:y-%02m-%02d.%02H" 141 | # time-stamp-end: "$" 142 | # End: 143 | -------------------------------------------------------------------------------- /config.c: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2000-2004 Brian S. Dean 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: config.c 1322 2014-06-17 20:08:28Z rliebscher $ */ 20 | 21 | #include "ac_cfg.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "avrdude.h" 30 | #include "libavrdude.h" 31 | #include "config.h" 32 | 33 | #include "config_gram.h" 34 | 35 | char default_programmer[MAX_STR_CONST]; 36 | char default_parallel[PATH_MAX]; 37 | char default_serial[PATH_MAX]; 38 | double default_bitclock; 39 | int default_safemode; 40 | 41 | char string_buf[MAX_STR_CONST]; 42 | char *string_buf_ptr; 43 | 44 | LISTID string_list; 45 | LISTID number_list; 46 | PROGRAMMER * current_prog; 47 | AVRPART * current_part; 48 | AVRMEM * current_mem; 49 | LISTID part_list; 50 | LISTID programmers; 51 | 52 | int lineno; 53 | const char * infile; 54 | 55 | extern char * yytext; 56 | 57 | #define DEBUG 0 58 | 59 | void cleanup_config(void) 60 | { 61 | ldestroy_cb(part_list, (void(*)(void*))avr_free_part); 62 | ldestroy_cb(programmers, (void(*)(void*))pgm_free); 63 | ldestroy_cb(string_list, (void(*)(void*))free_token); 64 | ldestroy_cb(number_list, (void(*)(void*))free_token); 65 | } 66 | 67 | int init_config(void) 68 | { 69 | string_list = lcreat(NULL, 0); 70 | number_list = lcreat(NULL, 0); 71 | current_prog = NULL; 72 | current_part = NULL; 73 | current_mem = NULL; 74 | part_list = lcreat(NULL, 0); 75 | programmers = lcreat(NULL, 0); 76 | 77 | lineno = 1; 78 | infile = NULL; 79 | 80 | return 0; 81 | } 82 | 83 | 84 | 85 | int yywrap() 86 | { 87 | return 1; 88 | } 89 | 90 | 91 | int yyerror(char * errmsg, ...) 92 | { 93 | va_list args; 94 | 95 | char message[512]; 96 | 97 | va_start(args, errmsg); 98 | 99 | vsnprintf(message, sizeof(message), errmsg, args); 100 | avrdude_message(MSG_INFO, "%s: error at %s:%d: %s\n", progname, infile, lineno, message); 101 | 102 | va_end(args); 103 | 104 | return 0; 105 | } 106 | 107 | 108 | int yywarning(char * errmsg, ...) 109 | { 110 | va_list args; 111 | 112 | char message[512]; 113 | 114 | va_start(args, errmsg); 115 | 116 | vsnprintf(message, sizeof(message), errmsg, args); 117 | avrdude_message(MSG_INFO, "%s: warning at %s:%d: %s\n", progname, infile, lineno, message); 118 | 119 | va_end(args); 120 | 121 | return 0; 122 | } 123 | 124 | 125 | TOKEN * new_token(int primary) 126 | { 127 | TOKEN * tkn; 128 | 129 | tkn = (TOKEN *)malloc(sizeof(TOKEN)); 130 | if (tkn == NULL) { 131 | yyerror("new_token(): out of memory"); 132 | return NULL; 133 | } 134 | 135 | memset(tkn, 0, sizeof(TOKEN)); 136 | 137 | tkn->primary = primary; 138 | 139 | return tkn; 140 | } 141 | 142 | 143 | void free_token(TOKEN * tkn) 144 | { 145 | if (tkn) { 146 | switch (tkn->value.type) { 147 | case V_STR: 148 | if (tkn->value.string) 149 | free(tkn->value.string); 150 | tkn->value.string = NULL; 151 | break; 152 | } 153 | 154 | free(tkn); 155 | } 156 | } 157 | 158 | 159 | void free_tokens(int n, ...) 160 | { 161 | TOKEN * t; 162 | va_list ap; 163 | 164 | va_start(ap, n); 165 | while (n--) { 166 | t = va_arg(ap, TOKEN *); 167 | free_token(t); 168 | } 169 | va_end(ap); 170 | } 171 | 172 | 173 | 174 | TOKEN * number(char * text) 175 | { 176 | struct token_t * tkn; 177 | 178 | tkn = new_token(TKN_NUMBER); 179 | if (tkn == NULL) { 180 | return NULL; /* yyerror already called */ 181 | } 182 | tkn->value.type = V_NUM; 183 | tkn->value.number = atoi(text); 184 | 185 | #if DEBUG 186 | avrdude_message(MSG_INFO, "NUMBER(%d)\n", tkn->value.number); 187 | #endif 188 | 189 | return tkn; 190 | } 191 | 192 | TOKEN * number_real(char * text) 193 | { 194 | struct token_t * tkn; 195 | 196 | tkn = new_token(TKN_NUMBER); 197 | tkn->value.type = V_NUM_REAL; 198 | tkn->value.number_real = atof(text); 199 | 200 | #if DEBUG 201 | avrdude_message(MSG_INFO, "NUMBER(%g)\n", tkn->value.number_real); 202 | #endif 203 | 204 | return tkn; 205 | } 206 | 207 | TOKEN * hexnumber(char * text) 208 | { 209 | struct token_t * tkn; 210 | char * e; 211 | 212 | tkn = new_token(TKN_NUMBER); 213 | if (tkn == NULL) { 214 | return NULL; /* yyerror already called */ 215 | } 216 | tkn->value.type = V_NUM; 217 | tkn->value.number = strtoul(text, &e, 16); 218 | if ((e == text) || (*e != 0)) { 219 | yyerror("can't scan hex number \"%s\"", text); 220 | return NULL; 221 | } 222 | 223 | #if DEBUG 224 | avrdude_message(MSG_INFO, "HEXNUMBER(%g)\n", tkn->value.number); 225 | #endif 226 | 227 | return tkn; 228 | } 229 | 230 | 231 | TOKEN * string(char * text) 232 | { 233 | struct token_t * tkn; 234 | int len; 235 | 236 | tkn = new_token(TKN_STRING); 237 | if (tkn == NULL) { 238 | return NULL; /* yyerror already called */ 239 | } 240 | 241 | len = strlen(text); 242 | 243 | tkn->value.type = V_STR; 244 | tkn->value.string = (char *) malloc(len+1); 245 | if (tkn->value.string == NULL) { 246 | yyerror("string(): out of memory"); 247 | return NULL; 248 | } 249 | strcpy(tkn->value.string, text); 250 | 251 | #if DEBUG 252 | avrdude_message(MSG_INFO, "STRING(%s)\n", tkn->value.string); 253 | #endif 254 | 255 | return tkn; 256 | } 257 | 258 | 259 | TOKEN * keyword(int primary) 260 | { 261 | struct token_t * tkn; 262 | 263 | tkn = new_token(primary); 264 | 265 | return tkn; 266 | } 267 | 268 | 269 | void print_token(TOKEN * tkn) 270 | { 271 | if (!tkn) 272 | return; 273 | 274 | avrdude_message(MSG_INFO, "token = %d = ", tkn->primary); 275 | switch (tkn->value.type) { 276 | case V_NUM: 277 | avrdude_message(MSG_INFO, "NUMBER, value=%d", tkn->value.number); 278 | break; 279 | 280 | case V_NUM_REAL: 281 | avrdude_message(MSG_INFO, "NUMBER, value=%g", tkn->value.number_real); 282 | break; 283 | 284 | case V_STR: 285 | avrdude_message(MSG_INFO, "STRING, value=%s", tkn->value.string); 286 | break; 287 | 288 | default: 289 | avrdude_message(MSG_INFO, ""); 290 | break; 291 | } 292 | 293 | avrdude_message(MSG_INFO, "\n"); 294 | } 295 | 296 | 297 | void pyytext(void) 298 | { 299 | #if DEBUG 300 | avrdude_message(MSG_INFO, "TOKEN: \"%s\"\n", yytext); 301 | #endif 302 | } 303 | 304 | 305 | char * dup_string(const char * str) 306 | { 307 | char * s; 308 | 309 | s = strdup(str); 310 | if (s == NULL) { 311 | yyerror("dup_string(): out of memory"); 312 | return NULL; 313 | } 314 | 315 | return s; 316 | } 317 | 318 | #ifdef HAVE_YYLEX_DESTROY 319 | /* reset lexer and free any allocated memory */ 320 | extern int yylex_destroy(void); 321 | #endif 322 | 323 | int read_config(const char * file) 324 | { 325 | FILE * f; 326 | int r; 327 | 328 | f = fopen(file, "r"); 329 | if (f == NULL) { 330 | avrdude_message(MSG_INFO, "%s: can't open config file \"%s\": %s\n", 331 | progname, file, strerror(errno)); 332 | return -1; 333 | } 334 | 335 | lineno = 1; 336 | infile = file; 337 | yyin = f; 338 | 339 | r = yyparse(); 340 | 341 | #ifdef HAVE_YYLEX_DESTROY 342 | /* reset lexer and free any allocated memory */ 343 | yylex_destroy(); 344 | #endif 345 | 346 | fclose(f); 347 | 348 | return r; 349 | } 350 | -------------------------------------------------------------------------------- /config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2000-2004 Brian S. Dean 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: config.h 1322 2014-06-17 20:08:28Z rliebscher $ */ 20 | 21 | /* These are the internal definitions needed for config parsing */ 22 | 23 | #ifndef config_h 24 | #define config_h 25 | 26 | #include "libavrdude.h" 27 | 28 | 29 | #define MAX_STR_CONST 1024 30 | 31 | enum { V_NONE, V_NUM, V_NUM_REAL, V_STR }; 32 | typedef struct value_t { 33 | int type; 34 | /*union { TODO: use an anonymous union here ? */ 35 | int number; 36 | double number_real; 37 | char * string; 38 | /*};*/ 39 | } VALUE; 40 | 41 | 42 | typedef struct token_t { 43 | int primary; 44 | VALUE value; 45 | } TOKEN; 46 | typedef struct token_t *token_p; 47 | 48 | 49 | extern FILE * yyin; 50 | extern PROGRAMMER * current_prog; 51 | extern AVRPART * current_part; 52 | extern AVRMEM * current_mem; 53 | extern int lineno; 54 | extern const char * infile; 55 | extern LISTID string_list; 56 | extern LISTID number_list; 57 | 58 | 59 | #if !defined(HAS_YYSTYPE) 60 | #define YYSTYPE token_p 61 | #endif 62 | extern YYSTYPE yylval; 63 | 64 | extern char string_buf[MAX_STR_CONST]; 65 | extern char *string_buf_ptr; 66 | 67 | #ifdef __cplusplus 68 | extern "C" { 69 | #endif 70 | 71 | int yyparse(void); 72 | 73 | int yyerror(char * errmsg, ...); 74 | 75 | int yywarning(char * errmsg, ...); 76 | 77 | TOKEN * new_token(int primary); 78 | 79 | void free_token(TOKEN * tkn); 80 | 81 | void free_tokens(int n, ...); 82 | 83 | TOKEN * number(char * text); 84 | 85 | TOKEN * number_real(char * text); 86 | 87 | TOKEN * hexnumber(char * text); 88 | 89 | TOKEN * string(char * text); 90 | 91 | TOKEN * keyword(int primary); 92 | 93 | void print_token(TOKEN * tkn); 94 | 95 | void pyytext(void); 96 | 97 | char * dup_string(const char * str); 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /confwin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2003-2004 Eric B. Weddington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include "avrdude.h" 21 | #include "libavrdude.h" 22 | 23 | #if defined(WIN32NATIVE) 24 | 25 | #include 26 | #include 27 | 28 | 29 | static char *filename; 30 | 31 | 32 | void win_sys_config_set(char sys_config[PATH_MAX]) 33 | { 34 | sys_config[0] = 0; 35 | 36 | /* Use Windows API call to search for the Windows default system config file.*/ 37 | SearchPath(NULL, "avrdude.conf", NULL, PATH_MAX, sys_config, &filename); 38 | return; 39 | } 40 | 41 | 42 | void win_usr_config_set(char usr_config[PATH_MAX]) 43 | { 44 | usr_config[0] = 0; 45 | 46 | /* Use Windows API call to search for the Windows default user config file. */ 47 | SearchPath(NULL, "avrdude.rc", NULL, PATH_MAX, usr_config, &filename); 48 | return; 49 | } 50 | 51 | 52 | #endif 53 | 54 | 55 | -------------------------------------------------------------------------------- /crc16.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Derived from CRC algorithm for JTAG ICE mkII, published in Atmel 3 | * Appnote AVR067. Converted from C++ to C. 4 | */ 5 | #include "crc16.h" 6 | 7 | /* CRC16 Definitions */ 8 | static const unsigned short crc_table[256] = { 9 | 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 10 | 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 11 | 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 12 | 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 13 | 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 14 | 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 15 | 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 16 | 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 17 | 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 18 | 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 19 | 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 20 | 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 21 | 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 22 | 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 23 | 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 24 | 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 25 | 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 26 | 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 27 | 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 28 | 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 29 | 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 30 | 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 31 | 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 32 | 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 33 | 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 34 | 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 35 | 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 36 | 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 37 | 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 38 | 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 39 | 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 40 | 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 41 | }; 42 | 43 | /* CRC calculation macros */ 44 | #define CRC_INIT 0xFFFF 45 | #define CRC(crcval,newchar) crcval = (crcval >> 8) ^ \ 46 | crc_table[(crcval ^ newchar) & 0x00ff] 47 | 48 | unsigned short 49 | crcsum(const unsigned char* message, unsigned long length, 50 | unsigned short crc) 51 | { 52 | unsigned long i; 53 | 54 | for(i = 0; i < length; i++) 55 | { 56 | CRC(crc, message[i]); 57 | } 58 | return crc; 59 | } 60 | 61 | int 62 | crcverify(const unsigned char* message, unsigned long length) 63 | { 64 | /* 65 | * Returns true if the last two bytes in a message is the crc of the 66 | * preceding bytes. 67 | */ 68 | unsigned short expected; 69 | 70 | expected = crcsum(message, length - 2, CRC_INIT); 71 | return (expected & 0xff) == message[length - 2] && 72 | ((expected >> 8) & 0xff) == message[length - 1]; 73 | } 74 | 75 | void 76 | crcappend(unsigned char* message, unsigned long length) 77 | { 78 | unsigned long crc; 79 | 80 | crc = crcsum(message, length, CRC_INIT); 81 | message[length] = (unsigned char)(crc & 0xff); 82 | message[length+1] = (unsigned char)((crc >> 8) & 0xff); 83 | } 84 | -------------------------------------------------------------------------------- /crc16.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC16_H 2 | #define CRC16_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* 9 | * Derived from CRC algorithm for JTAG ICE mkII, published in Atmel 10 | * Appnote AVR067. Converted from C++ to C. 11 | */ 12 | 13 | extern unsigned short crcsum(const unsigned char* message, 14 | unsigned long length, 15 | unsigned short crc); 16 | /* 17 | * Verify that the last two bytes is a (LSB first) valid CRC of the 18 | * message. 19 | */ 20 | extern int crcverify(const unsigned char* message, 21 | unsigned long length); 22 | /* 23 | * Append a two byte CRC (LSB first) to message. length is size of 24 | * message excluding crc. Space for the CRC bytes must be allocated 25 | * in advance! 26 | */ 27 | extern void crcappend(unsigned char* message, 28 | unsigned long length); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /dfu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2012 Kirill Levchenko 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: dfu.h 1268 2014-01-17 14:00:01Z joerg_wunsch $ */ 20 | 21 | #ifndef dfu_h 22 | #define dfu_h 23 | 24 | #include "ac_cfg.h" 25 | 26 | #ifdef HAVE_LIBUSB 27 | #if defined(HAVE_USB_H) 28 | # include 29 | #elif defined(HAVE_LUSB0_USB_H) 30 | # include 31 | #else 32 | # error "libusb needs either or " 33 | #endif 34 | #endif 35 | 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* If we have LIBUSB, define the dfu_dev struct normally. Otherwise, declare 43 | * it as an empty struct so that code compiles, but we generate an error at 44 | * run time. 45 | */ 46 | 47 | #ifdef HAVE_LIBUSB 48 | 49 | struct dfu_dev 50 | { 51 | char *bus_name, *dev_name; 52 | usb_dev_handle *dev_handle; 53 | struct usb_device_descriptor dev_desc; 54 | struct usb_config_descriptor conf_desc; 55 | struct usb_interface_descriptor intf_desc; 56 | struct usb_endpoint_descriptor endp_desc; 57 | char *manf_str, *prod_str, *serno_str; 58 | unsigned int timeout; 59 | }; 60 | 61 | #else 62 | 63 | struct dfu_dev { 64 | // empty 65 | }; 66 | 67 | #endif 68 | 69 | /* We assume unsigned char is 1 byte. */ 70 | 71 | #if UCHAR_MAX != 255 72 | #error UCHAR_MAX != 255 73 | #endif 74 | 75 | struct dfu_status { 76 | unsigned char bStatus; 77 | unsigned char bwPollTimeout[3]; 78 | unsigned char bState; 79 | unsigned char iString; 80 | }; 81 | 82 | // Values of bStatus field. 83 | 84 | #define DFU_STATUS_OK 0x0 85 | #define DFU_STATUS_ERR_TARGET 0x1 86 | #define DFU_STATUS_ERR_FILE 0x2 87 | #define DFU_STATUS_ERR_WRITE 0x3 88 | #define DFU_STATUS_ERR_ERASE 0x4 89 | #define DFU_STATUS_ERR_CHECK_ERASED 0x5 90 | #define DFU_STATUS_ERR_PROG 0x6 91 | #define DFU_STATUS_ERR_VERIFY 0x7 92 | #define DFU_STATUS_ERR_ADDRESS 0x8 93 | #define DFU_STATUS_ERR_NOTDONE 0x9 94 | #define DFU_STATUS_ERR_FIRMWARE 0xA 95 | #define DFU_STATUS_ERR_VENDOR 0xB 96 | #define DFU_STATUS_ERR_USBR 0xC 97 | #define DFU_STATUS_ERR_POR 0xD 98 | #define DFU_STATUS_ERR_UNKNOWN 0xE 99 | #define DFU_STATUS_ERR_STALLEDPKT 0xF 100 | 101 | // Values of bState field. 102 | 103 | #define DFU_STATE_APP_IDLE 0 104 | #define DFU_STATE_APP_DETACH 1 105 | #define DFU_STATE_DFU_IDLE 2 106 | #define DFU_STATE_DFU_DLOAD_SYNC 3 107 | #define DFU_STATE_DFU_DNBUSY 4 108 | #define DFU_STATE_DFU_DNLOAD_IDLE 5 109 | #define DFU_STATE_DFU_MANIFEST_SYNC 6 110 | #define DFU_STATE_DFU_MANIFEST 7 111 | #define DFU_STATE_DFU_MANIFEST_WAIT_RESET 8 112 | #define DFU_STATE_DFU_UPLOAD_IDLE 9 113 | #define DFU_STATE_DFU_ERROR 10 114 | 115 | // FUNCTIONS 116 | 117 | extern struct dfu_dev * dfu_open(char *port_spec); 118 | extern int dfu_init(struct dfu_dev *dfu, 119 | unsigned short vid, unsigned short pid); 120 | extern void dfu_close(struct dfu_dev *dfu); 121 | 122 | extern int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status); 123 | extern int dfu_clrstatus(struct dfu_dev *dfu); 124 | extern int dfu_dnload(struct dfu_dev *dfu, void *ptr, int size); 125 | extern int dfu_upload(struct dfu_dev *dfu, void *ptr, int size); 126 | extern int dfu_abort(struct dfu_dev *dfu); 127 | 128 | extern void dfu_show_info(struct dfu_dev *dfu); 129 | 130 | extern const char * dfu_status_str(int bStatus); 131 | extern const char * dfu_state_str(int bState); 132 | 133 | #ifdef __cplusplus 134 | } 135 | #endif 136 | 137 | #endif /* dfu_h */ 138 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # avrdude - A Downloader/Uploader for AVR device programmers 3 | # Copyright (C) 2003 Theodore A. Roth 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | # 20 | # $Id: Makefile.am 1107 2012-11-20 14:03:50Z joerg_wunsch $ 21 | # 22 | 23 | GENERATED_TEXINFOS = \ 24 | $(builddir)/programmers.texi \ 25 | $(builddir)/parts.texi \ 26 | $(builddir)/programmer_types.texi \ 27 | $(builddir)/version.texi 28 | 29 | CLEANFILES = \ 30 | $(GENERATED_TEXINFOS) \ 31 | $(builddir)/stamp-vti 32 | 33 | info_TEXINFOS = avrdude.texi 34 | 35 | EXTRA_DIST = \ 36 | parts_comments.txt 37 | 38 | all-local: info html ps pdf 39 | 40 | html: avrdude-html/avrdude.html 41 | 42 | avrdude-html/avrdude.html: $(srcdir)/$(info_TEXINFOS) $(GENERATED_TEXINFOS) 43 | texi2html -split_node $(srcdir)/$(info_TEXINFOS) 44 | if [ -e ./avrdude.html -o -e ./avrdude_1.html ]; then \ 45 | mkdir -p avrdude-html ; \ 46 | mv -f *.html avrdude-html ; \ 47 | else \ 48 | mv -f avrdude avrdude-html; \ 49 | fi; 50 | 51 | $(builddir)/avrdude.info: $(GENERATED_TEXINFOS) 52 | $(builddir)/avrdude.dvi: $(GENERATED_TEXINFOS) 53 | $(builddir)/avrdude.pdf: $(GENERATED_TEXINFOS) 54 | 55 | # if it does not exist make this first 56 | ../avrdude$(EXEEXT): 57 | $(MAKE) -C .. avrdude$(EXEEXT) 58 | 59 | $(builddir)/programmers.texi: ../avrdude$(EXEEXT) ../avrdude.conf Makefile 60 | ../avrdude$(EXEEXT) -C ../avrdude.conf -c \? 2>&1 \ 61 | | $(AWK) '$$2 ~ /^=$$/ {printf("@item @code{%s} @tab %s\n",$$1,gensub("[^=]+=[ \t]*","",1))}' \ 62 | | sed "s# *,\? *<\?\(http://[^ \t>]*\)>\?#,@*\n@url{\1}#g" \ 63 | >programmers.texi 64 | 65 | $(builddir)/programmer_types.texi: ../avrdude$(EXEEXT) ../avrdude.conf Makefile 66 | ../avrdude$(EXEEXT) -C ../avrdude.conf -c \?type 2>&1 \ 67 | | $(AWK) '$$2 ~ /^=$$/ {printf("@item @code{%s} @tab %s\n",$$1,gensub("[^=]+=[ \t]*","",1))}' \ 68 | | sed "s#<\?\(http://[^ \t,>]*\)>\?#@url{\1}#g" \ 69 | >programmer_types.texi 70 | 71 | $(builddir)/parts.texi: ../avrdude$(EXEEXT) ../avrdude.conf parts_comments.txt Makefile 72 | ../avrdude$(EXEEXT) -C ../avrdude.conf -p \? 2>&1 \ 73 | | $(AWK) '$$2 ~ /^=$$/ {printf("@item @code{%s} @tab %s\n",$$1,$$3)}' \ 74 | | sed -e "`sed 's:\([^ \t]*\)[ \t]*\(.*\):s/\1$$/\1 \2/g:g' parts.texi 76 | 77 | clean-local: 78 | rm -rf avrdude-html *.info 79 | 80 | install-data-local: install-docs 81 | 82 | install-docs: html ps pdf 83 | $(mkinstalldirs) $(DOC_INST_DIR) 84 | $(INSTALL_DATA) avrdude.ps $(DOC_INST_DIR)/avrdude.ps 85 | $(INSTALL_DATA) avrdude.pdf $(DOC_INST_DIR)/avrdude.pdf 86 | $(mkinstalldirs) $(DOC_INST_DIR)/avrdude-html 87 | @list=`echo avrdude-html/*.html`; \ 88 | for file in $$list; \ 89 | do \ 90 | $(INSTALL_DATA) $$file $(DOC_INST_DIR)/$$file; \ 91 | done 92 | 93 | uninstall-local: 94 | rm -rf $(DOC_INST_DIR) 95 | -------------------------------------------------------------------------------- /doc/TODO: -------------------------------------------------------------------------------- 1 | 2 | - Man page needs updated for avr910 info. 3 | 4 | - Website needs to link to docs: 5 | http://savannah.nongnu.org/download/avrdude/doc/avrdude-html/ 6 | 7 | - Add "skip empty pages" optimization on avr910 paged write. The stk500 has 8 | this optimization already. 9 | 10 | - Fix "overfull \hbox" issues in building documentation. 11 | 12 | - FIXME: term.c: terminal_get_input(): strip newlines in non-readline input 13 | code. 14 | 15 | - FIXME: avr910.c: avr910_cmd(): Insert version check here. 16 | 17 | - FIXME: ser_posix.c: serial_close(): Should really restore the terminal to 18 | original state here. 19 | 20 | - FIXME: main.c, par.c: exitspecs don't work if RESET-pin is controlled over 21 | PPICTRL. 22 | 23 | - transfer ppi-speedtuning to the windows version (CAVEAT: This will make 24 | programming too fast for chips with 500kHz clock) 25 | 26 | - make SCK-period configurable for PPI-programmers 27 | -------------------------------------------------------------------------------- /doc/mdate-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Get modification time of a file or directory and pretty-print it. 3 | 4 | scriptversion=2005-06-29.22 5 | 6 | # Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005 Free Software 7 | # Foundation, Inc. 8 | # written by Ulrich Drepper , June 1995 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2, or (at your option) 13 | # any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | # This file is maintained in Automake, please report 29 | # bugs to or send patches to 30 | # . 31 | 32 | case $1 in 33 | '') 34 | echo "$0: No file. Try \`$0 --help' for more information." 1>&2 35 | exit 1; 36 | ;; 37 | -h | --h*) 38 | cat <<\EOF 39 | Usage: mdate-sh [--help] [--version] FILE 40 | 41 | Pretty-print the modification time of FILE. 42 | 43 | Report bugs to . 44 | EOF 45 | exit $? 46 | ;; 47 | -v | --v*) 48 | echo "mdate-sh $scriptversion" 49 | exit $? 50 | ;; 51 | esac 52 | 53 | # Prevent date giving response in another language. 54 | LANG=C 55 | export LANG 56 | LC_ALL=C 57 | export LC_ALL 58 | LC_TIME=C 59 | export LC_TIME 60 | 61 | # GNU ls changes its time format in response to the TIME_STYLE 62 | # variable. Since we cannot assume `unset' works, revert this 63 | # variable to its documented default. 64 | if test "${TIME_STYLE+set}" = set; then 65 | TIME_STYLE=posix-long-iso 66 | export TIME_STYLE 67 | fi 68 | 69 | save_arg1=$1 70 | 71 | # Find out how to get the extended ls output of a file or directory. 72 | if ls -L /dev/null 1>/dev/null 2>&1; then 73 | ls_command='ls -L -l -d' 74 | else 75 | ls_command='ls -l -d' 76 | fi 77 | 78 | # A `ls -l' line looks as follows on OS/2. 79 | # drwxrwx--- 0 Aug 11 2001 foo 80 | # This differs from Unix, which adds ownership information. 81 | # drwxrwx--- 2 root root 4096 Aug 11 2001 foo 82 | # 83 | # To find the date, we split the line on spaces and iterate on words 84 | # until we find a month. This cannot work with files whose owner is a 85 | # user named `Jan', or `Feb', etc. However, it's unlikely that `/' 86 | # will be owned by a user whose name is a month. So we first look at 87 | # the extended ls output of the root directory to decide how many 88 | # words should be skipped to get the date. 89 | 90 | # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below. 91 | set x`ls -l -d /` 92 | 93 | # Find which argument is the month. 94 | month= 95 | command= 96 | until test $month 97 | do 98 | shift 99 | # Add another shift to the command. 100 | command="$command shift;" 101 | case $1 in 102 | Jan) month=January; nummonth=1;; 103 | Feb) month=February; nummonth=2;; 104 | Mar) month=March; nummonth=3;; 105 | Apr) month=April; nummonth=4;; 106 | May) month=May; nummonth=5;; 107 | Jun) month=June; nummonth=6;; 108 | Jul) month=July; nummonth=7;; 109 | Aug) month=August; nummonth=8;; 110 | Sep) month=September; nummonth=9;; 111 | Oct) month=October; nummonth=10;; 112 | Nov) month=November; nummonth=11;; 113 | Dec) month=December; nummonth=12;; 114 | esac 115 | done 116 | 117 | # Get the extended ls output of the file or directory. 118 | set dummy x`eval "$ls_command \"\$save_arg1\""` 119 | 120 | # Remove all preceding arguments 121 | eval $command 122 | 123 | # Because of the dummy argument above, month is in $2. 124 | # 125 | # On a POSIX system, we should have 126 | # 127 | # $# = 5 128 | # $1 = file size 129 | # $2 = month 130 | # $3 = day 131 | # $4 = year or time 132 | # $5 = filename 133 | # 134 | # On Darwin 7.7.0 and 7.6.0, we have 135 | # 136 | # $# = 4 137 | # $1 = day 138 | # $2 = month 139 | # $3 = year or time 140 | # $4 = filename 141 | 142 | # Get the month. 143 | case $2 in 144 | Jan) month=January; nummonth=1;; 145 | Feb) month=February; nummonth=2;; 146 | Mar) month=March; nummonth=3;; 147 | Apr) month=April; nummonth=4;; 148 | May) month=May; nummonth=5;; 149 | Jun) month=June; nummonth=6;; 150 | Jul) month=July; nummonth=7;; 151 | Aug) month=August; nummonth=8;; 152 | Sep) month=September; nummonth=9;; 153 | Oct) month=October; nummonth=10;; 154 | Nov) month=November; nummonth=11;; 155 | Dec) month=December; nummonth=12;; 156 | esac 157 | 158 | case $3 in 159 | ???*) day=$1;; 160 | *) day=$3; shift;; 161 | esac 162 | 163 | # Here we have to deal with the problem that the ls output gives either 164 | # the time of day or the year. 165 | case $3 in 166 | *:*) set `date`; eval year=\$$# 167 | case $2 in 168 | Jan) nummonthtod=1;; 169 | Feb) nummonthtod=2;; 170 | Mar) nummonthtod=3;; 171 | Apr) nummonthtod=4;; 172 | May) nummonthtod=5;; 173 | Jun) nummonthtod=6;; 174 | Jul) nummonthtod=7;; 175 | Aug) nummonthtod=8;; 176 | Sep) nummonthtod=9;; 177 | Oct) nummonthtod=10;; 178 | Nov) nummonthtod=11;; 179 | Dec) nummonthtod=12;; 180 | esac 181 | # For the first six month of the year the time notation can also 182 | # be used for files modified in the last year. 183 | if (expr $nummonth \> $nummonthtod) > /dev/null; 184 | then 185 | year=`expr $year - 1` 186 | fi;; 187 | *) year=$3;; 188 | esac 189 | 190 | # The result. 191 | echo $day $month $year 192 | 193 | # Local Variables: 194 | # mode: shell-script 195 | # sh-indentation: 2 196 | # eval: (add-hook 'write-file-hooks 'time-stamp) 197 | # time-stamp-start: "scriptversion=" 198 | # time-stamp-format: "%:y-%02m-%02d.%02H" 199 | # time-stamp-end: "$" 200 | # End: 201 | -------------------------------------------------------------------------------- /doc/parts_comments.txt: -------------------------------------------------------------------------------- 1 | AT90S1200 (****) 2 | AT90S2343 (*) 3 | ATmega2560 (**) 4 | ATmega2561 (**) 5 | ATtiny11 (***) 6 | -------------------------------------------------------------------------------- /flip1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2014 Joerg Wunsch 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: flip1.h 1311 2014-05-19 10:01:59Z joerg_wunsch $ */ 20 | 21 | #ifndef flip1_h 22 | #define flip1_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern const char flip1_desc[]; 29 | extern void flip1_initpgm(PROGRAMMER * pgm); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* flip1_h */ 36 | -------------------------------------------------------------------------------- /flip2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2012 Kirill Levchenko 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: flip2.h 1311 2014-05-19 10:01:59Z joerg_wunsch $ */ 20 | 21 | #ifndef flip2_h 22 | #define flip2_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern const char flip2_desc[]; 29 | extern void flip2_initpgm(PROGRAMMER * pgm); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* flip2_h */ 36 | -------------------------------------------------------------------------------- /freebsd_ppi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2005 Joerg Wunsch 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: freebsd_ppi.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef freebsd_ppi_h 22 | #define freebsd_ppi_h 23 | 24 | #include 25 | 26 | #define ppi_claim(fd) {} 27 | 28 | #define ppi_release(fd) {} 29 | 30 | #define DO_PPI_READ(fd, reg, valp) \ 31 | (void)ioctl(fd, \ 32 | (reg) == PPIDATA? PPIGDATA: ((reg) == PPICTRL? PPIGCTRL: PPIGSTATUS), \ 33 | valp) 34 | #define DO_PPI_WRITE(fd, reg, valp) \ 35 | (void)ioctl(fd, \ 36 | (reg) == PPIDATA? PPISDATA: ((reg) == PPICTRL? PPISCTRL: PPISSTATUS), \ 37 | valp) 38 | 39 | #endif /* freebsd_ppi_h */ 40 | -------------------------------------------------------------------------------- /ft245r.h: -------------------------------------------------------------------------------- 1 | #ifndef ft245r_h 2 | #define ft245r_h 3 | 4 | extern const char ft245r_desc[]; 5 | void ft245r_initpgm (PROGRAMMER * pgm); 6 | 7 | 8 | #endif /* ft245r_h */ 9 | -------------------------------------------------------------------------------- /jtag3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2012 Joerg Wunsch 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: jtag3.h 1283 2014-02-27 13:06:03Z joerg_wunsch $ */ 20 | 21 | #ifndef jtag3_h 22 | #define jtag3_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | int jtag3_open_common(PROGRAMMER * pgm, char * port); 29 | int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len); 30 | int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg); 31 | void jtag3_close(PROGRAMMER * pgm); 32 | int jtag3_getsync(PROGRAMMER * pgm, int mode); 33 | int jtag3_getparm(PROGRAMMER * pgm, unsigned char scope, 34 | unsigned char section, unsigned char parm, 35 | unsigned char *value, unsigned char length); 36 | int jtag3_setparm(PROGRAMMER * pgm, unsigned char scope, 37 | unsigned char section, unsigned char parm, 38 | unsigned char *value, unsigned char length); 39 | int jtag3_command(PROGRAMMER *pgm, unsigned char *cmd, unsigned int cmdlen, 40 | unsigned char **resp, const char *descr); 41 | extern const char jtag3_desc[]; 42 | extern const char jtag3_dw_desc[]; 43 | extern const char jtag3_pdi_desc[]; 44 | void jtag3_initpgm (PROGRAMMER * pgm); 45 | void jtag3_dw_initpgm (PROGRAMMER * pgm); 46 | void jtag3_pdi_initpgm (PROGRAMMER * pgm); 47 | 48 | /* 49 | * These functions are referenced from stk500v2.c for JTAGICE3 in 50 | * one of the STK500v2 modi. 51 | */ 52 | void jtag3_setup(PROGRAMMER * pgm); 53 | void jtag3_teardown(PROGRAMMER * pgm); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /jtagmkI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2002-2004 Brian S. Dean 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: jtagmkI.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef jtagmkI_h 22 | #define jtagmkI_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern const char jtagmkI_desc[]; 29 | void jtagmkI_initpgm (PROGRAMMER * pgm); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /jtagmkII.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2002-2004, 2006 Brian S. Dean 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: jtagmkII.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef jtagmkII_h 22 | #define jtagmkII_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | int jtagmkII_send(PROGRAMMER * pgm, unsigned char * data, size_t len); 29 | int jtagmkII_recv(PROGRAMMER * pgm, unsigned char **msg); 30 | void jtagmkII_close(PROGRAMMER * pgm); 31 | int jtagmkII_getsync(PROGRAMMER * pgm, int mode); 32 | int jtagmkII_getparm(PROGRAMMER * pgm, unsigned char parm, 33 | unsigned char * value); 34 | 35 | extern const char jtagmkII_desc[]; 36 | extern const char jtagmkII_avr32_desc[]; 37 | extern const char jtagmkII_dw_desc[]; 38 | extern const char jtagmkII_pdi_desc[]; 39 | extern const char jtagmkII_dragon_desc[]; 40 | extern const char jtagmkII_dragon_dw_desc[]; 41 | extern const char jtagmkII_dragon_pdi_desc[]; 42 | void jtagmkII_initpgm (PROGRAMMER * pgm); 43 | void jtagmkII_avr32_initpgm (PROGRAMMER * pgm); 44 | void jtagmkII_dw_initpgm (PROGRAMMER * pgm); 45 | void jtagmkII_pdi_initpgm (PROGRAMMER * pgm); 46 | void jtagmkII_dragon_initpgm (PROGRAMMER * pgm); 47 | void jtagmkII_dragon_dw_initpgm (PROGRAMMER * pgm); 48 | void jtagmkII_dragon_pdi_initpgm (PROGRAMMER * pgm); 49 | 50 | /* 51 | * These functions are referenced from stk500v2.c for JTAG ICE mkII 52 | * and AVR Dragon programmers running in one of the STK500v2 53 | * modi. 54 | */ 55 | void jtagmkII_setup(PROGRAMMER * pgm); 56 | void jtagmkII_teardown(PROGRAMMER * pgm); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /jtagmkI_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2005 Joerg Wunsch 4 | * 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | /* $Id: jtagmkI_private.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 21 | 22 | 23 | /* 24 | * JTAG ICE mkI definitions 25 | */ 26 | 27 | /* ICE command codes */ 28 | /* 0x20 Get Synch [Resp_OK] */ 29 | #define CMD_GET_SYNC ' ' 30 | 31 | /* 0x31 Single Step [Sync_CRC/EOP] [Resp_OK] */ 32 | /* 0x32 Read PC [Sync_CRC/EOP] [Resp_OK] [program counter] 33 | * [Resp_OK] */ 34 | /* 0x33 Write PC [program counter] [Sync_CRC/EOP] [Resp_OK] 35 | * [Resp_OK] */ 36 | /* 0xA2 Firmware Upgrade [upgrade string] [Sync_CRC/EOP] [Resp_OK] 37 | * [Resp_OK] */ 38 | /* 0xA0 Set Device Descriptor [device info] [Sync_CRC/EOP] [Resp_OK] 39 | * [Resp_OK] */ 40 | #define CMD_SET_DEVICE_DESCRIPTOR 0xA0 41 | 42 | /* 0x42 Set Parameter [parameter] [setting] [Sync_CRC/EOP] [Resp_OK] 43 | * [Resp_OK] */ 44 | #define CMD_SET_PARAM 'B' 45 | 46 | /* 0x46 Forced Stop [Sync_CRC/EOP] [Resp_OK] [checksum][program 47 | * counter] [Resp_OK] */ 48 | #define CMD_STOP 'F' 49 | 50 | /* 0x47 Go [Sync_CRC/EOP] [Resp_OK] */ 51 | #define CMD_GO 'G' 52 | 53 | /* 0x52 Read Memory [memory type] [word count] [start address] 54 | * [Sync_CRC/EOP] [Resp_OK] [word 0] ... [word n] [checksum] 55 | * [Resp_OK] */ 56 | #define CMD_READ_MEM 'R' 57 | 58 | /* 0x53 Get Sign On [Sync_CRC/EOP] [Resp_OK] ["AVRNOCD"] [Resp_OK] */ 59 | #define CMD_GET_SIGNON 'S' 60 | 61 | /* 0XA1 Erase Page spm [address] [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */ 62 | 63 | /* 0x57 Write Memory [memory type] [word count] [start address] 64 | * [Sync_CRC/EOP] [Resp_OK] [Cmd_DATA] [word 0] ... [word n] */ 65 | #define CMD_WRITE_MEM 'W' 66 | 67 | /* Second half of write memory: the data command. Undocumented. */ 68 | #define CMD_DATA 'h' 69 | 70 | /* 0x64 Get Debug Info [Sync_CRC/EOP] [Resp_OK] [0x00] [Resp_OK] */ 71 | /* 0x71 Get Parameter [parameter] [Sync_CRC/EOP] [Resp_OK] [setting] 72 | * [Resp_OK] */ 73 | #define CMD_GET_PARAM 'q' 74 | 75 | /* 0x78 Reset [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */ 76 | #define CMD_RESET 'x' 77 | 78 | /* 0xA3 Enter Progmode [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */ 79 | #define CMD_ENTER_PROGMODE 0xa3 80 | 81 | /* 0xA4 Leave Progmode [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */ 82 | #define CMD_LEAVE_PROGMODE 0xa4 83 | 84 | /* 0xA5 Chip Erase [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */ 85 | #define CMD_CHIP_ERASE 0xa5 86 | 87 | 88 | /* ICE responses */ 89 | #define RESP_OK 'A' 90 | #define RESP_BREAK 'B' 91 | #define RESP_INFO 'G' 92 | #define RESP_FAILED 'F' 93 | #define RESP_SYNC_ERROR 'E' 94 | #define RESP_SLEEP 'H' 95 | #define RESP_POWER 'I' 96 | 97 | #define PARM_BITRATE 'b' 98 | #define PARM_SW_VERSION 0x7b 99 | #define PARM_HW_VERSION 0x7a 100 | #define PARM_IREG_HIGH 0x81 101 | #define PARM_IREG_LOW 0x82 102 | #define PARM_OCD_VTARGET 0x84 103 | #define PARM_OCD_BREAK_CAUSE 0x85 104 | #define PARM_CLOCK 0x86 105 | #define PARM_EXTERNAL_RESET 0x8b 106 | #define PARM_FLASH_PAGESIZE_LOW 0x88 107 | #define PARM_FLASH_PAGESIZE_HIGH 0x89 108 | #define PARM_EEPROM_PAGESIZE 0x8a 109 | #define PARM_TIMERS_RUNNING 0xa0 110 | #define PARM_BP_FLOW 0xa1 111 | #define PARM_BP_X_HIGH 0xa2 112 | #define PARM_BP_X_LOW 0xa3 113 | #define PARM_BP_Y_HIGH 0xa4 114 | #define PARM_BP_Y_LOW 0xa5 115 | #define PARM_BP_MODE 0xa6 116 | #define PARM_JTAGID_BYTE0 0xa7 117 | #define PARM_JTAGID_BYTE1 0xa8 118 | #define PARM_JTAGID_BYTE2 0xa9 119 | #define PARM_JTAGID_BYTE3 0xaa 120 | #define PARM_UNITS_BEFORE 0xab 121 | #define PARM_UNITS_AFTER 0xac 122 | #define PARM_BIT_BEFORE 0xad 123 | #define PARM_BIT_AFTER 0xae 124 | #define PARM_PSB0_LOW 0xaf 125 | #define PARM_PSBO_HIGH 0xb0 126 | #define PARM_PSB1_LOW 0xb1 127 | #define PARM_PSB1_HIGH 0xb2 128 | #define PARM_MCU_MODE 0xb3 129 | 130 | #define JTAG_BITRATE_1_MHz 0xff 131 | #define JTAG_BITRATE_500_kHz 0xfe 132 | #define JTAG_BITRATE_250_kHz 0xfd 133 | #define JTAG_BITRATE_125_kHz 0xfb 134 | 135 | /* memory types for CMND_{READ,WRITE}_MEMORY */ 136 | #define MTYPE_IO_SHADOW 0x30 /* cached IO registers? */ 137 | #define MTYPE_SRAM 0x20 /* target's SRAM or [ext.] IO registers */ 138 | #define MTYPE_EEPROM 0x22 /* EEPROM, what way? */ 139 | #define MTYPE_EVENT 0x60 /* ICE event memory */ 140 | #define MTYPE_SPM 0xA0 /* flash through LPM/SPM */ 141 | #define MTYPE_FLASH_PAGE 0xB0 /* flash in programming mode */ 142 | #define MTYPE_EEPROM_PAGE 0xB1 /* EEPROM in programming mode */ 143 | #define MTYPE_FUSE_BITS 0xB2 /* fuse bits in programming mode */ 144 | #define MTYPE_LOCK_BITS 0xB3 /* lock bits in programming mode */ 145 | #define MTYPE_SIGN_JTAG 0xB4 /* signature in programming mode */ 146 | #define MTYPE_OSCCAL_BYTE 0xB5 /* osccal cells in programming mode */ 147 | 148 | struct device_descriptor 149 | { 150 | unsigned char ucReadIO[8]; /*LSB = IOloc 0, MSB = IOloc63 */ 151 | unsigned char ucWriteIO[8]; /*LSB = IOloc 0, MSB = IOloc63 */ 152 | unsigned char ucReadIOShadow[8]; /*LSB = IOloc 0, MSB = IOloc63 */ 153 | unsigned char ucWriteIOShadow[8]; /*LSB = IOloc 0, MSB = IOloc63 */ 154 | unsigned char ucReadExtIO[20]; /*LSB = IOloc 96, MSB = IOloc255 */ 155 | unsigned char ucWriteExtIO[20]; /*LSB = IOloc 96, MSB = IOloc255 */ 156 | unsigned char ucReadIOExtShadow[20]; /*LSB = IOloc 96, MSB = IOloc255 */ 157 | unsigned char ucWriteIOExtShadow[20];/*LSB = IOloc 96, MSB = IOloc255 */ 158 | unsigned char ucIDRAddress; /*IDR address */ 159 | unsigned char ucSPMCRAddress; /*SPMCR Register address and dW BasePC */ 160 | unsigned char ucRAMPZAddress; /*RAMPZ Register address in SRAM I/O */ 161 | /*space */ 162 | unsigned char uiFlashPageSize[2]; /*Device Flash Page Size, Size = */ 163 | /*2 exp ucFlashPageSize */ 164 | unsigned char ucEepromPageSize; /*Device Eeprom Page Size in bytes */ 165 | unsigned char ulBootAddress[4]; /*Device Boot Loader Start Address */ 166 | unsigned char uiUpperExtIOLoc; /*Topmost (last) extended I/O */ 167 | /*location, 0 if no external I/O */ 168 | }; 169 | -------------------------------------------------------------------------------- /libavrdude.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxproff/avrdude-ch341/d2e962355fc6281f7fe50b1b82ec3f6a44bf065a/libavrdude.a -------------------------------------------------------------------------------- /libch341dll_1_modtxt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxproff/avrdude-ch341/d2e962355fc6281f7fe50b1b82ec3f6a44bf065a/libch341dll_1_modtxt.a -------------------------------------------------------------------------------- /linux_ppdev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2003, 2005 Theodore A. Roth 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: linux_ppdev.h 1325 2014-06-23 20:20:38Z rliebscher $ */ 20 | 21 | #ifndef linux_ppdev_h 22 | #define linux_ppdev_h 23 | 24 | #define OBSOLETE__IOW _IOW 25 | 26 | #include 27 | #ifdef HAVE_PARPORT 28 | #include 29 | #include 30 | #endif 31 | 32 | #include 33 | 34 | #define ppi_claim(fd) \ 35 | if (ioctl(fd, PPCLAIM)) { \ 36 | avrdude_message(MSG_INFO, "%s: can't claim device \"%s\": %s\n\n", \ 37 | progname, port, strerror(errno)); \ 38 | close(fd); \ 39 | return; \ 40 | } 41 | 42 | #define ppi_release(fd) \ 43 | if (ioctl(fd, PPRELEASE)) { \ 44 | avrdude_message(MSG_INFO, "%s: can't release device: %s\n\n", \ 45 | progname, strerror(errno)); \ 46 | } 47 | 48 | #define DO_PPI_READ(fd, reg, valp) \ 49 | (void)ioctl(fd, \ 50 | (reg) == PPIDATA? PPRDATA: ((reg) == PPICTRL? PPRCONTROL: PPRSTATUS), \ 51 | valp) 52 | #define DO_PPI_WRITE(fd, reg, valp) \ 53 | (void)ioctl(fd, \ 54 | (reg) == PPIDATA? PPWDATA: ((reg) == PPICTRL? PPWCONTROL: PPWSTATUS), \ 55 | valp) 56 | 57 | #endif /* linux_ppdev_h */ 58 | -------------------------------------------------------------------------------- /linuxgpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2013 Radoslav Kolev 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /* $Id: par.h 722 2007-01-24 22:43:46Z joerg_wunsch $ */ 21 | 22 | #ifndef linuxgpio_h 23 | #define linuxgpio_h 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | extern const char linuxgpio_desc[]; 30 | void linuxgpio_initpgm (PROGRAMMER * pgm); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /my_ddk_hidsdi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2006 Christian Starkjohann 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: my_ddk_hidsdi.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | /* 22 | The following is a replacement for hidsdi.h from the Windows DDK. It defines some 23 | of the types and function prototypes of this header for our project. If you 24 | have the Windows DDK version of this file or a version shipped with MinGW, use 25 | that instead. 26 | */ 27 | #ifndef MY_DDK_HIDSDI_H 28 | #define MY_DDK_HIDSDI_H 29 | #include 30 | #include 31 | #include 32 | // #include "hidusage.h" 33 | // #include "hidpi.h" 34 | // #include "hidsdi.h" 35 | typedef struct{ 36 | ULONG Size; 37 | USHORT VendorID; 38 | USHORT ProductID; 39 | USHORT VersionNumber; 40 | }HIDD_ATTRIBUTES; 41 | void __stdcall HidD_GetHidGuid(OUT LPGUID hidGuid); 42 | BOOLEAN __stdcall HidD_GetAttributes(IN HANDLE device, OUT HIDD_ATTRIBUTES *attributes); 43 | BOOLEAN __stdcall HidD_GetManufacturerString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); 44 | BOOLEAN __stdcall HidD_GetProductString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); 45 | BOOLEAN __stdcall HidD_GetSerialNumberString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); 46 | BOOLEAN __stdcall HidD_GetFeature(IN HANDLE device, OUT void *reportBuffer, IN ULONG bufferLen); 47 | BOOLEAN __stdcall HidD_SetFeature(IN HANDLE device, IN void *reportBuffer, IN ULONG bufferLen); 48 | BOOLEAN __stdcall HidD_GetNumInputBuffers(IN HANDLE device, OUT ULONG *numBuffers); 49 | BOOLEAN __stdcall HidD_SetNumInputBuffers(IN HANDLE device, OUT ULONG numBuffers); 50 | #include 51 | #endif /* MY_DDK_HIDSDI_H */ 52 | -------------------------------------------------------------------------------- /par.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2000-2004 Brian S. Dean 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: par.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef par_h 22 | #define par_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern const char par_desc[]; 29 | void par_initpgm (PROGRAMMER * pgm); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /pgm_type.c: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2002-2004 Brian S. Dean 4 | * Copyright 2007 Joerg Wunsch 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | /* $Id: pgm.c 976 2011-08-23 21:03:36Z joerg_wunsch $ */ 21 | 22 | #include "ac_cfg.h" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "avrdude.h" 29 | #include "libavrdude.h" 30 | 31 | #include "arduino.h" 32 | #include "avr910.h" 33 | #include "avrftdi.h" 34 | #include "buspirate.h" 35 | #include "butterfly.h" 36 | #include "flip1.h" 37 | #include "flip2.h" 38 | #include "ft245r.h" 39 | #include "jtagmkI.h" 40 | #include "jtagmkII.h" 41 | #include "jtag3.h" 42 | #include "linuxgpio.h" 43 | #include "par.h" 44 | #include "pickit2.h" 45 | #include "ppi.h" 46 | #include "serbb.h" 47 | #include "stk500.h" 48 | #include "stk500generic.h" 49 | #include "stk500v2.h" 50 | #include "usbasp.h" 51 | #include "ch341a.h" 52 | #include "ch341a_bitbang.h" 53 | #if defined(WIN32NATIVE) 54 | #include "ch341a_bitbang_wch.h" 55 | #endif 56 | #include "usbtiny.h" 57 | #include "wiring.h" 58 | 59 | 60 | const PROGRAMMER_TYPE programmers_types[] = { 61 | {"arduino", arduino_initpgm, arduino_desc}, 62 | {"avr910", avr910_initpgm, avr910_desc}, 63 | {"avrftdi", avrftdi_initpgm, avrftdi_desc}, 64 | {"buspirate", buspirate_initpgm, buspirate_desc}, 65 | {"buspirate_bb", buspirate_bb_initpgm, buspirate_bb_desc}, 66 | {"butterfly", butterfly_initpgm, butterfly_desc}, 67 | {"butterfly_mk", butterfly_mk_initpgm, butterfly_mk_desc}, 68 | {"dragon_dw", jtagmkII_dragon_dw_initpgm, jtagmkII_dragon_dw_desc}, 69 | {"dragon_hvsp", stk500v2_dragon_hvsp_initpgm, stk500v2_dragon_hvsp_desc}, 70 | {"dragon_isp", stk500v2_dragon_isp_initpgm, stk500v2_dragon_isp_desc}, 71 | {"dragon_jtag", jtagmkII_dragon_initpgm, jtagmkII_dragon_desc}, 72 | {"dragon_pdi", jtagmkII_dragon_pdi_initpgm, jtagmkII_dragon_pdi_desc}, 73 | {"dragon_pp", stk500v2_dragon_pp_initpgm, stk500v2_dragon_pp_desc}, 74 | {"flip1", flip1_initpgm, flip1_desc}, 75 | {"flip2", flip2_initpgm, flip2_desc}, 76 | {"ftdi_syncbb", ft245r_initpgm, ft245r_desc}, 77 | {"jtagmki", jtagmkI_initpgm, jtagmkI_desc}, 78 | {"jtagmkii", jtagmkII_initpgm, jtagmkII_desc}, 79 | {"jtagmkii_avr32", jtagmkII_avr32_initpgm, jtagmkII_avr32_desc}, 80 | {"jtagmkii_dw", jtagmkII_dw_initpgm, jtagmkII_dw_desc}, 81 | {"jtagmkii_isp", stk500v2_jtagmkII_initpgm, stk500v2_jtagmkII_desc}, 82 | {"jtagmkii_pdi", jtagmkII_pdi_initpgm, jtagmkII_pdi_desc}, 83 | {"jtagice3", jtag3_initpgm, jtag3_desc}, 84 | {"jtagice3_pdi", jtag3_pdi_initpgm, jtag3_pdi_desc}, 85 | {"jtagice3_dw", jtag3_dw_initpgm, jtag3_dw_desc}, 86 | {"jtagice3_isp", stk500v2_jtag3_initpgm, stk500v2_jtag3_desc}, 87 | {"linuxgpio", linuxgpio_initpgm, linuxgpio_desc}, 88 | {"par", par_initpgm, par_desc}, 89 | {"pickit2", pickit2_initpgm, pickit2_desc}, 90 | {"serbb", serbb_initpgm, serbb_desc}, 91 | {"stk500", stk500_initpgm, stk500_desc}, 92 | {"stk500generic", stk500generic_initpgm, stk500generic_desc}, 93 | {"stk500v2", stk500v2_initpgm, stk500v2_desc}, 94 | {"stk500hvsp", stk500hvsp_initpgm, stk500hvsp_desc}, 95 | {"stk500pp", stk500pp_initpgm, stk500pp_desc}, 96 | {"stk600", stk600_initpgm, stk600_desc}, 97 | {"stk600hvsp", stk600hvsp_initpgm, stk600hvsp_desc}, 98 | {"stk600pp", stk600pp_initpgm, stk600pp_desc}, 99 | {"usbasp", usbasp_initpgm, usbasp_desc}, 100 | {"ch341a", ch341a_initpgm, ch341a_desc}, 101 | {"ch341a_bitbang", ch341a_bitbang_initpgm, ch341a_bitbang_desc}, 102 | #if defined(WIN32NATIVE) 103 | {"ch341a_bitbang_wch", ch341a_bitbang_wch_initpgm, ch341a_bitbang_wch_desc}, 104 | #endif 105 | {"usbtiny", usbtiny_initpgm, usbtiny_desc}, 106 | {"wiring", wiring_initpgm, wiring_desc}, 107 | }; 108 | 109 | const PROGRAMMER_TYPE * locate_programmer_type(const char * id) 110 | { 111 | const PROGRAMMER_TYPE * p = NULL; 112 | int i; 113 | int found; 114 | 115 | found = 0; 116 | 117 | for (i = 0; i < sizeof(programmers_types)/sizeof(programmers_types[0]) && !found; i++) { 118 | p = &(programmers_types[i]); 119 | if (strcasecmp(id, p->id) == 0) 120 | found = 1; 121 | } 122 | 123 | if (found) 124 | return p; 125 | 126 | return NULL; 127 | } 128 | 129 | /* 130 | * Iterate over the list of programmers given as "programmers", and 131 | * call the callback function cb for each entry found. cb is being 132 | * passed the following arguments: 133 | * . the name of the programmer (for -c) 134 | * . the descriptive text given in the config file 135 | * . the name of the config file this programmer has been defined in 136 | * . the line number of the config file this programmer has been defined at 137 | * . the "cookie" passed into walk_programmers() (opaque client data) 138 | */ 139 | /* 140 | void walk_programmer_types(LISTID programmer_types, walk_programmer_types_cb cb, void *cookie) 141 | { 142 | LNODEID ln1; 143 | PROGRAMMER * p; 144 | 145 | for (ln1 = lfirst(programmers); ln1; ln1 = lnext(ln1)) { 146 | p = ldata(ln1); 147 | cb(p->id, p->desc, cookie); 148 | } 149 | } 150 | }*/ 151 | 152 | void walk_programmer_types(walk_programmer_types_cb cb, void *cookie) 153 | { 154 | const PROGRAMMER_TYPE * p; 155 | int i; 156 | 157 | for (i = 0; i < sizeof(programmers_types)/sizeof(programmers_types[0]); i++) { 158 | p = &(programmers_types[i]); 159 | cb(p->id, p->desc, cookie); 160 | } 161 | } 162 | 163 | 164 | -------------------------------------------------------------------------------- /pickit2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2006 Thomas Fischl 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: pickit2.h 2010-05-03 dbrown $ */ 20 | 21 | #ifndef pickit2_h 22 | #define pickit2_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern const char pickit2_desc[]; 29 | void pickit2_initpgm (PROGRAMMER * pgm); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // pickit2_h 36 | -------------------------------------------------------------------------------- /ppi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2000-2004 Brian S. Dean 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: ppi.c 1321 2014-06-13 20:07:40Z awachtler $ */ 20 | 21 | 22 | #if !defined(WIN32NATIVE) 23 | 24 | #include "ac_cfg.h" 25 | 26 | #if HAVE_PARPORT 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) 36 | # include "freebsd_ppi.h" 37 | #elif defined(__linux__) 38 | # include "linux_ppdev.h" 39 | #elif defined(__sun__) || defined(__sun) /* Solaris */ 40 | # include "solaris_ecpp.h" 41 | #endif 42 | 43 | #include "avrdude.h" 44 | #include "libavrdude.h" 45 | 46 | #include "ppi.h" 47 | 48 | enum { 49 | PPI_READ, 50 | PPI_WRITE, 51 | PPI_SHADOWREAD 52 | }; 53 | 54 | static int ppi_shadow_access(union filedescriptor *fdp, int reg, 55 | unsigned char *v, unsigned char action) 56 | { 57 | static unsigned char shadow[3]; 58 | int shadow_num; 59 | 60 | switch (reg) { 61 | case PPIDATA: 62 | shadow_num = 0; 63 | break; 64 | case PPICTRL: 65 | shadow_num = 1; 66 | break; 67 | case PPISTATUS: 68 | shadow_num = 2; 69 | break; 70 | default: 71 | avrdude_message(MSG_INFO, "%s: avr_set(): invalid register=%d\n", 72 | progname, reg); 73 | return -1; 74 | break; 75 | } 76 | 77 | switch (action) { 78 | case PPI_SHADOWREAD: 79 | *v = shadow[shadow_num]; 80 | break; 81 | case PPI_READ: 82 | DO_PPI_READ(fdp->ifd, reg, v); 83 | shadow[shadow_num]=*v; 84 | break; 85 | case PPI_WRITE: 86 | shadow[shadow_num]=*v; 87 | DO_PPI_WRITE(fdp->ifd, reg, v); 88 | break; 89 | } 90 | return 0; 91 | } 92 | 93 | /* 94 | * set the indicated bit of the specified register. 95 | */ 96 | int ppi_set(union filedescriptor *fdp, int reg, int bit) 97 | { 98 | unsigned char v; 99 | int rc; 100 | 101 | rc = ppi_shadow_access(fdp, reg, &v, PPI_SHADOWREAD); 102 | v |= bit; 103 | rc |= ppi_shadow_access(fdp, reg, &v, PPI_WRITE); 104 | 105 | if (rc) 106 | return -1; 107 | 108 | return 0; 109 | } 110 | 111 | 112 | /* 113 | * clear the indicated bit of the specified register. 114 | */ 115 | int ppi_clr(union filedescriptor *fdp, int reg, int bit) 116 | { 117 | unsigned char v; 118 | int rc; 119 | 120 | rc = ppi_shadow_access(fdp, reg, &v, PPI_SHADOWREAD); 121 | v &= ~bit; 122 | rc |= ppi_shadow_access(fdp, reg, &v, PPI_WRITE); 123 | 124 | if (rc) 125 | return -1; 126 | 127 | return 0; 128 | } 129 | 130 | 131 | /* 132 | * get the indicated bit of the specified register. 133 | */ 134 | int ppi_get(union filedescriptor *fdp, int reg, int bit) 135 | { 136 | unsigned char v; 137 | int rc; 138 | 139 | rc = ppi_shadow_access(fdp, reg, &v, PPI_READ); 140 | v &= bit; 141 | 142 | if (rc) 143 | return -1; 144 | 145 | return v; /* v == bit */ 146 | } 147 | 148 | /* 149 | * toggle the indicated bit of the specified register. 150 | */ 151 | int ppi_toggle(union filedescriptor *fdp, int reg, int bit) 152 | { 153 | unsigned char v; 154 | int rc; 155 | 156 | rc = ppi_shadow_access(fdp, reg, &v, PPI_SHADOWREAD); 157 | v ^= bit; 158 | rc |= ppi_shadow_access(fdp, reg, &v, PPI_WRITE); 159 | 160 | if (rc) 161 | return -1; 162 | 163 | return 0; 164 | } 165 | 166 | 167 | /* 168 | * get all bits of the specified register. 169 | */ 170 | int ppi_getall(union filedescriptor *fdp, int reg) 171 | { 172 | unsigned char v; 173 | int rc; 174 | 175 | rc = ppi_shadow_access(fdp, reg, &v, PPI_READ); 176 | 177 | if (rc) 178 | return -1; 179 | 180 | return v; /* v == bit */ 181 | } 182 | 183 | /* 184 | * set all bits of the specified register to val. 185 | */ 186 | int ppi_setall(union filedescriptor *fdp, int reg, int val) 187 | { 188 | unsigned char v; 189 | int rc; 190 | 191 | v = val; 192 | rc = ppi_shadow_access(fdp, reg, &v, PPI_WRITE); 193 | 194 | if (rc) 195 | return -1; 196 | 197 | return 0; 198 | } 199 | 200 | 201 | void ppi_open(char * port, union filedescriptor *fdp) 202 | { 203 | int fd; 204 | unsigned char v; 205 | 206 | fd = open(port, O_RDWR); 207 | if (fd < 0) { 208 | avrdude_message(MSG_INFO, "%s: can't open device \"%s\": %s\n", 209 | progname, port, strerror(errno)); 210 | fdp->ifd = -1; 211 | return; 212 | } 213 | 214 | ppi_claim (fd); 215 | 216 | /* 217 | * Initialize shadow registers 218 | */ 219 | 220 | ppi_shadow_access (fdp, PPIDATA, &v, PPI_READ); 221 | ppi_shadow_access (fdp, PPICTRL, &v, PPI_READ); 222 | ppi_shadow_access (fdp, PPISTATUS, &v, PPI_READ); 223 | 224 | fdp->ifd = fd; 225 | } 226 | 227 | 228 | void ppi_close(union filedescriptor *fdp) 229 | { 230 | ppi_release (fdp->ifd); 231 | close(fdp->ifd); 232 | } 233 | 234 | #endif /* HAVE_PARPORT */ 235 | 236 | #endif /* !WIN32NATIVE */ 237 | -------------------------------------------------------------------------------- /ppi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2000-2004 Brian S. Dean 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: ppi.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef ppi_h 22 | #define ppi_h 23 | 24 | /* 25 | * PPI registers 26 | */ 27 | enum { 28 | PPIDATA, 29 | PPICTRL, 30 | PPISTATUS 31 | }; 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | int ppi_get (union filedescriptor *fdp, int reg, int bit); 38 | 39 | int ppi_set (union filedescriptor *fdp, int reg, int bit); 40 | 41 | int ppi_clr (union filedescriptor *fdp, int reg, int bit); 42 | 43 | int ppi_getall (union filedescriptor *fdp, int reg); 44 | 45 | int ppi_setall (union filedescriptor *fdp, int reg, int val); 46 | 47 | int ppi_toggle (union filedescriptor *fdp, int reg, int bit); 48 | 49 | void ppi_open (char * port, union filedescriptor *fdp); 50 | 51 | void ppi_close (union filedescriptor *fdp); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif 58 | 59 | 60 | -------------------------------------------------------------------------------- /serbb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean 4 | * Copyright (C) 2005 Michael Holzt 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | /* $Id: serbb.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef serbb_h 22 | #define serbb_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern const char serbb_desc[]; 29 | void serbb_initpgm (PROGRAMMER * pgm); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | 37 | 38 | -------------------------------------------------------------------------------- /solaris_ecpp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2005 Joerg Wunsch 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: solaris_ecpp.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef solaris_ecpp_h 22 | #define solaris_ecpp_h 23 | 24 | #include 25 | 26 | #define ppi_claim(fd) \ 27 | do { \ 28 | struct ecpp_transfer_parms p; \ 29 | (void)ioctl(fd, ECPPIOC_GETPARMS, &p); \ 30 | p.mode = ECPP_DIAG_MODE; \ 31 | (void)ioctl(fd, ECPPIOC_SETPARMS, &p); \ 32 | } while(0); 33 | 34 | #define ppi_release(fd) 35 | 36 | #define DO_PPI_READ(fd, reg, valp) \ 37 | do { struct ecpp_regs r; \ 38 | if ((reg) == PPIDATA) { (void)ioctl(fd, ECPPIOC_GETDATA, valp); } \ 39 | else { (void)ioctl(fd, ECPPIOC_GETREGS, &r); \ 40 | *(valp) = ((reg) == PPICTRL)? r.dcr: r.dsr; } \ 41 | } while(0) 42 | #define DO_PPI_WRITE(fd, reg, valp) \ 43 | do { struct ecpp_regs r; \ 44 | if ((reg) == PPIDATA) { (void)ioctl(fd, ECPPIOC_SETDATA, valp); } \ 45 | else { if ((reg) == PPICTRL) r.dcr = *(valp); else r.dsr = *(valp); \ 46 | (void)ioctl(fd, ECPPIOC_SETREGS, &r); } \ 47 | } while(0) 48 | 49 | 50 | #endif /* solaris_ecpp_h */ 51 | -------------------------------------------------------------------------------- /stamp-h1: -------------------------------------------------------------------------------- 1 | timestamp for ac_cfg.h 2 | -------------------------------------------------------------------------------- /static_link.txt: -------------------------------------------------------------------------------- 1 | i686-w64-mingw32-gcc -Wall -Wno-pointer-sign -g -O2 -DWIN32NATIVE avrdude-main.o avrdude-term.o libavrdude_la-config_gram.o libavrdude_la-lexer.o libavrdude_la-arduino.o libavrdude_la-avr.o libavrdude_la-avr910.o libavrdude_la-avrftdi.o libavrdude_la-avrftdi_tpi.o libavrdude_la-avrpart.o libavrdude_la-bitbang.o libavrdude_la-buspirate.o libavrdude_la-butterfly.o libavrdude_la-config.o libavrdude_la-confwin.o libavrdude_la-crc16.o libavrdude_la-dfu.o libavrdude_la-fileio.o libavrdude_la-flip1.o libavrdude_la-flip2.o libavrdude_la-ft245r.o libavrdude_la-jtagmkI.o libavrdude_la-jtagmkII.o libavrdude_la-jtag3.o libavrdude_la-linuxgpio.o libavrdude_la-lists.o libavrdude_la-par.o libavrdude_la-pgm.o libavrdude_la-pgm_type.o libavrdude_la-pickit2.o libavrdude_la-pindefs.o libavrdude_la-ppi.o libavrdude_la-ppiwin.o libavrdude_la-safemode.o libavrdude_la-serbb_posix.o libavrdude_la-serbb_win32.o libavrdude_la-ser_avrdoper.o libavrdude_la-ser_posix.o libavrdude_la-ser_win32.o libavrdude_la-stk500.o libavrdude_la-stk500v2.o libavrdude_la-stk500generic.o libavrdude_la-usbasp.o libavrdude_la-ch341a.o libavrdude_la-usb_libusb.o libavrdude_la-usbtiny.o libavrdude_la-update.o libavrdude_la-wiring.o /usr/i686-w64-mingw32/lib/libusb-1.0.a /usr/i686-w64-mingw32/lib/libusb.a -lftdi1 -lhid -lsetupapi -lelf -lpthread -lws2_32 -L/usr/i686-w64-mingw32/lib -static -s -o avrdude_static.exe -------------------------------------------------------------------------------- /stk500.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2002-2004 Brian S. Dean 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: stk500.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef stk500_h 22 | #define stk500_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern const char stk500_desc[]; 29 | void stk500_initpgm (PROGRAMMER * pgm); 30 | 31 | /* used by arduino.c to avoid duplicate code */ 32 | int stk500_getsync(PROGRAMMER * pgm); 33 | int stk500_drain(PROGRAMMER * pgm, int display); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif 40 | 41 | 42 | -------------------------------------------------------------------------------- /stk500_private.h: -------------------------------------------------------------------------------- 1 | //**** ATMEL AVR - A P P L I C A T I O N N O T E ************************ 2 | //* 3 | //* Title: AVR061 - STK500 Communication Protocol 4 | //* Filename: command.h 5 | //* Version: 1.0 6 | //* Last updated: 09.09.2002 7 | //* 8 | //* Support E-mail: avr@atmel.com 9 | //* 10 | //************************************************************************** 11 | 12 | // *****************[ STK Message constants ]*************************** 13 | 14 | #define STK_SIGN_ON_MESSAGE "AVR STK" // Sign on string for Cmnd_STK_GET_SIGN_ON 15 | 16 | // *****************[ STK Response constants ]*************************** 17 | 18 | #define Resp_STK_OK 0x10 // ' ' 19 | #define Resp_STK_FAILED 0x11 // ' ' 20 | #define Resp_STK_UNKNOWN 0x12 // ' ' 21 | #define Resp_STK_NODEVICE 0x13 // ' ' 22 | #define Resp_STK_INSYNC 0x14 // ' ' 23 | #define Resp_STK_NOSYNC 0x15 // ' ' 24 | 25 | #define Resp_ADC_CHANNEL_ERROR 0x16 // ' ' 26 | #define Resp_ADC_MEASURE_OK 0x17 // ' ' 27 | #define Resp_PWM_CHANNEL_ERROR 0x18 // ' ' 28 | #define Resp_PWM_ADJUST_OK 0x19 // ' ' 29 | 30 | // *****************[ STK Special constants ]*************************** 31 | 32 | #define Sync_CRC_EOP 0x20 // 'SPACE' 33 | 34 | // *****************[ STK Command constants ]*************************** 35 | 36 | #define Cmnd_STK_GET_SYNC 0x30 // ' ' 37 | #define Cmnd_STK_GET_SIGN_ON 0x31 // ' ' 38 | 39 | #define Cmnd_STK_SET_PARAMETER 0x40 // ' ' 40 | #define Cmnd_STK_GET_PARAMETER 0x41 // ' ' 41 | #define Cmnd_STK_SET_DEVICE 0x42 // ' ' 42 | #define Cmnd_STK_SET_DEVICE_EXT 0x45 // ' ' 43 | 44 | #define Cmnd_STK_ENTER_PROGMODE 0x50 // ' ' 45 | #define Cmnd_STK_LEAVE_PROGMODE 0x51 // ' ' 46 | #define Cmnd_STK_CHIP_ERASE 0x52 // ' ' 47 | #define Cmnd_STK_CHECK_AUTOINC 0x53 // ' ' 48 | #define Cmnd_STK_LOAD_ADDRESS 0x55 // ' ' 49 | #define Cmnd_STK_UNIVERSAL 0x56 // ' ' 50 | #define Cmnd_STK_UNIVERSAL_MULTI 0x57 // ' ' 51 | 52 | #define Cmnd_STK_PROG_FLASH 0x60 // ' ' 53 | #define Cmnd_STK_PROG_DATA 0x61 // ' ' 54 | #define Cmnd_STK_PROG_FUSE 0x62 // ' ' 55 | #define Cmnd_STK_PROG_LOCK 0x63 // ' ' 56 | #define Cmnd_STK_PROG_PAGE 0x64 // ' ' 57 | #define Cmnd_STK_PROG_FUSE_EXT 0x65 // ' ' 58 | 59 | #define Cmnd_STK_READ_FLASH 0x70 // ' ' 60 | #define Cmnd_STK_READ_DATA 0x71 // ' ' 61 | #define Cmnd_STK_READ_FUSE 0x72 // ' ' 62 | #define Cmnd_STK_READ_LOCK 0x73 // ' ' 63 | #define Cmnd_STK_READ_PAGE 0x74 // ' ' 64 | #define Cmnd_STK_READ_SIGN 0x75 // ' ' 65 | #define Cmnd_STK_READ_OSCCAL 0x76 // ' ' 66 | #define Cmnd_STK_READ_FUSE_EXT 0x77 // ' ' 67 | #define Cmnd_STK_READ_OSCCAL_EXT 0x78 // ' ' 68 | 69 | // *****************[ STK Parameter constants ]*************************** 70 | 71 | #define Parm_STK_HW_VER 0x80 // ' ' - R 72 | #define Parm_STK_SW_MAJOR 0x81 // ' ' - R 73 | #define Parm_STK_SW_MINOR 0x82 // ' ' - R 74 | #define Parm_STK_LEDS 0x83 // ' ' - R/W 75 | #define Parm_STK_VTARGET 0x84 // ' ' - R/W 76 | #define Parm_STK_VADJUST 0x85 // ' ' - R/W 77 | #define Parm_STK_OSC_PSCALE 0x86 // ' ' - R/W 78 | #define Parm_STK_OSC_CMATCH 0x87 // ' ' - R/W 79 | #define Parm_STK_RESET_DURATION 0x88 // ' ' - R/W 80 | #define Parm_STK_SCK_DURATION 0x89 // ' ' - R/W 81 | 82 | #define Parm_STK_BUFSIZEL 0x90 // ' ' - R/W, Range {0..255} 83 | #define Parm_STK_BUFSIZEH 0x91 // ' ' - R/W, Range {0..255} 84 | #define Parm_STK_DEVICE 0x92 // ' ' - R/W, Range {0..255} 85 | #define Parm_STK_PROGMODE 0x93 // ' ' - 'P' or 'S' 86 | #define Parm_STK_PARAMODE 0x94 // ' ' - TRUE or FALSE 87 | #define Parm_STK_POLLING 0x95 // ' ' - TRUE or FALSE 88 | #define Parm_STK_SELFTIMED 0x96 // ' ' - TRUE or FALSE 89 | #define Param_STK500_TOPCARD_DETECT 0x98 // ' ' - Detect top-card attached 90 | 91 | // *****************[ STK status bit definitions ]*************************** 92 | 93 | #define Stat_STK_INSYNC 0x01 // INSYNC status bit, '1' - INSYNC 94 | #define Stat_STK_PROGMODE 0x02 // Programming mode, '1' - PROGMODE 95 | #define Stat_STK_STANDALONE 0x04 // Standalone mode, '1' - SM mode 96 | #define Stat_STK_RESET 0x08 // RESET button, '1' - Pushed 97 | #define Stat_STK_PROGRAM 0x10 // Program button, ' 1' - Pushed 98 | #define Stat_STK_LEDG 0x20 // Green LED status, '1' - Lit 99 | #define Stat_STK_LEDR 0x40 // Red LED status, '1' - Lit 100 | #define Stat_STK_LEDBLINK 0x80 // LED blink ON/OFF, '1' - Blink 101 | 102 | 103 | // *****************************[ End Of COMMAND.H ]************************** 104 | -------------------------------------------------------------------------------- /stk500generic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2006 Joerg Wunsch 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: stk500generic.c 1321 2014-06-13 20:07:40Z awachtler $ */ 20 | 21 | /* 22 | * avrdude interface for Atmel STK500 programmer 23 | * 24 | * This is a wrapper around the STK500[v1] and STK500v2 programmers. 25 | * Try to select the programmer type that actually responds, and 26 | * divert to the actual programmer implementation if successful. 27 | */ 28 | 29 | #include "ac_cfg.h" 30 | 31 | #include 32 | #include 33 | 34 | #include "avrdude.h" 35 | #include "libavrdude.h" 36 | 37 | #include "stk500generic.h" 38 | #include "stk500.h" 39 | #include "stk500v2.h" 40 | 41 | static int stk500generic_open(PROGRAMMER * pgm, char * port) 42 | { 43 | stk500_initpgm(pgm); 44 | if (pgm->open(pgm, port) >= 0) 45 | { 46 | avrdude_message(MSG_INFO, "%s: successfully opened stk500v1 device -- please use -c stk500v1\n", 47 | progname); 48 | return 0; 49 | } 50 | 51 | pgm->close(pgm); 52 | 53 | stk500v2_initpgm(pgm); 54 | if (pgm->open(pgm, port) >= 0) 55 | { 56 | avrdude_message(MSG_INFO, "%s: successfully opened stk500v2 device -- please use -c stk500v2\n", 57 | progname); 58 | return 0; 59 | } 60 | 61 | avrdude_message(MSG_INFO, "%s: cannot open either stk500v1 or stk500v2 programmer\n", 62 | progname); 63 | return -1; 64 | } 65 | 66 | static void stk500generic_setup(PROGRAMMER * pgm) 67 | { 68 | /* 69 | * Only STK500v2 needs setup/teardown. 70 | */ 71 | stk500v2_initpgm(pgm); 72 | pgm->setup(pgm); 73 | } 74 | 75 | static void stk500generic_teardown(PROGRAMMER * pgm) 76 | { 77 | stk500v2_initpgm(pgm); 78 | pgm->teardown(pgm); 79 | } 80 | 81 | const char stk500generic_desc[] = "Atmel STK500, autodetect firmware version"; 82 | 83 | void stk500generic_initpgm(PROGRAMMER * pgm) 84 | { 85 | strcpy(pgm->type, "STK500GENERIC"); 86 | 87 | pgm->open = stk500generic_open; 88 | pgm->setup = stk500generic_setup; 89 | pgm->teardown = stk500generic_teardown; 90 | } 91 | -------------------------------------------------------------------------------- /stk500generic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2006 Joerg Wunsch 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: stk500generic.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef stk500generic_h__ 22 | #define stk500generic_h__ 23 | 24 | extern const char stk500generic_desc[]; 25 | void stk500generic_initpgm (PROGRAMMER * pgm); 26 | 27 | #endif 28 | 29 | 30 | -------------------------------------------------------------------------------- /stk500v2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2002-2005 Brian S. Dean 4 | * Copyright (C) 2006 Joerg Wunsch 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | /* $Id: stk500v2.h 1119 2012-12-03 15:52:38Z joerg_wunsch $ */ 21 | 22 | #ifndef stk500v2_h 23 | #define stk500v2_h 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | extern const char stk500v2_desc[]; 30 | extern const char stk500hvsp_desc[]; 31 | extern const char stk500pp_desc[]; 32 | extern const char stk500v2_jtagmkII_desc[]; 33 | extern const char stk500v2_dragon_hvsp_desc[]; 34 | extern const char stk500v2_dragon_isp_desc[]; 35 | extern const char stk500v2_dragon_pp_desc[]; 36 | extern const char stk500v2_jtag3_desc[]; 37 | extern const char stk600_desc[]; 38 | extern const char stk600hvsp_desc[]; 39 | extern const char stk600pp_desc[]; 40 | void stk500v2_initpgm (PROGRAMMER * pgm); 41 | void stk500hvsp_initpgm (PROGRAMMER * pgm); 42 | void stk500pp_initpgm (PROGRAMMER * pgm); 43 | void stk500v2_jtagmkII_initpgm(PROGRAMMER * pgm); 44 | void stk500v2_jtag3_initpgm(PROGRAMMER * pgm); 45 | void stk500v2_dragon_hvsp_initpgm(PROGRAMMER * pgm); 46 | void stk500v2_dragon_isp_initpgm(PROGRAMMER * pgm); 47 | void stk500v2_dragon_pp_initpgm(PROGRAMMER * pgm); 48 | void stk600_initpgm (PROGRAMMER * pgm); 49 | void stk600hvsp_initpgm (PROGRAMMER * pgm); 50 | void stk600pp_initpgm (PROGRAMMER * pgm); 51 | 52 | void stk500v2_setup(PROGRAMMER * pgm); 53 | void stk500v2_teardown(PROGRAMMER * pgm); 54 | int stk500v2_drain(PROGRAMMER * pgm, int display); 55 | int stk500v2_getsync(PROGRAMMER * pgm); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | 63 | 64 | -------------------------------------------------------------------------------- /term.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2000-2004 Brian S. Dean 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: term.h 1311 2014-05-19 10:01:59Z joerg_wunsch $ */ 20 | 21 | #ifndef term_h 22 | #define term_h 23 | 24 | #include "libavrdude.h" 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | int terminal_mode(PROGRAMMER * pgm, struct avrpart * p); 31 | char * terminal_get_input(const char *prompt); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tpi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2011 Darell Tan 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: tpi.h 1167 2013-05-06 12:49:26Z hweisbach $ */ 20 | 21 | #ifndef tpi_h 22 | #define tpi_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | static const unsigned char tpi_skey[] = { 0x12, 0x89, 0xAB, 0x45, 0xCD, 0xD8, 0x88, 0xFF }; 29 | 30 | /* registers */ 31 | #define TPI_REG_TPIIR 0x0F 32 | 33 | #define TPI_IDENT_CODE 0x80 34 | 35 | #define TPI_REG_TPIPCR 0x02 36 | #define TPI_REG_TPISR 0x00 37 | 38 | #define TPI_REG_TPISR_NVMEN (1 << 1) 39 | 40 | /* TPI commands */ 41 | #define TPI_CMD_SLD 0x20 42 | #define TPI_CMD_SLD_PI 0x24 43 | #define TPI_CMD_SIN 0x10 44 | #define TPI_CMD_SOUT 0x90 45 | #define TPI_CMD_SSTCS 0xC0 46 | #define TPI_CMD_SST 0x60 47 | #define TPI_CMD_SST_PI 0x64 48 | 49 | #define TPI_CMD_SLDCS 0x80 50 | #define TPI_CMD_SSTPR 0x68 51 | #define TPI_CMD_SKEY 0xE0 52 | 53 | /* for TPI_CMD_SIN & TPI_CMD_SOUT */ 54 | #define TPI_SIO_ADDR(x) ((x & 0x30) << 1 | (x & 0x0F)) 55 | 56 | /* ATtiny4/5/9/10 I/O registers */ 57 | #define TPI_IOREG_NVMCSR 0x32 58 | #define TPI_IOREG_NVMCMD 0x33 59 | 60 | /* bit for NVMCSR */ 61 | #define TPI_IOREG_NVMCSR_NVMBSY (1 << 7) 62 | 63 | /* NVM commands */ 64 | #define TPI_NVMCMD_NO_OPERATION 0x00 65 | #define TPI_NVMCMD_CHIP_ERASE 0x10 66 | #define TPI_NVMCMD_SECTION_ERASE 0x14 67 | #define TPI_NVMCMD_WORD_WRITE 0x1D 68 | 69 | static const unsigned char tpi_skey_cmd[] = { TPI_CMD_SKEY, 0xff, 0x88, 0xd8, 0xcd, 0x45, 0xab, 0x89, 0x12 }; 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /usbasp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2006 Thomas Fischl 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: usbasp.h 1311 2014-05-19 10:01:59Z joerg_wunsch $ */ 20 | 21 | #ifndef usbasp_h 22 | #define usbasp_h 23 | 24 | /* USB function call identifiers */ 25 | #define USBASP_FUNC_CONNECT 1 26 | #define USBASP_FUNC_DISCONNECT 2 27 | #define USBASP_FUNC_TRANSMIT 3 28 | #define USBASP_FUNC_READFLASH 4 29 | #define USBASP_FUNC_ENABLEPROG 5 30 | #define USBASP_FUNC_WRITEFLASH 6 31 | #define USBASP_FUNC_READEEPROM 7 32 | #define USBASP_FUNC_WRITEEEPROM 8 33 | #define USBASP_FUNC_SETLONGADDRESS 9 34 | #define USBASP_FUNC_SETISPSCK 10 35 | #define USBASP_FUNC_TPI_CONNECT 11 36 | #define USBASP_FUNC_TPI_DISCONNECT 12 37 | #define USBASP_FUNC_TPI_RAWREAD 13 38 | #define USBASP_FUNC_TPI_RAWWRITE 14 39 | #define USBASP_FUNC_TPI_READBLOCK 15 40 | #define USBASP_FUNC_TPI_WRITEBLOCK 16 41 | #define USBASP_FUNC_GETCAPABILITIES 127 42 | 43 | /* USBASP capabilities */ 44 | #define USBASP_CAP_TPI 0x01 45 | 46 | /* Block mode flags */ 47 | #define USBASP_BLOCKFLAG_FIRST 1 48 | #define USBASP_BLOCKFLAG_LAST 2 49 | 50 | /* Block mode data size */ 51 | #define USBASP_READBLOCKSIZE 200 52 | #define USBASP_WRITEBLOCKSIZE 200 53 | 54 | /* ISP SCK speed identifiers */ 55 | #define USBASP_ISP_SCK_AUTO 0 56 | #define USBASP_ISP_SCK_0_5 1 /* 500 Hz */ 57 | #define USBASP_ISP_SCK_1 2 /* 1 kHz */ 58 | #define USBASP_ISP_SCK_2 3 /* 2 kHz */ 59 | #define USBASP_ISP_SCK_4 4 /* 4 kHz */ 60 | #define USBASP_ISP_SCK_8 5 /* 8 kHz */ 61 | #define USBASP_ISP_SCK_16 6 /* 16 kHz */ 62 | #define USBASP_ISP_SCK_32 7 /* 32 kHz */ 63 | #define USBASP_ISP_SCK_93_75 8 /* 93.75 kHz */ 64 | #define USBASP_ISP_SCK_187_5 9 /* 187.5 kHz */ 65 | #define USBASP_ISP_SCK_375 10 /* 375 kHz */ 66 | #define USBASP_ISP_SCK_750 11 /* 750 kHz */ 67 | #define USBASP_ISP_SCK_1500 12 /* 1.5 MHz */ 68 | 69 | /* TPI instructions */ 70 | #define TPI_OP_SLD 0x20 71 | #define TPI_OP_SLD_INC 0x24 72 | #define TPI_OP_SST 0x60 73 | #define TPI_OP_SST_INC 0x64 74 | #define TPI_OP_SSTPR(a) (0x68 | (a)) 75 | #define TPI_OP_SIN(a) (0x10 | (((a)<<1)&0x60) | ((a)&0x0F) ) 76 | #define TPI_OP_SOUT(a) (0x90 | (((a)<<1)&0x60) | ((a)&0x0F) ) 77 | #define TPI_OP_SLDCS(a) (0x80 | ((a)&0x0F) ) 78 | #define TPI_OP_SSTCS(a) (0xC0 | ((a)&0x0F) ) 79 | #define TPI_OP_SKEY 0xE0 80 | 81 | /* TPI control/status registers */ 82 | #define TPIIR 0xF 83 | #define TPIPCR 0x2 84 | #define TPISR 0x0 85 | 86 | // TPIPCR bits 87 | #define TPIPCR_GT_2 0x04 88 | #define TPIPCR_GT_1 0x02 89 | #define TPIPCR_GT_0 0x01 90 | #define TPIPCR_GT_128b 0x00 91 | #define TPIPCR_GT_64b 0x01 92 | #define TPIPCR_GT_32b 0x02 93 | #define TPIPCR_GT_16b 0x03 94 | #define TPIPCR_GT_8b 0x04 95 | #define TPIPCR_GT_4b 0x05 96 | #define TPIPCR_GT_2b 0x06 97 | #define TPIPCR_GT_0b 0x07 98 | 99 | // TPISR bits 100 | #define TPISR_NVMEN 0x02 101 | 102 | /* NVM registers */ 103 | #define NVMCSR 0x32 104 | #define NVMCMD 0x33 105 | 106 | // NVMCSR bits 107 | #define NVMCSR_BSY 0x80 108 | 109 | // NVMCMD values 110 | #define NVMCMD_NOP 0x00 111 | #define NVMCMD_CHIP_ERASE 0x10 112 | #define NVMCMD_SECTION_ERASE 0x14 113 | #define NVMCMD_WORD_WRITE 0x1D 114 | 115 | 116 | typedef struct sckoptions_t { 117 | int id; 118 | double frequency; 119 | } CLOCKOPTIONS; 120 | 121 | /* USB error identifiers */ 122 | #define USB_ERROR_NOTFOUND 1 123 | #define USB_ERROR_ACCESS 2 124 | #define USB_ERROR_IO 3 125 | 126 | #ifdef __cplusplus 127 | extern "C" { 128 | #endif 129 | 130 | extern const char usbasp_desc[]; 131 | void usbasp_initpgm (PROGRAMMER * pgm); 132 | 133 | #ifdef __cplusplus 134 | } 135 | #endif 136 | 137 | #endif /* usbasp_h */ 138 | -------------------------------------------------------------------------------- /usbdevs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2006 Joerg Wunsch 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: usbdevs.h 1288 2014-02-28 14:36:38Z joerg_wunsch $ */ 20 | 21 | /* 22 | * defines for the USB interface 23 | */ 24 | 25 | #ifndef usbdevs_h 26 | #define usbdevs_h 27 | 28 | #define USB_VENDOR_ATMEL 1003 29 | #define USB_DEVICE_JTAGICEMKII 0x2103 30 | #define USB_DEVICE_AVRISPMKII 0x2104 31 | #define USB_DEVICE_STK600 0x2106 32 | #define USB_DEVICE_AVRDRAGON 0x2107 33 | #define USB_DEVICE_JTAGICE3 0x2110 34 | #define USB_DEVICE_XPLAINEDPRO 0x2111 35 | #define USB_DEVICE_JTAG3_EDBG 0x2140 36 | #define USB_DEVICE_ATMEL_ICE 0x2141 37 | 38 | #define USB_VENDOR_FTDI 0x0403 39 | #define USB_DEVICE_FT2232 0x6010 40 | #define USB_DEVICE_FT245 0x6001 41 | 42 | #define USBASP_SHARED_VID 0x16C0 /* VOTI */ 43 | #define USBASP_SHARED_PID 0x05DC /* Obdev's free shared PID */ 44 | 45 | #define USBASP_OLD_VID 0x03EB /* ATMEL */ 46 | #define USBASP_OLD_PID 0xC7B4 /* (unoffical) USBasp */ 47 | 48 | #define USBASP_NIBOBEE_VID 0x16C0 /* VOTI */ 49 | #define USBASP_NIBOBEE_PID 0x092F /* NIBObee PID */ 50 | 51 | // these are specifically assigned to USBtiny, 52 | // if you need your own VID and PIDs you can get them for cheap from 53 | // www.mecanique.co.uk so please don't reuse these. Thanks! 54 | #define USBTINY_VENDOR_DEFAULT 0x1781 55 | #define USBTINY_PRODUCT_DEFAULT 0x0C9F 56 | 57 | 58 | 59 | /* JTAGICEmkII, AVRISPmkII */ 60 | #define USBDEV_BULK_EP_WRITE_MKII 0x02 61 | #define USBDEV_BULK_EP_READ_MKII 0x82 62 | #define USBDEV_MAX_XFER_MKII 64 63 | 64 | /* STK600 */ 65 | #define USBDEV_BULK_EP_WRITE_STK600 0x02 66 | #define USBDEV_BULK_EP_READ_STK600 0x83 67 | 68 | /* JTAGICE3 */ 69 | #define USBDEV_BULK_EP_WRITE_3 0x01 70 | #define USBDEV_BULK_EP_READ_3 0x82 71 | #define USBDEV_EVT_EP_READ_3 0x83 72 | #define USBDEV_MAX_XFER_3 512 73 | 74 | /* 75 | * When operating on the JTAGICE3, usbdev_recv_frame() returns an 76 | * indication in the upper bits of the return value whether the 77 | * message has been received from the event endpoint rather than the 78 | * normal conversation endpoint. 79 | */ 80 | #define USB_RECV_LENGTH_MASK 0x0fff /* up to 4 KiB */ 81 | #define USB_RECV_FLAG_EVENT 0x1000 82 | 83 | #endif /* usbdevs_h */ 84 | -------------------------------------------------------------------------------- /usbtiny.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2007 Limor Fried 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #ifndef usbtiny_h 21 | #define usbtiny_h 22 | 23 | // Generic requests to the USBtiny 24 | #define USBTINY_ECHO 0 // echo test 25 | #define USBTINY_READ 1 // read byte (wIndex:address) 26 | #define USBTINY_WRITE 2 // write byte (wIndex:address, wValue:value) 27 | #define USBTINY_CLR 3 // clear bit (wIndex:address, wValue:bitno) 28 | #define USBTINY_SET 4 // set bit (wIndex:address, wValue:bitno) 29 | 30 | // Programming requests 31 | #define USBTINY_POWERUP 5 // apply power (wValue:SCK-period, wIndex:RESET) 32 | #define USBTINY_POWERDOWN 6 // remove power from chip 33 | #define USBTINY_SPI 7 // issue SPI command (wValue:c1c0, wIndex:c3c2) 34 | #define USBTINY_POLL_BYTES 8 // set poll bytes for write (wValue:p1p2) 35 | #define USBTINY_FLASH_READ 9 // read flash (wIndex:address) 36 | #define USBTINY_FLASH_WRITE 10 // write flash (wIndex:address, wValue:timeout) 37 | #define USBTINY_EEPROM_READ 11 // read eeprom (wIndex:address) 38 | #define USBTINY_EEPROM_WRITE 12 // write eeprom (wIndex:address, wValue:timeout) 39 | 40 | 41 | 42 | // Flags to indicate how to set RESET on power up 43 | #define RESET_LOW 0 44 | #define RESET_HIGH 1 45 | 46 | // The SCK speed can be set by avrdude, to allow programming of slow-clocked parts 47 | #define SCK_MIN 1 // usec delay (target clock >= 4 MHz) 48 | #define SCK_MAX 250 // usec (target clock >= 16 KHz) 49 | #define SCK_DEFAULT 10 // usec (target clock >= 0.4 MHz) 50 | 51 | // How much data, max, do we want to send in one USB packet? 52 | #define CHUNK_SIZE 128 // must be power of 2 less than 256 53 | 54 | // The default USB Timeout 55 | #define USB_TIMEOUT 500 // msec 56 | 57 | #ifdef __cplusplus 58 | extern "C" { 59 | #endif 60 | 61 | extern const char usbtiny_desc[]; 62 | void usbtiny_initpgm (PROGRAMMER * pgm); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* usbtiny_h */ 69 | -------------------------------------------------------------------------------- /windows/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # avrdude - A Downloader/Uploader for AVR device programmers 3 | # Copyright (C) 2003 Theodore A. Roth 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | # 20 | # $Id: Makefile.am 1107 2012-11-20 14:03:50Z joerg_wunsch $ 21 | # 22 | 23 | # 24 | # This Makefile will only be used on windows based systems. 25 | # 26 | 27 | local_install_list = \ 28 | giveio.sys \ 29 | install_giveio.bat \ 30 | remove_giveio.bat \ 31 | status_giveio.bat 32 | 33 | EXTRA_DIST = \ 34 | giveio.c \ 35 | $(local_install_list) 36 | 37 | bin_PROGRAMS = loaddrv 38 | 39 | loaddrv_SOURCES = \ 40 | loaddrv.c \ 41 | loaddrv.h 42 | 43 | install-exec-local: 44 | $(mkinstalldirs) $(DESTDIR)$(bindir) 45 | @list='$(local_install_list)'; for file in $$list; do \ 46 | echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) \ 47 | $(srcdir)/$$file $(DESTDIR)$(bindir)/$$file"; \ 48 | $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $(srcdir)/$$file \ 49 | $(DESTDIR)$(bindir)/$$file; \ 50 | done 51 | 52 | uninstall-local: 53 | @for file in $(local_install_list); do \ 54 | echo " rm -f $(DESTDIR)$(bindir)/$$file"; \ 55 | rm -f $(DESTDIR)$(bindir)/$$file; \ 56 | done 57 | 58 | -------------------------------------------------------------------------------- /windows/giveio.c: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 3 | Author: Dale Roberts 4 | Date: 8/30/95 5 | Program: GIVEIO.SYS 6 | Compile: Use DDK BUILD facility 7 | 8 | Purpose: Give direct port I/O access to a user mode process. 9 | 10 | *********************************************************************/ 11 | #include 12 | 13 | /* 14 | * The name of our device driver. 15 | */ 16 | #define DEVICE_NAME_STRING L"giveio" 17 | 18 | /* 19 | * This is the "structure" of the IOPM. It is just a simple 20 | * character array of length 0x2000. 21 | * 22 | * This holds 8K * 8 bits -> 64K bits of the IOPM, which maps the 23 | * entire 64K I/O space of the x86 processor. Any 0 bits will give 24 | * access to the corresponding port for user mode processes. Any 1 25 | * bits will disallow I/O access to the corresponding port. 26 | */ 27 | #define IOPM_SIZE 0x2000 28 | typedef UCHAR IOPM[IOPM_SIZE]; 29 | 30 | /* 31 | * This will hold simply an array of 0's which will be copied 32 | * into our actual IOPM in the TSS by Ke386SetIoAccessMap(). 33 | * The memory is allocated at driver load time. 34 | */ 35 | IOPM *IOPM_local = 0; 36 | 37 | /* 38 | * These are the two undocumented calls that we will use to give 39 | * the calling process I/O access. 40 | * 41 | * Ke386IoSetAccessMap() copies the passed map to the TSS. 42 | * 43 | * Ke386IoSetAccessProcess() adjusts the IOPM offset pointer so that 44 | * the newly copied map is actually used. Otherwise, the IOPM offset 45 | * points beyond the end of the TSS segment limit, causing any I/O 46 | * access by the user mode process to generate an exception. 47 | */ 48 | void Ke386SetIoAccessMap(int, IOPM *); 49 | void Ke386QueryIoAccessMap(int, IOPM *); 50 | void Ke386IoSetAccessProcess(PEPROCESS, int); 51 | 52 | /********************************************************************* 53 | Release any allocated objects. 54 | *********************************************************************/ 55 | VOID GiveioUnload(IN PDRIVER_OBJECT DriverObject) 56 | { 57 | WCHAR DOSNameBuffer[] = L"\\DosDevices\\" DEVICE_NAME_STRING; 58 | UNICODE_STRING uniDOSString; 59 | 60 | if(IOPM_local) 61 | MmFreeNonCachedMemory(IOPM_local, sizeof(IOPM)); 62 | 63 | RtlInitUnicodeString(&uniDOSString, DOSNameBuffer); 64 | IoDeleteSymbolicLink (&uniDOSString); 65 | IoDeleteDevice(DriverObject->DeviceObject); 66 | } 67 | 68 | /********************************************************************* 69 | Set the IOPM (I/O permission map) of the calling process so that it 70 | is given full I/O access. Our IOPM_local[] array is all zeros, so 71 | the IOPM will be all zeros. If OnFlag is 1, the process is given I/O 72 | access. If it is 0, access is removed. 73 | *********************************************************************/ 74 | VOID SetIOPermissionMap(int OnFlag) 75 | { 76 | Ke386IoSetAccessProcess(PsGetCurrentProcess(), OnFlag); 77 | Ke386SetIoAccessMap(1, IOPM_local); 78 | } 79 | 80 | void GiveIO(void) 81 | { 82 | SetIOPermissionMap(1); 83 | } 84 | 85 | /********************************************************************* 86 | Service handler for a CreateFile() user mode call. 87 | 88 | This routine is entered in the driver object function call table by 89 | the DriverEntry() routine. When the user mode application calls 90 | CreateFile(), this routine gets called while still in the context of 91 | the user mode application, but with the CPL (the processor's Current 92 | Privelege Level) set to 0. This allows us to do kernel mode 93 | operations. GiveIO() is called to give the calling process I/O 94 | access. All the user mode application needs do to obtain I/O access 95 | is open this device with CreateFile(). No other operations are 96 | required. 97 | *********************************************************************/ 98 | NTSTATUS GiveioCreateDispatch( 99 | IN PDEVICE_OBJECT DeviceObject, 100 | IN PIRP Irp 101 | ) 102 | { 103 | GiveIO(); // give the calling process I/O access 104 | 105 | Irp->IoStatus.Information = 0; 106 | Irp->IoStatus.Status = STATUS_SUCCESS; 107 | IoCompleteRequest(Irp, IO_NO_INCREMENT); 108 | return STATUS_SUCCESS; 109 | } 110 | 111 | /********************************************************************* 112 | Driver Entry routine. 113 | 114 | This routine is called only once after the driver is initially 115 | loaded into memory. It allocates everything necessary for the 116 | driver's operation. In our case, it allocates memory for our IOPM 117 | array, and creates a device which user mode applications can open. 118 | It also creates a symbolic link to the device driver. This allows 119 | a user mode application to access our driver using the \\.\giveio 120 | notation. 121 | *********************************************************************/ 122 | NTSTATUS DriverEntry( 123 | IN PDRIVER_OBJECT DriverObject, 124 | IN PUNICODE_STRING RegistryPath 125 | ) 126 | { 127 | PDEVICE_OBJECT deviceObject; 128 | NTSTATUS status; 129 | WCHAR NameBuffer[] = L"\\Device\\" DEVICE_NAME_STRING; 130 | WCHAR DOSNameBuffer[] = L"\\DosDevices\\" DEVICE_NAME_STRING; 131 | UNICODE_STRING uniNameString, uniDOSString; 132 | 133 | // 134 | // Allocate a buffer for the local IOPM and zero it. 135 | // 136 | IOPM_local = MmAllocateNonCachedMemory(sizeof(IOPM)); 137 | if(IOPM_local == 0) 138 | return STATUS_INSUFFICIENT_RESOURCES; 139 | RtlZeroMemory(IOPM_local, sizeof(IOPM)); 140 | 141 | // 142 | // Set up device driver name and device object. 143 | // 144 | RtlInitUnicodeString(&uniNameString, NameBuffer); 145 | RtlInitUnicodeString(&uniDOSString, DOSNameBuffer); 146 | 147 | status = IoCreateDevice(DriverObject, 0, 148 | &uniNameString, 149 | FILE_DEVICE_UNKNOWN, 150 | 0, FALSE, &deviceObject); 151 | 152 | if(!NT_SUCCESS(status)) 153 | return status; 154 | 155 | status = IoCreateSymbolicLink (&uniDOSString, &uniNameString); 156 | 157 | if (!NT_SUCCESS(status)) 158 | return status; 159 | 160 | // 161 | // Initialize the Driver Object with driver's entry points. 162 | // All we require are the Create and Unload operations. 163 | // 164 | DriverObject->MajorFunction[IRP_MJ_CREATE] = GiveioCreateDispatch; 165 | DriverObject->DriverUnload = GiveioUnload; 166 | return STATUS_SUCCESS; 167 | } 168 | 169 | -------------------------------------------------------------------------------- /windows/giveio.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxxproff/avrdude-ch341/d2e962355fc6281f7fe50b1b82ec3f6a44bf065a/windows/giveio.sys -------------------------------------------------------------------------------- /windows/install_giveio.bat: -------------------------------------------------------------------------------- 1 | @set DIRVERNAME=giveio 2 | @set DIRVERFILE=%DIRVERNAME%.sys 3 | 4 | @echo Copying the driver to the windows directory 5 | @echo target file: %WINDIR%\%DIRVERFILE% 6 | @copy %DIRVERFILE% %WINDIR%\%DIRVERFILE% 7 | 8 | @echo Remove a running service if needed... 9 | @loaddrv stop %DIRVERNAME% >NUL 10 | @if errorlevel 2 goto install 11 | 12 | @loaddrv remove %DIRVERNAME% >NUL 13 | @if errorlevel 1 goto install 14 | 15 | :install 16 | @echo Installing Windows NT/2k/XP driver: %DIRVERNAME% 17 | 18 | @loaddrv install %DIRVERNAME% %WINDIR%\%DIRVERFILE% 19 | @if errorlevel 3 goto error 20 | 21 | @loaddrv start %DIRVERNAME% 22 | @if errorlevel 1 goto error 23 | 24 | @loaddrv starttype %DIRVERNAME% auto 25 | @if errorlevel 1 goto error 26 | 27 | @echo Success 28 | @goto exit 29 | 30 | :error 31 | @echo ERROR: Installation of %DIRVERNAME% failed 32 | 33 | :exit 34 | 35 | -------------------------------------------------------------------------------- /windows/loaddrv.h: -------------------------------------------------------------------------------- 1 | #ifndef LOADDRV_H 2 | #define LOADDRV_H 3 | 4 | #include 5 | 6 | #define OKAY 0 7 | #define UNEXPECTED_ERROR 9999 8 | 9 | //prototypes 10 | DWORD LoadDriverInit(void); 11 | void LoadDriverCleanup(void); 12 | DWORD DriverInstall(LPSTR, LPSTR); 13 | DWORD DriverStart(LPSTR); 14 | DWORD DriverStop(LPSTR); 15 | DWORD DriverRemove(LPSTR); 16 | DWORD DriverStatus(LPSTR); 17 | DWORD DriverStartType(LPSTR, DWORD); 18 | #endif //LOADDRV_H 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/remove_giveio.bat: -------------------------------------------------------------------------------- 1 | @set DIRVERNAME=giveio 2 | 3 | @loaddrv stop %DIRVERNAME% 4 | @if errorlevel 2 goto error 5 | 6 | @loaddrv remove %DIRVERNAME% 7 | @if errorlevel 1 goto error 8 | 9 | @goto exit 10 | 11 | :error 12 | @echo ERROR: Deinstallation of %DIRVERNAME% failed 13 | 14 | :exit 15 | -------------------------------------------------------------------------------- /windows/status_giveio.bat: -------------------------------------------------------------------------------- 1 | @set DIRVERNAME=giveio 2 | 3 | @loaddrv status %DIRVERNAME% 4 | @if errorlevel 1 goto error 5 | 6 | @goto exit 7 | 8 | :error 9 | @echo ERROR: Status querry for %DIRVERNAME% failed 10 | 11 | :exit 12 | 13 | -------------------------------------------------------------------------------- /wiring.c: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2011 Brett Hagman 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: wiring.c 1321 2014-06-13 20:07:40Z awachtler $ */ 20 | 21 | /* 22 | * avrdude interface for Wiring bootloaders 23 | * 24 | * http://wiring.org.co/ 25 | * 26 | * The Wiring bootloader uses a near-complete STK500v2 protocol. 27 | * (Only ISP specific programming commands are not implemented 28 | * e.g. chip erase). 29 | * DTR and RTS signals are diddled to set the board into programming mode. 30 | * 31 | * Also includes an extended parameter to introduce a delay after opening 32 | * to accommodate multi-layered programmers/bootloaders. If the extended 33 | * parameter 'snooze' > 0, then no DTR/RTS toggle takes place, and 34 | * AVRDUDE will wait that amount of time in milliseconds before syncing. 35 | * 36 | * Unfortunately, there is no way to easily chain private programmer data 37 | * when we "inherit" programmer types as we have (stk500v2). Sooooo, a 38 | * *cringe* global variable is used to store the snooze time. 39 | */ 40 | 41 | #include "ac_cfg.h" 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include "avrdude.h" 49 | #include "libavrdude.h" 50 | 51 | #include "stk500v2_private.h" 52 | #include "stk500v2.h" 53 | #include "wiring.h" 54 | 55 | /* 56 | * Private data for this programmer. 57 | */ 58 | struct wiringpdata 59 | { 60 | /* 61 | * We just have the single snooze integer to carry around for now. 62 | */ 63 | int snoozetime; 64 | }; 65 | 66 | 67 | /* wiringpdata is our private data */ 68 | /* pdata is stk500v2's private data (inherited) */ 69 | 70 | #define WIRINGPDATA(x) ((struct wiringpdata *)(x)) 71 | 72 | #define STK500V2PDATA(pgm) ((struct pdata *)(pgm->cookie)) 73 | 74 | 75 | static void wiring_setup(PROGRAMMER * pgm) 76 | { 77 | void *mycookie; 78 | 79 | /* 80 | * First, have STK500v2 backend allocate its own private data. 81 | */ 82 | stk500v2_setup(pgm); 83 | 84 | /* 85 | * Now prepare our data 86 | */ 87 | if ((mycookie = malloc(sizeof(struct wiringpdata))) == 0) { 88 | avrdude_message(MSG_INFO, "%s: wiring_setup(): Out of memory allocating private data\n", 89 | progname); 90 | exit(1); 91 | } 92 | memset(mycookie, 0, sizeof(struct wiringpdata)); 93 | WIRINGPDATA(mycookie)->snoozetime = 0; 94 | 95 | /* 96 | * Store our own cookie in a safe place for the time being. 97 | */ 98 | STK500V2PDATA(pgm)->chained_pdata = mycookie; 99 | } 100 | 101 | static void wiring_teardown(PROGRAMMER * pgm) 102 | { 103 | void *mycookie; 104 | 105 | mycookie = STK500V2PDATA(pgm)->chained_pdata; 106 | 107 | free(mycookie); 108 | 109 | stk500v2_teardown(pgm); 110 | } 111 | 112 | static int wiring_parseextparms(PROGRAMMER * pgm, LISTID extparms) 113 | { 114 | LNODEID ln; 115 | const char *extended_param; 116 | int rv = 0; 117 | void *mycookie = STK500V2PDATA(pgm)->chained_pdata; 118 | 119 | for (ln = lfirst(extparms); ln; ln = lnext(ln)) { 120 | extended_param = ldata(ln); 121 | 122 | if (strncmp(extended_param, "snooze=", strlen("snooze=")) == 0) { 123 | int newsnooze; 124 | if (sscanf(extended_param, "snooze=%i", &newsnooze) != 1 || 125 | newsnooze < 0) { 126 | avrdude_message(MSG_INFO, "%s: wiring_parseextparms(): invalid snooze time '%s'\n", 127 | progname, extended_param); 128 | rv = -1; 129 | continue; 130 | } 131 | avrdude_message(MSG_NOTICE2, "%s: wiring_parseextparms(): snooze time set to %d ms\n", 132 | progname, newsnooze); 133 | WIRINGPDATA(mycookie)->snoozetime = newsnooze; 134 | 135 | continue; 136 | } 137 | 138 | avrdude_message(MSG_INFO, "%s: wiring_parseextparms(): invalid extended parameter '%s'\n", 139 | progname, extended_param); 140 | rv = -1; 141 | } 142 | 143 | return rv; 144 | } 145 | 146 | static int wiring_open(PROGRAMMER * pgm, char * port) 147 | { 148 | int timetosnooze; 149 | void *mycookie = STK500V2PDATA(pgm)->chained_pdata; 150 | union pinfo pinfo; 151 | 152 | strcpy(pgm->port, port); 153 | pinfo.baud = pgm->baudrate ? pgm->baudrate: 115200; 154 | serial_open(port, pinfo, &pgm->fd); 155 | 156 | /* If we have a snoozetime, then we wait and do NOT toggle DTR/RTS */ 157 | 158 | if (WIRINGPDATA(mycookie)->snoozetime > 0) { 159 | timetosnooze = WIRINGPDATA(mycookie)->snoozetime; 160 | 161 | avrdude_message(MSG_NOTICE2, "%s: wiring_open(): snoozing for %d ms\n", 162 | progname, timetosnooze); 163 | while (timetosnooze--) 164 | usleep(1000); 165 | avrdude_message(MSG_NOTICE2, "%s: wiring_open(): done snoozing\n", 166 | progname); 167 | } else { 168 | /* Perform Wiring programming mode RESET. */ 169 | /* This effectively *releases* both DTR and RTS. */ 170 | /* i.e. both DTR and RTS rise to a HIGH logic level */ 171 | /* since they are active LOW signals. */ 172 | 173 | avrdude_message(MSG_NOTICE2, "%s: wiring_open(): releasing DTR/RTS\n", 174 | progname); 175 | 176 | serial_set_dtr_rts(&pgm->fd, 0); 177 | usleep(50*1000); 178 | 179 | /* After releasing for 50 milliseconds, DTR and RTS */ 180 | /* are asserted (i.e. logic LOW) again. */ 181 | 182 | avrdude_message(MSG_NOTICE2, "%s: wiring_open(): asserting DTR/RTS\n", 183 | progname); 184 | 185 | serial_set_dtr_rts(&pgm->fd, 1); 186 | usleep(50*1000); 187 | } 188 | 189 | /* drain any extraneous input */ 190 | stk500v2_drain(pgm, 0); 191 | 192 | if (stk500v2_getsync(pgm) < 0) 193 | return -1; 194 | 195 | return 0; 196 | } 197 | 198 | static void wiring_close(PROGRAMMER * pgm) 199 | { 200 | serial_set_dtr_rts(&pgm->fd, 0); 201 | serial_close(&pgm->fd); 202 | pgm->fd.ifd = -1; 203 | } 204 | 205 | const char wiring_desc[] = "http://wiring.org.co/, Basically STK500v2 protocol, with some glue to trigger the bootloader."; 206 | 207 | void wiring_initpgm(PROGRAMMER * pgm) 208 | { 209 | /* The Wiring bootloader uses a near-complete STK500v2 protocol. */ 210 | 211 | stk500v2_initpgm(pgm); 212 | 213 | strcpy(pgm->type, "Wiring"); 214 | pgm->open = wiring_open; 215 | pgm->close = wiring_close; 216 | 217 | pgm->setup = wiring_setup; 218 | pgm->teardown = wiring_teardown; 219 | pgm->parseextparams = wiring_parseextparms; 220 | } 221 | 222 | -------------------------------------------------------------------------------- /wiring.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avrdude - A Downloader/Uploader for AVR device programmers 3 | * Copyright (C) 2011 Brett Hagman 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /* $Id: wiring.h 1107 2012-11-20 14:03:50Z joerg_wunsch $ */ 20 | 21 | #ifndef wiring_h__ 22 | #define wiring_h__ 23 | 24 | extern const char wiring_desc[]; 25 | void wiring_initpgm(PROGRAMMER * pgm); 26 | 27 | #endif 28 | 29 | 30 | -------------------------------------------------------------------------------- /ylwrap: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # ylwrap - wrapper for lex/yacc invocations. 3 | 4 | scriptversion=2007-11-22.22 5 | 6 | # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 7 | # 2007 Free Software Foundation, Inc. 8 | # 9 | # Written by Tom Tromey . 10 | # 11 | # This program is free software; you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation; either version 2, or (at your option) 14 | # any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 24 | # 02110-1301, USA. 25 | 26 | # As a special exception to the GNU General Public License, if you 27 | # distribute this file as part of a program that contains a 28 | # configuration script generated by Autoconf, you may include it under 29 | # the same distribution terms that you use for the rest of that program. 30 | 31 | # This file is maintained in Automake, please report 32 | # bugs to or send patches to 33 | # . 34 | 35 | case "$1" in 36 | '') 37 | echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 38 | exit 1 39 | ;; 40 | --basedir) 41 | basedir=$2 42 | shift 2 43 | ;; 44 | -h|--h*) 45 | cat <<\EOF 46 | Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... 47 | 48 | Wrapper for lex/yacc invocations, renaming files as desired. 49 | 50 | INPUT is the input file 51 | OUTPUT is one file PROG generates 52 | DESIRED is the file we actually want instead of OUTPUT 53 | PROGRAM is program to run 54 | ARGS are passed to PROG 55 | 56 | Any number of OUTPUT,DESIRED pairs may be used. 57 | 58 | Report bugs to . 59 | EOF 60 | exit $? 61 | ;; 62 | -v|--v*) 63 | echo "ylwrap $scriptversion" 64 | exit $? 65 | ;; 66 | esac 67 | 68 | 69 | # The input. 70 | input="$1" 71 | shift 72 | case "$input" in 73 | [\\/]* | ?:[\\/]*) 74 | # Absolute path; do nothing. 75 | ;; 76 | *) 77 | # Relative path. Make it absolute. 78 | input="`pwd`/$input" 79 | ;; 80 | esac 81 | 82 | pairlist= 83 | while test "$#" -ne 0; do 84 | if test "$1" = "--"; then 85 | shift 86 | break 87 | fi 88 | pairlist="$pairlist $1" 89 | shift 90 | done 91 | 92 | # The program to run. 93 | prog="$1" 94 | shift 95 | # Make any relative path in $prog absolute. 96 | case "$prog" in 97 | [\\/]* | ?:[\\/]*) ;; 98 | *[\\/]*) prog="`pwd`/$prog" ;; 99 | esac 100 | 101 | # FIXME: add hostname here for parallel makes that run commands on 102 | # other machines. But that might take us over the 14-char limit. 103 | dirname=ylwrap$$ 104 | trap "cd '`pwd`'; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 105 | mkdir $dirname || exit 1 106 | 107 | cd $dirname 108 | 109 | case $# in 110 | 0) "$prog" "$input" ;; 111 | *) "$prog" "$@" "$input" ;; 112 | esac 113 | ret=$? 114 | 115 | if test $ret -eq 0; then 116 | set X $pairlist 117 | shift 118 | first=yes 119 | # Since DOS filename conventions don't allow two dots, 120 | # the DOS version of Bison writes out y_tab.c instead of y.tab.c 121 | # and y_tab.h instead of y.tab.h. Test to see if this is the case. 122 | y_tab_nodot="no" 123 | if test -f y_tab.c || test -f y_tab.h; then 124 | y_tab_nodot="yes" 125 | fi 126 | 127 | # The directory holding the input. 128 | input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` 129 | # Quote $INPUT_DIR so we can use it in a regexp. 130 | # FIXME: really we should care about more than `.' and `\'. 131 | input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` 132 | 133 | while test "$#" -ne 0; do 134 | from="$1" 135 | # Handle y_tab.c and y_tab.h output by DOS 136 | if test $y_tab_nodot = "yes"; then 137 | if test $from = "y.tab.c"; then 138 | from="y_tab.c" 139 | else 140 | if test $from = "y.tab.h"; then 141 | from="y_tab.h" 142 | fi 143 | fi 144 | fi 145 | if test -f "$from"; then 146 | # If $2 is an absolute path name, then just use that, 147 | # otherwise prepend `../'. 148 | case "$2" in 149 | [\\/]* | ?:[\\/]*) target="$2";; 150 | *) target="../$2";; 151 | esac 152 | 153 | # We do not want to overwrite a header file if it hasn't 154 | # changed. This avoid useless recompilations. However the 155 | # parser itself (the first file) should always be updated, 156 | # because it is the destination of the .y.c rule in the 157 | # Makefile. Divert the output of all other files to a temporary 158 | # file so we can compare them to existing versions. 159 | if test $first = no; then 160 | realtarget="$target" 161 | target="tmp-`echo $target | sed s/.*[\\/]//g`" 162 | fi 163 | # Edit out `#line' or `#' directives. 164 | # 165 | # We don't want the resulting debug information to point at 166 | # an absolute srcdir; it is better for it to just mention the 167 | # .y file with no path. 168 | # 169 | # We want to use the real output file name, not yy.lex.c for 170 | # instance. 171 | # 172 | # We want the include guards to be adjusted too. 173 | FROM=`echo "$from" | sed \ 174 | -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ 175 | -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` 176 | TARGET=`echo "$2" | sed \ 177 | -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ 178 | -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` 179 | 180 | sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \ 181 | -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$? 182 | 183 | # Check whether header files must be updated. 184 | if test $first = no; then 185 | if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then 186 | echo "$2" is unchanged 187 | rm -f "$target" 188 | else 189 | echo updating "$2" 190 | mv -f "$target" "$realtarget" 191 | fi 192 | fi 193 | else 194 | # A missing file is only an error for the first file. This 195 | # is a blatant hack to let us support using "yacc -d". If -d 196 | # is not specified, we don't want an error when the header 197 | # file is "missing". 198 | if test $first = yes; then 199 | ret=1 200 | fi 201 | fi 202 | shift 203 | shift 204 | first=no 205 | done 206 | else 207 | ret=$? 208 | fi 209 | 210 | # Remove the directory. 211 | cd .. 212 | rm -rf $dirname 213 | 214 | exit $ret 215 | 216 | # Local Variables: 217 | # mode: shell-script 218 | # sh-indentation: 2 219 | # eval: (add-hook 'write-file-hooks 'time-stamp) 220 | # time-stamp-start: "scriptversion=" 221 | # time-stamp-format: "%:y-%02m-%02d.%02H" 222 | # time-stamp-end: "$" 223 | # End: 224 | --------------------------------------------------------------------------------