forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Some information on the PSP Nand controller interface

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
ryoko_no_usagi



Joined: 29 Nov 2005
Posts: 65

PostPosted: Thu Sep 28, 2006 5:50 pm    Post subject: Some information on the PSP Nand controller interface Reply with quote

Groepaz and Moonlight asked if I could provide some additional
information regarding the PSP nand controller, and below I present
some info on the nand hardware registers. The information is probably
not 100% correct, obviously. I simply looked over my reversed source
code and tried to dechipher the meaning of the registers from that. No
testing or experimentation was performed. Besides the clear danger of
me misinterpretting something, there is also the possibility that the
controller has changed with different revisions. The information
presented here was obtained from a 1.5 fw PSP.

Code:

bd101000: Nand Control Reg (rw)
+---------------------------------+
|31 - 18 | 17    | 16    | 15 - 0 |
| ???    | ECCWR | ECCRD | ???    |
+---------------------------------+

ECCWR: Calculate ECC for user page during writing
ECCRD: Calculate ECC for user page during reading

-----------------------------------------------------------------

bd101004: Nand Status Reg (rw)
+-----------------------------+
| 31 - 8 | 7    | 6 - 1 | 0   |
|  ???   | PROT | ???   | RDY |
+-----------------------------+

PROT: 0: NAND is not write-protected
      1: NAND is write-protected

RDY: 0: NAND is busy
     1: NAND is ready

-----------------------------------------------------------------

bd101008: Nand Command Reg (w)
+---------------+
|31 - 8 | 7 - 0 |
| ???   | CMD   |
+---------------+

CMD: 0x50 - Read Spare Page
     0x60 - Erase block1
     0x70 - Read Status
     0x90 - Read ID
     0xd0 - Erase block2
     0xff - Reset

Maybe all commands are supported?

-----------------------------------------------------------------

bd10100c: Nand Address Reg (w)
+--------------------------+
|31 - 27 | 26 - 10 | 9 - 0 |
| ???    | ADDR    | ???   |
+--------------------------+

ADDR: Physical page to access

-----------------------------------------------------------------

bd101014: Nand Reset Reg (w)
+-------------+
|31 - 1 | 0   |
| ???   | RST |
+-------------+

RST: Reset NAND controller to default state?

-----------------------------------------------------------------

bd101020: Nand DMA Address Reg (w)
+--------------------------+
|31 - 27 | 26 - 10 | 9 - 0 |
| ???    | ADDR    | ???   |
+--------------------------+

ADDR: Physical page to access

-----------------------------------------------------------------

bd101024: Nand DMA Control Reg (w)
+----------------------------------------+
|31 - 19 | 9   | 8   | 7 - 2 | 1   | 0   |
| ???    | EN1 | EN2 | ???   | DIR | EN0 |
+----------------------------------------+

EN1: Set to enable DMA transfer? (ECC?) Or set to clear previous status?

EN2: Set to enable DMA transfer? (USER?) Or set to clear previous status?

DIR: 0 -> Transfer from Nand to Nand Data Buffer
     1 -> Transfer from Nand Data Buffer to Nand

EN0: Set to enable DMA transfer

-----------------------------------------------------------------

bd101028: Nand DMA Status Reg (r)
+-------+
|31 - 0 |
| STAT  |
+-------+

STAT: Maybe != 0 -> write failed?

-----------------------------------------------------------------

bd101038: Nand DMA Intr Reg (rw)
+----------------------------------------+
|31 - 19 | 9   | 8   | 7 - 2 | 1   | 0   |
| ???    | IN1 | IN2 | ???   | IN3 | IN4 |
+----------------------------------------+

Probably the same bits as bd101024

-----------------------------------------------------------------

bd101200: Nand Resume Reg (write 0x0b040205 to resume?) (w)
+-------+
|31 - 0 |
| RES   |
+-------+
RES: write 0x0b040205 to resume?

-----------------------------------------------------------------

bd101300: Nand Serial Data Reg (rw?)
+------------------------------------+
|31 - 24 | 23 - 16 | 15 - 8 | 7 - 0  |
| byte 3 | byte 2  | byte 1 | byte 0 |
+------------------------------------+

Serial Data register

-----------------------------------------------------------------

bff00000: Nand DMA User Data Buf start (rw)
bff00200: Nand DMA USer Data Buf end

512 bytes buffer to hold DMA data for a user page.

-----------------------------------------------------------------

bff00800: Nand User ECC Reg (rw)
+-------+
|31 - 0 |
| ECC   |
+-------+
Hardware calculated ECC for a user page

-----------------------------------------------------------------

bff00900: Nand DMA Spare Data Buf start (rw)
bff00910: Nand DMA Spare Data Buf end

16 bytes buffer to hold DMA data for a spare page.



Moonlight:

How to write to NAND using hardware register poking:

1) Copy user data to Nand User Data buf (bff00000 - bff00200) (careful with cache!)
2) Write ECC value to Nand User ECC buf (bff00800) (Alternatively, the hw might be able to generate it)
3) Write appropriate flags to Nand Control reg (bd1010000)
4) Write spare data to Nand Spare Data buf (bff00900 - bff00910)
5) Write page number to Nand DMA Addr reg (bd101020)
6) Clear appropriate flags in the Nand DMA Intr reg (bd101038)
7) Start DMA transfer by writing the appropriate flags to Nand DMA control reg (bd101024)
8) Wait for interrupt and process accordingly

Maybe it's possible to write data using the serial data register too, but I haven't seen anything
in the firmware that utilizes that.

How to read from NAND:

1) Write appropriate flags to Nand Control reg (bd1010000)
2) Write page number to Nand DMA Addr reg (bd101020)
3) Clear appropriate flags in the Nand DMA Intr reg (bd101038)
4) Start DMA transfer by writing the appropriate flags to the Nand DMA control reg (bd101024)
5) Wait for interrupt
6) Copy user data from Nand User Data buf (bff00000 - bff00200) (careful with cache!)
7) Check User ECC status (?) (bff00800)
8) Copy ECC value from from Nand User ECC buf (bff00800)
9) Copy spare data from Nand Spare Data buf (bff00900)
10) Check Spare ECC manually

EDIT: corrected some register info


Last edited by ryoko_no_usagi on Wed Nov 01, 2006 7:32 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail MSN Messenger
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Fri Sep 29, 2006 11:58 am    Post subject: Reply with quote

yay cool stuff.... if someone with the possibility to reflash (ie with a chip or other nand replacement) could verify some of that stuff that would be great!
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group