Skip to content

Commit

Permalink
Merge remote-tracking branch 'microsoft/master' into microsoft_update…
Browse files Browse the repository at this point in the history
…_20180205
  • Loading branch information
dhalbert committed Feb 7, 2018
2 parents 38cb858 + a8f76e5 commit 2e78722
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 72 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,6 @@ drop-pkg:
rm -rf build/uf2-samd21-$(UF2_VERSION_BASE)

all-boards:
for f in `cd boards; ls` ; do $(MAKE) BOARD=$$f drop-board ; done
for f in `cd boards; ls` ; do "$(MAKE)" BOARD=$$f drop-board ; done

drop: all-boards drop-pkg
8 changes: 1 addition & 7 deletions inc/uf2.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#define INDEX_URL "https://www.pxt.io/"
#endif

#ifndef WEBUSB_URL
#define WEBUSB_URL "pxt.io"
#endif

#include "uf2_version.h"

// needs to be more than ~4200 (to force FAT16)
Expand All @@ -55,9 +51,7 @@
// Support Human Interface Device (HID) - serial, flashing and debug
#define USE_HID 1 // 788 bytes
// Expose HID via WebUSB
#define USE_WEBUSB 0
// Return allowed WebUSB URLs; it seems to have been removed from the standard
#define USE_WEBUSB_ORIGINS 0
#define USE_WEBUSB 1
// Doesn't yet disable code, just enumeration
#define USE_MSC 1

Expand Down
66 changes: 2 additions & 64 deletions src/cdc_enumerate.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static char bosDescriptor[] = {
0x8B, 0xFD, 0xA0, 0x76, 0x88, 0x15, 0xB6, 0x65, // WebUSB GUID
0x00, 0x01, // Version 1.0
0x01, // Vendor request code
0x01, // landing page
0x00, // landing page

0x1C, // Length
0x10, // Device Capability descriptor
Expand Down Expand Up @@ -356,39 +356,6 @@ static char msOS20Descriptor[] = {

STATIC_ASSERT(sizeof(msOS20Descriptor) == WINUSB_SIZE);

#if USE_WEBUSB_ORIGINS
#define ALLOWED_ORIGINS_SEQ 1, 2
static const char *allowed_origins[] = {"localhost:3232", "samd.pxt.io"};

#define NUM_ALLOWED_ORIGINS 2
static const uint8_t allowedOriginsDesc[] = {
// Allowed Origins Header, bNumConfigurations = 1
0x05,
0x00,
0x0c + NUM_ALLOWED_ORIGINS,
0x00,
0x01,
// Configuration Subset Header, bNumFunctions = 1
0x04,
0x01,
0x01,
0x01,
// Function Subset Header, bFirstInterface = pluggedInterface
0x03 + NUM_ALLOWED_ORIGINS,
0x02,
WEB_IF_NUM,
ALLOWED_ORIGINS_SEQ,
};

STATIC_ASSERT((sizeof(allowed_origins) / sizeof(allowed_origins[0])) == NUM_ALLOWED_ORIGINS);
STATIC_ASSERT(sizeof(allowedOriginsDesc) == 0x0c + NUM_ALLOWED_ORIGINS);
#endif

typedef struct {
uint8_t len, tp, scheme;
uint8_t buf[64];
} __attribute__((packed)) WebUSB_URL;

#endif

static uint8_t currentConfiguration;
Expand Down Expand Up @@ -835,36 +802,7 @@ void AT91F_CDC_Enumerate() {
break;
#if USE_WEBUSB
case STD_VENDOR_CTRL1:
#if USE_WEBUSB_ORIGINS
if (wIndex == 0x01)
sendCtrl(allowedOriginsDesc, sizeof(allowedOriginsDesc));
else if (wIndex == 0x02) {
WebUSB_URL url;
uint32_t idx = (uint32_t)ctrlOutCache.buf[2] - 1;
if (idx >= NUM_ALLOWED_ORIGINS)
stall_ep(0);
url.len = strlen(allowed_origins[idx]) + 3;
url.tp = 3;
// first URL is http, rest is https
url.scheme = idx == 0 ? 0 : 1;
memcpy(url.buf, allowed_origins[idx], url.len - 3);
sendCtrl(&url, url.len);
} else {
stall_ep(0);
}
#else
if (wIndex == 0x02 && ctrlOutCache.buf[2] == 0x01) {
WebUSB_URL url;
url.len = strlen(WEBUSB_URL) + 3;
url.tp = 3;
// first URL is http, rest is https
url.scheme = 1;
memcpy(url.buf, WEBUSB_URL, url.len - 3);
sendCtrl(&url, url.len);
} else {
stall_ep(0);
}
#endif
stall_ep(0);
break;
case STD_VENDOR_CTRL2:
if (wIndex == 0x07)
Expand Down

0 comments on commit 2e78722

Please sign in to comment.