|
|
|
@ -440,23 +440,38 @@ static void set_config(usbd_device *dev, uint16_t wValue) {
|
|
|
|
|
static usbd_device *usbd_dev;
|
|
|
|
|
static uint8_t usbd_control_buffer[256] __attribute__((aligned(2)));
|
|
|
|
|
|
|
|
|
|
static const struct usb_device_capability_descriptor *capabilities[] = {
|
|
|
|
|
static const struct usb_device_capability_descriptor *capabilities_landing[] = {
|
|
|
|
|
(const struct usb_device_capability_descriptor
|
|
|
|
|
*)&webusb_platform_capability_descriptor,
|
|
|
|
|
*)&webusb_platform_capability_descriptor_landing,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct usb_bos_descriptor bos_descriptor = {
|
|
|
|
|
static const struct usb_device_capability_descriptor
|
|
|
|
|
*capabilities_no_landing[] = {
|
|
|
|
|
(const struct usb_device_capability_descriptor
|
|
|
|
|
*)&webusb_platform_capability_descriptor_no_landing,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct usb_bos_descriptor bos_descriptor_landing = {
|
|
|
|
|
.bLength = USB_DT_BOS_SIZE,
|
|
|
|
|
.bDescriptorType = USB_DT_BOS,
|
|
|
|
|
.bNumDeviceCaps =
|
|
|
|
|
sizeof(capabilities_landing) / sizeof(capabilities_landing[0]),
|
|
|
|
|
.capabilities = capabilities_landing};
|
|
|
|
|
|
|
|
|
|
static const struct usb_bos_descriptor bos_descriptor_no_landing = {
|
|
|
|
|
.bLength = USB_DT_BOS_SIZE,
|
|
|
|
|
.bDescriptorType = USB_DT_BOS,
|
|
|
|
|
.bNumDeviceCaps = sizeof(capabilities) / sizeof(capabilities[0]),
|
|
|
|
|
.capabilities = capabilities};
|
|
|
|
|
.bNumDeviceCaps =
|
|
|
|
|
sizeof(capabilities_no_landing) / sizeof(capabilities_no_landing[0]),
|
|
|
|
|
.capabilities = capabilities_no_landing};
|
|
|
|
|
|
|
|
|
|
static void usbInit(void) {
|
|
|
|
|
static void usbInit(bool firmware_present) {
|
|
|
|
|
usbd_dev = usbd_init(&otgfs_usb_driver, &dev_descr, &config, usb_strings,
|
|
|
|
|
sizeof(usb_strings) / sizeof(const char *),
|
|
|
|
|
usbd_control_buffer, sizeof(usbd_control_buffer));
|
|
|
|
|
usbd_register_set_config_callback(usbd_dev, set_config);
|
|
|
|
|
usb21_setup(usbd_dev, &bos_descriptor);
|
|
|
|
|
usb21_setup(usbd_dev, firmware_present ? &bos_descriptor_no_landing
|
|
|
|
|
: &bos_descriptor_landing);
|
|
|
|
|
webusb_setup(usbd_dev, "trezor.io/start");
|
|
|
|
|
winusb_setup(usbd_dev, USB_INTERFACE_INDEX_MAIN);
|
|
|
|
|
}
|
|
|
|
@ -491,7 +506,7 @@ static void checkButtons(void) {
|
|
|
|
|
|
|
|
|
|
void usbLoop(void) {
|
|
|
|
|
bool firmware_present = firmware_present_new();
|
|
|
|
|
usbInit();
|
|
|
|
|
usbInit(firmware_present);
|
|
|
|
|
for (;;) {
|
|
|
|
|
usbd_poll(usbd_dev);
|
|
|
|
|
if (!firmware_present &&
|
|
|
|
|