|
One of the parts of the USB device descriptor is a parameter called "iSerialNumber" - an index to a string that defines a serial number for the device. The Microchip firmware sets the index to 0x00, which is interpreted as 'no serial number'. The result is that windows identifies the device based on vendor ID, product ID, and the USB port that it is plugged into. This means that any time you plug the device into a different USB port, it sees it as a new device and prompts you to install the driver (again) - not a huge deal, but annoying none the less. The one advantage is that with no serial number, you can plug in multiple identical devices and they're always identified separately - what I've read indicates that if serial numbers are used, they have to be unique on each device. If you're only planning to use a single PIC device, or don't mind taking the extra time to program each of your multiple devices with separate serial numbers, then it's a relatively simple matter to assign serial numbers by modifying the Microchip firmware. Note that this article is using the 'generic' class firmware, as used in all my other articles to date. All of the work is done in USBDSC.C, which contains the descriptors. First, you need to add a string representing the serial number. At the bottom of the file you should see a few ROM STRUCTs with some strings in them, labeled sd000, sd001, etc. You just need to follow the same kind of format to add your string. For me, the next available string index was 'sd003', and I arbitrarily chose to make my string "001". After that, you need to add a reference to your new string to the array of pointers at the bottom. The resulting changes are detailed below: //EXISTING rom struct{byte bLength;byte bDscType;word string[33];}sd002={ sizeof(sd002),DSC_STR, 'P','I','C','D','E','M',' ','F','S',' ','U','S','B',' ', 'D','e','m','o',' ','B','o','a','r','d',' ','(','C',')', ' ','2','0','0','4'};
//ADDED rom struct{byte bLength;byte bDscType;word string[3];}sd003={ sizeof(sd003),DSC_STR,'0','0','1'};
rom const unsigned char *rom USB_CD_Ptr[]={&cfg01,&cfg01}; //rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002}; //ORIGINAL rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002,&sd003}; //ADDED |
After this, there's just one thing left to do: Update the descriptor to use your string as the serial number. This is in the Device Descriptor, second to last byte, and in the Microchip firmware was labeled "Device serial number string index". The default value, as mentioned previously, was 0x00, so you just need to change it to the right index for your string - since my string was sd003, I changed it to 0x03. That's it! No more driver prompts every time you switch ports.
|