Skip to content

Commit 9d374f8

Browse files
committed
mstorage.c: fix the issue that _read_capacity() returns the wrong last valid address of storage medium
1 parent baa3145 commit 9d374f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

components/drivers/usb/usbdevice/class/mstorage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ static rt_size_t _read_capacity(ufunction_t func, ustorage_cbw_t cbw)
426426

427427
data = (struct mstorage*)func->user_data;
428428
buf = data->ep_in->buffer;
429-
sector_count = data->geometry.sector_count;
429+
sector_count = data->geometry.sector_count - 1; /* Last Logical Block Address */
430430
sector_size = data->geometry.bytes_per_sector;
431431

432432
buf[0] = sector_count >> 24;

0 commit comments

Comments
 (0)