Oops - ensure the SCSI transfer length is correct in the Mass Storage bootloader.
authorDean Camera <dean@fourwalledcubicle.com>
Fri, 29 Mar 2013 10:40:40 +0000 (10:40 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Fri, 29 Mar 2013 10:40:40 +0000 (10:40 +0000)
Bootloaders/MassStorage/Lib/SCSI.c
Bootloaders/MassStorage/Lib/VirtualFAT.h

index b23a5a0..eeb2c25 100644 (file)
@@ -255,14 +255,12 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
        }
 
        /* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
        }
 
        /* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
-       while (TotalBlocks--)
+       for (uint16_t i = 0; i < TotalBlocks; i++)
        {
                if (IsDataRead == DATA_READ)
        {
                if (IsDataRead == DATA_READ)
-                 VirtualFAT_ReadBlock(BlockAddress);
+                 VirtualFAT_ReadBlock(BlockAddress + i);
                else
                else
-                 VirtualFAT_WriteBlock(BlockAddress);
-
-               BlockAddress++;
+                 VirtualFAT_WriteBlock(BlockAddress + i);
        }
 
        /* Update the bytes transferred counter and succeed the command */
        }
 
        /* Update the bytes transferred counter and succeed the command */
index 58f5723..d01f9be 100644 (file)
                enum
                {
                        /** Boot sector disk block. */
                enum
                {
                        /** Boot sector disk block. */
-                       DISK_BLOCK_BootBlock        = 0,
+                       DISK_BLOCK_BootBlock          = 0,
                        /** First copy of the FAT table block. */
                        /** First copy of the FAT table block. */
-                       DISK_BLOCK_FATBlock1        = 1,
+                       DISK_BLOCK_FATBlock1          = 1,
                        /** Second copy of the FAT table block. */
                        /** Second copy of the FAT table block. */
-                       DISK_BLOCK_FATBlock2        = 2,
+                       DISK_BLOCK_FATBlock2          = 2,
                        /** Root file and directory entries block. */
                        /** Root file and directory entries block. */
-                       DISK_BLOCK_RootFilesBlock   = 3,
+                       DISK_BLOCK_RootFilesBlock     = 3,
                        /** Start block of the disk data section. */
                        /** Start block of the disk data section. */
-                       DISK_BLOCK_DataStartBlock   = 4,
+                       DISK_BLOCK_DataStartBlock     = 4,
                };
 
        /* Type Definitions: */
                };
 
        /* Type Definitions: */