Internal Filesystem

From Hackspire
Revision as of 00:01, 15 June 2013 by Tangrs (talk | contribs) (Created page with "There are two layers involved with the internal filesystem. FlashFX Pro does wear leveling and bad block management while Reliance is the filesystem on top of it. ==FlashFX Pro=...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

There are two layers involved with the internal filesystem. FlashFX Pro does wear leveling and bad block management while Reliance is the filesystem on top of it.

FlashFX Pro

FlashFX Pro maps logical addresses to physical addresses on the NAND. The physical space is divided into units, each unit divided up into blocks (each equal to page size of the NAND). All integers are read as little endian.

The first block in a unit has a header describing the unit:

1 2 3 4
Signature
Signature
Signature
Signature
clientAddress
eraseCount
ulSequenceNumber
serialNumber
lnuTotal
numSpareUnits
blockSize lnuPerRegion
partitionStartUnit unitTotalBlocks
unitClientBlocks unitDataBlocks
checksum

The spare area of the NAND is 1/32th of the page size and holds extra information

1 2 3 4
Alloc info ones-complement of byte 0 XOR byte 1 error-correcting Hamming code of bytes 0-2
seems to always be FF FF FF 0F for used pages, FF FF FF FF for unused
error-correcting code of second half of page data
error-correcting code of first half of page data

Checksum

The checksum in the unit header is calculated by adding all the bytes in the header mod 2^16.

uint16_t checksum(void *_ptr, size_t size) {
	uint16_t sum = 0;
	uint8_t *ptr = _ptr;

	while (size--) {
		sum += *ptr++;
	}

	return sum;
}

Allocation information

This contains the status and logical address of the block. A unit header will have a magic signature (0x48E2).

Status

Bits 12-15 indicate the status of the block.

Bit 12 Indicates NAND metatag?
Bit 13 Indicates a unit header?
Bit 14 If set, indicates invalid block.
Bit 15 Indicates a valid block

A free block has all bits set and a discarded block has none of the bits set.

Logical address

Mask with 0x0FFF to get address.

Reliance

TODO

Resources

Goplat's post on Omnimaga

Patent for FlashFX