avrdude/src/stk500v2_private.h

286 lines
10 KiB
C
Raw Normal View History

Mega-commit to bring in both, the STK500v2 support from Erik Walthinsen, as well as JTAG ICE mkII support (by me). Erik's submission has been cleaned up a little bit, mostly to add his name and the current year to the copyright of the new file, remove trailing white space before importing the files, and fix the minor syntax errors in his avrdude.conf.in additions (missing semicolons). The JTAG ICE mkII support should be considered alpha to beta quality at this point. Few things are still to be done, like defering the hfuse (OCDEN) tweaks until they are really required. Also, for reasons not yet known, the target MCU doesn't start to run after signing off from the ICE, it needs a power-cycle first (at least on my STK500). Note that for the JTAG ICE, I did change a few things in the internal API. Notably I made the serial receive timeout configurable by the backends via an exported variable (done in both the Posix and the Win32 implementation), and I made the serial_recv() function return a -1 instead of bailing out with exit(1) upon encountering a receive timeout (currently only done in the Posix implementation). Both measures together allow me to receive a datastreem from the ICE at 115 kbps on a somewhat lossy PCI multi-UART card that occasionally drops a character. The JTAG ICE mkII protocol has enough of safety layers to allow recovering from these events, but the previous code wasn't prepared for any kind of recovery. The Win32 change for this still has to be done, and the traditional drivers need to be converted to exit(1) upon encountering a timeout (as they're now getting a -1 returned they didn't see before in that case). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
//**** ATMEL AVR - A P P L I C A T I O N N O T E ************************
//*
//* Title: AVR068 - STK500 Communication Protocol
//* Filename: command.h
//* Version: 1.0
//* Last updated: 10.01.2005
//*
//* Support E-mail: avr@atmel.com
//*
//**************************************************************************
// *****************[ STK message constants ]***************************
#define MESSAGE_START 0x1B //= ESC = 27 decimal
#define TOKEN 0x0E
// *****************[ STK general command constants ]**************************
#define CMD_SIGN_ON 0x01
#define CMD_SET_PARAMETER 0x02
#define CMD_GET_PARAMETER 0x03
#define CMD_SET_DEVICE_PARAMETERS 0x04
#define CMD_OSCCAL 0x05
#define CMD_LOAD_ADDRESS 0x06
#define CMD_FIRMWARE_UPGRADE 0x07
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
#define CMD_CHECK_TARGET_CONNECTION 0x0D
#define CMD_LOAD_RC_ID_TABLE 0x0E
#define CMD_LOAD_EC_ID_TABLE 0x0F
Mega-commit to bring in both, the STK500v2 support from Erik Walthinsen, as well as JTAG ICE mkII support (by me). Erik's submission has been cleaned up a little bit, mostly to add his name and the current year to the copyright of the new file, remove trailing white space before importing the files, and fix the minor syntax errors in his avrdude.conf.in additions (missing semicolons). The JTAG ICE mkII support should be considered alpha to beta quality at this point. Few things are still to be done, like defering the hfuse (OCDEN) tweaks until they are really required. Also, for reasons not yet known, the target MCU doesn't start to run after signing off from the ICE, it needs a power-cycle first (at least on my STK500). Note that for the JTAG ICE, I did change a few things in the internal API. Notably I made the serial receive timeout configurable by the backends via an exported variable (done in both the Posix and the Win32 implementation), and I made the serial_recv() function return a -1 instead of bailing out with exit(1) upon encountering a receive timeout (currently only done in the Posix implementation). Both measures together allow me to receive a datastreem from the ICE at 115 kbps on a somewhat lossy PCI multi-UART card that occasionally drops a character. The JTAG ICE mkII protocol has enough of safety layers to allow recovering from these events, but the previous code wasn't prepared for any kind of recovery. The Win32 change for this still has to be done, and the traditional drivers need to be converted to exit(1) upon encountering a timeout (as they're now getting a -1 returned they didn't see before in that case). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
// *****************[ STK ISP command constants ]******************************
#define CMD_ENTER_PROGMODE_ISP 0x10
#define CMD_LEAVE_PROGMODE_ISP 0x11
#define CMD_CHIP_ERASE_ISP 0x12
#define CMD_PROGRAM_FLASH_ISP 0x13
#define CMD_READ_FLASH_ISP 0x14
#define CMD_PROGRAM_EEPROM_ISP 0x15
#define CMD_READ_EEPROM_ISP 0x16
#define CMD_PROGRAM_FUSE_ISP 0x17
#define CMD_READ_FUSE_ISP 0x18
#define CMD_PROGRAM_LOCK_ISP 0x19
#define CMD_READ_LOCK_ISP 0x1A
#define CMD_READ_SIGNATURE_ISP 0x1B
#define CMD_READ_OSCCAL_ISP 0x1C
#define CMD_SPI_MULTI 0x1D /* STK500v2, AVRISPmkII,
* JTAGICEmkII */
#define CMD_SET_SCK 0x1D /* JTAGICE3 */
#define CMD_GET_SCK 0x1E /* JTAGICE3 */
Mega-commit to bring in both, the STK500v2 support from Erik Walthinsen, as well as JTAG ICE mkII support (by me). Erik's submission has been cleaned up a little bit, mostly to add his name and the current year to the copyright of the new file, remove trailing white space before importing the files, and fix the minor syntax errors in his avrdude.conf.in additions (missing semicolons). The JTAG ICE mkII support should be considered alpha to beta quality at this point. Few things are still to be done, like defering the hfuse (OCDEN) tweaks until they are really required. Also, for reasons not yet known, the target MCU doesn't start to run after signing off from the ICE, it needs a power-cycle first (at least on my STK500). Note that for the JTAG ICE, I did change a few things in the internal API. Notably I made the serial receive timeout configurable by the backends via an exported variable (done in both the Posix and the Win32 implementation), and I made the serial_recv() function return a -1 instead of bailing out with exit(1) upon encountering a receive timeout (currently only done in the Posix implementation). Both measures together allow me to receive a datastreem from the ICE at 115 kbps on a somewhat lossy PCI multi-UART card that occasionally drops a character. The JTAG ICE mkII protocol has enough of safety layers to allow recovering from these events, but the previous code wasn't prepared for any kind of recovery. The Win32 change for this still has to be done, and the traditional drivers need to be converted to exit(1) upon encountering a timeout (as they're now getting a -1 returned they didn't see before in that case). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
// *****************[ STK PP command constants ]*******************************
#define CMD_ENTER_PROGMODE_PP 0x20
#define CMD_LEAVE_PROGMODE_PP 0x21
#define CMD_CHIP_ERASE_PP 0x22
#define CMD_PROGRAM_FLASH_PP 0x23
#define CMD_READ_FLASH_PP 0x24
#define CMD_PROGRAM_EEPROM_PP 0x25
#define CMD_READ_EEPROM_PP 0x26
#define CMD_PROGRAM_FUSE_PP 0x27
#define CMD_READ_FUSE_PP 0x28
#define CMD_PROGRAM_LOCK_PP 0x29
#define CMD_READ_LOCK_PP 0x2A
#define CMD_READ_SIGNATURE_PP 0x2B
#define CMD_READ_OSCCAL_PP 0x2C
#define CMD_SET_CONTROL_STACK 0x2D
// *****************[ STK HVSP command constants ]*****************************
#define CMD_ENTER_PROGMODE_HVSP 0x30
#define CMD_LEAVE_PROGMODE_HVSP 0x31
#define CMD_CHIP_ERASE_HVSP 0x32
#define CMD_PROGRAM_FLASH_HVSP 0x33
#define CMD_READ_FLASH_HVSP 0x34
#define CMD_PROGRAM_EEPROM_HVSP 0x35
#define CMD_READ_EEPROM_HVSP 0x36
#define CMD_PROGRAM_FUSE_HVSP 0x37
#define CMD_READ_FUSE_HVSP 0x38
#define CMD_PROGRAM_LOCK_HVSP 0x39
#define CMD_READ_LOCK_HVSP 0x3A
#define CMD_READ_SIGNATURE_HVSP 0x3B
#define CMD_READ_OSCCAL_HVSP 0x3C
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
// These two are redefined since 0x30/0x31 collide
// with the STK600 bootloader.
#define CMD_ENTER_PROGMODE_HVSP_STK600 0x3D
#define CMD_LEAVE_PROGMODE_HVSP_STK600 0x3E
// *** XPROG command constants ***
#define CMD_XPROG 0x50
#define CMD_XPROG_SETMODE 0x51
// *** AVR32 JTAG Programming command ***
#define CMD_JTAG_AVR32 0x80
#define CMD_ENTER_PROGMODE_JTAG_AVR32 0x81
#define CMD_LEAVE_PROGMODE_JTAG_AVR32 0x82
// *** AVR JTAG Programming command ***
#define CMD_JTAG_AVR 0x90
Mega-commit to bring in both, the STK500v2 support from Erik Walthinsen, as well as JTAG ICE mkII support (by me). Erik's submission has been cleaned up a little bit, mostly to add his name and the current year to the copyright of the new file, remove trailing white space before importing the files, and fix the minor syntax errors in his avrdude.conf.in additions (missing semicolons). The JTAG ICE mkII support should be considered alpha to beta quality at this point. Few things are still to be done, like defering the hfuse (OCDEN) tweaks until they are really required. Also, for reasons not yet known, the target MCU doesn't start to run after signing off from the ICE, it needs a power-cycle first (at least on my STK500). Note that for the JTAG ICE, I did change a few things in the internal API. Notably I made the serial receive timeout configurable by the backends via an exported variable (done in both the Posix and the Win32 implementation), and I made the serial_recv() function return a -1 instead of bailing out with exit(1) upon encountering a receive timeout (currently only done in the Posix implementation). Both measures together allow me to receive a datastreem from the ICE at 115 kbps on a somewhat lossy PCI multi-UART card that occasionally drops a character. The JTAG ICE mkII protocol has enough of safety layers to allow recovering from these events, but the previous code wasn't prepared for any kind of recovery. The Win32 change for this still has to be done, and the traditional drivers need to be converted to exit(1) upon encountering a timeout (as they're now getting a -1 returned they didn't see before in that case). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
// *****************[ STK test command constants ]***************************
#define CMD_ENTER_TESTMODE 0x60
#define CMD_LEAVE_TESTMODE 0x61
#define CMD_CHIP_WRITE 0x62
#define CMD_PROGRAM_FLASH_PARTIAL 0x63
#define CMD_PROGRAM_EEPROM_PARTIAL 0x64
#define CMD_PROGRAM_SIGNATURE_ROW 0x65
#define CMD_READ_FLASH_MARGIN 0x66
#define CMD_READ_EEPROM_MARGIN 0x67
#define CMD_READ_SIGNATURE_ROW_MARGIN 0x68
#define CMD_PROGRAM_TEST_FUSE 0x69
#define CMD_READ_TEST_FUSE 0x6A
#define CMD_PROGRAM_HIDDEN_FUSE_LOW 0x6B
#define CMD_READ_HIDDEN_FUSE_LOW 0x6C
#define CMD_PROGRAM_HIDDEN_FUSE_HIGH 0x6D
#define CMD_READ_HIDDEN_FUSE_HIGH 0x6E
#define CMD_PROGRAM_HIDDEN_FUSE_EXT 0x6F
#define CMD_READ_HIDDEN_FUSE_EXT 0x70
// *****************[ STK status constants ]***************************
// Success
#define STATUS_CMD_OK 0x00
// Warnings
#define STATUS_CMD_TOUT 0x80
#define STATUS_RDY_BSY_TOUT 0x81
#define STATUS_SET_PARAM_MISSING 0x82
// Errors
#define STATUS_CMD_FAILED 0xC0
#define STATUS_CKSUM_ERROR 0xC1
#define STATUS_CMD_UNKNOWN 0xC9
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
#define STATUS_CMD_ILLEGAL_PARAMETER 0xCA
2022-11-27 21:41:29 +00:00
#define STATUS_PHY_ERROR 0xCB
#define STATUS_CLOCK_ERROR 0xCC
#define STATUS_BAUD_INVALID 0xCD
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
// Status
#define STATUS_ISP_READY 0x00
#define STATUS_CONN_FAIL_SDO 0x01
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
#define STATUS_CONN_FAIL_RST 0x02
#define STATUS_CONN_FAIL_SCK 0x04
#define STATUS_TGT_NOT_DETECTED 0x10
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
#define STATUS_TGT_REVERSE_INSERTED 0x20
// hw_status
// Bits in status variable
// Bit 0-3: Periphery MCU
// Bit 4-7: Controller MCU
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
#define STATUS_AREF_ERROR 0
// Set to '1' if AREF is short circuited
#define STATUS_VTG_ERROR 4
// Set to '1' if VTG is short circuited
#define STATUS_RC_CARD_ERROR 5
// Set to '1' if board id changes when board is powered
#define STATUS_PROGMODE 6
// Set to '1' if board is in programming mode
#define STATUS_POWER_SURGE 7
// Set to '1' if board draws excessive current
Mega-commit to bring in both, the STK500v2 support from Erik Walthinsen, as well as JTAG ICE mkII support (by me). Erik's submission has been cleaned up a little bit, mostly to add his name and the current year to the copyright of the new file, remove trailing white space before importing the files, and fix the minor syntax errors in his avrdude.conf.in additions (missing semicolons). The JTAG ICE mkII support should be considered alpha to beta quality at this point. Few things are still to be done, like defering the hfuse (OCDEN) tweaks until they are really required. Also, for reasons not yet known, the target MCU doesn't start to run after signing off from the ICE, it needs a power-cycle first (at least on my STK500). Note that for the JTAG ICE, I did change a few things in the internal API. Notably I made the serial receive timeout configurable by the backends via an exported variable (done in both the Posix and the Win32 implementation), and I made the serial_recv() function return a -1 instead of bailing out with exit(1) upon encountering a receive timeout (currently only done in the Posix implementation). Both measures together allow me to receive a datastreem from the ICE at 115 kbps on a somewhat lossy PCI multi-UART card that occasionally drops a character. The JTAG ICE mkII protocol has enough of safety layers to allow recovering from these events, but the previous code wasn't prepared for any kind of recovery. The Win32 change for this still has to be done, and the traditional drivers need to be converted to exit(1) upon encountering a timeout (as they're now getting a -1 returned they didn't see before in that case). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
// *****************[ STK parameter constants ]***************************
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
#define PARAM_BUILD_NUMBER_LOW 0x80 /* ??? */
#define PARAM_BUILD_NUMBER_HIGH 0x81 /* ??? */
Mega-commit to bring in both, the STK500v2 support from Erik Walthinsen, as well as JTAG ICE mkII support (by me). Erik's submission has been cleaned up a little bit, mostly to add his name and the current year to the copyright of the new file, remove trailing white space before importing the files, and fix the minor syntax errors in his avrdude.conf.in additions (missing semicolons). The JTAG ICE mkII support should be considered alpha to beta quality at this point. Few things are still to be done, like defering the hfuse (OCDEN) tweaks until they are really required. Also, for reasons not yet known, the target MCU doesn't start to run after signing off from the ICE, it needs a power-cycle first (at least on my STK500). Note that for the JTAG ICE, I did change a few things in the internal API. Notably I made the serial receive timeout configurable by the backends via an exported variable (done in both the Posix and the Win32 implementation), and I made the serial_recv() function return a -1 instead of bailing out with exit(1) upon encountering a receive timeout (currently only done in the Posix implementation). Both measures together allow me to receive a datastreem from the ICE at 115 kbps on a somewhat lossy PCI multi-UART card that occasionally drops a character. The JTAG ICE mkII protocol has enough of safety layers to allow recovering from these events, but the previous code wasn't prepared for any kind of recovery. The Win32 change for this still has to be done, and the traditional drivers need to be converted to exit(1) upon encountering a timeout (as they're now getting a -1 returned they didn't see before in that case). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
#define PARAM_HW_VER 0x90
#define PARAM_SW_MAJOR 0x91
#define PARAM_SW_MINOR 0x92
#define PARAM_VTARGET 0x94
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
#define PARAM_VADJUST 0x95 /* STK500 only */
#define PARAM_OSC_PSCALE 0x96 /* STK500 only */
#define PARAM_OSC_CMATCH 0x97 /* STK500 only */
#define PARAM_SCK_DURATION 0x98 /* STK500 only */
#define PARAM_TOPCARD_DETECT 0x9A /* STK500 only */
#define PARAM_STATUS 0x9C /* STK500 only */
#define PARAM_DATA 0x9D /* STK500 only */
#define PARAM_RESET_POLARITY 0x9E /* STK500 only, and STK600 FW
* version <= 2.0.3 */
Mega-commit to bring in both, the STK500v2 support from Erik Walthinsen, as well as JTAG ICE mkII support (by me). Erik's submission has been cleaned up a little bit, mostly to add his name and the current year to the copyright of the new file, remove trailing white space before importing the files, and fix the minor syntax errors in his avrdude.conf.in additions (missing semicolons). The JTAG ICE mkII support should be considered alpha to beta quality at this point. Few things are still to be done, like defering the hfuse (OCDEN) tweaks until they are really required. Also, for reasons not yet known, the target MCU doesn't start to run after signing off from the ICE, it needs a power-cycle first (at least on my STK500). Note that for the JTAG ICE, I did change a few things in the internal API. Notably I made the serial receive timeout configurable by the backends via an exported variable (done in both the Posix and the Win32 implementation), and I made the serial_recv() function return a -1 instead of bailing out with exit(1) upon encountering a receive timeout (currently only done in the Posix implementation). Both measures together allow me to receive a datastreem from the ICE at 115 kbps on a somewhat lossy PCI multi-UART card that occasionally drops a character. The JTAG ICE mkII protocol has enough of safety layers to allow recovering from these events, but the previous code wasn't prepared for any kind of recovery. The Win32 change for this still has to be done, and the traditional drivers need to be converted to exit(1) upon encountering a timeout (as they're now getting a -1 returned they didn't see before in that case). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
#define PARAM_CONTROLLER_INIT 0x9F
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
/* STK600 parameters */
#define PARAM_STATUS_TGT_CONN 0xA1
#define PARAM_DISCHARGEDELAY 0xA4
#define PARAM_SOCKETCARD_ID 0xA5
#define PARAM_ROUTINGCARD_ID 0xA6
#define PARAM_EXPCARD_ID 0xA7
#define PARAM_SW_MAJOR_PERIPHERY1 0xA8
#define PARAM_SW_MINOR_PERIPHERY1 0xA9
#define PARAM_SW_MAJOR_PERIPHERY2 0xAA
#define PARAM_SW_MINOR_PERIPHERY2 0xAB
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
#define PARAM_BOARD_ID_STATUS 0xAD
#define PARAM_RESET 0xB4
#define PARAM_JTAG_ALLOW_FULL_PAGE_STREAM 0x50
#define PARAM_JTAG_EEPROM_PAGE_SIZE 0x52
#define PARAM_JTAG_DAISY_BITS_BEFORE 0x53
#define PARAM_JTAG_DAISY_BITS_AFTER 0x54
#define PARAM_JTAG_DAISY_UNITS_BEFORE 0x55
#define PARAM_JTAG_DAISY_UNITS_AFTER 0x56
// *** Parameter constants for 2 byte values ***
#define PARAM2_SCK_DURATION 0xC0
#define PARAM2_CLOCK_CONF 0xC1
#define PARAM2_AREF0 0xC2
#define PARAM2_AREF1 0xC3
#define PARAM2_JTAG_FLASH_SIZE_H 0xC5
#define PARAM2_JTAG_FLASH_SIZE_L 0xC6
#define PARAM2_JTAG_FLASH_PAGE_SIZE 0xC7
#define PARAM2_RC_ID_TABLE_REV 0xC8
#define PARAM2_EC_ID_TABLE_REV 0xC9
/* STK600 XPROG section */
// XPROG modes
#define XPRG_MODE_PDI 0
#define XPRG_MODE_JTAG 1
#define XPRG_MODE_TPI 2
Add initial support for the Atmel STK600, for "classic" AVRs (AT90, ATtiny, ATmega) in both, ISP and high-voltage programming modes. * Makefile.am: Add -lm. * avrdude.conf.in: Add stk600, stk600pp, and stk600hvsp. * config_gram.y: Add support for the stk600* keywords. * lexer.l: (Ditto.) * pgm.h: Add the "chan" parameter to set_varef(). * stk500.c: (Ditto.) * serial.h: Add USB endpoint support to struct filedescriptor. * stk500v2.c: Implement the meat of the STK600 support. * stk500v2.h: Add new prototypes for stk600*() programmers. * stk500v2_private.h: Add new constants used in the STK600. * term.c: Add AREF channel support. * usb_libusb.c: Automatically determine the correct write endpoint ID, the STK600 uses 0x83 while all other tools use 0x82. Propagate the EP to use through struct filedescriptor. * usbdevs.h: Add the STK600 USB product ID. * tools/get-stk600-cards.xsl: XSL transformation for targetboards.xml to obtain the list of socket and routing card IDs, to be used in stk500v2.c (for displaying the names). * tools/get-stk600-devices.xsl: XSL transformation for targetboards.xml to obtain the table of socket/routing cards and their respective AVR device support for doc/avrdude.texi. * avrdude.1: Document all the STK600 stuff. * doc/avrdude.texi: Ditto. Added a new chapter for Programmer Specific Information. Thanks to Eirik Rasmussen from Atmel Norway for his support in getting this code running within that short amount of time! git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@768 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-14 13:00:08 +00:00
// Write mode flags
#define XPRG_MEM_WRITE_ERASE 0
#define XPRG_MEM_WRITE_WRITE 1
// CRC types
#define XPRG_CRC_APP 1
#define XPRG_CRC_BOOT 2
#define XPRG_CRC_FLASH 3
Mega-commit to bring in both, the STK500v2 support from Erik Walthinsen, as well as JTAG ICE mkII support (by me). Erik's submission has been cleaned up a little bit, mostly to add his name and the current year to the copyright of the new file, remove trailing white space before importing the files, and fix the minor syntax errors in his avrdude.conf.in additions (missing semicolons). The JTAG ICE mkII support should be considered alpha to beta quality at this point. Few things are still to be done, like defering the hfuse (OCDEN) tweaks until they are really required. Also, for reasons not yet known, the target MCU doesn't start to run after signing off from the ICE, it needs a power-cycle first (at least on my STK500). Note that for the JTAG ICE, I did change a few things in the internal API. Notably I made the serial receive timeout configurable by the backends via an exported variable (done in both the Posix and the Win32 implementation), and I made the serial_recv() function return a -1 instead of bailing out with exit(1) upon encountering a receive timeout (currently only done in the Posix implementation). Both measures together allow me to receive a datastreem from the ICE at 115 kbps on a somewhat lossy PCI multi-UART card that occasionally drops a character. The JTAG ICE mkII protocol has enough of safety layers to allow recovering from these events, but the previous code wasn't prepared for any kind of recovery. The Win32 change for this still has to be done, and the traditional drivers need to be converted to exit(1) upon encountering a timeout (as they're now getting a -1 returned they didn't see before in that case). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
// *****************[ STK answer constants ]***************************
#define ANSWER_CKSUM_ERROR 0xB0
/*
* Private data for this programmer.
*/
struct pdata
{
/*
* See stk500pp_read_byte() for an explanation of the flash and
* EEPROM page caches.
*/
unsigned char *flash_pagecache;
unsigned long flash_pageaddr;
unsigned int flash_pagesize;
unsigned char *eeprom_pagecache;
unsigned long eeprom_pageaddr;
unsigned int eeprom_pagesize;
unsigned char command_sequence;
enum
{
PGMTYPE_UNKNOWN,
PGMTYPE_STK500,
PGMTYPE_AVRISP,
PGMTYPE_AVRISP_MKII,
PGMTYPE_JTAGICE_MKII,
PGMTYPE_STK600,
PGMTYPE_JTAGICE3
}
pgmtype;
Use const in PROGRAMMER function arguments where appropriate In order to get meaningful const properties for the PROGRAMMER, AVRPART and AVRMEM arguments, some code needed to be moved around, otherwise a network of "tainted" assignments risked rendering nothing const: - Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm, const AVRPART *p); this allows changes in the PROGRAMMER structure after the part is known. For example, use TPI, UPDI, PDI functions in that programmer appropriate to the part. This used to be done later in the process, eg, in the initialize() function, which "taints" all other programmer functions wrt const and sometimes requires other finessing with flags etc. Much clearer with the modified enable() interface. - Move TPI initpgm-type code from initialize() to enable() --- note that initpgm() does not have the info at the time when it is called whether or not TPI is required - buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate modification of the flag does not change PROGRAMMER structure) - Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and FLAGS32_WRITE bits - Move the xbeeResetPin component to private data in stk500.c as this is needed by xbee when it saddles on the stk500 code (previously, the flags component of the part was re-dedicated to this) - Change the way the "chained" private data are used in jtag3.c whilst keeping the PROGRAMMER structure read-only otherwise - In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to stk500v2_enable() so the former keeps the PROGRAMMER structure read-only (for const assertion). - In usbasp change the code from changing PROGRAMMER functions late to dispatching to TPI or regular SPI protocol functions at runtime; reason being the decision whether to use TPI protocol is done at run-time depending on the capability of the attached programmer Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 15:05:28 +00:00
const AVRPART *lastpart;
/* Start address of Xmega boot area */
unsigned long boot_start;
/*
* Chained pdata for the JTAG ICE mkII backend. This is used when
* calling the backend functions for ISP/HVSP/PP programming
* functionality of the JTAG ICE mkII and AVR Dragon.
*/
void *chained_pdata;
};