Fix off-by-one in the VirtualFAT cluster chain generator.

This commit is contained in:
Dean Camera 2013-03-09 08:08:31 +00:00
parent 7f5dab4f26
commit 6da1677bc3
2 changed files with 2 additions and 2 deletions

View File

@ -114,7 +114,7 @@ static void ReadBlock(uint16_t BlockNumber)
}
/* Mark last cluster as end of file */
((uint16_t*)&BlockBuffer)[FILE_CLUSTERS(2049) + 3] = 0xFFFF;
((uint16_t*)&BlockBuffer)[FILE_CLUSTERS(2049) + 1] = 0xFFFF;
break;
case 3:

View File

@ -39,11 +39,11 @@
/* Macros: */
#define FIRMWARE_FILE_SIZE (FLASHEND + 1UL)
#define FILE_CLUSTERS(size) ((size / CLUSTER_SIZE_BYTES) + ((size % CLUSTER_SIZE_BYTES) ? 1 : 0))
#define SECTOR_SIZE_BYTES 512
#define SECTOR_PER_CLUSTER 4
#define CLUSTER_SIZE_BYTES (SECTOR_PER_CLUSTER * SECTOR_SIZE_BYTES)
#define FILE_CLUSTERS(size) ((size / CLUSTER_SIZE_BYTES) + ((size % CLUSTER_SIZE_BYTES) ? 1 : 0))
#define LUN_MEDIA_BLOCKS ((FIRMWARE_FILE_SIZE / SECTOR_SIZE_BYTES) + 32)