How to let Qi to write NAND?

Wentao Han wentao.han at gmail.com
Fri Apr 24 10:27:08 CEST 2009


On Fri, Apr 24, 2009 at 4:11 PM, Gianluca Renzi <gianlucarenzi at eptar.com> wrote:
> 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();
> }

Both NFCMD and NFADDR are memory-mapped IO ports connecting to NAND
flash controller. I just followed
src/cpu/s3c2442/nand_read.c:nand_read_page_ll() to write this code
snippet.

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



-- 
Wentao Han

Institute of High-Performance Computing
Department of Computer Science and Technology
Tsinghua University

Beijing 100084, China



More information about the openmoko-kernel mailing list