jffs2+mtd+big endian problem
Li Yang
leoli at motorola.com
Mon Jan 19 05:58:01 EST 2004
On Mon, 2004-01-19 at 17:17, David Woodhouse wrote:
> On Mon, 2004-01-19 at 16:43 +0800, Li Yang-r58472 wrote:
> > Hi,
> >
> > I'm doing a JFFS2 port to a PowerPC target board. I have several
> > questions while porting.
> >
> > 1. Which kind of endian should I use in JFFS2? Mkfs.jffs2 (older
> > version, I have tried the new binary on JFFS2 website, the
big-endian
> > option breaks) can generate images of the two endian types.
>
> There are two options. First, you can try a fixed version of
mkfs.jffs2
> which gets the byte-swapping right. I've uploaded the current CVS
> version, 1.39, to sources.redhat.com now -- I think that should be OK.
>
> Second, you could use the current CVS JFFS2 code (you should probably
> use that anyway since it has a lot of optimisations missing from older
> kernels), and make it use little-endian images by defining
> JFFS2_LITTLE_ENDIAN instead of JFFS2_NATIVE_ENDIAN at about line 90 of
> include/linux/jffs2.h
I have some problem accessing CVS from the damned corporate network.
I'm a poor guy living on binaries and snapshots. :( Thanks for you
update.
I'm using JFFS2 code from kernel-2.4.22. Seems it's pretty old code in
the kernel. Could you kindly give me a recent snapshot or direct me to
a link to download it?
>
> > 2. I added a new map file in driver/mtd/maps directory. Which
> > read/write/memcpy operation should I use? __raw_readw() or readw()?
> > Or Inw()? They determined whether to swap bytes.
>
> That depends on how your hardware is wired up. It's probably best not
to
> try this with JFFS2, which introduces its own endianness complexity...
> try it with raw read/write (and the erase ioctl of course) on the
> /dev/mtd devices. Read and write data in units of 1, 2 and 4 bytes at
> various offsets and see what you get.
>
> > I have tried several cases. When I use little-endian fs and
> > __raw_read(), the JFFS2 mount got error: jffs2_scan_eraseblock():
> > Magic bitmask 0x1985 not found at 0x00000000: 0x8519 instead.
> >
> > However, after I change to use big-endian fs, mount can be
successful.
> > Create new file on JFFS2 got error: Node totlen on flash
(0x44000000)
> > != totlen in node ref (0x00000044). Seems data written to flash are
> > 32-bit byte-swaped.
>
> That's odd. If you look in the image file you downloaded to the board,
> is it telling the truth? Do you actually see (00,00,00,44) or
> (44,00,00,00). Can you make the actual image available to me to play
> with, and I'll tell you whether it's a valid image and your board
> mapping is at fault, or whether it's an invalid image.
The image generated by mkfs.jffs2 with -b seems ok, but it's not all
right after I done some operations on the target. In the bottom is the
log of these operations.
Yes, I have examined a section which is formatted by the target board.
The first several bytes of the section are:
fe3c0000: 03208519 0c000000 98dc60f0 ffffffff . ........`.....
fe3c0010: ffffffff ffffffff ffffffff ffffffff ................
They are all 32-bit swapped. I traced into the JFFS2 code, and know it
use mtd->write to write data into flash. Which function is it turned
out to be finally? Is it the write defined in the drivers/mtd/maps/
files? I used __raw_write*() at the very beginning, it shouldn't be
like this.
>
> > Has anyone here done JFFS2 on Powerpc Big-endian system? What are
> > your options?
>
> Mostly people using JFFS2 on PPC are using it in big-endian mode, I
> think.
>
> --
> dwmw2
Log of the operations:
# mount -t jffs2 /dev/mtdblock1 /mnt
mtdblock_open
ok
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x003c0000:
0x0320 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x003c0004:
0x0c00 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x003c0008:
0x98dc instead
JFFS2: Erase block at 0x003c0000 is not formatted. It will be erased
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00400000:
0x0320 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00400004:
0x0c00 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00400008:
0x98dc instead
JFFS2: Erase block at 0x00400000 is not formatted. It will be erased
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00440000:
0x0320 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00440004:
0x0c00 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00440008:
0x98dc instead
JFFS2: Erase block at 0x00440000 is not formatted. It will be erased
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00480000:
0x0320 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00480004:
0x0c00 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00480008:
0x98dc instead
JFFS2: Erase block at 0x00480000 is not formatted. It will be erased
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x004c0000:
0x0320 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x004c0004:
0x0c00 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x004c0008:
0x98dc instead
JFFS2: Erase block at 0x004c0000 is not formatted. It will be erased
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00500000:
0x0320 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00500004:
0x0c00 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00500008:
0x98dc instead
JFFS2: Erase block at 0x00500000 is not formatted. It will be erased
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00540000:
0x0320 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00540004:
0x0c00 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00540008:
0x98dc instead
JFFS2: Erase block at 0x00540000 is not formatted. It will be erased
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00580000:
0x0320 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00580004:
0x0c00 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00580008:
0x98dc instead
JFFS2: Erase block at 0x00580000 is not formatted. It will be erased
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x005c0000:
0x0320 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x005c0004:
0x0c00 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x005c0008:
0x98dc instead
JFFS2: Erase block at 0x005c0000 is not formatted. It will be erased
# cd /mnt
# ls
bin dev home mnt prj_tmp root tmp var
boot etc lib opt proc sbin usr
# touch abc
Node totlen on flash (0x44000000) != totlen in node ref (0x00000044)
# ls
abc boot etc lib opt proc sbin usr
bin dev home mnt prj_tmp root tmp var
# echo "jhskjfsldfjdklsf" > abc
Node totlen on flash (0x44000000) != totlen in node ref (0x00000044)
Node totlen on flash (0x44000000) != totlen in node ref (0x00000044)
More information about the linux-mtd
mailing list