How to let Qi to write NAND?

Gianluca Renzi gianlucarenzi at eptar.com
Fri Apr 24 10:11:44 CEST 2009


On Friday 24 April 2009 09:52:18 Wentao Han wrote:
> >>  any one knows how to write (actually erase+program) NAND within Qi? We
> >> want Qi to keep some information between different bootups in NAND. We
> >> tried to write the nand write code by mimicking Qi's nand read codes,
> >> but it refuses to work. Any advice is appreciated.
> >
> > Can you send the code?
>
> Here is our code for erasing a block:
> void nand_erase(int row_addr)
> {
>         nand_select();
>         nand_clear_RnB();
>         NFCMD = NAND_CMD_ERASE1;
>         NFADDR = row_addr & 0xff;
>         NFADDR = (row_addr >> 8) & 0xff;
>         NFADDR = (row_addr >> 16) & 0xff;
>         NFCMD = NAND_CMD_ERASE2;
>         nand_wait();
>         nand_deselect();
> }
> where NAND_CMD_ERASE1 = 0x60 and NAND_CMD_ERASE2 = 0xD0. After it was
> called in bootloader_second_phase() with row_addr = 128 (which stands
> for the erasing block starting from 0x40000, I think), the contents
> remained. I suppose they should become all 1's. Any hints?
just a question:
why do you overwrite NFADDR every pageshift calculation??
To me, the correct code would be:
void nand_erase(int row_addr)
{
        nand_select();
        nand_clear_RnB();
        NFCMD = NAND_CMD_ERASE1;
        NFADDR |= row_addr & 0xff;
        NFADDR |= (row_addr >> 8) & 0xff;
        NFADDR |= (row_addr >> 16) & 0xff;
	
#warning "NFCMD redefined BEFORE executing NAND command"
        NFCMD = NAND_CMD_ERASE2;

        /* it will overwrite the previous NFCMD command.
	   Are you sure to do so? */
        nand_wait();
        nand_deselect();
}

Best regards,
-- 
Gianluca Renzi
R&D
phone: +39.0542.609120
fax: +39.0542.609212



More information about the openmoko-kernel mailing list