NAND

Table of contents

  1. Can I boot from NAND flash?
  2. Is there support for 32-bit wide NAND flash ?
  3. How do I erase my MTD partition on NAND flash?
  4. Can I copy a JFFS2 image to NAND via /dev/mtdX?
  5. Can I use seek/read/write on /dev/mtdX?
  6. Must my boot-loader be aware of NAND flash?
  7. Can I program NAND via JTAG?
  8. How do I use NAND simulator?

Can I boot from NAND flash?

我可以从NAND flash启动吗?

Not from a bare NAND chip. You need a glue logic around, which gives you memory access to the chip on boot-up, like the DiskOnChip devices do. This will be a quite complex CPLD. An alternative is to use a small e.g. 1MB NOR flash, which contains the boot code and maybe a compressed kernel image. Then you can use JFFS2 or UBIFS on NAND as your root file-system.

不可以从一个裸的NAND芯片。你需要一个粘合逻辑,以便在启动时访问芯片,就像DiskOnChip设备所做的那样。这将是一个相当复杂的CPLD。一个可替代的方案就是使用一个比如1MB大小的NOR flash,它包含boot代码,可能也有压缩过得内核镜像。然后你可以在NAND上使用JFFS2或者UBIFS作为你的根文件系统。

Some chips have internal circuitry which is capable of reading and booting from the first page of NAND after power up. This allows you to boot a small (e.g. 256/512/2048 byte) boot code, which can initialize SDRAM, then read and execute a more complete bootloader from subsequent NAND blocks. An example is U-Boot, which can be built as a 2-stage "initial" and "secondary" bootloader for use with NAND.

一些芯片有内部电路支持在上电后读取NAND的第一个页并启动。这允许你启动一个很小的启动代码(比如256/512/2048字节),可以初始化SDRAM,从之后的NAND块读取和执行更完整的bootloader。U-Boot就是一个例子,它可以构建为用于NAND的两个阶段,“初始化”和“辅助”引导加载程序。

Samson's S3C2410 ARM based SOC-CPU provides a mechanism to boot from NAND flash.

三星的S3C2410 基于ARM的SOC-CPU提供了一种从NAND闪存启动的机制。

Is there support for 32-bit wide NAND flash?

支持32位宽的NAND flash吗?

No. The generic NAND driver supports 8/16 bit wide NAND flash only. 32 bit NAND flash can be built by using 2 or 4 chips and connect them to D0-7, D8-D15, D16-D23 and D24-D31 on the data bus. You can tie all corresponding control signals together. But you have to build a new nand16 or nand32 driver, which can be derived from the existing nand.c. Be aware, that the write-buffer size is 2 or 4 times as big as on 8 bit NAND. This means, if you flush the buffer to ensure, that your data are on disk, you may waste much more memory space than on 8 bit NAND. Another point is bad block handling. When a block on 1 chip is bad, the corresponding blocks on the other chips are lost too, as you present them as one big block to the file-system driver. The JFFS2 code, which handles the write-buffer and the out of band (spare) area of NAND doesn't support 32 bit neither.

不支持。通用的NAND驱动程序只支持8/16位宽的NAND闪存。32位宽的NAND flash可以使用2或4片芯片来构建,将其连接到数据总线的D0-7,D8-D15,D16-D23,和D24-D31即可。你可以将所有对应的控制信号结合起来。但是你必须创建一个新的nand16或者nand32驱动,这可以从现有的nand.c中参考得到。注意,写缓冲的大小是8位宽NAND的2或4倍。这意味着,当你的数据在硬盘sang,如果你刷新缓冲区,与8位宽NAND相比会消耗更多的缓存空间。另一个点是坏块处理。当一个芯片上的一个块坏了,另一块上的对应块也没用了,因为对于文件系统驱动来说,他们是一整个大块。处理NAND的写缓冲区和带外(备用)区域的IFFS2代码也不支持32位。

How do I erase my MTD partition on NAND flash?

我要怎么在NAND flash上擦除MTD分区?

flash_erase (erase one eraseblock) or flash_eraseall utilities may be used. If you are going to use this partition with JFFS2, then it is recommended to use -j or --jffs2 options. This will write the so called "clean-marker" to the out of band area, so you can mount the file-system and no further formatting is needed. This is also necessary before you copy a filesystem image to the chip.

flash_erase(擦除一个可擦除块)或者flash_eraseall工具可以派上用场。如果你将要是有的分区是JFFS2,那么推荐使用-j或者--jffs2选项。这将把所谓的“干净标记”写入带外区域,这样您就可以挂载文件系统,而不需要进一步格式化。在你复制一个文件系统镜像到芯片去之前,这个操作同样是必须的。

Can I copy a JFFS2 image to NAND via /dev/mtdX?

我可以通过/dev/mtdZ复制JFFS2镜像到NAND吗?

Technically yes, as long as this MTD partition does not contain bad blocks. But it is generally a bad idea. For bad block aware copying, use nandwrite from the mtd-utils package.

从技术上讲是的,只要这个MTD分区没有包含坏块。但是总的来说这是一个坏主意。对于坏块感知复制,请使用mtd-utils包中的nandwrite。

Also, make sure, that the erasesize you set to mkfs.jffs2 is the same as the erasesize of your chip. Data will only be written with ECC, if your default settings for OOB-layout selection are set for JFFS2.

此外,请确保你设置为mkfs.jffs2的擦除大小与芯片的擦除大小相同。如果为JFFS2设置了OOB布局选择的默认设置,则仅使用ECC写入数据。

Can I use seek/read/write on /dev/mtdX?

我可以在/dev/mtdX上使用seek/read/write吗?

Yes, as long as your program is aware of bad blocks. Make sure to set the desired ECC layout by ioctl (MEMSETOOBSEL). A example for bad block handling and usage of ioctl (MEMOOBSEL) can be found in the nandwrite utility.

可以,只要你的程序能认出坏块。确保通过ioctl(MEMSETOOBSEL)设置所需的ECC布局。

Must my bootloader be aware of NAND flash?

我的BootLoader必须能识别NAND flash吗?

Yes, if you use your bootloader to erase the flash chip and copy a file-system image to it. For erase make sure, that you don't erase factory-marked bad blocks. They are marked in the 6th byte (offset 0x5) in the out of band area of the first page of a block. The block is bad, if any bit in this byte is zero. If you erase such a block, the bad block information is erased too and lost. Further use of this block will lead to erroneous results.

是的,如果你使用你的BootLoader来擦除flash芯片并复制一个文件系统上去。对于擦除,请确保不会擦除出厂标记的坏块。他们被标记在块第一页的OOB区第6字节(偏移0x05)。如果该字节的任意一位为0,则该块是坏块。如果你擦除了这样的一个块,这个坏块的消息也会被擦除并丢失。之后使用这个块就会导致一个错误的结果。

For JFFS2 file-systems it's recommended to program the JFFS2 erased marker into the out of band area of the first page in each erased block after erasing the block. Do not program it into the data area of the page!

对于JFFS2文件系统,建议在擦除块之后将JFFS2擦除标记编程到每个擦除快中第一页的OOB区。不要将它放在页的数据区。

For (obsolete) 256 byte page size devices program the following data into the out of band area:

对于(老式的)256字节页面大小设备,将以下数据编程到OOB区:

Offset0x060x07
Data0x850x19

For 512 byte page size devices program the following data into the out of band area:

对于512字节的页面大小,设备将以下数据编程到OOB区:

Offset0x080x090x0a0x0b0x0c0x0d0x0e0x0f
Data0x850x190x030x200x080x000x000x00

If you copy a file-system image to the chip, it's recommended to write it with ECC. You can use the ECC code in the nand driver to do this. If you have a bad block on your chip, just skip this block and copy the data to the next block. JFFS2 and other NAND flash aware file-systems handle this gap.

如果你复制一个文件系统镜像到芯片中,建议使用ECC编写。你可以在nand驱动中使用ECC代码来做。如果你的芯片中有一个坏块,那么只要跳过这个坏块并将数据复制到下一个块即可。JFFS2和其他支持的NAND flash的文件系统将会处理。

Can I program NAND via JTAG?

我可以通过JTAG对NAND编程吗?

Yes, you can. The requirements are the same as for boot-loaders (see here).

是的,你可以。要求与引导加载程序相同(见上一小节)。

How do I use NAND simulator?

我要怎么使用NAND调试器?

NAND simulator (nandsim) is an extremely useful debugging and development tool which simulates NAND flashes in RAM or a file. To select the simulated flash type one should specify ID bytes of your flash - the ones which are returned by the "Read ID" command (0x90) - consult the flash manual. The following are examples of input parameters:

NAND模拟器(nandsim)是一个非常有用的调试和开发工具,它可以在RAM或文件中模拟NAND。要选择模拟的flash型号,请参阅闪存手册,指定闪存的ID字节-由“Read ID”命令(0x90)返回的字节。下面就是输入参数的例子:

  1. modprobe nandsim first_id_byte=0x20 second_id_byte=0x33 - 16MiB, 512 bytes page;
  2. modprobe nandsim first_id_byte=0x20 second_id_byte=0x35 - 32MiB, 512 bytes page;
  3. modprobe nandsim first_id_byte=0x20 second_id_byte=0x36 - 64MiB, 512 bytes page;
  4. modprobe nandsim first_id_byte=0x20 second_id_byte=0x78 - 128MiB, 512 bytes page;
  5. modprobe nandsim first_id_byte=0x20 second_id_byte=0x71 - 256MiB, 512 bytes page;
  6. modprobe nandsim first_id_byte=0x20 second_id_byte=0xa2 third_id_byte=0x00 fourth_id_byte=0x15 - 64MiB, 2048 bytes page;
  7. modprobe nandsim first_id_byte=0xec second_id_byte=0xa1 third_id_byte=0x00 fourth_id_byte=0x15 - 128MiB, 2048 bytes page;
  8. modprobe nandsim first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=0x15 - 256MiB, 2048 bytes page;
  9. modprobe nandsim first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte=0x15 - 512MiB, 2048 bytes page;
  10. modprobe nandsim first_id_byte=0xec second_id_byte=0xd3 third_id_byte=0x51 fourth_id_byte=0x95 - 1GiB, 2048 bytes page;

If you do not have enough RAM, you can make nandsim emulate the flash on top of a file. Please, use the cache_file nandsim module parameter.

如果你没有足够的RAM,可以让nandsim在文件顶部模拟闪存。请使用cache_file nandsim模块参数。

nandsim can emulate various errors and report wear statistics, which is extremely useful when testing how flash software handles errors (e.g., what does JFFS2 do in case of bit-flips or write errors).

Nandsim可以模拟各种错误并报告磨损统计数据,这在测试闪存软件如何处理错误时非常有用(例如,如果出现位翻转或写入错误,JFFS2会做什么)。

Note, theoretically nandsim can emulate 16-bit bus width devices, but it may not work.

请注意,理论上nandsim可以模拟16位总线宽度的设备,但它可能无法工作。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值