psx.wiki

FAT (Memory Card File System): Difference between revisions

Revision as of 02:22, 23 October 2026
RemmyLee
(Hardware and system software pages from the Sony manuals)
Revision as of 02:27, 23 October 2026
RemmyLee
(File format pages from the Sony File Formats manual)
Line 1:Line 1:
+---
+title: FAT (Memory Card File System)
+type: format
+summary: File system of the Memory Card and the PDA.
+category: File formats
+info: Capacity = 1 Mbit (128 KB)
+info: Block size = 8 KB
+info: Sector size = 128 bytes
+---
+
+## Overview
+
+A Memory Card holds 1 Mbit (128 KB) of flash memory. The memory is organized in blocks of 8 KB.[^ff53]
+
+The Memory Card is managed with its own file system. Sony calls it the FAT. PDA application data is also managed in the blocks.[^ff53]
+
+Writes to flash memory are made in 128-byte units known as sectors. Each block has 64 sectors.[^ff53]
+
+## Block Layout
+
+The blocks of a Memory Card are as follows:[^ff53]
+
+Table: 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 sectors of the FAT block are as follows:[^ff53]
+
+Table: 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'. The remaining bytes are 0 up to the checksum in the 128th byte.[^ff54]
+
+A card whose first 2 bytes are 'MC' is a formatted Memory Card. Any other card is unformatted.[^ff54]
+
+### Block Information Sector
+
+Each data block has one block information sector:[^ff54]
+
+Table: 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 gives the state of the block:[^ff54]
+
+Table: 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 |
+
+Formatting sets every block list information field to A0. A new file gets the values 51 to 53.[^ff54]
+
+A deleted file keeps its blocks with the values A1 to A3. Restoring the original values restores the file.[^ff54]
+
+A new file can break the chain from header block to end block.[^ff54]
+
+The next FAT read then sets every block of the broken chain to A0.[^ff54]
+
+A 1-block file has only the value 51 (or A1). A 2-block file has 51 and 53 (or A1 and A3) and no 52.[^ff54]
+
+### Block Information Fields
+
+File size is in bytes. It equals 8192 bytes times the number of blocks given when the file is created.[^ff55]
+
+Next block points to the next block of a file.[^ff55]
+
+The pointer is 1 less than the block number. Blocks 1 to 15 are stored as 0 to 14.[^ff55]
+
+Next block is 0xFFFF when there is no next block.[^ff55]
+
+Filename holds the file name. The string ends with a NULL (0x00).[^ff55]
+
+McxExecFlag() sets the PDA application flag to 1 for a PDA application. Otherwise the flag is clear.[^ff55]
+
+libcard and libmcrd do not copy the PDA application flag. A PDA application copied from the PlayStation has the flag set to 0.[^ff55]
+
+The checksum is the XOR of the first 127 bytes of the sector.[^ff55]
+
+### Alternate Sectors
+
+An alternate information sector holds a substituted sector number and a checksum.[^ff55]
+
+The alternate sector replaces the sector named in its alternate information sector.[^ff55]
+
+If alternate information sector 3 holds 123, reads and writes of sector 123 go to alternate sector 3.[^ff55]
+
+The dummy write sector takes dummy writes that clear unidentified flags.[^ff55]
+
+## FAT Operation
+
+The format operation writes the following values (hex):[^ff55]
+
+Table: 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 sum in byte 127 is the XOR of bytes 0 to 126.[^ff56]
+
+Sectors from alternate sector 1 to the dummy write sector need no initial value.[^ff57]
+
+Delete changes the high 4 bits of the first byte of each block information sector of the file from 5 to A.[^ff56]
+
+Undelete changes the same bits from A back to 5. Delete and undelete leave all other data unchanged except the checksum.[^ff56]
+
+## PDA Processing
+
+A write to the FAT sector of a block that holds a running PDA application is refused with an error.[^ff56]
+
+The library takes this state to mean that the Memory Card was swapped.[^ff56]
+
+The libmcx command "display while transferring file" disables writes to sectors 16 to 55. A write to them gives an error.[^ff56]
+
+## References
+
+[^ff53]: Sony Computer Entertainment Inc. File Formats. November 1998. Page 5-3, Tables 5-1 and 5-2.
+[^ff54]: Sony Computer Entertainment Inc. File Formats. November 1998. Page 5-4, Tables 5-3 and 5-4.
+[^ff55]: Sony Computer Entertainment Inc. File Formats. November 1998. Page 5-5, Table 5-5.
+[^ff56]: Sony Computer Entertainment Inc. File Formats. November 1998. Page 5-6.
+[^ff57]: Sony Computer Entertainment Inc. File Formats. November 1998. Page 5-7.