Changes

Jump to navigation Jump to search
m
{{seealso|Hardware/NAND Interface}}
{{seealso|Hardware/NAND Interface}}
{{cleanup}}
The Wii contains 512 MiB of NAND flash storage, which is used to store "system software", channels (including Virtual Console titles), game saves, and system settings.
The NAND flash device is divided into 4096 blocks of 8 clusters. Each cluster is 8 pages. Each page is 2048 bytes of data and 64 bytes of "spare data" (used for error-correction (ECC) data and HMAC signatures on individual clusters).
* Block 0 (pages 0-0x3F): [[boot1]]** boot1 is the second-stage bootloader; it is decrypted by [[boot0]], which resides on a read-only mask ROM inside the [[Starlet ]] coprocessor. Its primary function is to load and decrypt [[boot2]].
** Block 0 is guaranteed by the manufacturer to be valid, so there is no bad block map necessary.
* Blocks 1-7 (Pages 0x40 - 0x1ff) : boot2 (two copies and blockmaps)
* Block 8 / Cluster 0x40 / Page 0x200: beginning of per-console unique data
* Clusters 0x40 - 0x7EFF: Encrypted filesystem data. Data is encrypted with a per-console AES key, and then signed with a (separate, per-console) HMAC key.
* Clusters 0x7F00-0x7FFF: Filesystem metadata (SFFS, unencrypted). There are 16 superblocks contained therein -- one every 16 clusters.
== Metadata layout ==
Each metadata "superblock" starts with the 4 magic bytes "SFFS", followed by a 4-byte "generation number" and another 4-byte number (always 0x10?). When accessing the FS, IOS will choose the superblock with the highest generation number and use it; whenever it modifies the filesystem in any way, it will increment the generation number by 1 and write out an entirely new superblock in the next slot (in round-robin order).
The next 0x10000 bytes (bytes 0xc:0x1000c within the superblock) are 0x8000 2-byte cluster numbers, and comprise the FAT. The FAT is followed by the FST -- the tree structure containing the directory hierarchy and (plaintext!) filenames.
=== FAT ===
The FAT contains cluster chain / allocation information for the entire NAND chip, including parts of it which are not technically part of the filesystem!
The first 64 entries will always be 0xFFFC, which indicates that this cluster is "reserved". These correspond to the first 64 clusters or 8 blocks -- which is where boot1 and boot2 are stored.
Special values include:
* 0xFFFB - last cluster within a chain
* 0xFFFC - reserved cluster
* 0xFFFD - bad block (marked at factory) -- you should always see these in groups of 8 (8 clusters per NAND block)
* 0xFFFE - empty (unused / available) space
| 0x00
| 0x0B
| 0x0B0x0C
| "NANDBOOTINFO"
| Filename
| 1
| 0xfd
| file File access "mode" -- if bit 0 is set * If <code>(mode & 3) == 1</code>, this is a regular file * If <code>(leaf nodemode & 3) and not == 2</code>, this is a directory* <code>mode >> 0x6</code> gives the owner permissions* <code>(mode & 0x30) >> 4</code> gives the group permissions* <code>(mode & 0xc) >> 2</code> gives the other permissions 
|-
| 0x0D
268

edits

Navigation menu