Skip to contentSkip to conversation

jffs2 / eCos

DISCUSSION Bob Koninckx 3 participants 10 messages Mar 30, 2003 – Apr 2, 2003 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hi all

I successfully included jffs2 in my powerpc based system. The fileio1 test runs sucessfully. I am now trying to flash an initial version of the filesystem to be used by my application.

The block size of my flash is 128kBytes. I made the filesystem image with the following command

mkfs.jffs2 -v --big-endian -e 0x20000 -r ./jffs2root -o jffs2root.img -p

First I tried mkfs.jffs2 version 1.32. Mounting the filesystem did not even succeed in this case. Apparently some magic number that needed to be 1985 was read as 8519. Some endianness problem I suppose.

After upgrading to version 1.35, the filesystem can be mounted. Files and directories appear to be present (the same fileio1 test still runs sucessfull and lists what should be present). Opening a file on this system seems to succeed (fopen returns a FILE * anyway). However, when I try to _read_ from the file, I get EIO errors.

Has anybody successfully used mkfs.jffs2 for making a filesystem image for a powerpc target system running eCos ? Am I doing something obvious wrong ?

Thanks, Bob

PS1. I am not subscribed to the jffs2 mailing list, please reply to my personal address
PS2. The host system I am using is a PIII running RH linux 8.0

Signature · 8 lines
----------------------------------------------------------------------
ir. Bob Koninckx
Katholieke Universiteit Leuven
Division Production Engineering,                   tel.  +32 16 322535
Machine Design and Automation                      fax.  +32 16 322987
Celestijnenlaan 300B                  bob.koninckx at mech.kuleuven.ac.be
B-3001 Leuven Belgium               http://www.mech.kuleuven.ac.be/pma
----------------------------------------------------------------------
#1 lore raw
Quoted 5 lines · Bob Koninckx

I successfully included jffs2 in my powerpc based system. The fileio1 test runs sucessfully. I am now trying to flash an initial version of the filesystem to be used by my application.

Quoted 8 lines

The block size of my flash is 128kBytes. I made the filesystem image with the following command

mkfs.jffs2 -v --big-endian -e 0x20000 -r ./jffs2root -o jffs2root.img -p

First I tried mkfs.jffs2 version 1.32. Mounting the filesystem did not even succeed in this case. Apparently some magic number that needed to be 1985 was read as 8519. Some endianness problem I suppose.

You forgot -b (big endian), it seems.

Quoted 5 lines

After upgrading to version 1.35, the filesystem can be mounted. Files and directories appear to be present (the same fileio1 test still runs sucessfull and lists what should be present). Opening a file on this system seems to succeed (fopen returns a FILE * anyway). However, when I try to _read_ from the file, I get EIO errors.

This is strange. You still forgot -b but can mount it?

J?rn

Signature · 4 lines
More computing sins are committed in the name of efficiency (without
necessarily achieving it) than for any other single reason - including
blind stupidity.
-- W. A. Wulf 
#2 lore raw
Quoted 9 lines · J?rn Engel
Quoted 8 lines · Bob Koninckx

I successfully included jffs2 in my powerpc based system. The fileio1 test runs sucessfully. I am now trying to flash an initial version of the filesystem to be used by my application.

The block size of my flash is 128kBytes. I made the filesystem image with the following command

Quoted 7 lines
Quoted 5 lines

mkfs.jffs2 -v --big-endian -e 0x20000 -r ./jffs2root -o jffs2root.img -p

First I tried mkfs.jffs2 version 1.32. Mounting the filesystem did not even succeed in this case. Apparently some magic number that needed to be 1985 was read as 8519. Some endianness problem I suppose.

You forgot -b (big endian), it seems.

I _did_ specify --big-endian. That has the same effect doesn't it ?

Quoted 10 lines
Quoted 6 lines

After upgrading to version 1.35, the filesystem can be mounted. Files and directories appear to be present (the same fileio1 test still runs sucessfull and lists what should be present). Opening a file on this system seems to succeed (fopen returns a FILE * anyway). However, when I try to _read_ from the file, I get EIO errors.

This is strange. You still forgot -b but can mount it?

J?rn

Signature · 8 lines
----------------------------------------------------------------------
ir. Bob Koninckx
Katholieke Universiteit Leuven
Division Production Engineering,                   tel.  +32 16 322535
Machine Design and Automation                      fax.  +32 16 322987
Celestijnenlaan 300B                  bob.koninckx at mech.kuleuven.ac.be
B-3001 Leuven Belgium               http://www.mech.kuleuven.ac.be/pma
----------------------------------------------------------------------
#3 lore raw
Quoted 12 lines · Bob Koninckx
Quoted 11 lines · J?rn Engel
Quoted 10 lines · Bob Koninckx

I successfully included jffs2 in my powerpc based system. The fileio1 test runs sucessfully. I am now trying to flash an initial version of the filesystem to be used by my application.

The block size of my flash is 128kBytes. I made the filesystem image with the following command

mkfs.jffs2 -v --big-endian -e 0x20000 -r ./jffs2root -o jffs2root.img -p

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

First I tried mkfs.jffs2 version 1.32. Mounting the filesystem did not even succeed in this case. Apparently some magic number that needed to be 1985 was read as 8519. Some endianness problem I suppose.

You forgot -b (big endian), it seems.

I _did_ specify --big-endian. That has the same effect doesn't it ?

It should. But then again, I'd have to check the code to see that it's smarter than me. :)

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

After upgrading to version 1.35, the filesystem can be mounted. Files and directories appear to be present (the same fileio1 test still runs sucessfull and lists what should be present). Opening a file on this system seems to succeed (fopen returns a FILE * anyway). However, when I try to _read_ from the file, I get EIO errors.

This is strange. You still forgot -b but can mount it?

Even stranger now. Jffs2 on powerpc work just fine for me (unter linux), mkfs.jffs2 on i386 host included.

J?rn

Signature · 3 lines
Measure. Don't tune for speed until you've measured, and even then
don't unless one part of the code overwhelms the rest.
-- Rob Pike
#4 lore raw
In reply to Bob Koninckx
Quoted 3 lines · Bob Koninckx

First I tried mkfs.jffs2 version 1.32. Mounting the filesystem did not even succeed in this case. Apparently some magic number that needed to be 1985 was read as 8519. Some endianness problem I suppose.

We broke the endianness support in mkfs.jffs2...

Quoted 1 line

After upgrading to version 1.35, the filesystem can be mounted.

... then we fixed it :)

Quoted 5 lines

Files
and directories appear to be present (the same fileio1 test still runs sucessfull and lists what should be present). Opening a file on this system seems to succeed (fopen returns a FILE * anyway). However, when I try to _read_ from the file, I get EIO errors.

Compile with CONFIG_JFFS2_FS_DEBUG set to 1 (in os-ecos.h iirc). Show the error messages you get before it gives you EIO.

Quoted 3 lines

Has anybody successfully used mkfs.jffs2 for making a filesystem image for a powerpc target system running eCos ? Am I doing something obvious wrong ?

You're doing nothing obviously wrong. The endianness support in mkfs.jffs2 was temporarily broken, but that led to the failure to mount which you first saw -- it shouldn't be related to the latter problem.

Signature · 1 line
dwmw2
#5 lore raw

Ok, I think I've come closer :)

Apparently, it has to do with the check

} else if (frag->ofs < offset && (offset & (PAGE_CACHE_SIZE-1)) != 0) {
D1(printk(KERN_NOTICE "Eep. Overlap in ino #%u fraglist. frag->ofs =

          0x%08x, offset = 0x%08x\n",
          f->inocache->ino, frag->ofs, offset));

D1(jffs2_print_frag_list(f));
memset(buf, 0, end - offset);
return -EIO;
} else if (!frag->node) {

in read.c / function jffs2_read_inode_range

The ecos libc buffers only 256 bytes of data, PAGE_CACHE SIZE is defined to be 4kB. The first access consequently succeeds, the second one fails
...

I suppose all that needs to be done (for eCos) is make the PAGE_CACHE_SIZE definition agree with the eCos libc BUFSIZ definition. I am not sure though.

Bob

Quoted 30 lines · David Woodhouse
Quoted 3 lines · Bob Koninckx

First I tried mkfs.jffs2 version 1.32. Mounting the filesystem did not even succeed in this case. Apparently some magic number that needed to be 1985 was read as 8519. Some endianness problem I suppose.

We broke the endianness support in mkfs.jffs2...

Quoted 1 line

After upgrading to version 1.35, the filesystem can be mounted.

... then we fixed it :)

Quoted 5 lines

Files
and directories appear to be present (the same fileio1 test still runs sucessfull and lists what should be present). Opening a file on this system seems to succeed (fopen returns a FILE * anyway). However, when I try to _read_ from the file, I get EIO errors.

Compile with CONFIG_JFFS2_FS_DEBUG set to 1 (in os-ecos.h iirc). Show the error messages you get before it gives you EIO.

Quoted 3 lines

Has anybody successfully used mkfs.jffs2 for making a filesystem image for a powerpc target system running eCos ? Am I doing something obvious wrong ?

You're doing nothing obviously wrong. The endianness support in mkfs.jffs2 was temporarily broken, but that led to the failure to mount which you first saw -- it shouldn't be related to the latter problem.

Signature · 1 line
dwmw2
Signature · 8 lines
----------------------------------------------------------------------
ir. Bob Koninckx
Katholieke Universiteit Leuven
Division Production Engineering,                   tel.  +32 16 322535
Machine Design and Automation                      fax.  +32 16 322987
Celestijnenlaan 300B                  bob.koninckx at mech.kuleuven.ac.be
B-3001 Leuven Belgium               http://www.mech.kuleuven.ac.be/pma
----------------------------------------------------------------------
#6 lore raw

Please don't reply to cross-posts which have travelled via the eCos list. The gratuitous and redundant noise which that list adds to the Subject line is not welcome here.

Also, please don't top-post (except for editorial comments such as this one and the one above :)

Quoted 15 lines · Bob Koninckx

Ok, I think I've come closer :)

Apparently, it has to do with the check

} else if (frag->ofs < offset && (offset & (PAGE_CACHE_SIZE-1)) != 0) {
D1(printk(KERN_NOTICE "Eep. Overlap in ino #%u fraglist. frag->ofs =

          0x%08x, offset = 0x%08x\n",
          f->inocache->ino, frag->ofs, offset));

D1(jffs2_print_frag_list(f));
memset(buf, 0, end - offset);
return -EIO;
} else if (!frag->node) {

Quoted 4 lines

in read.c / function jffs2_read_inode_range

The ecos libc buffers only 256 bytes of data, PAGE_CACHE SIZE is defined to be 4kB. The first access consequently succeeds, the second one fail

Hmmm. I could have sworn I'd already fixed that -- doesn't seem like it though.

Quoted 3 lines

I suppose all that needs to be done (for eCos) is make the PAGE_CACHE_SIZE definition agree with the eCos libc BUFSIZ definition. I am not sure though.

No because that would mean we never write a node with more than BUFSIZ (256 bytes) of data payload, which would mean we take up a lot more space on the medium for any given file -- more node headers and worse compression.

We should just fix jffs2_read_inode_range() to handle reads which don't start at the beginning of a node. It's not hard.

Signature · 1 line
dwmw2
#7 lore raw
Quoted 3 lines · David Woodhouse

Please don't reply to cross-posts which have travelled via the eCos list. The gratuitous and redundant noise which that list adds to the Subject line is not welcome here.

Sorry about that. Won't happen again ...

Quoted 3 lines

Also, please don't top-post (except for editorial comments such as this one and the one above :)

I am learning fast

Quoted 29 lines · Bob Koninckx
Quoted 15 lines

Ok, I think I've come closer :)

Apparently, it has to do with the check

} else if (frag->ofs < offset && (offset & (PAGE_CACHE_SIZE-1)) != 0) {
D1(printk(KERN_NOTICE "Eep. Overlap in ino #%u fraglist. frag->ofs =

          0x%08x, offset = 0x%08x\n",
          f->inocache->ino, frag->ofs, offset));

D1(jffs2_print_frag_list(f));
memset(buf, 0, end - offset);
return -EIO;
} else if (!frag->node) {

Quoted 4 lines

in read.c / function jffs2_read_inode_range

The ecos libc buffers only 256 bytes of data, PAGE_CACHE SIZE is defined to be 4kB. The first access consequently succeeds, the second one fail

Hmmm. I could have sworn I'd already fixed that -- doesn't seem like it though.

Quoted 3 lines

I suppose all that needs to be done (for eCos) is make the PAGE_CACHE_SIZE definition agree with the eCos libc BUFSIZ definition. I am not sure though.

Quoted 7 lines

No because that would mean we never write a node with more than BUFSIZ (256 bytes) of data payload, which would mean we take up a lot more space on the medium for any given file -- more node headers and worse compression.

We should just fix jffs2_read_inode_range() to handle reads which don't start at the beginning of a node. It's not hard.

I removed the above mentioned check and now it _appears_ to work correctly. Is this all that needs to be done ? Are there similar issues when writing to the filesys ?

Bob

Quoted 3 lines
Signature · 2 lines
-- 
dwmw2
Signature · 8 lines
----------------------------------------------------------------------
ir. Bob Koninckx
Katholieke Universiteit Leuven       
Division Production Engineering,                   tel.  +32 16 322535
Machine Design and Automation                      fax.  +32 16 322987
Celestijnenlaan 300B                  [email protected]
B-3001 Leuven Belgium               http://www.mech.kuleuven.ac.be/pma
----------------------------------------------------------------------
#8 lore raw
Quoted 5 lines · Bob Koninckx
Quoted 2 lines

We should just fix jffs2_read_inode_range() to handle reads which don't start at the beginning of a node. It's not hard.

I removed the above mentioned check and now it _appears_ to work correctly. Is this all that needs to be done ?

Can you show me the patch or resulting code?

Quoted 1 line

Are there similar issues when writing to the filesys ?

No, writing should be fine -- but you really do want to try to ensure that you don't get writes split up into 256-byte chunks, since that'll waste space on the file system (till it gets GC'd and merged).

Signature · 1 line
dwmw2
#9 lore raw
Quoted 8 lines · David Woodhouse
Quoted 5 lines · Bob Koninckx
Quoted 2 lines

We should just fix jffs2_read_inode_range() to handle reads which don't start at the beginning of a node. It's not hard.

I removed the above mentioned check and now it _appears_ to work correctly. Is this all that needs to be done ?

Can you show me the patch or resulting code?

Just commented the lines containing the test out. Anyway, if you want a patch to see it for yourself... :-)

Quoted 6 lines
Quoted 2 lines

Are there similar issues when writing to the filesys ?

No, writing should be fine -- but you really do want to try to ensure that you don't get writes split up into 256-byte chunks, since that'll waste space on the file system (till it gets GC'd and merged).

Certainly won't be before the week-end. You don't have by any chance any (standard) test cases, do you ? Any suggestions to seriously test it (apart from creating a file that is larger than 256 bytes and checking with the debugger that no "holes" are left)

Thanks for looking after this so far anyway,

Bob

Quoted 1 line
Signature · 8 lines
----------------------------------------------------------------------
ir. Bob Koninckx
Katholieke Universiteit Leuven
Division Production Engineering,                   tel.  +32 16 322535
Machine Design and Automation                      fax.  +32 16 322987
Celestijnenlaan 300B                  [email protected]
B-3001 Leuven Belgium               http://www.mech.kuleuven.ac.be/pma
----------------------------------------------------------------------

? jffs.patch
Index: read.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/src/read.c,v retrieving revision 1.3

read.c +6 -6
diff -u -5 -r1.3 read.c
@@ -175,16 +175,16 @@
 			D1(printk(KERN_DEBUG "Filling non-frag hole from %d-%d\n", offset, offset+holesize));
 			memset(buf, 0, holesize);
 			buf += holesize;
 			offset += holesize;
 			continue;
-		} else if (frag->ofs < offset && (offset & (PAGE_CACHE_SIZE-1)) != 0) {
-			D1(printk(KERN_NOTICE "Eep. Overlap in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n",
-				  f->inocache->ino, frag->ofs, offset));
-			D1(jffs2_print_frag_list(f));
-			memset(buf, 0, end - offset);
-			return -EIO;
+//		} else if (frag->ofs < offset && (offset & (PAGE_CACHE_SIZE-1)) != 0) {
+//			D1(printk(KERN_NOTICE "Eep. Overlap in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n",
+//				  f->inocache->ino, frag->ofs, offset));
+//			D1(jffs2_print_frag_list(f));
+//			memset(buf, 0, end - offset);
+//			return -EIO;
 		} else if (!frag->node) {
 			uint32_t holeend = min(end, frag->ofs + frag->size);
 			D1(printk(KERN_DEBUG "Filling frag hole from %d-%d (frag 0x%x 0x%x)\n", offset, holeend, frag->ofs, frag->ofs + frag->size));
 			memset(buf, 0, holeend - offset);
 			buf += holeend - offset;