Difference between revisions of "/dev/flash"
(added all 4 ioctls) |
(if you're going to open 2 (, close _both_ of them) |
||
Line 2: | Line 2: | ||
/dev/flash provides a raw interface to the NAND flash memory. No file system permissions restrict the access to the NAND memory, however, the contents are encrypted. | /dev/flash provides a raw interface to the NAND flash memory. No file system permissions restrict the access to the NAND memory, however, the contents are encrypted. | ||
− | Be careful when using these interfaces! Calling the wrong ioctl (or calling write() instead of read() could have unfortunate results. | + | Be careful when using these interfaces! Calling the wrong ioctl (or calling write() instead of read() ) could have unfortunate results. |
=== Reading === | === Reading === |
Revision as of 18:38, 3 August 2008
Description
/dev/flash provides a raw interface to the NAND flash memory. No file system permissions restrict the access to the NAND memory, however, the contents are encrypted.
Be careful when using these interfaces! Calling the wrong ioctl (or calling write() instead of read() ) could have unfortunate results.
Reading
/dev/flash may be read to get the raw, encrypted contents of the Wii NAND flash chip. You must either read with a block size of 2048 or 2112 (2048 + 64); the former will give you the normal contents of one page, and the latter will give you the same data plus the 64 bytes of OOB / spare / ECC data. If you hope to use this to eventually restore the contents of your Wii, you MUST back up the spare data.
In between each read, you should seek() to the page number you are trying to read; for example, seeking to 0x200 would put you at page 0x200, the start of the encrypted filesystem. That is to say, you must seek before every access, and the "file position" is in terms of pages, not bytes. There are 256K (262,144) total pages.
Ioctls
Template:Table Template:Table/Header Template:Table/Row Template:Table/Row Template:Table/Row Template:Table/Row |}
Return Codes
(These names were taken from a NAND flash diagnostic program scraped from flash)
- -1: NAND_RESULT_ACCESS
- -3: NAND_RESULT_ECC_CRIT
- -4: NAND_RESULT_CORRUPT
- -5: NAND_RESULT_BUSY
- -6: NAND_RESULT_EXISTS
- -8: NAND_RESULT_INVALID
- -9: NAND_RESULT_MAXBLOCKS
- -10: NAND_RESULT_MAXFD
- -11: NAND_RESULT_MAXFILES
- -12: NAND_RESULT_NOEXISTS
- -13: NAND_RESULT_NOTEMPTY
- -14: NAND_RESULT_OPENFD
- -64: NAND_RESULT_UNKNOWN
- -128: NAND_RESULT_FATALERROR