Skip to content

Commit 087b7c7

Browse files
authored
Merge pull request #39 from keyboardio/jesse/extract-descriptor-strings
Make it possible to override usb vendor/product strings from config.h or the commandline
2 parents 0173069 + af09454 commit 087b7c7

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ To use a custom VID/PID pair, you need to set the macros `USB_VID` and `USB_PID`
9292
DEFS="-DUSB_VID=0x1209 -DUSB_PID=0xCAFE" make
9393

9494

95+
## USB Vendor, Product, and Interface strings
96+
97+
To customize the USB vendor, product, and interface strings that DAPBoot reports to the USB host, you may set the macros `USB_VENDOR_STRING`, `USB_PRODUCT_STRING`, and `USB_INTERFACE_STRING`, respectively. You can do this by setting the `DEFS` environment variable or including these macros in your board's `config.h`
98+
99+
95100
## Licensing
96101
All contents of the dapboot project are licensed under terms that are compatible with the terms of the GNU Lesser General Public License version 3.
97102

src/usb_conf.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,10 @@ static const struct usb_bos_descriptor bos = {
9898
static char serial_number[USB_SERIAL_NUM_LENGTH+1];
9999

100100
static const char *usb_strings[] = {
101-
"Devanarchy",
102-
#ifdef BOOTLOADER_HIGH
103-
"DAPBoot High-Memory DFU Bootloader",
104-
#else
105-
"DAPBoot DFU Bootloader",
106-
#endif
101+
USB_VENDOR_STRING,
102+
USB_PRODUCT_STRING,
107103
serial_number,
108-
"DAPBoot DFU"
104+
USB_INTERFACE_STRING
109105
};
110106

111107
/* Buffer to be used for control requests. */

src/usb_conf.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,29 @@
2525
#define USB_VID 0x1209
2626
#endif
2727

28+
#ifndef USB_VENDOR_STRING
29+
#define USB_VENDOR_STRING "Devanarchy"
30+
#endif
31+
2832
#ifndef USB_PID
2933
#define USB_PID 0xdb42
3034
#endif
3135

36+
37+
#ifndef USB_PRODUCT_STRING
38+
39+
#ifdef BOOTLOADER_HIGH
40+
#define USB_PRODUCT_STRING "DAPBoot High-Memory DFU Bootloader"
41+
#else
42+
#define USB_PRODUCT_STRING "DAPBoot DFU Bootloader"
43+
#endif
44+
45+
#endif
46+
47+
#ifndef USB_INTERFACE_STRING
48+
#define USB_INTERFACE_STRING "DAPBoot DFU"
49+
#endif
50+
3251
#define USB_CONTROL_BUF_SIZE 1024
3352
#define USB_SERIAL_NUM_LENGTH 24
3453
#define INTF_DFU 0

0 commit comments

Comments
 (0)