Can the logical erase block size of an MTD device be increased?

社会主义新天地 提交于 2019-12-12 02:52:24

问题


The minimum erase block size for jffs2 (mtd-utils version 1.5.0, mkfs.jffs2 revision 1.60) seems to be 8KiB:

Erase size 0x1000 too small. Increasing to 8KiB minimum

However I am running Linux 3.10 with an at25df321a,

m25p80 spi32766.0: at25df321a (4096 Kbytes),

and the erase block size is only 4KiB:

mtd5
Name:                           spi32766.0
Type:                           nor
Eraseblock size:                4096 bytes, 4.0 KiB
Amount of eraseblocks:          1024 (4194304 bytes, 4.0 MiB)
Minimum input/output unit size: 1 byte
Sub-page size:                  1 byte
Character device major/minor:   90:10
Bad blocks are allowed:         false
Device is writable:             true

Is there a way to make the mtd system treat multiple erase blocks as one? Maybe some ioctl or module parameter?

If I flash a jffs2 image with larger erase block size, I get lots of kernel error messages, missing files and sometimes panic.

workaround

I found that flasherase --jffs2 results in a working filesystem inspite of the 4KiB erase block size. So I hacked the mkfs.jfss2.c file and the resulting image seems to work fine. I'll give it some testing.

diff -rupN orig/mkfs.jffs2.c new/mkfs.jffs2.c
--- orig/mkfs.jffs2.c   2014-10-20 15:43:31.751696500 +0200
+++ new/mkfs.jffs2.c    2014-10-20 15:43:12.623431400 +0200
@@ -1659,11 +1659,11 @@ int main(int argc, char **argv)
                                                  }
                                                  erase_block_size *= units;

-                                                 /* If it's less than 8KiB, they're not allowed */
-                                                 if (erase_block_size < 0x2000) {
-                                                         fprintf(stderr, "Erase size 0x%x too small. Increasing to 8KiB minimum\n",
+                                                 /* If it's less than 4KiB, they're not allowed */
+                                                 if (erase_block_size < 0x1000) {
+                                                         fprintf(stderr, "Erase size 0x%x too small. Increasing to 4KiB minimum\n",
                                                                          erase_block_size);
-                                                         erase_block_size = 0x2000;
+                                                         erase_block_size = 0x1000;
                                                  }
                                                  break;
                                          }

回答1:


http://lists.infradead.org/pipermail/linux-mtd/2010-September/031876.html

JFFS2 should be able to fit at least one node to eraseblock. The maximum node size is 4KiB+few bytes. This is why the minimum eraseblocks size is 8KiB.

But in practice, even 8KiB is bad because you and up with wasting a lot of space at the end of eraseblocks.

You should join several erasblock into one virtual eraseblock of 64 or 128 KiB and use it - this will be more optimal.

Some drivers have already implemented this. I know about

MTD_SPI_NOR_USE_4K_SECTORS

Linux configuration option. It have to be set to "n" to enable large erase sectors of size 0x00010000.



来源:https://stackoverflow.com/questions/26466470/can-the-logical-erase-block-size-of-an-mtd-device-be-increased

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!