JFFS2 filesystem corrupts immediately (Magic bitmask 0x1985 not found errors)

4

I have created a root filesystem with buildroot that is using squashfs. It works fine, and now I would like to create an overlayfs, which would hold /home and /etc directories.

For this purpose, I wanted to create a simple jffs2 filesystem with couple of files:

jlumme@simppa:~/projects/jffs2_home$ ls -la
total 20
drwxrwxr-x 4 jlumme jlumme 4096 Apr 21 16:21 .
drwxrwxr-x 6 jlumme jlumme 4096 Apr 21 16:21 ..
drwxrwxr-x 2 jlumme jlumme 4096 Apr 21 13:45 default
drwxrwxr-x 2 jlumme jlumme 4096 Apr 21 13:45 ftp
-rw-rw-r-- 1 jlumme jlumme   24 Apr 21 15:34 test.txt

The flash chip I use is SST25VF064C, so I believe it's erase block size is 64 KB, and thus I create a filesystem image from that folder:

mkfs.jffs2 -r jffs2_home/ -e 64 -o home.jffs2
$ ls -la
-rw-r--r--  1 jlumme jlumme   496 Apr 21 15:42 home.jffs2

(Suprisingly, if I set -e 32, or even -e 4, the resulting binary image doesn't change at all???). Nevertheless, moving on, I have aligned my mtdblock that contains home, to 64KB, and my flash layout looks like this:

uboot/<0x00000000 0x40000>
kernel/<0x00040000 0x3D9000>
dtb/<0x00419000 0x10000>
rootfs/<0x00429000 0x1F7000>
home/<0x00620000 0x1E0000>

On my board, I can mount the mtdblock4 fine, and I can read the file contents properly. However, if I modify the file, and try saving it, vi complains:

[   77.030000] jffs2: Node totlen on flash (0xffffffff) != totlen from node ref (0x00000044)

Now, if I unmount the filesystem, and remount it, I start getting complaints immediately:

# mount -t jffs2 /dev/mtdblock4 /home/
[   99.740000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x001d4070: 0xff0a instead
[   99.760000] jffs2: Empty flash at 0x001d4074 ends at 0x001d412c
[   99.770000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x001d412c: 0xffff instead
[   99.790000] jffs2: Empty flash at 0x001d4130 ends at 0x001d4194
[   99.790000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x001d4194: 0xff0a instead

I suppose now my filesystem is already corrupted... and I don't really understand the reason for it.. Any ideas where am I going wrong with this ? Thanks for all suggestions..

linux
flash
filesystems
embedded-linux
jffs2
asked on Stack Overflow Apr 21, 2013 by julumme • edited Apr 21, 2013 by julumme

1 Answer

0

This is what I did to solve the issue.

  1. Updated newer MTD drivers from http://www.linux-mtd.infradead.org/
    - There was new code for SST25V064C chip
  2. Made sure the area reserved for JFFS2 was initialized to 0xFF
  3. (possibly optional) Specified more accurately the creation of jffs2 file system:

    mkfs.jffs2 -e 64 -l -p -s 4096 -r jffs2_home/ -o home.jffs2
    

With these changes the file system now reads and writes as expected.

answered on Stack Overflow Apr 27, 2013 by julumme

User contributions licensed under CC BY-SA 3.0