diff options
author | Sebastian Holzapfel <seb.holzapfel@data61.csiro.au> | 2018-02-06 14:33:59 +0300 |
---|---|---|
committer | Karl Palsson <karlp@tweak.net.au> | 2018-03-03 01:42:05 +0300 |
commit | 64a6f362b891cd4b1ff028a7ebddc1ac48350fdd (patch) | |
tree | ae0ecb4b814440b64e77320861254bc5c403cf47 /lib/usb | |
parent | f871e539ed9453a9a4e93847a39d23e5a28acea5 (diff) |
usb-msc: fix write acknowledgement bug
Fixes https://github.com/libopencm3/libopencm3/issues/409
Diffstat (limited to 'lib/usb')
-rw-r--r-- | lib/usb/usb_msc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/usb/usb_msc.c b/lib/usb/usb_msc.c index ba18b49c..0b8c6133 100644 --- a/lib/usb/usb_msc.c +++ b/lib/usb/usb_msc.c @@ -594,6 +594,21 @@ static void msc_data_rx_cb(usbd_device *usbd_dev, uint8_t ep) trans->current_block++; } } + + /* Fix "writes aren't acknowledged" bug on Linux (PR #409) */ + if (false == trans->csw_valid) { + scsi_command(ms, trans, EVENT_NEED_STATUS); + trans->csw_valid = true; + } + left = sizeof(struct usb_msc_csw) - trans->csw_sent; + if (0 < left) { + max_len = MIN(ms->ep_out_size, left); + p = &trans->csw.buf[trans->csw_sent]; + len = usbd_ep_write_packet(usbd_dev, ms->ep_in, p, + max_len); + trans->csw_sent += len; + } + } else if (trans->byte_count < trans->bytes_to_write) { if (0 < trans->block_count) { if ((0 == trans->byte_count) && (NULL != ms->lock)) { |