c - Why u-boot always mark writed block as bad? -



c - Why u-boot always mark writed block as bad? -

i'm developing nand flash driver of u-boot. think works environment of u-boot doesn't work properly. here have done testing:

erase whole nand flash code purely coded myself, these codes not related u-boot. , no bad blocks found. (is possible nand flash have no bad block?). here code

void nand_erase(u32 addr) { if (addr & (block_size - 1)) { printf("not block align\n"); return; } u32 row = addr / 2048; nand_select_chip(); nand_cmd(0x60); nfaddr = row & 0xff; nfaddr = (row >> 8) & 0xff; nfaddr = (row >> 16) & 0x07; nand_cmd(0xd0); nand_wait_ready(); nand_cmd(0x70); u8 status = nand_read(); if (status & 0x01) { printf("block 0x%x bad", addr); } nand_deselect_chip(); }

start u-boot, prompt"bad crc ,using default environment".

now utilize "setenv test 100" , "printenv test", works well, , "saveenv", prompt "ok" well.

and utilize "nand bad", shows nothing.

restart board , u-boot

now says "readenv() failed, using default environment".

and "printenv test", fails. chekced "nand bad", shows bad block @ "config_env_offset"

then changed config_env_offset value. , repeat step 1-7. shows bad block 1 time again @ new config_env_offset.

i've checked driver, write operation , read operation think. steps here:

"nand dump 0" , , shows 0xff

"nand write 20000000 0 800" write memory nand flash.

then "nand dump 0", shows same values "md 20000000 100" does.

so, can see after saveenv, block @ config_env_offset marked bad, don't know why

now figure out. set ecc.mode = nand_ecc_hw_syndrome, xxx_syndrome function doesn't maintain ecc layout. write ecc after main data. override first , sec bytes of oob area in each page , u-boot check these 2 bytes bad block marker, here answer.

c linux gcc u-boot

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -