Nand dumping.
mithris 26 Jan 2008 16:00
Some quick and dirty code to dump stuff from the JXD301s internal NAND.
#define PF_DIR (*((volatile unsigned short *)0xFFC00730))
#define PF_INEN (*((volatile unsigned short *)0xFFC00740))
#define PF_DATA (*((volatile unsigned short *)0xFFC00700))
#define NAND_COMMAND (*((volatile unsigned char *)0x20004000))
#define NAND_ADDRESS (*((volatile unsigned char *)0x20008000))
#define NAND_DATA (*((volatile unsigned char *)0x20000000))
void dumpnand()
{
// Set PF4 DIR to output
PF_DIR |= (1 << 4);
// Disable buffer
PF_INEN &= ~(1 << 4);
// Set outut
PF_DATA &= ~(1 << 4);
NAND_COMMAND = 0;
NAND_ADDRESS = 0;
NAND_ADDRESS = 0;
NAND_ADDRESS = 0;
NAND_ADDRESS = 0;
NAND_ADDRESS = 0;
// Read command.
NAND_COMMAND = 0x30;
for (int i = 0; i < 3600; ++i) {
PF_DIR |= (1 << 4);
}
unsigned char *buf = (unsigned char *)0x200000;
for (int i = 0; i < 0x840; ++i) {
*buf++ = NAND_DATA;
}
}
void dumpnandpage(unsigned int page, void *destination)
{
// Set PF4 DIR to output
PF_DIR |= (1 << 4);
// Disable buffer
PF_INEN &= ~(1 << 4);
// Set outut
PF_DATA &= ~(1 << 4);
// Address command
NAND_COMMAND = 0;
// First clock.
NAND_ADDRESS = 0;
// Second
NAND_ADDRESS = 0;
// This is where we input our address.
NAND_ADDRESS = page & 0xff;
NAND_ADDRESS = (page >> 8) & 0xff;
NAND_ADDRESS = (page >> 16) & 0xff;
// Read command.
NAND_COMMAND = 0x30;
// Wait a bit.
for (int i = 0; i < 3600; ++i) {
PF_DIR |= (1 << 4);
}
unsigned char *buf = (unsigned char *)destination;
for (int i = 0; i < 0x840; ++i) {
*buf++ = NAND_DATA;
}
}