User`s manual

Dynamic C Users Manual digi.com 167
The memset() function is used to initialize the entry to zero. The values for starthead and endhead
should be 0xFE to indicate that the media uses LBA (Logical Block Addressing) instead of head and cylin-
der addressing. The FAT library uses LBA internally. The values for the startsector, partsecsize
and parttype fields determine where the partition starts, how many sectors it contains and what parti-
tion type it is. The number of sectors in the partition is calculated by dividing the number of raw bytes in
the partition by the sector size of the flash. The number of raw bytes in the partition includes not only
bytes for file storage, but also the space needed by the BPB and the root directory. One is added to dev-
>partsecsize to ensure an extra sector is assigned if MY_PARTITION_SIZE is not evenly divisible
by the size of a flash sector. The partition type (.parttype) is determined by the partition size: 1 indi-
cates FAT12 and 6 indicates FAT16. Fill in an mbr_part structure for each partition you are creating.
The remaining entries should be zeroed out.
When laying out partitions, there are three basic checks to make sure the partitions fit in the available
device space and do not overlap.
1. No partition can start on a sector less than 1.
2. Each partition resides on sectors from startsector through startsector+partsecsize-1.
No other partition can have a startsector value within that range.
3. No partition ending sector (startsector+partsecsize-1) can be greater than or equal to the
total sectors on the device.
The partition boundaries are validated in the call to fat_FormatDevice() and the function will return
an error if any of the partition boundaries are invalid. If fat_FormatDevice() returns success, then
call fat_AutoMount() with flags of FDDF_COND_PART_FORMAT | FDDF_MOUNT_DEV_# |
FDDF_MOUNT_PART_ALL; where # is the device number for the device being partitioned. This will for-
mat and mount the newly created partitions.
10.2.5.4 Directory and File Names
File and directory names are limited to 8 characters followed by an optional period (.) and an extension of
up to 3 characters. The characters may be any combination of letters, digits, or characters with code point
values greater than 127. The following special characters are also allowed:
$ % ' - _ @ ~ ` ! ( ) { } ^ # &
File names passed to the file system are always converted to upper case; the original case value is lost.
The maximum size of a directory is limited by the available space. It is recommended that no more than
ten layers of directories be used with the Dynamic C FAT file system.
memset(dev->part, 0, sizeof(mbr_part));
dev->part[0].starthead = 0xFE;
dev->part[0].endhead = 0xFE;
dev->part[0].startsector = 1;
dev->part[0].partsecsize = (MY_PARTITION_SIZE / 512 ) + 1;
dev->part[0].parttype = (dev->part[0].partsecsize < SEC_2MB) ? 1 : 6;