一个专注于SLAM、机器视觉、Linux 等相关技术文章分享的公众号
分析nandflash写操作技术路线
mtd->_erase = nand_erase;
mtd->_read = nand_read;
mtd->_write = nand_write;
mtd->_panic_write = panic_nand_write;
mtd->_read_oob = nand_read_oob;
mtd->_write_oob = nand_write_oob;
mtd->_sync = nand_sync;
mtd->_lock = NULL;
mtd->_unlock = NULL;
mtd->_block_isreserved = nand_block_isreserved;
mtd->_block_isbad = nand_block_isbad;
mtd->_block_markbad = nand_block_markbad;
mtd->writebufsize = mtd->writesize;
if (!chip->write_page)
chip->write_page = nand_write_page;
nand_write_skip_bad
|->nand_write
|->mtd_write
|->mtd->_write
|->nand_write
|->nand_do_write_ops
|->chip->select_chip
|->chip->write_page
|->nand_write_page
|->chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page);
|->chip->ecc.write_page_raw
|->nand_write_page_raw
|->chip->write_buf
|->nand_write_buf
|->chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
|->chip->waitfunc(mtd, chip);
可能是ecc校验问题导致的写错误
https://e2e.ti.com/support/arm/sitara_arm/f/791/t/463003
# Inject a fake bit that is stuck low (2K page flash being used)
nand erase 0 0x20000
mw.b 0x82000000 0xff 0x1000
mw.b 0x82000000 0xfe 1
nand write.raw 0x82000000 0x0 0x1
# Write some data which needs to toggle the fake stuck bit
mw.b 0x82000000 0xab 1
nand write 0x82000000 0x0 0x800
An error will occur:
NAND write: device 0 offset 0x0, size 0x800
NAND write to offset 0 failed -5
0 bytes written: ERROR
But you can verify data was correctly written:
# Show data is correct when ECC is used
nand read 0x82000000 0x0 0x800
md 0x82000000
# Show the bit is still stuck low
nand read.raw 0x82000000 0x0 0x1
md 0x82000000
实验发现,nandflash擦除也有问题,也是无法操作,只能读.....
chip->erase = single_erase
nand_erase_opts
|->mtd_erase
|->mtd->_erase
|->nand_erase
|->nand_erase_nand
|->chip->erase
|->single_erase
|->chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page);
|->chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1);
可以在s3c2440_nand.c中设置nand->ecc.mode = NAND_ECC_NONE;
本来是想打开调试项的,结果又报一堆错误,真是醉了。。。。
include/../drivers/mtd/ubi/ubi.h: In function 'ubi_io_read_data':
include/../drivers/mtd/ubi/ubi.h:983: error: 'CONFIG_MTD_DEBUG_VERBOSE' undeclared (first use in this function)
include/../drivers/mtd/ubi/ubi.h:983: error: (Each undeclared identifier is reported only once
include/../drivers/mtd/ubi/ubi.h:983: error: for each function it appears in.)
include/../drivers/mtd/ubi/ubi.h: In function 'ubi_io_write_data':
include/../drivers/mtd/ubi/ubi.h:995: error: 'CONFIG_MTD_DEBUG_VERBOSE' undeclared (first use in this function)
include/../drivers/mtd/ubi/ubi.h: In function 'ubi_ro_mode':
include/../drivers/mtd/ubi/ubi.h:1007: error: 'CONFIG_MTD_DEBUG_VERBOSE' undeclared (first use in this function)
drivers/mtd/mtdcore.c: In function 'add_mtd_device':
drivers/mtd/mtdcore.c:479: error: 'CONFIG_MTD_DEBUG_VERBOSE' undeclared (first use in this function)
include/../drivers/mtd/ubi/ubi.h: In function 'ubi_io_read_data':
include/../drivers/mtd/ubi/ubi.h:983: error: expected expression before ')' token
include/../drivers/mtd/ubi/ubi.h: In function 'ubi_io_write_data':
include/../drivers/mtd/ubi/ubi.h:995: error: expected expression before ')' token
include/../drivers/mtd/ubi/ubi.h: In function 'ubi_ro_mode':
include/../drivers/mtd/ubi/ubi.h:1007: error: expected expression before ')' token
drivers/mtd/mtdcore.c: In function 'add_mtd_device':
drivers/mtd/mtdcore.c:479: error: expected expression before ')' token
不搞了。。。。