Closed aamcampbell closed 9 years ago
The correct value to pass to readsector()
and writesector()
is (ullSectorStart + ulSectorIdx)
. This change has been made to both the DiskRead()
and DiskWrite()
methods. See commit 9104a7ed (Trunk Build 665).
The FreeRTOS F_DRIVER block device read and write functions use the wrong variable(s) for the sector index.
From os/freertos/services/osbdev.c, line 478 (
DiskRead()
):Line 534 contains similar logic for the
DiskWrite()
function.The F_DRIVER
readsector
andwritesector
methods can only handle one sector at a time, so they are called from within afor
loop so that multiple sectors can be transferred by the RedOsBDevRead and Write methods. The loop iterator isulSectorIdx
, which is correctly used to find the write place in the given buffer. However, the loop iterator is ignored when determining the sector number pass toreadsector
andwritesector
. Instead,(ullSectorStart + ulSectorCount)
is passed as the sector number.The values of
ullSectorStart
andulSectorCount
are not modified within the loop. For multi-sector transfers, this means that the same sector will be read or written repetitively instead of the expected number of sectors being transferred to or from the disk. Furthermore, the sector being accessed is always one beyond the end of the requested transfer, which affects single-sector transfers as well. For example, on single-sector transfers (ulSectorCount
= 1), the desired sector is atullSectorStart
, butullSectorStart + 1
is used as the sector number.The FreeRTOS BDEV_F_DRIVER implementations of DiskRead and DiskWrite (os/freertos/services/osbdev.c) are affected by this bug. Other block device service implementations are not affected.
This issue report is for documentation purposes only; the bug has already been fixed.