From 169f21fbb158a07ee628d86f3c20339fcf490939 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 25 Mar 2013 20:58:33 +0000 Subject: Add Long File Name (VFAT) entry to the Mass Storage class bootloader, so that systems such as Linux that load a VFAT filesystem driver instead of the legacy MSDOS filesystem do not corrupt the volume by trying to write a LFN entry. --- Bootloaders/MassStorage/Lib/VirtualFAT.c | 71 ++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 18 deletions(-) (limited to 'Bootloaders/MassStorage/Lib/VirtualFAT.c') diff --git a/Bootloaders/MassStorage/Lib/VirtualFAT.c b/Bootloaders/MassStorage/Lib/VirtualFAT.c index e0541f436..c0d9786ee 100644 --- a/Bootloaders/MassStorage/Lib/VirtualFAT.c +++ b/Bootloaders/MassStorage/Lib/VirtualFAT.c @@ -72,33 +72,68 @@ static const FATBootBlock_t BootBlock = }; /** FAT 8.3 style directory entry, for the virtual FLASH contents file. */ -static FATDirectoryEntry_t FirmwareFileEntries[2] = +static FATDirectoryEntry_t FirmwareFileEntries[] = { /* Root volume label entry; disk label is contained in the Filename and * Extension fields (concatenated) 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, + .MSDOS = + { + .Filename = "LUFA BOO", + .Extension = "T ", + .Attributes = FAT_FLAG_VOLUME_NAME, + .Reserved = {0}, + .CreationTime = 0, + .CreationDate = 0, + .StartingCluster = 0, + .FileSizeBytes = 0, + } }, - /* File entry for the virtual Firmware image. */ + /* VFAT Long File Name entry for the virtual firmware file; required to + * prevent corruption of systems that are unable to detect the device + * as being a legacy MSDOS style FAT12 volume to prevent corruption. */ { - .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, + .VFAT = + { + .Ordinal = FAT_ORDINAL_LAST_ENTRY | 1, + .Attribute = FAT_FLAG_LONG_FILE_NAME, + .Reserved1 = 0, + .Reserved2 = 0, + + .Checksum = 0x57, + + .Unicode1 = 'F', + .Unicode2 = 'I', + .Unicode3 = 'R', + .Unicode4 = 'M', + .Unicode5 = 'W', + .Unicode6 = 'A', + .Unicode7 = 'R', + .Unicode8 = 'E', + .Unicode9 = '.', + .Unicode10 = 'B', + .Unicode11 = 'I', + .Unicode12 = 'N', + .Unicode13 = 0, + } + }, + + /* MSDOS file entry for the virtual Firmware image. */ + { + .MSDOS = + { + .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, + } }, }; -- cgit v1.2.3