|
楼主 |
发表于 2020-5-22 16:37
|
显示全部楼层
本帖最后由 jiuweiljp 于 2020-5-27 22:20 编辑
后期补充
上一篇帖子中breed的作者提到过他用breed做了一个RAW的nand 读写器,好羡慕啊
今天看网文buildroot busybox
提到过‘MTD_FILE_MODE_RAW’这也是raw模式,查了下mtd-utils源代码
nanddump.c 如果没有理解错使用noecc 也是MTD_FILE_MODE_RAW模式
- if (noecc) {
- if (ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_RAW) != 0) {
- perror("MTDFILEMODE");
- goto closeall;
- }
- } else {
- /* check if we can read ecc stats */
- if (!ioctl(fd, ECCGETSTATS, &stat1)) {
- eccstats = true;
- if (!quiet) {
- fprintf(stderr, "ECC failed: %d\n", stat1.failed);
- fprintf(stderr, "ECC corrected: %d\n", stat1.corrected);
- fprintf(stderr, "Number of bad blocks: %d\n", stat1.badblocks);
- fprintf(stderr, "Number of bbt blocks: %d\n", stat1.bbtblocks);
- }
- } else
- perror("No ECC status information available");
- }
复制代码 nandwrite.c 这个也是
- /* Select OOB write mode */
- if (noecc)
- write_mode = MTD_OPS_RAW;
- else if (autoplace)
- write_mode = MTD_OPS_AUTO_OOB;
- else
- write_mode = MTD_OPS_PLACE_OOB;
- if (noecc) {
- ret = ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_RAW);
- if (ret) {
- switch (errno) {
- case ENOTTY:
- errmsg_die("ioctl MTDFILEMODE is missing");
- default:
- sys_errmsg_die("MTDFILEMODE");
- }
- }
- }
复制代码 nandbiterrs.c 有两次提到了这个,正在研究这个工具用法,不知道什么作用
- static int rewrite_page(void)
- {
- if (ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_RAW) != 0)
- goto fail_mode;
- if (write_page() != 0)
- return -1;
- if (ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_NORMAL) != 0)
- goto fail_mode;
- return 0;
复制代码- static int write_page(void)
- {
- int raw = flags & PAGE_ERASED;
- int err;
- if (raw && ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_RAW) != 0)
- goto fail_mode;
- err = mtd_write(mtd_desc, &mtd, fd, peb, page*pagesize,
- wbuffer, pagesize, NULL, 0, 0);
复制代码
-------------------下面是一些文件的帮助,没什么意义
- ./nandbiterrs --h
- Usage: nandbiterrs [OPTIONS] <device>
- Common options:
- -h, --help Display this help output
- -k, --keep Restore existing contents after test
- -b, --peb <num> Use this physical erase block
- -p, --page <num> Use this page within the erase block
- -s, --seed <num> Specify seed for PRNG
- -e, --erased Test erased pages instead of written pages
- Options controling test mode:
- -i, --incremental Manually insert bit errors until ECC fails
- -o, --overwrite Rewrite page until bits flip and ECC fails
- Test mode specific options:
- -w, --writes <num> Number of writes (default 10000)
- ---------------------------
- ./nandpagetest --h
- Usage: nandpagetest [OPTIONS] <device>
- Options:
- -h, --help Display this help output
- -b, --peb <num> Index of the first erase block to use
- -c, --count <num> Number of erase blocks to use (at least 2, default all)
- -s, --skip <num> Number of erase blocks to skip
- -S, --seed <num> Seed for pseudor random number generator
- -k, --keep Restore existing contents after test
- -------------------------
复制代码 http://blog.chinaunix.net/uid-20546441-id-351133.html
|
|