title: Can the logical erase block size of an MTD device be increased?
body: <p>The minimum erase block size for jffs2 (mtd-utils version 1.5.0, <code>mkfs.jffs2</code> revision 1.60) seems to be 8KiB:</p>
  
  <pre><code>Erase size 0x1000 too small. Increasing to 8KiB minimum
  </code></pre>
  
  <p>However I am running Linux 3.10 with an at25df321a,</p>
  
  <pre><code>m25p80 spi32766.0: at25df321a (4096 Kbytes),
  </code></pre>
  
  <p>and the erase block size is only 4KiB:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Is there a way to make the mtd system treat multiple erase blocks as one? Maybe some ioctl or module parameter?</p>
  
  <p>If I flash a jffs2 image with larger erase block size, I get lots of kernel error messages, missing files and sometimes panic.</p>
  
  <p><strong>workaround</strong></p>
  
  <p>I found that <code>flasherase --jffs2</code> results in a working filesystem inspite of the 4KiB erase block size. So I hacked the <code>mkfs.jfss2.c</code> file and the resulting image seems to work fine. I'll give it some testing.</p>
  
  <pre><code>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 &lt; 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 &lt; 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;
                                            }
  </code></pre>