psx.wiki

FAT (Memory Card File System)

File system of the Memory Card and the PDA.

FAT (Memory Card File System)
Capacity1 Mbit (128 KB)
Block size8 KB
Sector size128 bytes

This is an old revision of this page, as edited by RemmyLee at 02:47, 23 October 2026. Edit this revision | Latest revision

Overview

A Memory Card contains 1 Mbit (128 KB) of flash memory and is organized in blocks of 8 KB. The card is managed with an independent file system known as the FAT, and PDA application data is also managed in the blocks. Writes to flash memory are performed in 128-byte units known as sectors, so each block holds 64 sectors (8192 bytes / 128 bytes).1

Block Layout

Block 0 holds the FAT, and blocks 1 to 15 hold data:1

Table 1: Layout of Memory Card blocks
Block No. Contents
0 FAT block
1 Data block 1
2..14 Data blocks 2 to 14
15 Data block 15

FAT Block

The 64 sectors of the FAT block are assigned as follows:1

Table 2: FAT block memory map
Sector No. Contents
0 Format ID sector
1..15 Block information sectors 1 to 15
16..35 Alternate information sectors 1 to 20
36..55 Alternate sectors 1 to 20
56..62 Reserved sectors 1 to 7
63 Dummy write sector

Format ID Sector

The first 2 bytes of the format ID are 'M' and 'C', and the remaining bytes are 0 except for the checksum in the 128th byte. When the first 2 bytes are 'MC' the card is identified as a formatted Memory Card. Otherwise it is considered unformatted.2

Block Information Sector

Each data block has one block information sector, whose first field gives the state of the block. The sector has the following structure:2

Table 3: Structure of block information sector
Contents Data type Size (bytes)
Block list information unsigned long 4
File size long 4
Next block unsigned short 2
Filename char x 21 21
Reserved unsigned char 1
Unused 94
PDA application unsigned char 1
Checksum unsigned char 1

The block list information takes the following values:2

Table 4: Meaning of block list information
Value Contents
51 Header block
52 Intermediate block
53 End block
A0 Free block
A1 Header block with delete mark
A2 Intermediate block with delete mark
A3 End block with delete mark

Immediately after formatting, every block list information field is A0. When a file is created its blocks take the values 51 to 53, and when it is deleted they take the values A1 to A3. A deleted file can therefore be restored by restoring the original values. However, a file created after a deletion can break the chain from header block to end block. In this case the next FAT read sets every block of the broken chain to A0.2

A file of 1 block has only the value 51 (or A1). A file of 2 blocks has 51 and 53 (or A1 and A3), and in this case no block has the value 52 (or A2).2

Block Information Fields

File size is in bytes. It is computed as the number of blocks specified when the file is created times 8192 bytes.3

When a file spans several blocks, Next block holds a pointer to the next block that is 1 less than the block number. Blocks 1 to 15 are therefore stored as 0 to 14, and 0xFFFF is stored when there is no next block. Filename holds the file name, and the string must end with a NULL (0x00).3

McxExecFlag() sets the PDA application flag to 1 for a PDA application, and the flag is cleared otherwise. libcard and libmcrd do not copy this flag. Consequently a PDA application that is copied, rather than downloaded from the PlayStation, has the flag set to 0.3

The checksum in the last byte is the XOR of the first 127 bytes of the sector.3

Alternate Sectors

An alternate information sector holds a substituted sector number and a checksum. When a sector is named in an alternate information sector, the alternate sector of the same number is used in its place. For example, if alternate information sector 3 contains 123, a read or write of sector 123 goes to alternate sector 3 instead.3

The alternate sector holds the data of the sector it replaces. The dummy write sector is used for dummy writes that clear unidentified flags.3

FAT Operation

The format operation sets up each sector as shown in the following table (hex). In each row the sum in byte 127 is the XOR of bytes 0 to 126. Sectors from alternate sector 1 to the dummy write sector need no initial value.345

Table 5: State of formatted FAT
Target sector 0 1 2 3 4..7 8 9 10..126 127
0 4D 43 00 00 00 00 00 00 sum
1..15 A0 00 00 00 00 FF FF 00 sum
16..35 FF FF FF FF 00 FF FF 00 sum

The delete operation changes the high-order 4 bits of the first byte of each block information sector of the file from 5 to A. The undelete operation changes them back from A to 5 and thereby restores the file. Both operations leave all other data unchanged except the checksum.4

PDA Processing

A write to the FAT sector of a block that holds a running PDA application is inhibited, and an error is generated. The library takes this state to mean that the Memory Card has been swapped.4

While the libmcx command "display while transferring file" runs, writes to the alternate information sectors (16 to 35) and the alternate sectors (36 to 55) are disabled. An attempt to write to them generates an error.4

References


  1. ^ a b c Sony Computer Entertainment Inc. File Formats. November 1998. Page 5-3, Tables 5-1 and 5-2.

  2. ^ a b c d e Sony Computer Entertainment Inc. File Formats. November 1998. Page 5-4, Tables 5-3 and 5-4.

  3. ^ a b c d e f g Sony Computer Entertainment Inc. File Formats. November 1998. Page 5-5, Table 5-5.

  4. ^ a b c d Sony Computer Entertainment Inc. File Formats. November 1998. Page 5-6.

  5. ^ Sony Computer Entertainment Inc. File Formats. November 1998. Page 5-7.

Categories: File formats