From fbea2413f6c3cf935ded2466ce27029575b7d1d4 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 8 Jan 2012 11:52:15 +0100 Subject: DFU: add support for setting the USB SERIAL by a board this will allow us to use the Unique Chip ID as serial number in the USB descriptor, which in turn allows customers to write device-specific udev rules for persistent naming, etc. --- boards/at91sam3u-ek/board.h | 2 ++ usb/device/dfu/dfu.h | 1 + usb/device/dfu/dfu_desc.c | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/boards/at91sam3u-ek/board.h b/boards/at91sam3u-ek/board.h index da479a8..9669fd3 100644 --- a/boards/at91sam3u-ek/board.h +++ b/boards/at91sam3u-ek/board.h @@ -696,5 +696,7 @@ typedef enum IRQn #define BOARD_USB_PRODUCT 0x0763 #define BOARD_USB_RELEASE 0x0001 +#define BOARD_USB_SERIAL + #endif //#ifndef BOARD_H diff --git a/usb/device/dfu/dfu.h b/usb/device/dfu/dfu.h index 5ca1baf..3cbcac5 100644 --- a/usb/device/dfu/dfu.h +++ b/usb/device/dfu/dfu.h @@ -120,6 +120,7 @@ struct dfu { }; extern struct dfu dfu; +void set_usb_serial_str(const uint8_t *serial_usbstr); /* call-backs by the board/SOC */ extern int USBDFU_handle_dnload(uint8_t altif, unsigned int offset, diff --git a/usb/device/dfu/dfu_desc.c b/usb/device/dfu/dfu_desc.c index 6c27c2e..c428e3a 100644 --- a/usb/device/dfu/dfu_desc.c +++ b/usb/device/dfu/dfu_desc.c @@ -1,4 +1,6 @@ +#include + #include #include #include @@ -32,7 +34,11 @@ static const USBDeviceDescriptor fsDevice = { .bcdDevice = BOARD_USB_RELEASE, .iManufacturer = STR_MANUF, .iProduct = STR_PROD, +#ifdef BOARD_USB_SERIAL .iSerialNumber = STR_SERIAL, +#else + .iSerialNumber = 0, +#endif .bNumConfigurations = 1, }; @@ -84,9 +90,16 @@ const struct dfu_desc dfu_cfg_descriptor = { static const unsigned char *usb_strings[] = { USB_STRINGS_GENERATED - (const unsigned char *) &string1 +#ifdef BOARD_USB_SERIAL + NULL +#endif }; +void set_usb_serial_str(const uint8_t *serial_usbstr) +{ + usb_strings[STR_SERIAL] = serial_usbstr; +} + const USBDDriverDescriptors dfu_descriptors = { .pFsDevice = &fsDevice, .pFsConfiguration = &dfu_cfg_descriptor.ucfg, -- cgit v1.2.3