public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* OneNAND: Enabling ECC in main area
@ 2007-02-19 23:10 Julianne C.
  2007-02-20 14:35 ` Adrian Hunter
  2007-02-26  0:16 ` Kyungmin Park
  0 siblings, 2 replies; 3+ messages in thread
From: Julianne C. @ 2007-02-19 23:10 UTC (permalink / raw)
  To: linux-mtd

This is a continuation of the "unexpected zero" problem reported
earlier.  With further experimentation and investigation, we observe
the following behavior:

The bootloader on the board we use (LogicPD PXA270) does not have ECC
enabled during its operation.  Hence, we need to enable it sometime
during the OneNAND device driver setup.
This is the code that is inserted in the onenand_probe function, just
after the first wait call.

    // Contains old value of sysconfig register from bootloader
    syscfg = syscfg & 0xfeff; // ~0x0100;

    this->write_word (syscfg,
                             this->base + ONENAND_REG_SYS_CFG1);


    // Reset the command after enabling the ECC.
    this->write_word (ONENAND_CMD_RESET,
                             this->base + ONENAND_BOOTRAM);

    // Wait reset.
    this->wait (mtd,
                    FL_RESETING);

Using the utility mtd_debug 'write' mode, a file with a known pattern
is written to a partition on the OneNAND device:

mtd_debug write /dev/mtd3 0 0x10000 test_64k.bin

When we inspect the area using nanddump:

nanddump -p -l 0x2000 /dev/mtd3

we see the expected pattern in the main area of the partition, but the
spare OOB area is still completely untouched (all FF).

We created a modified version of the mtd_debug program that writes
only to the OOB area using the ioctl command

        err = ioctl (fd,
                        MEMWRITEOOB,
                        &oob);

where the oob structure contains a count sequence leaving out the 5
spare bytes reserved for ECC in each 16 bytes of OOB.  On inspection
using nanddump again, we see that all of the OOB data has been written
successfully, including the 2 spare area ECC bytes.

It is my understanding (please correct me if I am wrong) that setting
the 'ECC enable' bit in system config 1 register (bit 8) to zero (as
in the enable described above), should enable ECC for both the main
and OOB areas.

Is there something we are missing in getting the ECC to work with the main area?

Also, if the ECC is working correctly, should we see non FF bytes in
the spare area in bytes 8 to 10 of each 16 byte portion of the OOB
when we do a dump of the data?

Regards,

Julianne C.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: OneNAND: Enabling ECC in main area
  2007-02-19 23:10 OneNAND: Enabling ECC in main area Julianne C.
@ 2007-02-20 14:35 ` Adrian Hunter
  2007-02-26  0:16 ` Kyungmin Park
  1 sibling, 0 replies; 3+ messages in thread
From: Adrian Hunter @ 2007-02-20 14:35 UTC (permalink / raw)
  To: linux-mtd

ext Julianne C. wrote:
> Also, if the ECC is working correctly, should we see non FF bytes in
> the spare area in bytes 8 to 10 of each 16 byte portion of the OOB
> when we do a dump of the data?

Yes.  We have ECC enabled and that is what we see.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: OneNAND: Enabling ECC in main area
  2007-02-19 23:10 OneNAND: Enabling ECC in main area Julianne C.
  2007-02-20 14:35 ` Adrian Hunter
@ 2007-02-26  0:16 ` Kyungmin Park
  1 sibling, 0 replies; 3+ messages in thread
From: Kyungmin Park @ 2007-02-26  0:16 UTC (permalink / raw)
  To: 'Julianne C.', 'linux-mtd'

Hi,

> 
> The bootloader on the board we use (LogicPD PXA270) does not 
> have ECC enabled during its operation.  Hence, we need to 
> enable it sometime during the OneNAND device driver setup.
> This is the code that is inserted in the onenand_probe 
> function, just after the first wait call.
> 
>     // Contains old value of sysconfig register from bootloader
>     syscfg = syscfg & 0xfeff; // ~0x0100;
> 
>     this->write_word (syscfg,
>                              this->base + ONENAND_REG_SYS_CFG1);
> 
> 
>     // Reset the command after enabling the ECC.
>     this->write_word (ONENAND_CMD_RESET,
>                              this->base + ONENAND_BOOTRAM);
> 
>     // Wait reset.
>     this->wait (mtd,
>                     FL_RESETING);

The order is wrong.

The Reset command set syscfg1 value to default.
If you want to keep the bootloader value you don't need to insert reset
command.

        /* Save system configuration 1 */
        syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
        /* Clear Sync. Burst Read mode to read BootRAM */
        this->write_word((syscfg & ~ONENAND_SYS_CFG1_SYNC_READ), this->base
+ ONENAND_REG_SYS_CFG1);

        /* Send the command for reading device ID from BootRAM */
        this->write_word(ONENAND_CMD_READID, this->base + ONENAND_BOOTRAM);

        /* Read manufacturer and device IDs from BootRAM */
        bram_maf_id = this->read_word(this->base + ONENAND_BOOTRAM + 0x0);
        bram_dev_id = this->read_word(this->base + ONENAND_BOOTRAM + 0x2);

        /* Reset OneNAND to read default register values */
        this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_BOOTRAM);
        /* Wait reset */
        this->wait(mtd, FL_RESETING);

=>   syscfg &= ~ONENAND_SYS_CFG1_NO_ECC;

        /* Restore system configuration 1 */
        this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);

Thank you,
Kyungmin Park

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-02-26  0:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-19 23:10 OneNAND: Enabling ECC in main area Julianne C.
2007-02-20 14:35 ` Adrian Hunter
2007-02-26  0:16 ` Kyungmin Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox