diff options
-rw-r--r-- | board/discovery-stm32f072/echo.c | 2 | ||||
-rw-r--r-- | board/fruitpie/board.c | 2 | ||||
-rw-r--r-- | board/hoho/board.c | 2 | ||||
-rw-r--r-- | board/twinkie/board.c | 2 | ||||
-rw-r--r-- | chip/stm32/usb.c | 11 | ||||
-rw-r--r-- | common/version.c | 7 | ||||
-rw-r--r-- | include/usb.h | 2 |
7 files changed, 21 insertions, 7 deletions
diff --git a/board/discovery-stm32f072/echo.c b/board/discovery-stm32f072/echo.c index ec7353e43e..08550a4b36 100644 --- a/board/discovery-stm32f072/echo.c +++ b/board/discovery-stm32f072/echo.c @@ -43,7 +43,7 @@ const void *const usb_strings[] = { [USB_STR_DESC] = usb_string_desc, [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."), [USB_STR_PRODUCT] = USB_STRING_DESC("discovery-stm32f072"), - [USB_STR_VERSION] = USB_STRING_DESC("v1.0"), + [USB_STR_VERSION] = NULL /* filled at runtime */, }; BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT); diff --git a/board/fruitpie/board.c b/board/fruitpie/board.c index 800fedea96..cd733c6c8f 100644 --- a/board/fruitpie/board.c +++ b/board/fruitpie/board.c @@ -67,7 +67,7 @@ const void * const usb_strings[] = { [USB_STR_DESC] = usb_string_desc, [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."), [USB_STR_PRODUCT] = USB_STRING_DESC("FruitPie"), - [USB_STR_VERSION] = USB_STRING_DESC("v1.0"), + [USB_STR_VERSION] = NULL /* filled at runtime */, }; BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT); diff --git a/board/hoho/board.c b/board/hoho/board.c index 598768ee6d..c521d2c6f8 100644 --- a/board/hoho/board.c +++ b/board/hoho/board.c @@ -86,7 +86,7 @@ const void * const usb_strings[] = { [USB_STR_DESC] = usb_string_desc, [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."), [USB_STR_PRODUCT] = USB_STRING_DESC("Hoho"), - [USB_STR_VERSION] = USB_STRING_DESC("v0.001"), + [USB_STR_VERSION] = NULL /* filled at runtime */, [USB_STR_BB_URL] = USB_STRING_DESC(USB_GOOGLE_TYPEC_URL), }; BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT); diff --git a/board/twinkie/board.c b/board/twinkie/board.c index 07faadd11b..69fe2735b2 100644 --- a/board/twinkie/board.c +++ b/board/twinkie/board.c @@ -73,7 +73,7 @@ const void * const usb_strings[] = { [USB_STR_DESC] = usb_string_desc, [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."), [USB_STR_PRODUCT] = USB_STRING_DESC("Twinkie"), - [USB_STR_VERSION] = USB_STRING_DESC("v0.001"), + [USB_STR_VERSION] = NULL /* filled at runtime */, [USB_STR_SNIFFER] = USB_STRING_DESC("USB-PD Sniffer"), }; BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT); diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c index d4ad8e48ea..a43c63905b 100644 --- a/chip/stm32/usb.c +++ b/chip/stm32/usb.c @@ -44,7 +44,7 @@ static const struct usb_device_descriptor dev_desc = { .bcdDevice = 0x0200, /* 2.00 */ .iManufacturer = USB_STR_VENDOR, .iProduct = USB_STR_PRODUCT, - .iSerialNumber = USB_STR_VERSION, + .iSerialNumber = 0, .bNumConfigurations = 1 }; @@ -55,7 +55,7 @@ const struct usb_config_descriptor USB_CONF_DESC(conf) = { .wTotalLength = 0x0BAD, /* no of returned bytes, set at runtime */ .bNumInterfaces = USB_IFACE_COUNT, .bConfigurationValue = 1, - .iConfiguration = 0, + .iConfiguration = USB_STR_VERSION, .bmAttributes = 0x80, /* bus powered */ .bMaxPower = 250, /* MaxPower 500 mA */ }; @@ -121,7 +121,12 @@ static void ep0_rx(void) if (idx >= USB_STR_COUNT) /* The string does not exist : STALL */ goto unknown_req; - + if (idx == USB_STR_VERSION) { + /* use the generated firmware version string */ + desc = usb_fw_version; + len = desc[0]; + break; + } desc = usb_strings[idx]; len = desc[0]; break; diff --git a/common/version.c b/common/version.c index 766b4ad56b..a80d843580 100644 --- a/common/version.c +++ b/common/version.c @@ -6,7 +6,9 @@ /* Embed firmware version number in the binary */ #include <stdint.h> +#include "common.h" #include "ec_version.h" +#include "usb.h" #include "version.h" const struct version_struct version_data @@ -19,6 +21,11 @@ const struct version_struct version_data const char build_info[] __attribute__((section(".rodata.buildinfo"))) = CROS_EC_VERSION " " DATE " " BUILDER; +#ifdef CONFIG_USB +/* UTF-16 encoded USB string descriptor */ +const void * const usb_fw_version = USB_STRING_DESC(CROS_EC_VERSION32); +#endif + uint32_t ver_get_numcommits(void) { int i; diff --git a/include/usb.h b/include/usb.h index ffbdf37c27..53e53939d7 100644 --- a/include/usb.h +++ b/include/usb.h @@ -257,6 +257,8 @@ static inline void memcpy_usbram(usb_uint *ebuf, const uint8_t *src, int size) /* These descriptors defined in board code */ extern const void * const usb_strings[]; extern const uint8_t usb_string_desc[]; +/* USB string descriptor with the firmware version */ +extern const void * const usb_fw_version; extern const struct bos_context bos_ctx; /* Helpers for endpoint declaration */ |