uboot/drivers/mtd/nand: how to enable on-die-ecc on a flash chip / how to send command to flash chip

Can someone please give me a hint howto send a command to a flash chip, in my case to enable on-die-ecc?

I found at some place how to read the byte, but I don’t understand how to modify it for write (chip->write_byte isn’t the way):

  • ############################################## /
    /
    MICRON: Test on-die ECC status; return: 1/On or 0/Off */
    int test_on_die_ecc(struct mtd_info *mtd)
    {
    struct nand_chip *chip = mtd->priv;
    int addr = 0x90;
    uint8_t data, data_;
    chip->cmdfunc(mtd,NAND_CMD_GET_FEATURES,addr,-1);
    ndelay(2000);
    data = chip->read_byte(mtd);
    return((data & 0x08) ? 1 : 0 );
    }
  • 2 days later:

I could solve it on my own. :slight_smile:

int set_on_die_ecc(struct mtd_info *mtd)
{
struct nand_chip *chip = mtd->priv;
int addr = 0x90;
uint8_t buf[8] = {8,0,0,0,0,0,0,0};
chip->cmdfunc(mtd,NAND_CMD_SET_FEATURES,addr,-1);
ndelay(1000);
chip->write_buf(mtd, buf, 8);
printf(“set_on_die_ecc\n”);
OnDieECC_enabled = 1;
return ( 0 );
}