老版本的linux内核中mtd test 出现 mtd_oobtest: error: verify failed at 0xXXXX 问题
2014-12-22 10:31
411 查看
最近在做parallel nor的东西,在用mtd/tests/下的mtd_oobtest时,老时有下面的打印:
mtd_oobtest: error: verify failed at 0xXXX
mtd_oobtest会对相关的device共作五步test,其中1,3,4过了,就是在2,5这两步是老是出现上面的错误,
后来发现,其实这个问题只是在老版本的内核存在,在新内核中没有。我用的是3.14的内核,发现在调用prandom_bytes_state(&rnd_state, writebuf, use_len_max * pgcnt);
获得到的数据与从oob中读出来的数据不一样,这主要是由于在调用这个函数时的逻辑出错了,有一个patch是针对这个问题,已经merge到新版本的内核中,如果你用的是3.16应该是没有这个问题的。patch如下:
mtd_oobtest: error: verify failed at 0xXXX
mtd_oobtest会对相关的device共作五步test,其中1,3,4过了,就是在2,5这两步是老是出现上面的错误,
后来发现,其实这个问题只是在老版本的内核存在,在新内核中没有。我用的是3.14的内核,发现在调用prandom_bytes_state(&rnd_state, writebuf, use_len_max * pgcnt);
获得到的数据与从oob中读出来的数据不一样,这主要是由于在调用这个函数时的逻辑出错了,有一个patch是针对这个问题,已经merge到新版本的内核中,如果你用的是3.16应该是没有这个问题的。patch如下:
Subject: [v3] mtd: mtd_oobtest: generate consitent data for verification mtd_oobtest writes OOB, read it back and verify. The verification is not correctly done if oobsize is not multiple of 4. Although the data to be written and the data to be compared are generated by several prandom_byte_state() calls starting with the same seed, these two are generated with the different size and different number of calls. Due to the implementation of prandom_byte_state() if the size on each call is not multiple of 4, the resulting data is not always same. This fixes it by just calling prandom_byte_state() once and using correct range instead of calling it multiple times for each. Reported-by: George Cherian <george.cherian@ti.com> Reported-by: Lothar Waßmann <LW@KARO-electronics.de> Cc: George Cherian <george.cherian@ti.com> Cc: Lothar Waßmann <LW@KARO-electronics.de> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Brian Norris <computersforpeace@gmail.com> Cc: Lee Jones <lee.jones@linaro.org> Cc: linux-mtd@lists.infradead.org Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Tested-by: <LW@KARO-electronics.de> --- v3: bracket-up the new complicated math for clarity requested by Lee Jones drivers/mtd/tests/oobtest.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c index 2e9e2d1..f19ab1a 100644 --- a/drivers/mtd/tests/oobtest.c +++ b/drivers/mtd/tests/oobtest.c @@ -69,8 +69,8 @@ static int write_eraseblock(int ebnum) int err = 0; loff_t addr = ebnum * mtd->erasesize; + prandom_bytes_state(&rnd_state, writebuf, use_len_max * pgcnt); for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { - prandom_bytes_state(&rnd_state, writebuf, use_len); ops.mode = MTD_OPS_AUTO_OOB; ops.len = 0; ops.retlen = 0; @@ -78,7 +78,7 @@ static int write_eraseblock(int ebnum) ops.oobretlen = 0; ops.ooboffs = use_offset; ops.datbuf = NULL; - ops.oobbuf = writebuf; + ops.oobbuf = writebuf + (use_len_max * i) + use_offset; err = mtd_write_oob(mtd, addr, &ops); if (err || ops.oobretlen != use_len) { pr_err("error: writeoob failed at %#llx\n", @@ -122,8 +122,8 @@ static int verify_eraseblock(int ebnum) int err = 0; loff_t addr = ebnum * mtd->erasesize; + prandom_bytes_state(&rnd_state, writebuf, use_len_max * pgcnt); for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { - prandom_bytes_state(&rnd_state, writebuf, use_len); ops.mode = MTD_OPS_AUTO_OOB; ops.len = 0; ops.retlen = 0; @@ -139,7 +139,8 @@ static int verify_eraseblock(int ebnum) errcnt += 1; return err ? err : -1; } - if (memcmp(readbuf, writebuf, use_len)) { + if (memcmp(readbuf, writebuf + (use_len_max * i) + use_offset, + use_len)) { pr_err("error: verify failed at %#llx\n", (long long)addr); errcnt += 1; @@ -166,7 +167,9 @@ static int verify_eraseblock(int ebnum) errcnt += 1; return err ? err : -1; } - if (memcmp(readbuf + use_offset, writebuf, use_len)) { + if (memcmp(readbuf + use_offset, + writebuf + (use_len_max * i) + use_offset, + use_len)) { pr_err("error: verify failed at %#llx\n", (long long)addr); errcnt += 1; @@ -566,8 +569,8 @@ static int __init mtd_oobtest_init(void) if (bbt[i] || bbt[i + 1]) continue; addr = (i + 1) * mtd->erasesize - mtd->writesize; + prandom_bytes_state(&rnd_state, writebuf, sz * cnt); for (pg = 0; pg < cnt; ++pg) { - prandom_bytes_state(&rnd_state, writebuf, sz); ops.mode = MTD_OPS_AUTO_OOB; ops.len = 0; ops.retlen = 0; @@ -575,7 +578,7 @@ static int __init mtd_oobtest_init(void) ops.oobretlen = 0; ops.ooboffs = 0; ops.datbuf = NULL; - ops.oobbuf = writebuf; + ops.oobbuf = writebuf + pg * sz; err = mtd_write_oob(mtd, addr, &ops); if (err) goto out;
相关文章推荐
- Junit单元测试问题 junit.framework.AssertionFailedError: Method "test" not found at android.test.AndroidTes
- N76E003 在Keil下载出现 *** Error: Flash Verify Failed at 0x0000
- android中ADT版本问题: java.lang.NoClassDefFoundError和conversion to dalvik format failed with error 1错误
- PHP出现Notice: unserialize() [function.unserialize]: Error at offset问题的解决方案
- 关于Genymotion出现“An error occured while deploying the file.INSTALL_FAILED_INVALID_URI”问题的原因分析
- 解决Xcode上传出现的Error ITMS-9000问题 ,No image found at the path referenced under key CFBundleIcons AppIcon
- 关于问题“应用程序未安装或安装时出现「INSTALL_FAILED_CONTAINER_ERROR」”的解决方案方面的事情
- 在生成android版本时候出现的蛋疼问题Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1),
- 使用不同版本XCode出现的问题fatal error: malformed or corrupted AST file: 'Unable to load module
- 解决最近windows版本Node.js中npm出现的“Error: ENOENT, stat 'C:\Users\UserName\AppData\Roaming\npm”的问题
- Win环境下本地运行hadoop1版本出现访问权限问题 Failed to set permissions of path
- PHP出现Notice: unserialize() [function.unserialize]: Error at offset问题的解决方案
- PHP出现Notice: unserialize() [function.unserialize]: Error at offset问题的解决方案
- rpm出现"error: %preun( ) scriptlet failed, exit status 1问题
- xilinx ISE 软件仿真时出现 Error: (vlog-19) Failed to access library 'rtl_work' at "rtl_work"解决办法
- Android SDK版本问题: conversion to dalvik format failed with error 1的解决办法
- python32版本,出现问题“struct.error: argument for 's' must be a bytes object”的解决办法
- rpm出现"error: %preun( ) scriptlet failed, exit status 1问题
- 搭建go开发环境时,出现GoSublime error: MarGo build failed的问题
- modelsim仿真ISE工程时出现# ** Error: (vlog-19) Failed to access library 'rtl_work' at "rtl_work