writing to JFFS2 filesystem makes it it unusable. Plenty of "Magic bitmask 0x1985" errors...

Juha Lumme juha.lumme at gmail.com
Wed Apr 24 06:49:52 EDT 2013


Hi,

I have read the FAQ about JFFS2, but unfortunately I haven't been able 
to solve this after several days of trying.. I hope I can get some help here
I have a problem getting a jffs2 file system to work read-write. I can 
mount it ok, and read it correctly, but writing to it results to 
strangeness (fails).
Some background:
My flash chip is sst25vf064c (8MB SPI flash chip with erase block size 
of 64KB, or also 32 is ok according to datasheet).

I'm on an ARM board, and working on a read-only rootfs created with 
buildroot (squashfs). Now I would like to create overlays for /home and 
/etc for writing purposes, and thought JFFS2 would be a good solution 
for this.

For testing purposes, I have created a simple home structure:
jlumme at 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

 From this I create an jffs2 image, with this command:
mkfs.jffs2 -r jffs2_home/ -e 64 -p -o home.jffs2
$ ls home.jffs2 -la
-rw-r--r-- 1 jlumme jlumme 65536 Apr 24 19:16 home.jffs2

I'm writing my whole flash chip with flashrom, and my flash layout looks 
like this:
uboot/<0x00000000 0x40000>
kernel/<0x00040000 0x3D9000>
dtb/<0x00419000 0x10000>
rootfs/<0x00429000 0x1F7000>
home/<0x00620000 0x1E0000> //This is where I would like to put my jffs2, 
the start is 64KB aligned

With DD I create my 1.9MB home section content, so that all other data 
is 0xFF, except what is inside home.jffs2. The flash section for home 
looks now like this (I only show the relevant beginning here, rest is 
just 0xFF until end of flash area):
http://paste.ubuntu.com/5597974/

I can mount my mtdblock fine, and all the files look ok. Now if I modify 
the test.txt, and save it, vi immediately spits out a warning:
[   77.030000] jffs2: Node totlen on flash (0xffffffff) != totlen from 
node ref (0x00000044)
At this point I can still see "the modifications". However, if I 
un-mount the drive, and remount it, I start getting new errors:
# 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

This is pretty much as far as I have gotten.
My kernel is from freescale mainline "patches-3.8" branch, with newest 
snapshot of drivers/mtd/devices folder (I saw some patches related to 
the sst25vfXXX chips, so I thought I should try those).
In my kernel I have following MTD flags enabled:
http://paste.ubuntu.com/5597993/

By default, cat /proc/mtd shows this:
# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00001000 "uboot"
mtd1: 003d9000 00001000 "kernel"
mtd2: 00010000 00001000 "dtb"
mtd3: 001f7000 00001000 "rootfs"
mtd4: 001e0000 00001000 "home"

I thought why this erase area is 4KB here (I can't create 4KB erase file 
systems. 8KB is minimum mkfs.jffs2 accepts), and hacked the m25p80.c, so 
that erasearea was 64KB, but this didn't help the case unfortunately. I 
know there is probably a good reason why this has been set to 4KB 
(sector size is 4KB), but it was confusing.
I'm really stuck here, not sure what I could try next..

I really appreciate any tips where I might have gone wrong...



More information about the linux-mtd mailing list