This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 8d1a49d96 tinyusb/msc_fat_view: Add support for bigger buffer
8d1a49d96 is described below
commit 8d1a49d962f6e2af8a7acb6095ed3e4183f57705
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Fri Mar 13 19:38:11 2026 +0100
tinyusb/msc_fat_view: Add support for bigger buffer
So far msc_fat_view assumed that buffer size for
read and writes is 512 bytes.
Now it can utilized bigger buffers.
Buffer size can be set by syscfg value
USBD_MSC_EP_BUFSIZE.
Setting this to bigger size can improve performance.
Signed-off-by: Jerzy Kasenberg <[email protected]>
Signed-off-by: Jerzy Kasenberg <[email protected]>
---
hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c | 29 +++++++++++++++-----------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c
b/hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c
index 83decb292..5c825a429 100644
--- a/hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c
+++ b/hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c
@@ -1383,7 +1383,12 @@ tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t
offset, void *buffer, uint
if (medium_state < MEDIUM_RELOAD) {
return -1;
}
- msc_fat_view_read_sector(lba, buffer);
+ MSC_FAT_VIEW_LOG_DEBUG("SCSI READ10 %d, %d, %d\n", (int)lba, (int)offset,
+ (int)bufsize);
+
+ for (uint32_t i = 0; i < bufsize; i += SECTOR_SIZE, ++lba) {
+ msc_fat_view_read_sector(lba, (uint8_t *)buffer + i);
+ }
return bufsize;
}
@@ -1397,7 +1402,6 @@ tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t
offset, uint8_t *buffer,
{
int32_t res;
MSC_FAT_VIEW_LOG_DEBUG("SCSI WRITE10 %d, %d, %d\n", (int)lba, (int)offset,
(int)bufsize);
- assert(bufsize == SECTOR_SIZE);
assert(offset == 0);
last_scsi_command = SCSI_CMD_WRITE_10;
@@ -1408,17 +1412,18 @@ tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t
offset, uint8_t *buffer,
return -1;
}
- if (lba == 0) {
- res = bufsize;
- /* Ignore writes to boot sector */
- } else if (lba < FAT_ROOT_DIR_FIRST_SECTOR) {
- res = msc_fat_view_write_fat_sector(lba - FAT_FIRST_SECTOR, buffer);
- } else if (lba < FAT_CLUSTER2_FIRST_SECTOR) {
- res = msc_fat_view_write_root_sector(lba - FAT_ROOT_DIR_FIRST_SECTOR,
buffer);
- } else {
- res = msc_fat_view_write_normal_sector(lba, buffer);
+ for (res = 0; res + SECTOR_SIZE <= bufsize; res += SECTOR_SIZE, ++lba) {
+ if (lba == 0) {
+ /* Ignore writes to boot sector */
+ } else if (lba < FAT_ROOT_DIR_FIRST_SECTOR) {
+ msc_fat_view_write_fat_sector(lba - FAT_FIRST_SECTOR, buffer +
res);
+ } else if (lba < FAT_CLUSTER2_FIRST_SECTOR) {
+ msc_fat_view_write_root_sector(lba - FAT_ROOT_DIR_FIRST_SECTOR,
+ buffer + res);
+ } else {
+ msc_fat_view_write_normal_sector(lba, buffer + res);
+ }
}
-
return res;
}