I am working on upgrading the firmware on a legacy board running a modified 2.6.12.1 with the at91rm9200 processor and at45db642D dataflash to using a at45db641E dataflash. The characteristics of the 641E are:
- 32768 pages
- page size of 264 bytes
- flexible erase options to erase a page (264 bytes), a block (2 KB), a sector (256 KB), or the whole chip (64 Mbits).
The kernel memory manager page size is the standard 4096 bytes, I believe.
I want to put an appropriate jffs2 image on the device. The mkfs.jffs2 options I'm wondering about are (from man page):
- --pagesize: Use page size SIZE. The default is 4 KiB. This size is the maximum size of a data node. Set according to target system's memory management page size (NOTE: this is NOT related to NAND page size).
- --eraseblock: Use erase block size SIZE. The default is 64 KiB. If you use a erase block size different than the erase block size of the target MTD device, JFFS2 may not perform optimally. If the SIZE specified is below 4096, the units are assumed to be KiB.
The man says pagesize is related to kernel memory manage page size (4096 in my case, same as the default) and NOT the device's page of 264 bytes. So I would need to specify --pagesize=4096 and NOT --pagesize=264, is this correct?
The man also says --eraseblock must be the same size as the erase block of the MTD device. I'm confused about several things.
- The 641E has several different erase options. Which must be selected for mkfs.jffs2 --eraseblock option?
- If the correct option is either the 641E's page size or block size, how can I specify that to mkfs.jffs2 given the fact that values below 4096 are assumed to be in KB and not bytes?
- This link (referenced by this related but insufficient SO question) says that jffs2 nodes must fit entirely within an erase block. Since their size is 4+ KB, larger than the "erase block" size of the device, the link says "You should join several erasblock into one virtual eraseblock of 64 or 128 KiB and use it - this will be more optiomal" followed by "You need to make your driver report 128KiB eraseblock size and emulate it, then it'll work. It won't work out of the box." How do I set up such a "virtual eraseblock"?
- Within the at91 dataflash driver,
device->erasesize=pagesize
. So it seems like there are a few similarly named but different concepts: driver erasesize, device erase block size, and jffs2 eraseblock size. What are the relationships and differences between these? How does the jffs2 specified eraseblock size eventually affect the operations executed by the drivers?
Thank you for any help.
I've managed to inspect the various source files in the kernel to figure out what is going on, at least well enough to get it working. Please note that this applies to 2.6.12.1 and not necessarily later kernel versions.
There are four terms that are similarly named, related, but not necessarily equal. From highest level to lowest...
Here are the constraints as I understand them.
So in my case, the virtual block size was adjusted from 264 bytes to 4224 bytes by the kernel. My jffs2 file system thus worked by using
-e 4224
option for mkfs.jffs2. The driver erases each 4224-byte long virtual block one page at a time.Other considerations:
-s pagesize
option is related to the kernel page size according to the man page. I used my kernel page size using-s 4096
.-e
parameter less than 4096 bytes is unlikely, making my problem with the units moot.