Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions legacy/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ FPUFLAGS ?= -msoft-float
DEVICEFLAG ?= -D GD32F470
CFLAGS += $(DEVICEFLAG)

# USB control callback configuration
MAX_USB_CALLBACKS ?= 6
CFLAGS += -DMAX_USER_CONTROL_CALLBACK=$(MAX_USB_CALLBACKS)

ifeq ($(MAC_OS), 1)
CONFFLAG ?= -DCONFIDENTIAL='__attribute__((used)) __attribute__((section("__CONFIDENTIAL,__confidential")))'
Expand Down
6 changes: 3 additions & 3 deletions legacy/bootloader/usb_desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static const struct usb_device_descriptor dev_descr = {
.bMaxPacketSize0 = 64,
.idVendor = 0x1209,
.idProduct = 0x53c0,
.bcdDevice = 0x0100,
.bcdDevice = 0x0101,
.iManufacturer = 1,
.iProduct = 2,
.iSerialNumber = 3,
Expand Down Expand Up @@ -71,7 +71,7 @@ static const struct usb_config_descriptor config = {
};

static const char *usb_strings[] = {
"ByteForge",
"ONEKEY",
"OneKey",
"Classic",
"000000000000000000000000",
};
14 changes: 7 additions & 7 deletions legacy/firmware/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@
#endif

#define USB_STRINGS \
X(MANUFACTURER, "ByteForge") \
X(PRODUCT, "ONEKEY CLASSIC") \
X(MANUFACTURER, "OneKey") \
X(PRODUCT, "Classic") \
X(SERIAL_NUMBER, config_uuid_str) \
X(INTERFACE_MAIN, "ONEKEY Interface") \
X(INTERFACE_DEBUG, "ONEKEY Debug Link Interface") \
X(INTERFACE_U2F, "ONEKEY U2F Interface")
X(INTERFACE_MAIN, "OneKey Interface") \
X(INTERFACE_DEBUG, "OneKey Debug Link Interface") \
X(INTERFACE_FIDO, "OneKey FIDO Interface")

#define X(name, value) USB_STRING_##name,
enum {
Expand Down Expand Up @@ -109,7 +109,7 @@ static struct usb_device_descriptor dev_descr = {
.bMaxPacketSize0 = USB_PACKET_SIZE,
.idVendor = 0x1209,
.idProduct = 0x4F4B,
.bcdDevice = 0x0100,
.bcdDevice = 0x0101,
.iManufacturer = USB_STRING_MANUFACTURER,
.iProduct = USB_STRING_PRODUCT,
.iSerialNumber = USB_STRING_SERIAL_NUMBER,
Expand Down Expand Up @@ -184,7 +184,7 @@ static const struct usb_interface_descriptor hid_iface_u2f[] = {{
.bInterfaceClass = USB_CLASS_HID,
.bInterfaceSubClass = 0,
.bInterfaceProtocol = 0,
.iInterface = USB_STRING_INTERFACE_U2F,
.iInterface = USB_STRING_INTERFACE_FIDO,
.endpoint = hid_endpoints_u2f,
.extra = &hid_function_u2f,
.extralen = sizeof(hid_function_u2f),
Expand Down
6 changes: 5 additions & 1 deletion legacy/script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ vendor/trezor-common/tools/cointool.py render firmware/fido2
if [ "$EMULATOR" = 1 ]; then
make -C emulator
else
make -C vendor/libopencm3 lib/gd32/f4xx
# Pass MAX_USER_CONTROL_CALLBACK to libopencm3 build
# Read value from Makefile.include to keep it in sync
MAX_USB_CALLBACKS=$(grep "^MAX_USB_CALLBACKS" Makefile.include | cut -d'=' -f2 | tr -d ' ?')
MAX_USB_CALLBACKS=${MAX_USB_CALLBACKS:-6} # Default to 6 if not found
CFLAGS="-DMAX_USER_CONTROL_CALLBACK=$MAX_USB_CALLBACKS" make -C vendor/libopencm3 lib/gd32/f4xx
fi
make -C vendor/libsol
rm layout.o || true
Expand Down
6 changes: 6 additions & 0 deletions legacy/usb_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ LGPL License Terms @ref lgpl_license
#ifndef __USB_PRIVATE_H
#define __USB_PRIVATE_H

/* Allow override via compiler flag -DMAX_USER_CONTROL_CALLBACK=N */
#ifndef MAX_USER_CONTROL_CALLBACK
#define MAX_USER_CONTROL_CALLBACK 4
#endif

#ifndef MAX_USER_SET_CONFIG_CALLBACK
#define MAX_USER_SET_CONFIG_CALLBACK 4
#endif

/** Internal collection of device information. */
struct _usbd_device {
Expand Down
6 changes: 6 additions & 0 deletions legacy/winusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ static void winusb_set_config(usbd_device *usbd_dev, uint16_t wValue) {
usbd_register_control_callback(usbd_dev, USB_REQ_TYPE_VENDOR,
USB_REQ_TYPE_TYPE,
winusb_control_vendor_request);

/* Re-register descriptor callback for MS OS String Descriptor (0xEE)
* This is needed because SET_CONFIGURATION clears all user callbacks */
usbd_register_control_callback(usbd_dev, USB_REQ_TYPE_DEVICE,
USB_REQ_TYPE_RECIPIENT,
winusb_descriptor_request);
}

void winusb_setup(usbd_device *usbd_dev, uint8_t interface) {
Expand Down
2 changes: 1 addition & 1 deletion vendor/libopencm3
Loading