NAND闪存之OOB
一、前言
NOR和NAND是市场上两种主要的非易失闪存技术。Intel于1988年首先开发出NOR flash技术,彻底改变了原先由EPROM和EEPROM一统天下的局面。紧接着,1989年,东芝公司发表了NAND flash结构,强调降低每比特的成本,更高的性能,并且像磁盘一样可以通过接口轻松升级。但是经过了十多年之后,仍然有相当多的硬件工程师分不清NOR和NAND闪存。
“NAND存储器”经常可以与“NOR存储器”相互换使用。许多业内人士也搞不清楚NAND闪存技术相对于NOR技术的优越之处,因为大多数情况下闪存只是用来存储少量的代码并且需要多次擦写,这时NOR闪存更适合一些。而NAND则是高数据存储密度的理想解决方案。
对于Nand Flash,每一个页,对应一个空闲区域(OOB),这个区域是基于Nand Flash的硬件特性,数据在读写的时候容易出错,为了保证数据的正确性,就产生了这样一个检测和纠错的区域,用来放置数据的校验值。OOB的读写操作,一般都是随着页的操作一起完成,也就是在读写页的时候,对应的OOB就产生了,那么OOB有什么用途呢?
二、OOB的功能
1、标记坏块
对于Nand Flash,比较严重的是坏块,也就是说一个块中包含有一个或者多个位是坏的,而现在对于坏块有两种分类:
- 出厂的时候就存在坏块:在出厂之前,就会做对应的标记,标记为坏块,一般芯片厂商会将每个坏块第一个page的spare area的第6个byte标记为不等于0xff。
- 使用过程中产生的坏块,就需要将这个块作为坏块来处理,为了与固有的坏块信息保持一致,也需要将新发现的坏块的第一个page的spare area的第6个Byte标记为非0xff的值。
对于上面的处理方式,如果我们需要擦除一个块之前,必须先要检查下第一个page的spare area的第6byte是否为0xff,如果是就证明是一个好块,是可以擦除;如果不是,就证明这是一个坏块,那么就不能擦除,对于这种方法,难免会出现一些错误操作,所以Nand Flash专门设计了一个BBT(bad block table)的坏块表用来进行管理。各个Nand的坏块管理的方法还不尽一样,有的会将bbt放到block0,因为block0一定是好块,但是block0一般是用来作为boot,那么也将导致不能放bbt,也有的会将bbt放到最后一个分区。
从上面可以看出,OOB是每一个页都会有的数据,里面存放的的有ECC,而BBT是一个flash才会有的,针对每个block的坏块识别是第一个spare area的第六个字节。
2、ECC校验
ECC(Error Checking and Correction),是一种用于Nand Flash的差错检测和修正的算法。由于操作的时序和电路稳定性等原因,常常会出现一些bit出错,也就是原来的某个位,本来是0而变成了1,或者本来是1而变成0。从现象来看,问题其实看起来并不是特别的严重,但是如果恰好某个重要的文件的某一位发生了变化,那么问题就大了,可能会导致此时文件不能运行,如果这个文件是一个影响系统的程序,那么直接将导致系统会出现问题,所以对于Nand Flash就出现了这样一个机制。它能纠正1个bit的错误和检测出2个bit的错误,对于1bit以上的错误无法纠正,而对于2bit以上的错误不能保证能检测。对于ECC其纠错算法如下:
- 当往Nand Flash写入数据时候,每256个字节生成一个ECC校验,针对这些数据会生成一个ECC校验码,然后保存到对应的page的OOB数据区。
- 当读取Nand Flash的数据时候,每256个字节就会生成一个ECC校验,那么对于这些数据就会计算出一个ECC校验码,然后将从OOB中读取存储的ECC校验和计算的ECC校验相比较。
3、存储文件系统信息
- 对于ramfs/jffs2文件系统映像文件中没有OOB的内容,需要根据OOB的标记略过坏块,然后将一页的数据写入,然后计算这一页数据的ECC校验码,然后将它写入到OOB区;
- 对于yaffs文件系统,因为本身包含有OOB区的数据(里面纪录有坏块标记,ECC校验码,其他信息),所以首先需要检查坏块,如果是,则跳过,然后写入数据,最后写入OOB数据。
三、nand操作
1、uboot中nand命令
使用nand dump.oob可以打印包含oob的数据
=> nand
nand - NAND sub-system
Usage:
nand info - show available NAND devices
nand device [dev] - show or set current device
nand read - addr off|partition size
nand write - addr off|partition size
read/write 'size' bytes starting at offset 'off'
to/from memory address 'addr', skipping bad blocks.
nand read.raw - addr off|partition [count]
nand write.raw - addr off|partition [count]
Use read.raw/write.raw to avoid ECC and access the flash as-is.
nand write.trimffs - addr off|partition size
write 'size' bytes starting at offset 'off' from memory address
'addr', skipping bad blocks and dropping any pages at the end
of eraseblocks that contain only 0xFF
nand erase[.spread] [clean] off size - erase 'size' bytes from offset 'off'
With '.spread', erase enough for given file size, otherwise,
'size' includes skipped bad blocks.
nand erase.part [clean] partition - erase entire mtd partition'
nand erase.chip [clean] - erase entire chip'
nand bad - show bad blocks
nand dump[.oob] off - dump page
nand scrub [-y] off size | scrub.part partition | scrub.chip
really clean NAND erasing bad blocks (UNSAFE)
nand markbad off [...] - mark bad block(s) at offset (UNSAFE)
nand biterr off - make a bit error at offset (UNSAFE)
=> nand device
Device 0: nand0, sector size 128 KiB
Page size 2048 b
OOB size 64 b
Erase size 131072 b
subpagesize 2048 b
options 0x40000200
bbt options 0x 8000
=> nand dump 0 0 0x840
Page 00000000 dump:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
32 fb ff ff 46 43 42 20 00 00 00 01 50 3c 19 06
00 00 00 00 00 08 00 00 40 08 00 00 40 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00
00 02 00 00 00 02 00 00 02 00 00 00 0a 00 00 00
03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 02 00 00 00 05 00 00
ca 00 00 00 ca 00 00 00 00 01 00 00 e2 07 00 00
37 46 7f b7 e3 75 fb ba 94 82 bb 3d 38 6d 3d d4
94 76 37 ae a8 04 ce 85 41 04 b8 88 b1 68 8e f9
a9 da b3 84 30 b3 28 eb 91 da 93 91 b4 2b 87 66
0c 95 85 74 8e a5 cb 42 8d 8c 26 7f 59 81 25 07
31 04 00 00 00 00 08 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fd e1 40 1e 42 99 c1 bf 63 59 86 b2 b4 e0 cf
4e 95 31 07 10 14 72 0d f9 77 6b 1e 4f 17 09 ee
49 98 14 e8 9a d6 10 36 e6 3f 51 2c 6a 90 1a 12
c2 9d 89 14 87 98 4d 6c 9a 4c 74 8f 6e 01 f5 08
82 d4 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
OOB:
ff 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
2、linux系统中nand命令
使用nanddump -o -p -l 1000 /dev/mtd0打印包含oob的数据
# nanddump
Usage: nanddump [OPTIONS] MTD-device
Dumps the contents of a nand mtd partition.
-h --help Display this help and exit
--version Output version information and exit
--bb=METHOD Choose bad block handling method (see below).
-a --forcebinary Force printing of binary data to tty
-c --canonicalprint Print canonical Hex+ASCII dump
-f file --file=file Dump to file
-l length --length=length Length
-n --noecc Read without error correction
--omitoob Omit OOB data (default)
-o --oob Dump OOB data
-p --prettyprint Print nice (hexdump)
-q --quiet Don't display progress and status messages
-s addr --startaddress=addr Start address
--bb=METHOD, where METHOD can be `padbad', `dumpbad', or `skipbad':
padbad: dump flash data, substituting 0xFF for any bad blocks
dumpbad: dump flash data, including any bad blocks
skipbad: dump good data, completely skipping any bad blocks (default)
# nanddump -o -p -l 1000 /dev/mtd0
ECC failed: 2
ECC corrected: 0
Number of bad blocks: 0
Number of bbt blocks: 0
Block size 131072, page size 2048, OOB size 64
Dumping data starting at 0x00000000 and ending at 0x000003e8...
ECC: 1 uncorrectable bitflip(s) at offset 0x00000000
0x00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000010: 00 00 00 00 00 00 32 fb ff ff 46 43 42 20 00 00
0x00000020: 00 01 50 3c 19 06 00 00 00 00 00 08 00 00 40 08
0x00000030: 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000040: 00 00 02 00 00 00 00 02 00 00 00 02 00 00 02 00
0x00000050: 00 00 0a 00 00 00 03 00 00 00 00 00 00 00 00 00
0x00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02
0x00000080: 00 00 00 05 00 00 ca 00 00 00 ca 00 00 00 00 01
0x00000090: 00 00 e2 07 00 00 37 46 7f b7 e3 75 fb ba 94 82
0x000000a0: bb 3d 38 6d 3d d4 94 76 37 ae a8 04 ce 85 41 04
0x000000b0: b8 88 b1 68 8e f9 a9 da b3 84 30 b3 28 eb 91 da
0x000000c0: 93 91 b4 2b 87 66 0c 95 85 74 8e a5 cb 42 8d 8c
0x000000d0: 26 7f 59 81 25 07 31 04 00 00 00 00 08 00 00 00
0x000000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000150: 00 00 00 00 00 00 00 fd e1 40 1e 42 99 c1 bf 63
0x00000160: 59 86 b2 b4 e0 cf 4e 95 31 07 10 14 72 0d f9 77
0x00000170: 6b 1e 4f 17 09 ee 49 98 14 e8 9a d6 10 36 e6 3f
0x00000180: 51 2c 6a 90 1a 12 c2 9d 89 14 87 98 4d 6c 9a 4c
0x00000190: 74 8f 6e 01 f5 08 82 d4 00 00 00 00 00 00 00 00
0x000001a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000001b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000001c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000001d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000001e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000001f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000002a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000002b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000002c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000002d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000002e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000002f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000003a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000003b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000003c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000003d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000003e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000003f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000004a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000004b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000004c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000004d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000004e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000004f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000005a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000005b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000005c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000005d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000005e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000005f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000006a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000006b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000006c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000006d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000006e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000006f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000007a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000007b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000007c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000007d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000007e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000007f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
OOB Data: ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
OOB Data: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
OOB Data: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
OOB Data: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000800: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000810: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000820: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000830: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000840: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000850: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
...
3、使用工具
使用编程器等工具可以读取原始的flash数据,只不过需要自己区分数据区和冗余区(spare area)。
四、疑问
1、uboot中nand命令和linux系统中nanddump命令打印的数据为什么起始不太一致?
uboot:
0x00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000020: 32 fb ff ff 46 43 42 20 00 00 00 01 50 3c 19 06
0x00000030: 00 00 00 00 00 08 00 00 40 08 00 00 40 00 00 00
linux:
0x00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000010: 00 00 00 00 00 00 32 fb ff ff 46 43 42 20 00 00
0x00000020: 00 01 50 3c 19 06 00 00 00 00 00 08 00 00 40 08
0x00000030: 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00
2、编程器读取的flash里面的oob,为啥有的是在每页的末尾,有的则分布不均匀?有没有去除编程器固件中oob的通用方法?
参考文章《mrctf2022-iot题目之nand有效数据分析(1)》
五、参考链接
https://baike.baidu.com/item/Nand%20flash/4883033