Chunyan Zhang | 28 Nov 12:05 2014

[PATCH] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c

This patch changes the 32-bit time type (timeval) to 64-bit
(ktime_t), since 32-bit time types will break in the year 2038.

I use ktime_t instead of timeval to define 'start' and 'finish'
which are used to get the time for tow points.

This patch also changes do_gettimeofday() to ktime_get() accordingly, since
ktime_get returns a ktime_t, but do_gettimeofday returns a struct timeval,
and the other reason is that ktime_get() uses the monotonic clock.

Signed-off-by: Chunyan Zhang <zhang.chunyan <at>>
 drivers/mtd/tests/speedtest.c   |   10 +++++-----
 drivers/mtd/tests/torturetest.c |    9 ++++-----
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c
index 5ee9f70..73e26d6 100644
--- a/drivers/mtd/tests/speedtest.c
+++ b/drivers/mtd/tests/speedtest.c
 <at>  <at>  -29,6 +29,7  <at>  <at> 
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/random.h>
+#include <linux/ktime.h>

 #include "mtd_test.h"

 <at>  <at>  -49,7 +50,7  <at>  <at>  static int pgsize;
 static int ebcnt;
(Continue reading)

Stefan Roese | 27 Nov 15:18 2014

[PATCH] mtd: gpmi: Remove "We support only one NAND chip" from bindings doc

This sentence "We support only one NAND chip now" is not true any more.
Multiple chips are supported. So lets remove this sentence to not
confuse anyone.

Signed-off-by: Stefan Roese <sr <at>>
Cc: Huang Shijie <b32955 <at>>
Cc: Brian Norris <computersforpeace <at>>
 Documentation/devicetree/bindings/mtd/gpmi-nand.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
index a011fdf..d02acaf 100644
--- a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt
 <at>  <at>  -1,7 +1,7  <at>  <at> 
 * Freescale General-Purpose Media Interface (GPMI)

 The GPMI nand controller provides an interface to control the
-NAND flash chips. We support only one NAND chip now.
+NAND flash chips.

 Required properties:
   - compatible : should be "fsl,<chip>-gpmi-nand"


Linux MTD discussion mailing list
(Continue reading)

Boris Brezillon | 27 Nov 14:29 2014

[PATCH] nand: add nandflipbits tool

The nandflipbits tool is intended to be used when one need to flip one or
several specific bits on a NAND media.
It can be useful to manually recover from an unexpected bit flip on a flash
device, though the main purpose of this tool is to provide a way to test
ECC algorithms robustness.

One typical example I used this tool for is testing HW ECC engines behavior
when bitflips occur in an erased page: most HW engines do not correctly
handle this case, because, most of the time, ECC bits generated for an
empty page are not all 1s, and, empty page detection embedded in such
engines is only validating that all bits are set to 1s (which is not true
when a bit-flip has occurred).

Signed-off-by: Boris Brezillon <boris.brezillon <at>>
 Makefile       |   2 +-
 nandflipbits.c | 332 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 333 insertions(+), 1 deletion(-)
 create mode 100644 nandflipbits.c

diff --git a/Makefile b/Makefile
index eade234..55252f8 100644
--- a/Makefile
+++ b/Makefile
 <at>  <at>  -20,7 +20,7  <at>  <at>  MTD_BINS = \
 	ftl_format flash_erase nanddump doc_loadbios \
 	ftl_check mkfs.jffs2 flash_lock flash_unlock \
 	flash_otp_info flash_otp_dump flash_otp_lock flash_otp_write \
-	mtd_debug flashcp nandwrite nandtest \
+	mtd_debug flashcp nandwrite nandtest nandflipbits \
(Continue reading)

Anton Habegger | 27 Nov 13:48 2014

UBIFS corruption after power cut


We got an unrecoverable UBI file system after power cut. It happens only ones and it is not reproducible yet. 
U-Boot is able to load a file from this file system, but the recovering part on linux fails.
The corruption occurs on a powerpc device (mpc5125) with kernel 2.6.34. 
I tried to overcome this issue with the more recent back port repository from and I also emulated an MTD device with
mtdram module on kernel 3.13 (Ubuntu 14.4). Unfortunately both versions aren't able to recover the image.

I see following scenarios:
- An UBI image created with 2.6.34 can became corrupted with power cuts due to open bugs at this time. This
image will be never recoverable. Is this possible?
- There is a misconfiguration somewhere
- There is a bug in the 3.13
- Anything else..  

Dmesg on kernel 3.13 on X86_64 with emulated device:
[88784.920976] UBIFS: recovery needed
[88784.921518] UBIFS error (pid 24455): ubifs_check_node: bad node type 255
[88784.921525] UBIFS error (pid 24455): ubifs_check_node: bad node at LEB 90:65656
[88784.921548] 	magic          0x6101831
[88784.921551] 	crc            0x6d37b9e0
[88784.921552] 	node_type      255 (unknown node)
[88784.921554] 	group_type     255 (unknown)
[88784.921556] 	sqnum          18446744073709551615
[88784.921557] 	len            4294967295
[88784.921562] node type 255 was not recognized
[88784.921570] CPU: 0 PID: 24455 Comm: mount Tainted: GF          O 3.13.0-35-generic #62-Ubuntu
[88784.921572] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform,
BIOS 6.00 07/31/2013
(Continue reading)

William Smith | 27 Nov 10:59 2014

nand_do_read_oob() has a bug?

Linux3.18-rc6, nand_base.c

In nand_do_read_oob(), there's a while() loop to deal with continuous multiple oob read operation.

Assume that:
    ops->mode = MTD_OPS_PLACE_OOB;
    ops->ooblen> mtd->oobsize;
    ops->ooboffs != 0;
    len = mtd->oobsize;

in while() loop:
    len = min(len, readlen); // here, len = mtd->oobsize
    buf = nand_transfer_oob(chip, buf, ops, len);
in function nand_transfer_oob():
    memcpy(oob, chip->oob_poi + ops->ooboffs, len); // here, len = mtd->oobsize

If the ops->ooboffs is none zero, then the copy operation will exceed the (chip->oob_poi + mtd->oobsize),
some useless bytes will be copy into buf, right?
Is this a bug?

Linux MTD discussion mailing list

Rod Campbell | 24 Nov 21:41 2014

Read-only file systems using NAND/MTD


Is there an update about implementing a read-only file system on NAND?  The
most recent discussion I could find was from May 2012:

The conclusion seemed to be to use ubi underneath something like squashfs to
provide bad-block awareness.  Is this still the recommended solution?  

Rod Campbell

From the desk of:
Rod Campbell
Senior Software Engineer
Linear Acoustic Inc.
108 Foxshire Drive, Lancaster PA 17601
Tel: 717-735-3611
Fax: 717-735-3612
E-mail: Rod.Campbell <at>

Linux MTD discussion mailing list

Angelo Dureghello | 24 Nov 10:01 2014

UBI 1MiB size partition

Dear all,

i read UBI faq and surfed the net, but can't find still a clear answer
to this:

I have a 1MiB partition on a nand flash o would like to format as UBI.
I already have the rootfs atrtached as UBI0 / UBI0_0, so i am going
to attach this partition as UBI1.

But with the available ubi commands i am not able. Is this a limitiation
due to the small partition size ?

[root <at> barix ~]# flash_erase /dev/mtd5 0 8
Erasing 128 Kibyte  <at>  e0000 -- 100 % complete

[root <at> barix ~]# ubiattach -m 5
UBI: attaching mtd5 to ubi1
UBI: scanning is finished
UBI: empty MTD device detected
UBI warning: print_rsvd_warning: cannot reserve enough PEBs for bad PEB 
handling, reserved 4, need 20
UBI: attached mtd5 (name "config", size 1 MiB) to ubi1
UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
UBI: good PEBs: 8, bad PEBs: 0, corrupted PEBs: 0
UBI: user volume: 0, internal volumes: 1, max. volumes count: 128
UBI: max/mean erase counter: 0/0, WL threshold: 4096, image sequence 
number: 193419012
UBI: available PEBs: 0, total reserved PEBs: 8, PEBs reserved for bad 
(Continue reading)

Brian Norris | 21 Nov 20:20 2014

Re: [PATCH] mtd: tests: abort torturetest on erase errors

+ linux-mtd

On Fri, Nov 21, 2014 at 06:55:54PM +0000, Jeff Lauruhn (jlauruhn) wrote:
>  Brian;
> What is the purpose of the torture test?

Please, no personal questions like this. Ask publicly so others can

And please read the code, comments, and existing documentation first.


Linux MTD discussion mailing list

Brian Norris | 21 Nov 19:24 2014

[PATCH] mtd: tests: abort torturetest on erase errors

The torture test should quit once it actually induces an error in the
flash. This step was accidentally removed during refactoring.

Without this fix, the torturetest just continues infinitely, or until
the maximum cycle count is reached. e.g.:

   [ 7619.218171] mtd_test: error -5 while erasing EB 100
   [ 7619.297981] mtd_test: error -5 while erasing EB 100
   [ 7619.377953] mtd_test: error -5 while erasing EB 100
   [ 7619.457998] mtd_test: error -5 while erasing EB 100
   [ 7619.537990] mtd_test: error -5 while erasing EB 100

Fixes: 6cf78358c94f ("mtd: mtd_torturetest: use mtd_test helpers")
Signed-off-by: Brian Norris <computersforpeace <at>>
Cc: Akinobu Mita <akinobu.mita <at>>
Cc: <stable <at>>
 drivers/mtd/tests/torturetest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/tests/torturetest.c b/drivers/mtd/tests/torturetest.c
index eeab96973cf0..b55bc52a1340 100644
--- a/drivers/mtd/tests/torturetest.c
+++ b/drivers/mtd/tests/torturetest.c
 <at>  <at>  -264,7 +264,9  <at>  <at>  static int __init tort_init(void)
 		int i;
 		void *patt;

(Continue reading)

Qi Wang 王起 (qiwang | 21 Nov 02:16 2014

[PATCH 0/2] staging: mtd: Support for GigaDevice SPI NAND flash

> On 11/20/2014 10:18 AM, Ezequiel Garcia wrote:
> Hm, perhaps it's better to rely in the NAND core code and avoid that BBT
> and ECC code handling duplication?
> Ionela and I are preparing an SPI NAND framework, but it's far from
> ready yet, so if you have something to submit, please do so :)

Yes, duplicate BBT and ECC code from nand code do is not a good idea.
But SPI NAND framework should be a standalone module in MTD, might cause
chaos if it still rely on NAND core code, that is my only concern.
How do you think?


Qi Wang

Linux MTD discussion mailing list

Ezequiel Garcia | 20 Nov 17:04 2014

Re: Using ubiblock

Hi Richard,

(Ccing the rest of the world)

On 11/20/2014 12:55 PM, Richard Koch wrote:
> I was searching for a way to use squashfs for my read-only root file system
> and came across your kernel and mtd patches.


> I was hoping you could provide me with an example of how to use it. I tried
> using nandwrite but perhaps thats not the right way?

Sigh, we really need to document this better!

> / # cat /proc/mtd
> dev:    size   erasesize  name
> mtd0: 16c00000 00020000 "nand0.roroot"
> / # flash_erase /dev/mtd0 0 0
> / # ubiattach /dev/ubi_ctrl -m 0
> UBI: attaching mtd0 to ubi1
> UBI: scanning is finished
> UBI: attached mtd0 (name "nand0.roroot", size 364 MiB) to ubi1
> UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
(Continue reading)