Skip to contentSkip to conversation

A question about how to send a page program command to NAND flash

DISCUSSION Kevin Liao 2 participants 2 messages Jun 9, 2003 Memory technology devices (MTD)

lore
Share & tools
lore

Kevin Liao

author
#0 lore raw

In nand.c, I found that there was a piece of code in nand_command(...) as below:

...
if (command != NAND_CMD_SEQIN)
writeb (command, NAND_IO_ADDR);
else {
if (mtd->oobblock == 256 && column >= 256) {
column -= 256;
writeb (NAND_CMD_READOOB, NAND_IO_ADDR); writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
} else if (mtd->oobblock == 512 && column >= 256) {

   if (column < 512) {
    column -= 256;
    writeb (NAND_CMD_READ1, NAND_IO_ADDR);
    writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
   } else {
    column -= 512;
    writeb (NAND_CMD_READOOB, NAND_IO_ADDR);
    writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);

}
} else {
writeb (NAND_CMD_READ0, NAND_IO_ADDR);
writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
}
}
...

My question is why we need to send some kind of read command first before issuing the real page program command? Thanks a lot.

Regards,
Kevin

#1 lore raw
Quoted 24 lines · Kevin Liao

In nand.c, I found that there was a piece of code in nand_command(...) as below:

...
if (command != NAND_CMD_SEQIN)
writeb (command, NAND_IO_ADDR);
else {

  if (mtd->oobblock == 256 && column >= 256) {
   column -= 256;
   writeb (NAND_CMD_READOOB, NAND_IO_ADDR);
   writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
  } else if (mtd->oobblock == 512 && column >= 256) {
   if (column < 512) {
    column -= 256;
    writeb (NAND_CMD_READ1, NAND_IO_ADDR);
    writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
   } else {
    column -= 512;
    writeb (NAND_CMD_READOOB, NAND_IO_ADDR);
    writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
   }
  } else {
   writeb (NAND_CMD_READ0, NAND_IO_ADDR);
   writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
Quoted 6 lines

}
}
...

My question is why we need to send some kind of read command first before issuing the real page program command? Thanks a lot.

This is required to adjust the "pointer" to the correct part of a page. This is explained in the NAND datasheets (available from the vendors' websites).

-- CHarles