Updated the AVRISP-MKII Clone programmer project to be compatible with the latest...
authorDean Camera <dean@fourwalledcubicle.com>
Wed, 8 Feb 2012 18:29:17 +0000 (18:29 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Wed, 8 Feb 2012 18:29:17 +0000 (18:29 +0000)
Changed the AVRISP-MKII Clone programmer project to report a fixed 3.3V VTARGET voltage on USB AVRs lacking an ADC instead of 5V to prevent warnings in AVR Studio 5.1 when programming XMEGA devices.

LUFA/DoxygenPages/ChangeLog.txt
Projects/AVRISP-MKII/AVRISP-MKII.txt
Projects/AVRISP-MKII/Descriptors.c
Projects/AVRISP-MKII/Lib/V2ProtocolParams.c
Projects/AVRISP-MKII/Lib/V2ProtocolParams.h
Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h
Projects/AVRISP-MKII/makefile
Projects/XPLAINBridge/AVRISPDescriptors.c
Projects/XPLAINBridge/XPLAINBridge.txt
Projects/XPLAINBridge/makefile

index 0d42163..cf1ae73 100644 (file)
@@ -37,6 +37,9 @@
   *  - Library Applications:
   *   - Altered the Mass Storage Host LowLevel demo so that SCSI data STALLs from the attached device can be recovered from automatically without
   *     having to reset the Mass Storage interface
+  *   - Updated the AVRISP-MKII Clone programmer project to be compatible with the latest version of AVR Studio (version 5.1)
+  *   - Changed the AVRISP-MKII Clone programmer project to report a fixed 3.3V VTARGET voltage on USB AVRs lacking an ADC instead of 5V to prevent
+  *     warnings in AVR Studio 5.1 when programming XMEGA devices
   *
   *  <b>Fixed:</b>
   *  - Core:
index 4533a85..d2977dd 100644 (file)
@@ -46,9 +46,9 @@
  *
  *  Firmware for an AVRStudio compatible AVRISP-MKII clone programmer. This project will enable the USB AVR series of
  *  microcontrollers to act as a clone of the official Atmel AVRISP-MKII programmer, usable within AVRStudio. In its
- *  most basic form, it allows for the programming of 5V AVRs from within AVRStudio with no special hardware other than
- *  the USB AVR and the parts needed for the USB interface. If the user desires, more advanced circuits incorporating
- *  level conversion can be made to allow for the programming of 3.3V AVR designs.
+ *  most basic form, it allows for the programming of AVRs at the programmer's VCC voltage from within AVRStudio with
+ *  no special hardware other than the USB AVR and the parts needed for the USB interface. If the user desires, more
+ *  advanced circuits incorporating level conversion can be made to allow for the programming of 3.3V AVR designs.
  *
  *  This device spoofs Atmel's official AVRISP-MKII device PID so that it remains compatible with Atmel's AVRISP-MKII
  *  drivers. When prompted, direct your OS to install Atmel's AVRISP-MKII drivers provided with AVRStudio.
@@ -59,7 +59,7 @@
  *
  *  On AVR models with an ADC converter, AVCC should be tied to 5V (e.g. VBUS) and the \c VTARGET_ADC_CHANNEL token should be
  *  set to an appropriate ADC channel number in the project makefile for VTARGET detection to operate correctly. On models
- *  without an ADC converter, VTARGET will report a fixed 5V level at all times.
+ *  without an ADC converter, VTARGET will report a fixed 3.3V level at all times.
  *
  *  While this application can be compiled for USB AVRs with as little as 8KB of FLASH, for full functionality 16KB or more
  *  of FLASH is required. On 8KB devices, ISP or PDI/TPI programming support can be disabled to reduce program size.
  *    <td>NO_VTARGET_DETECT</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Define to disable VTARGET sampling and reporting on AVR models with an ADC converter. This will cause the programmer
- *        to report a fixed 5V target voltage to the host regardless of the real target voltage. <i>Ignored when compiled for
+ *        to report a fixed 3.3V target voltage to the host regardless of the real target voltage. <i>Ignored when compiled for
  *        targets lacking an ADC.</i></td>
  *   </tr>
  *   <tr>
  *    <td>LIBUSB_DRIVER_COMPAT</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Define to switch to a non-standard endpoint scheme, breaking compatibility with AVRStudio under Windows but making
- *        the code compatible with software such as avrdude (all platforms) that use the libUSB driver.
+ *        the code compatible with software such as avrdude (all platforms) that use the libUSB driver.</td>
  *   </tr>
  *   <tr>
  *    <td>XCK_RESCUE_CLOCK_ENABLE</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Define to move the ISP rescue clock to the AVR's XCK pin instead of the OCR1A output pin. This is useful for existing programming
- *        hardware that does not expose the OCR1A pin of the AVR, but *may* cause some issues with PDI programming mode.
+ *        hardware that does not expose the OCR1A pin of the AVR, but *may* cause some issues with PDI programming mode.</td>
  *   </tr>
  *   <tr>
  *    <td>INVERTED_ISP_MISO</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Define to invert the received data on the ISP MISO line. This is sometimes needed depending on the level translation hardware used,
- *        if the translator hardware inverts the received logic level.
+ *        if the translator hardware inverts the received logic level.</td>
+ *   </tr>
+ *   <tr>
+ *    <td>FIRMWARE_VERSION_MINOR</td>
+ *    <td>Define to set the minor firmware revision nunber reported to the host on request. By default this will use a firmware version compatible
+ *        with the latest Atmel IDE version, however if desired the reported minor value can be adjusted here.</td>
  *   </tr>
  *  </table>
  */
index 9b01e9c..12f44f9 100644 (file)
@@ -140,9 +140,9 @@ const USB_Descriptor_String_t PROGMEM LanguageString =
  */
 const USB_Descriptor_String_t PROGMEM ManufacturerString =
 {
-       .Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
+       .Header                 = {.Size = USB_STRING_LEN(5), .Type = DTYPE_String},
 
-       .UnicodeString          = L"Dean Camera"
+       .UnicodeString          = L"ATMEL"
 };
 
 /** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
@@ -151,9 +151,9 @@ const USB_Descriptor_String_t PROGMEM ManufacturerString =
  */
 const USB_Descriptor_String_t PROGMEM ProductString =
 {
-       .Header                 = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String},
+       .Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
 
-       .UnicodeString          = L"LUFA AVRISP MkII Clone"
+       .UnicodeString          = L"AVRISP mkII"
 };
 
 /** Serial number string. This is a Unicode string containing the device's unique serial number, expressed as a
@@ -162,8 +162,8 @@ const USB_Descriptor_String_t PROGMEM ProductString =
 const USB_Descriptor_String_t PROGMEM SerialString =
 {
        .Header                 = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},
-
-       .UnicodeString          = L"0000A00128255"
+       
+       .UnicodeString          = L"000200012345\0" // Note: Real AVRISP-MKII has the embedded NUL byte, bug in firmware?
 };
 
 /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
index c9b305c..1ec2b04 100644 (file)
@@ -60,11 +60,11 @@ static ParameterItem_t ParameterTable[] =
 
                { .ParamID          = PARAM_SW_MINOR,
                  .ParamPrivileges  = PARAM_PRIV_READ,
-                 .ParamValue       = 0x0D                               },
+                 .ParamValue       = FIRMWARE_VERSION_MINOR             },
 
                { .ParamID          = PARAM_VTARGET,
                  .ParamPrivileges  = PARAM_PRIV_READ,
-                 .ParamValue       = 0x32                               },
+                 .ParamValue       = (uint8_t)(3.3 * 10)                },
 
                { .ParamID          = PARAM_SCK_DURATION,
                  .ParamPrivileges  = PARAM_PRIV_READ | PARAM_PRIV_WRITE,
index d7bc916..ab47664 100644 (file)
 
                /** Total number of parameters in the parameter table */
                #define TABLE_PARAM_COUNT   (sizeof(ParameterTable) / sizeof(ParameterTable[0]))
+               
+               #if (!defined(FIRMWARE_VERSION_MINOR) || defined(__DOXYGEN__))
+                       /** Minor firmware version, reported to the host on request; must match the version
+                        *  the host is expecting, or it (may) reject further communications with the programmer. */
+                       #define FIRMWARE_VERSION_MINOR   0x11
+               #endif
 
        /* Type Defines: */
                /** Type define for a parameter table entry indicating a PC readable or writable device parameter. */
index 2e3d11f..d342730 100644 (file)
@@ -455,6 +455,12 @@ static void XPROGProtocol_SetParam(void)
                case XPRG_PARAM_NVMCSR_REG:
                        XPROG_Param_NVMCSRRegAddr = Endpoint_Read_8();
                        break;
+               case XPRG_PARAM_UNKNOWN_1:
+                       /* TODO: Undocumented parameter added in AVRStudio 5.1, purpose unknown. Must ACK and discard or
+                                the communication with AVRStudio 5.1 will fail.
+                       */
+                       Endpoint_Discard_16();
+                       break;
                default:
                        ReturnStatus = XPRG_ERR_FAILED;
                        break;
index 367c85e..523fc15 100644 (file)
 
        /* Preprocessor Checks: */
                #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
+                       /* On the XPLAIN board, we only need PDI programming
+                          for the ATXMEGA128A1 - disable ISP to prevent hardware
+                          damage.
+                        */
                        #undef ENABLE_ISP_PROTOCOL
 
                        #if !defined(ENABLE_XPROG_PROTOCOL)
                #define XPRG_PARAM_EEPPAGESIZE              0x02
                #define XPRG_PARAM_NVMCMD_REG               0x03
                #define XPRG_PARAM_NVMCSR_REG               0x04
+               #define XPRG_PARAM_UNKNOWN_1                0x05
 
                #define XPRG_PROTOCOL_PDI                   0x00
                #define XPRG_PROTOCOL_JTAG                  0x01
index 10b3c75..475ec71 100644 (file)
@@ -145,6 +145,7 @@ LUFA_OPTS += -D VTARGET_SCALE_FACTOR=1
 #LUFA_OPTS += -D LIBUSB_DRIVER_COMPAT
 #LUFA_OPTS += -D XCK_RESCUE_CLOCK_ENABLE
 #LUFA_OPTS += -D INVERTED_ISP_MISO
+#LUFA_OPTS += -D FIRMWARE_VERSION_MINOR=0x11
 
 
 # Create the LUFA source path variables by including the LUFA root makefile
index ae3ce00..5f2071e 100644 (file)
@@ -81,7 +81,7 @@ const AVRISP_USB_Descriptor_Configuration_t PROGMEM AVRISP_ConfigurationDescript
                        .ConfigurationNumber    = 1,
                        .ConfigurationStrIndex  = NO_DESCRIPTOR,
 
-                       .ConfigAttributes       = USB_CONFIG_ATTR_RESERVED,
+                       .ConfigAttributes       = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED),
 
                        .MaxPowerConsumption    = USB_CONFIG_POWER_MA(100)
                },
@@ -96,8 +96,8 @@ const AVRISP_USB_Descriptor_Configuration_t PROGMEM AVRISP_ConfigurationDescript
                        .TotalEndpoints         = 2,
 
                        .Class                  = USB_CSCP_VendorSpecificClass,
-                       .SubClass               = 0x00,
-                       .Protocol               = 0x00,
+                       .SubClass               = USB_CSCP_NoDeviceSubclass,
+                       .Protocol               = USB_CSCP_NoDeviceProtocol,
 
                        .InterfaceStrIndex      = NO_DESCRIPTOR
                },
@@ -140,9 +140,9 @@ const USB_Descriptor_String_t PROGMEM AVRISP_LanguageString =
  */
 const USB_Descriptor_String_t PROGMEM AVRISP_ManufacturerString =
 {
-       .Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
+       .Header                 = {.Size = USB_STRING_LEN(5), .Type = DTYPE_String},
 
-       .UnicodeString          = L"Dean Camera"
+       .UnicodeString          = L"ATMEL"
 };
 
 /** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
@@ -151,9 +151,9 @@ const USB_Descriptor_String_t PROGMEM AVRISP_ManufacturerString =
  */
 const USB_Descriptor_String_t PROGMEM AVRISP_ProductString =
 {
-       .Header                 = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String},
+       .Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
 
-       .UnicodeString          = L"LUFA AVRISP MkII Clone"
+       .UnicodeString          = L"AVRISP mkII"
 };
 
 /** Serial number string. This is a Unicode string containing the device's unique serial number, expressed as a
@@ -163,7 +163,7 @@ const USB_Descriptor_String_t PROGMEM AVRISP_SerialString =
 {
        .Header                 = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},
 
-       .UnicodeString          = L"0000A00128255"
+       .UnicodeString          = L"000200053650\0"
 };
 
 /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
@@ -219,4 +219,3 @@ uint16_t AVRISP_GetDescriptor(const uint16_t wValue,
        *DescriptorAddress = Address;
        return Size;
 }
-
index 3532417..52cf99f 100644 (file)
  *    <td>LIBUSB_DRIVER_COMPAT</td>
  *    <td>Makefile LUFA_OPTS</td>
  *    <td>Define to switch to a non-standard endpoint scheme, breaking compatibility with AVRStudio under Windows but making
- *        the code compatible with software such as avrdude (all platforms) that use the libUSB driver.
+ *        the code compatible with software such as avrdude (all platforms) that use the libUSB driver.</td>
+ *   </tr>
+ *   <tr>
+ *    <td>FIRMWARE_VERSION_MINOR</td>
+ *    <td>Define to set the minor firmware revision nunber reported to the host on request. By default this will use a firmware version compatible
+ *        with the latest Atmel IDE version, however if desired the reported minor value can be adjusted here.</td>
  *   </tr>
  *  </table>
  */
index ff829a5..28e47eb 100644 (file)
@@ -127,7 +127,7 @@ AVRISP_PATH = ../AVRISP-MKII
 LUFA_OPTS  = -D USB_DEVICE_ONLY
 LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0
 LUFA_OPTS += -D ORDERED_EP_CONFIG
-LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
+LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=16
 LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
 LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
 LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
@@ -142,7 +142,7 @@ LUFA_OPTS += -D VTARGET_ADC_CHANNEL=2
 LUFA_OPTS += -D VTARGET_REF_VOLTS=3.3
 LUFA_OPTS += -D VTARGET_SCALE_FACTOR=2
 #LUFA_OPTS += -D LIBUSB_DRIVER_COMPAT
-
+#LUFA_OPTS += -D FIRMWARE_VERSION_MINOR=0x11
 
 # Create the LUFA source path variables by including the LUFA root makefile
 include $(LUFA_PATH)/LUFA/makefile