Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mesh] Fixes WCID in bootloader #1653

Merged
merged 1 commit into from Jan 29, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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