diff --git a/Demos/Device/ClassDriver/CDC/Descriptors.c b/Demos/Device/ClassDriver/CDC/Descriptors.c
index 9a2fe5e68a..1cdad8e8f3 100644
--- a/Demos/Device/ClassDriver/CDC/Descriptors.c
+++ b/Demos/Device/ClassDriver/CDC/Descriptors.c
@@ -59,7 +59,7 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
.ManufacturerStrIndex = 0x01,
.ProductStrIndex = 0x02,
- .SerialNumStrIndex = NO_DESCRIPTOR,
+ .SerialNumStrIndex = USE_INTERNAL_SERIAL,
.NumberOfConfigurations = 1
};
diff --git a/Demos/Device/ClassDriver/DualCDC/Descriptors.c b/Demos/Device/ClassDriver/DualCDC/Descriptors.c
index 951a5586cc..92b3eb930e 100644
--- a/Demos/Device/ClassDriver/DualCDC/Descriptors.c
+++ b/Demos/Device/ClassDriver/DualCDC/Descriptors.c
@@ -59,7 +59,7 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
.ManufacturerStrIndex = 0x01,
.ProductStrIndex = 0x02,
- .SerialNumStrIndex = NO_DESCRIPTOR,
+ .SerialNumStrIndex = USE_INTERNAL_SERIAL,
.NumberOfConfigurations = 1
};
diff --git a/Demos/Device/ClassDriver/MassStorage/Descriptors.c b/Demos/Device/ClassDriver/MassStorage/Descriptors.c
index 6c02a6c552..13d18a69d1 100644
--- a/Demos/Device/ClassDriver/MassStorage/Descriptors.c
+++ b/Demos/Device/ClassDriver/MassStorage/Descriptors.c
@@ -59,7 +59,7 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
.ManufacturerStrIndex = 0x01,
.ProductStrIndex = 0x02,
- .SerialNumStrIndex = 0x03,
+ .SerialNumStrIndex = USE_INTERNAL_SERIAL,
.NumberOfConfigurations = 1
};
@@ -156,20 +156,6 @@ USB_Descriptor_String_t PROGMEM ProductString =
.UnicodeString = L"LUFA Mass Storage Demo"
};
-/** Serial number descriptor string. This is a Unicode string containing a string of HEX characters at least 12
- * digits in length to uniquely identify a device when concatenated with the device's Vendor and Product IDs. By
- * using the unique serial number string to identify a device, the device drivers do not need to be reinstalled
- * each time the device is inserted into a different USB port on the same system. This should be unique between
- * devices, or conflicts will occur if two devices sharing the same serial number are inserted into the same system
- * at the same time.
- */
-USB_Descriptor_String_t PROGMEM SerialNumberString =
-{
- .Header = {.Size = USB_STRING_LEN(12), .Type = DTYPE_String},
-
- .UnicodeString = L"000000000000"
-};
-
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
* documentation) by the application code so that the address and size of a requested descriptor can be given
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
@@ -209,10 +195,6 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex,
Address = (void*)&ProductString;
Size = pgm_read_byte(&ProductString.Header.Size);
break;
- case 0x03:
- Address = (void*)&SerialNumberString;
- Size = pgm_read_byte(&SerialNumberString.Header.Size);
- break;
}
break;
diff --git a/Demos/Device/ClassDriver/USBtoSerial/Descriptors.c b/Demos/Device/ClassDriver/USBtoSerial/Descriptors.c
index d4db3a4b72..38f5689b57 100644
--- a/Demos/Device/ClassDriver/USBtoSerial/Descriptors.c
+++ b/Demos/Device/ClassDriver/USBtoSerial/Descriptors.c
@@ -59,7 +59,7 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
.ManufacturerStrIndex = 0x01,
.ProductStrIndex = 0x02,
- .SerialNumStrIndex = NO_DESCRIPTOR,
+ .SerialNumStrIndex = USE_INTERNAL_SERIAL,
.NumberOfConfigurations = 1
};
diff --git a/LUFA/Drivers/USB/HighLevel/StdDescriptors.h b/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
index 2ce75b2d9f..274b84fc4d 100644
--- a/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
+++ b/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
@@ -74,6 +74,21 @@
* descriptor does not exist.
*/
#define NO_DESCRIPTOR 0
+
+ #if (!defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))) || defined(__DOXYGEN__)
+ /** String descriptor index for the device's unique serial number string descriptor within the device.
+ * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
+ * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
+ * a unique serial number internally, and setting the device descriptors serial number string index to this value
+ * will cause it to use the internal serial number.
+ *
+ * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseduo-serial
+ * number for the device.
+ */
+ #define USE_INTERNAL_SERIAL 0xDC
+ #else
+ #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
+ #endif
/** Macro to calculate the power value for the device descriptor, from a given number of milliamps. */
#define USB_CONFIG_POWER_MA(mA) (mA >> 1)
@@ -244,13 +259,14 @@
*/
uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
* serial number, in uppercase Unicode ASCII.
- *
- * \note On some AVR models, there is an embedded serial number
- * in the chip which can be used for the device serial number.
- * To use this serial number, define USE_INTERNAL_SERIAL to a
- * unique string index number in the project makefile and set
- * this value to USE_INTERNAL_SERIAL.
- *
+ *
+ * \note On some AVR models, there is an embedded serial number
+ * in the chip which can be used for the device serial number.
+ * To use this serial number, set this to USE_INTERNAL_SERIAL.
+ * On unsupported devices, this will evaluate to 0 and will cause
+ * the host to generate a pseudo-unique value for the device upon
+ * insertion.
+ *
* \see ManufacturerStrIndex structure entry.
*/
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
index 55b49b8034..4014ed1caf 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
@@ -179,7 +179,7 @@ static void USB_Device_GetDescriptor(void)
void* DescriptorPointer;
uint16_t DescriptorSize;
- #if defined(USE_INTERNAL_SERIAL)
+ #if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL))
{
uint8_t SignatureDescriptor[2 + (sizeof(int16_t) * 12)];
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.h b/LUFA/Drivers/USB/LowLevel/DevChapter9.h
index 65fa0418cd..505256e68b 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.h
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.h
@@ -45,21 +45,12 @@
#include "../HighLevel/USBTask.h"
#include "LowLevel.h"
- /* Preprocessor Checks: */
- #if defined(USE_INTERNAL_SERIAL) && !(defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
- #error USE_INTERNAL_SERIAL invalid, the selected AVR model does not contain unique serial bytes.
- #endif
-
- #if defined(USE_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL <= 1)
- #error USE_INTERNAL_SERIAL must be defined to the string descriptor index chosen for the serial number descriptor.
- #endif
-
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
#endif
- /* Public Interface - May be used in end-application: */
+ /* Public Interface - May be used in end-application: */
/* Global Variables: */
/** Indicates the currently set configuration number of the device. USB devices may have several
* different configurations which the host can select between; this indicates the currently selected
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt
index f7ae4c664a..6f116da67c 100644
--- a/LUFA/ManPages/ChangeLog.txt
+++ b/LUFA/ManPages/ChangeLog.txt
@@ -28,7 +28,8 @@
* cleared to prevent endpoint type corruption
* - Fix documentation mentioning Pipe_GetCurrentToken() function when real name is Pipe_GetPipeToken()
* - Extend USB_GetDeviceConfigDescriptor() routine to require the configuration number within the device to fetch
- * - Added new USE_INTERNAL_SERIAL compile time option
+ * - Added new USE_INTERNAL_SERIAL define for using the unique serial numbers in some AVR models as the USB device's serial number,
+ * added NO_INTERNAL_SERIAL compile time option to turn off new serial number reading code
*
* \section Sec_ChangeLog090605 Version 090605
*
diff --git a/LUFA/ManPages/CompileTimeTokens.txt b/LUFA/ManPages/CompileTimeTokens.txt
index e1f248d8fb..bc49ba2cc9 100644
--- a/LUFA/ManPages/CompileTimeTokens.txt
+++ b/LUFA/ManPages/CompileTimeTokens.txt
@@ -80,13 +80,11 @@
* compatibility. If this token is defined, the structure element names are switched to the LUFA-specific but more descriptive
* names documented in the StdDescriptors.h source file.
*
- * USE_INTERNAL_SERIAL - ( \ref Group_Descriptors ) \n
+ * NO_INTERNAL_SERIAL - ( \ref Group_Descriptors ) \n
* Some AVR models contain a unique 20-digit serial number which can be used as the device serial number, while in device mode. This
* allows the host to uniquely identify the device regardless of if it is moved between USB ports on the same computer, allowing
- * allocated resources (such as drivers, COM Port number allocations) to be preserved. To make the library use this value for the
- * device's serial number, define this token in the project makefile, set it to a unique string descriptor index (i.e. one not used
- * elsewhere in the device for a string descriptor) and set the Device Descriptor's serial number descriptor index entry to the
- * USE_INTERNAL_SERIAL value.
+ * allocated resources (such as drivers, COM Port number allocations) to be preserved. This is not needed in many apps, and so the
+ * code that performs this task can be disabled by defining this option and passing it to the compiler via the -D switch.
*
* FIXED_CONTROL_ENDPOINT_SIZE - ( \ref Group_EndpointManagement ) \n
* By default, the library determines the size of the control endpoint (when in device mode) by reading the device descriptor.