Skip to content

Commit 1ffb4d7

Browse files
update USBMSD::memoryWrite implementation
Fix prevents unaligned USB transfers
1 parent 89e67d3 commit 1ffb4d7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/source/usb/USBMSD.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,14 @@ void USBMSD::_read_next()
572572

573573
void USBMSD::memoryWrite(uint8_t *buf, uint16_t size)
574574
{
575+
// Max sized packets are required to be sent until the transfer is complete
576+
MBED_ASSERT(_block_size % MAX_PACKET == 0);
577+
if ((size != MAX_PACKET) && (size != 0)) {
578+
_stage = ERROR;
579+
endpoint_stall(_bulk_out);
580+
return;
581+
}
582+
575583
if ((_addr + size) > _memory_size) {
576584
size = _memory_size - _addr;
577585
_stage = ERROR;

0 commit comments

Comments
 (0)