aboutsummaryrefslogtreecommitdiffstats
path: root/Bootloaders
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2013-03-10 19:53:48 +0000
committerDean Camera <dean@fourwalledcubicle.com>2013-03-10 19:53:48 +0000
commit68c317c4e9b54843fdafa5b0ab1eb19e8ffc37c3 (patch)
tree7881f2e51e0a0d06ab06db6014958399d1e7c533 /Bootloaders
parentde9d05f32a8f6ea8e10f601bcbb0bcbcea0975d1 (diff)
downloadlufa-68c317c4e9b54843fdafa5b0ab1eb19e8ffc37c3.tar.gz
lufa-68c317c4e9b54843fdafa5b0ab1eb19e8ffc37c3.tar.bz2
lufa-68c317c4e9b54843fdafa5b0ab1eb19e8ffc37c3.zip
Fix off-by-one error in the Mass Storage bootloader file size, add missing Volume Label directory entry. Remove incorrect reference to "printer" in the bootloader documentation.
Diffstat (limited to 'Bootloaders')
-rw-r--r--Bootloaders/MassStorage/BootloaderMassStorage.txt2
-rw-r--r--Bootloaders/MassStorage/Lib/VirtualFAT.c42
-rw-r--r--Bootloaders/MassStorage/Lib/VirtualFAT.h2
3 files changed, 32 insertions, 14 deletions
diff --git a/Bootloaders/MassStorage/BootloaderMassStorage.txt b/Bootloaders/MassStorage/BootloaderMassStorage.txt
index 032e28010..7ca7c1f85 100644
--- a/Bootloaders/MassStorage/BootloaderMassStorage.txt
+++ b/Bootloaders/MassStorage/BootloaderMassStorage.txt
@@ -57,7 +57,7 @@
*
* \section Sec_Installation Driver Installation
*
- * This bootloader uses the Mass Storage printer drivers inbuilt into all modern operating systems, thus no additional
+ * This bootloader uses the Mass Storage drivers inbuilt into all modern operating systems, thus no additional
* drivers need to be supplied for correct operation.
*
* \section Sec_HostApp Host Controller Application
diff --git a/Bootloaders/MassStorage/Lib/VirtualFAT.c b/Bootloaders/MassStorage/Lib/VirtualFAT.c
index 0bcda0620..024c4a6f0 100644
--- a/Bootloaders/MassStorage/Lib/VirtualFAT.c
+++ b/Bootloaders/MassStorage/Lib/VirtualFAT.c
@@ -72,16 +72,34 @@ static const FATBootBlock_t BootBlock =
};
/** FAT 8.3 style directory entry, for the virtual FLASH contents file. */
-static FATDirectoryEntry_t FirmwareFileEntry =
+static FATDirectoryEntry_t FirmwareFileEntries[2] =
{
- .Filename = "FIRMWARE",
- .Extension = "BIN",
- .Attributes = 0,
- .Reserved = {0},
- .CreationTime = FAT_TIME(1, 1, 0),
- .CreationDate = FAT_DATE(14, 2, 1989),
- .StartingCluster = 2,
- .FileSizeBytes = FIRMWARE_FILE_SIZE_BYTES,
+ /* Root volume label entry; disk label is contained in the Filename and
+ * Extension fields (concantenated) with a special attribute flag - other
+ * fields are ignored. Should be the same as the label in the boot block.
+ */
+ {
+ .Filename = "LUFA BOO",
+ .Extension = "T ",
+ .Attributes = (1 << 3),
+ .Reserved = {0},
+ .CreationTime = 0,
+ .CreationDate = 0,
+ .StartingCluster = 0,
+ .FileSizeBytes = 0,
+ },
+
+ /* File entry for the virtual Firmware image. */
+ {
+ .Filename = "FIRMWARE",
+ .Extension = "BIN",
+ .Attributes = 0,
+ .Reserved = {0},
+ .CreationTime = FAT_TIME(1, 1, 0),
+ .CreationDate = FAT_DATE(14, 2, 1989),
+ .StartingCluster = 2,
+ .FileSizeBytes = FIRMWARE_FILE_SIZE_BYTES,
+ },
};
@@ -101,8 +119,8 @@ static void UpdateFAT12ClusterEntry(uint8_t* const FATTable,
const uint16_t ChainEntry)
{
/* Calculate the starting offset of the cluster entry in the FAT12 table */
- uint8_t FATOffset = (Index * 3) / 2;
- bool UpperNibble = (((Index * 3) % 2) != 0);
+ uint8_t FATOffset = (Index + (Index >> 1));
+ bool UpperNibble = ((Index & 1) != 0);
/* Check if the start of the entry is at an upper nibble of the byte, fill
* out FAT12 entry as required */
@@ -195,7 +213,7 @@ static void ReadVirtualBlock(const uint16_t BlockNumber)
break;
case 3: /* Block 3: Root file entries */
- memcpy(BlockBuffer, &FirmwareFileEntry, sizeof(FATDirectoryEntry_t));
+ memcpy(BlockBuffer, FirmwareFileEntries, sizeof(FirmwareFileEntries));
break;
default: /* Blocks 4 onwards: Data allocation section */
diff --git a/Bootloaders/MassStorage/Lib/VirtualFAT.h b/Bootloaders/MassStorage/Lib/VirtualFAT.h
index af4548898..16b4b738d 100644
--- a/Bootloaders/MassStorage/Lib/VirtualFAT.h
+++ b/Bootloaders/MassStorage/Lib/VirtualFAT.h
@@ -39,7 +39,7 @@
/* Macros: */
/** Size of the virtual FIRMWARE.BIN file in bytes. */
- #define FIRMWARE_FILE_SIZE_BYTES (FLASHEND - (FLASHEND - BOOT_START_ADDR) + 1UL)
+ #define FIRMWARE_FILE_SIZE_BYTES (FLASHEND - (FLASHEND - BOOT_START_ADDR))
/** Number of sectors that comprise a single logical disk cluster. */
#define SECTOR_PER_CLUSTER 4