Skip to content

Commit

Permalink
Merge pull request #1653 from particle-iot/fix/gen3-dfu-wcid
Browse files Browse the repository at this point in the history
[Mesh] Fixes WCID in bootloader
  • Loading branch information
avtolstoy committed Jan 29, 2019
2 parents bf4aa3e + 261aa43 commit be21ee9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
17 changes: 13 additions & 4 deletions bootloader/src/nRF52840/usbd_device.cpp
Expand Up @@ -160,8 +160,8 @@ const uint8_t s_deviceDescriptor[] = {
HIBYTE(USBD_VID_SPARK), /*idVendor*/
LOBYTE(USBD_PID_DFU), /*idProduct*/
HIBYTE(USBD_PID_DFU), /*idProduct*/
LOBYTE(0x0250), /*bcdDevice (2.50) */
HIBYTE(0x0250), /*bcdDevice (2.50) */
LOBYTE(0x0251), /*bcdDevice (2.51) */
HIBYTE(0x0251), /*bcdDevice (2.51) */
Device::STRING_IDX_MANUFACTURER, /*Index of manufacturer string*/
Device::STRING_IDX_PRODUCT, /*Index of product string*/
Device::STRING_IDX_SERIAL, /*Index of serial number string*/
Expand Down Expand Up @@ -444,6 +444,7 @@ void NrfDevice::setup() {
static_assert(sizeof(SetupRequest) == sizeof(nrf_drv_usbd_setup_t), "SetupRequest and nrf_drv_usbd_setup_t are expected to be of the same size");
memcpy(&r, &setup, sizeof(r));


switch (r.bmRequestTypeRecipient) {
case SetupRequest::RECIPIENT_DEVICE: {
setupDevice(&r);
Expand Down Expand Up @@ -507,7 +508,13 @@ void NrfDevice::setupDevice(SetupRequest* r) {
}
break;
}
case SetupRequest::TYPE_VENDOR: /* FIXME */
case SetupRequest::TYPE_VENDOR:
case SetupRequest::TYPE_CLASS: {
if (drv_) {
drv_->setup(r);
}
break;
}
default: {
nrf_drv_usbd_setup_stall();
break;
Expand Down Expand Up @@ -869,7 +876,9 @@ void NrfDevice::setupReply(SetupRequest* r, const uint8_t* data, size_t size) {
bool zlpRequired = (size < r->wLength) &&
(0 == (size % nrf_drv_usbd_ep_max_packet_size_get(NRF_DRV_USBD_EPIN0)));
nrf_drv_usbd_transfer_t transfer = {
.p_data = {.tx = data},
.p_data = {
.tx = data
},
.size = txSize,
.flags = (uint32_t)(zlpRequired ? NRF_DRV_USBD_TRANSFER_ZLP_FLAG : 0)
};
Expand Down
6 changes: 3 additions & 3 deletions bootloader/src/nRF52840/usbd_dfu.cpp
Expand Up @@ -377,7 +377,7 @@ DfuMal* DfuClassDriver::currentMal() {
}

int DfuClassDriver::setup(SetupRequest* req) {
if ((req->bRequest == 0xee && req->bmRequestType == 0b11000001 && req->wIndex == 0x0005) ||
if ((req->bRequest == 0xee && req->bmRequestType == 0xc1 && req->wIndex == 0x0005) ||
(req->bRequest == 0xee && req->bmRequestType == 0xc0 && req->wIndex == 0x0004)) {
return handleMsftRequest(req);
}
Expand Down Expand Up @@ -503,7 +503,7 @@ int DfuClassDriver::inDone(uint8_t ep, unsigned status) {
}

const uint8_t* DfuClassDriver::getConfigurationDescriptor(uint16_t* length) {
*length = *((uint16_t*)cfgDesc_ + 2);
*length = *((uint16_t*)(cfgDesc_ + 2));
return cfgDesc_;
}

Expand Down Expand Up @@ -544,4 +544,4 @@ bool DfuClassDriver::checkReset() {
}
HAL_enable_irq(st);
return res;
}
}
2 changes: 0 additions & 2 deletions bootloader/src/nRF52840/usbd_wcid.h
Expand Up @@ -21,8 +21,6 @@
#define USB_WCID_DATA(...) __VA_ARGS__

#define USB_WCID_MS_OS_STRING_DESCRIPTOR(signature, code) \
0x12, /* bLength */ \
0x03, /* bDescriptorType */ \
signature, /* qwSignature */ \
code, /* MS_VendorCode */ \
0x00 /* Padding */
Expand Down

0 comments on commit be21ee9

Please sign in to comment.