Is my erase block size correct?
I am attempting to troubleshoot an issue where my UBIFS becomes corrupted after repeated upgrade attempts. Before I submit a bug report to the list, I'm attempting to rule out as many possibilities as I can.
While rechecking the datasheet for our NAND flash (Micron MT29F4G08BABWP 4Gb), I noticed a discrepancy between the erase block size presented in the datasheet (128KiB + 4KiB) and that returned from mtdinfo (see below). The extra 4KiB overhead is due to a 64Byte overhead for each of the 64 pages/block.
root@ctc-imx51 ~$ mtdinfo -a
Count of MTD devices: 4 Present MTD devices: mtd0, mtd1, mtd2, mtd3 Sysfs interface supported: yes
mtd0
Name: nor_flash Type: dataflash Eraseblock size: 512 bytes Amount of eraseblocks: 8192 (4194304 bytes, 4.0 MiB) Minimum input/output unit size: 512 bytes Sub-page size: 512 bytes Character device major/minor: 90:0 Bad blocks are allowed: false Device is writable: true
mtd1
Name: nand.bootloader Type: nand Eraseblock size: 131072 bytes, 128.0 KiB Amount of eraseblocks: 8 (1048576 bytes, 1024.0 KiB) Minimum input/output unit size: 2048 bytes Sub-page size: 512 bytes OOB size: 64 bytes Character device major/minor: 90:2 Bad blocks are allowed: true Device is writable: true
mtd2
Name: nand.kernel Type: nand Eraseblock size: 131072 bytes, 128.0 KiB Amount of eraseblocks: 24 (3145728 bytes, 3.0 MiB) Minimum input/output unit size: 2048 bytes Sub-page size: 512 bytes OOB size: 64 bytes Character device major/minor: 90:4 Bad blocks are allowed: true Device is writable: true
mtd3
Name: nand.rootfs Type: nand Eraseblock size: 131072 bytes, 128.0 KiB Amount of eraseblocks: 4064 (532676608 bytes, 508.0 MiB) Minimum input/output unit size: 2048 bytes Sub-page size: 512 bytes OOB size: 64 bytes Character device major/minor: 90:6 Bad blocks are allowed: true Device is writable: true
I've dug into the kernel source a bit and have come to the conclusion that the erase block size reported by mtdinfo comes from an interrogation of the MTD device by its driver. I take this to mean that either I'm using the wrong driver, the driver is configured incorrectly, or the driver is correct and is not reporting the 4KiB overhead of each erase block.
Any help in confirming or refuting any of my 3 possible conclusions would be greatly appreciated. Alternate theories are, of course, welcome.
Best regards,
Russell Zuck
Quoted 5 lines · Russell Zuck
While rechecking the datasheet for our NAND flash (Micron MT29F4G08BABWP 4Gb), I noticed a discrepancy between the erase block size presented in the datasheet (128KiB + 4KiB) and that returned from mtdinfo (see below). The extra 4KiB overhead is due to a 64Byte overhead for each of the 64 pages/block.
128KiB + 4KiB just means there is 128KiB in-band (regular) data area, plus 4KiB OOB (out-of-band) area. Normally, the eraseblock size is judged by just the data area (i.e., 128KiB). But you can "find" the 4KiB by some math from the mtdinfo output:
Quoted 1 line
root@ctc-imx51 ~$ mtdinfo -a
...
Quoted 6 lines
mtd1
Name: nand.bootloader Type: nand Eraseblock size: 131072 bytes, 128.0 KiB Amount of eraseblocks: 8 (1048576 bytes, 1024.0 KiB) Minimum input/output unit size: 2048 bytes
I/O size == page size
Quoted 2 lines
Sub-page size: 512 bytes OOB size: 64 bytes
OOB size == out-of-band area per page
Quoted 3 lines
Character device major/minor: 90:2 Bad blocks are allowed: true Device is writable: true
So, OOB-per-eraseblock =
eraseblock size / page size * OOB-per-page =
128KiB / 2KiB * 64B =
64 * 64B = 4KiB
Quoted 2 lines
Any help in confirming or refuting any of my 3 possible conclusions would be greatly appreciated. Alternate theories are, of course, welcome.
"the driver is correct and is not reporting the 4KiB overhead of each erase block."
This is pretty much true. mtdinfo (and the MTD subsystem) just records these numbers slightly differently than you are reading from the data sheet.
If you post more debug information and info about your system/driver used, others may help with your UBIFS issues.
Brian
Quoted 2 lines · Brian Norris
If you post more debug information and info about your system/driver used, others may help with your UBIFS issues.
Thank you very much for the explanation. I'll post the details of my UBIFS issue with supporting info in a separate thread.
Best regards,
Russ
Quoted 4 lines · Russell Zuck
mtd0
Name: nor_flash Type: dataflash Eraseblock size: 512 bytes
What does /proc/mtd contain?
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 5 lines · Artem Bityutskiy
Quoted 4 lines
mtd0
Quoted 3 lines
Name: nor_flash Type: dataflash Eraseblock size: 512 bytesWhat does
/proc/mtdcontain?
My apologies for the delayed reply. I've been on vacation and unplugged by design.
Currently, we are booting out of the nor_flash partition and also loading the kernel from there. Due to other technical challenges, we are not using either the mtd1 or mtd2 partitions at the moment.
dev: size erasesize name
mtd0: 00400000 00000200 "nor_flash"
mtd1: 00100000 00020000 "nand.bootloader"
mtd2: 00300000 00020000 "nand.kernel"
mtd3: 1fc00000 00020000 "nand.rootfs"
Please see my thread "UBIFS corruption after software upgrade" originally posted on 7/24/2012 for more details about the problem that prompted this question about erase block size. Any assistance you can provide with this issue would be greatly appreciated.
Best regards,
Russell Zuck