Skip to content

Commit 2b6eebc

Browse files
committed
fix(class/msc/usbh_msc): when device stalls by usbh_msc_get_maxlun, ingore error and set lun=0, refs:#259
1 parent ab59bee commit 2b6eebc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

class/msc/usbh_msc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,12 @@ static int usbh_msc_connect(struct usbh_hubport *hport, uint8_t intf)
278278

279279
ret = usbh_msc_get_maxlun(msc_class, g_msc_buf[msc_class->sdchar - 'a']);
280280
if (ret < 0) {
281-
return ret;
281+
if (ret == -USB_ERR_STALL) {
282+
USB_LOG_WRN("Device does not support multiple LUNs\r\n");
283+
g_msc_buf[msc_class->sdchar - 'a'][0] = 0;
284+
} else {
285+
return ret;
286+
}
282287
}
283288

284289
USB_LOG_INFO("Get max LUN:%u\r\n", g_msc_buf[msc_class->sdchar - 'a'][0] + 1);
@@ -372,7 +377,6 @@ static int usbh_msc_disconnect(struct usbh_hubport *hport, uint8_t intf)
372377
return ret;
373378
}
374379

375-
376380
int usbh_msc_scsi_write10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors)
377381
{
378382
struct CBW *cbw;

0 commit comments

Comments
 (0)