FSCreateMBR Function

MDD File System Interface Library

MDDFS Interface Library Help
FSCreateMBR Function
C
int FSCreateMBR(
    unsigned long firstSector, 
    unsigned long numSectors
);
Description

This function can be used to create a master boot record for a device. Note that this function should not be used on a device that is already formatted with a master boot record (i.e. most SD cards, CF cards, USB keys). This function will fill the global data buffer with appropriate partition information for a FAT partition with a type determined by the number of sectors available to the partition. It will then write the MBR information to the first sector on the device. This function should be followed by a call to FSformat, which will create a boot sector, root dir, and FAT appropriate the the information contained in the new master boot record. Note that FSformat only supports FAT12 and FAT16 formatting at this time, and so cannot be used to format a device with more than 0x3FFD5F sectors.

Preconditions

The I/O pins for the device have been initialized by the InitIO function.

Parameters
Parameters 
Description 
firstSector 
The first sector of the partition on the device (cannot be 0; that's the MBR
numSectors 
The number of sectors available in memory (including the MBR
Return Values
Return Values 
Description 
MBR was created successfully 
EOF 
MBR could not be created 
Side Effects

None

Remarks

This function can damage the device being used, and should not be called unless the user is sure about the size of the device and the first sector value.

Microchip MDD File System Interface 1.4.2 - [Oct 15, 2012]
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.