Skip to contentSkip to conversation

MTD and jffs2 mount problem on Linux-2.6.23 rc2

DISCUSSION Dach Miroslaw 3 participants 7 messages Mar 5, 2008 – Mar 6, 2008 1 message not in the archive Memory technology devices (MTD)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): C3F2E592.DC63%[email protected]

#1 lore raw

Hi Grant,

Thanks for your hints. As regards the endianness. I have tried both little and big endian options. In my case only Big endian (native for ppc405) is accepted. There is however the CRC calculation mismatch between the calculated one (by the kernel) during mounting the jffs2 and that one which is calculated by mkfs.jffs2.

I am however not sure that the Flash memory access in my case is fine for all modes A8 A16 A32.
I have got than idea to test jffs2 image stored somehow in RAM instead of Flash to test if jffs2 image generated by mkfs.jffs2 is consistent from kernel 2.6.23 point of view.

this what I have tried was:

losetup /dev/loop0 img2.jffs2
mount -t jffs2 /dev/loop0 /mnt

unfortunately mount did not work.

Maybe it is possible somehow to use RAMDISK to emulate the Flash to mount jffs2 image?

Best Regards

M.

-----Original Message-----
From: Grant Erickson [mailto:[email protected]]
Sent: Tue 3/4/2008 8:40 PM
To: Dach Miroslaw
Subject: Re: MTD and jffs2 mount problem on Linux-2.6.23 rc2

Quoted 2 lines · Dach Miroslaw

In fact I have NOR flash. The 'dd' command to copy data to flash and backwards to the file works fine so I thing that 'dd' is not the issue.

Seems reasonable.

Quoted 2 lines

I suspect that crc32 works differently when generating the jffs2 image file and the kernel uses different calculation methode? Maybe I am wrong.

Are you specifying an endianness/byte ordering on the command line when creating the JFFS2 file system?

Quoted 3 lines

Maybe it is the problem to access the Flash memory? Is there any method to mount jffs2 image in RAM instead of Flash just to test the jffs2 image consistency?

If your kernel is so configured, you should be able to mount it via the loopback device:

mount -t loop root.img /mnt

Regards,

Grant

#2 lore raw

Hi!
Am Mittwoch, den 05.03.2008, 09:24 +0100 schrieb Dach Miroslaw:

Quoted 9 lines

Hi Grant,

Thanks for your hints. As regards the endianness. I have tried both little and big endian options. In my case only Big endian (native for ppc405) is accepted. There is however the CRC calculation mismatch between the calculated one (by the kernel) during mounting the jffs2 and that one which is calculated by mkfs.jffs2.

I am however not sure that the Flash memory access in my case is fine for all modes A8 A16 A32.
I have got than idea to test jffs2 image stored somehow in RAM instead of Flash to test if jffs2 image generated by mkfs.jffs2 is consistent from kernel 2.6.23 point of view.

Quoted 6 lines

this what I have tried was:

losetup /dev/loop0 img2.jffs2
mount -t jffs2 /dev/loop0 /mnt

unfortunately mount did not work.

This can't work, because jffs2 is using the block-device mtdblock only to get device-information about the mtd-device. jffs2 itself is using the mtd-api directly. so jffs2 only on mtd.

Quoted 3 lines

Maybe it is possible somehow to use RAMDISK to emulate the Flash to mount jffs2 image?

There is a nand-Simulator (nandsim). It simulates a nand in kernel-virtual-memory. With nandsim you'll get a ram-mtd-device, on witch jffs2 can be used.

Using nandsim: http://www.linux-mtd.infradead.org/faq/nand.html

Example: simulating 32MB 8bit nand-flash (page:512, eb: 16K):
* nandsim & mtd

   # modprobe nandsim first_id_byte=0x20 second_id_byte=0x35
   # modprobe mtdblock
   # modprobe mtdchar
 * erase (not neccessary)
   # flash_eraseall /dev/mtd0
   Erasing 16 Kibyte @ 1ffc000 -- 99 % complete.
 * Create jffs2-Image
   # mkfs.jffs2 -p 512 -s 512 -e 16384 -d jffs2 -o jffs2.img
 * Write to nandsim
   # nandwrite /dev/mtd0 jffs2.img
   Writing data to block 0
   Writing data to block 4000
 * Mount
   # mount /dev/mtdblock0 /mnt/ -t jffs2
Quoted 34 lines

Best Regards

M.

-----Original Message-----
From: Grant Erickson [mailto:[email protected]]
Sent: Tue 3/4/2008 8:40 PM
To: Dach Miroslaw
Subject: Re: MTD and jffs2 mount problem on Linux-2.6.23 rc2

Quoted 2 lines · Dach Miroslaw

In fact I have NOR flash. The 'dd' command to copy data to flash and backwards to the file works fine so I thing that 'dd' is not the issue.

Seems reasonable.

Quoted 2 lines

I suspect that crc32 works differently when generating the jffs2 image file and the kernel uses different calculation methode? Maybe I am wrong.

Are you specifying an endianness/byte ordering on the command line when creating the JFFS2 file system?

Quoted 3 lines

Maybe it is the problem to access the Flash memory? Is there any method to mount jffs2 image in RAM instead of Flash just to test the jffs2 image consistency?

If your kernel is so configured, you should be able to mount it via the loopback device:

mount -t loop root.img /mnt

Regards,

Quoted 8 lines

Grant

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Greetings
Manfred

#3 lore raw
Quoted 9 lines · Schlägl Manfred jun.

Am Mittwoch, den 05.03.2008, 09:24 +0100 schrieb Dach Miroslaw:

Quoted 5 lines

losetup /dev/loop0 img2.jffs2
mount -t jffs2 /dev/loop0 /mnt

unfortunately mount did not work.

This can't work, because jffs2 is using the block-device mtdblock only to get device-information about the mtd-device. jffs2 itself is using the mtd-api directly. so jffs2 only on mtd.

Some people use loop and block2mtd to mount jffs2 images. Hardly elegant, but it seems to work.

Jörn

Signature · 4 lines
Don't worry about people stealing your ideas. If your ideas are any good,
you'll have to ram them down people's throats.
-- Howard Aiken quoted by Ken Iverson quoted by Jim Horning quoted by
   Raph Levien, 1979
#4 lore raw

Hi Jörn,

Thank you for the hint. I have recompiled the kernel with built-in block2mtd driver.

Do you know where to find some examples how to use block2mtd with jffs2 image.

Best Regards

M.

-----Original Message-----
From: Jörn Engel [mailto:[email protected]]
Sent: Wed 3/5/2008 1:03 PM
To: Schlägl Manfred jun.
Cc: Dach Miroslaw; [email protected]; Grant Erickson
Subject: Re: MTD and jffs2 mount problem on Linux-2.6.23 rc2

Quoted 9 lines · Schlägl Manfred jun.

Am Mittwoch, den 05.03.2008, 09:24 +0100 schrieb Dach Miroslaw:

Quoted 5 lines

losetup /dev/loop0 img2.jffs2
mount -t jffs2 /dev/loop0 /mnt

unfortunately mount did not work.

This can't work, because jffs2 is using the block-device mtdblock only to get device-information about the mtd-device. jffs2 itself is using the mtd-api directly. so jffs2 only on mtd.

Some people use loop and block2mtd to mount jffs2 images. Hardly elegant, but it seems to work.

Jörn

Signature · 4 lines
Don't worry about people stealing your ideas. If your ideas are any good,
you'll have to ram them down people's throats.
-- Howard Aiken quoted by Ken Iverson quoted by Jim Horning quoted by
   Raph Levien, 1979
#5 lore raw
Quoted 4 lines · Dach Miroslaw

Thank you for the hint. I have recompiled the kernel with built-in block2mtd driver.

Do you know where to find some examples how to use block2mtd with jffs2 image.

I don't. If someone wants to write some documentation, I'd gladly add it.

But I believe this should do the trick:
echo block2mtd=/dev/loop0 > /sys/modules/block2mtd/parameters/block2mtd or to explicitly set the erase size:
echo block2mtd=/dev/loop0,128KiB > /sys/modules/block2mtd/parameters/block2mtd

Jörn

Signature · 4 lines
The story so far:
In the beginning the Universe was created.  This has made a lot
of people very angry and been widely regarded as a bad move.
-- Douglas Adams
#6 lore raw

Hi Jorn,

I have followed your idea with block2mtd.

The steps I have done are as following:

# mkdir /mnt
# ./mkfs.jffs2 -n --pad=0xA0000 --eraseblock=0x20000 --root=MTEST-PC-M24 --output=image2.jffs2
# losetup /dev/loop0 image2.jffs2
# insmod block2mtd block2mtd=/dev/loop0,640ki
[ 2715.317777] block2mtd: mtd4: [d: /dev/loop0] erase_size = 640KiB [655360]
# mount -t jffs2 /dev/mtdblock4 /mnt
[ 2725.702309] jffs2: Too few erase blocks (1)

mount: mounting mtd4 on /mnt failed

I have no idea what is the meaning of "Too few erase blocks".

Best Regards

M.

-----Original Message-----
From: Jörn Engel [mailto:[email protected]]
Sent: Wed 3/5/2008 2:50 PM
To: Dach Miroslaw
Cc: Jörn Engel; Schlägl Manfred jun.; [email protected]; Grant Erickson
Subject: Re: MTD and jffs2 mount problem on Linux-2.6.23 rc2

Quoted 4 lines · Dach Miroslaw

Thank you for the hint. I have recompiled the kernel with built-in block2mtd driver.

Do you know where to find some examples how to use block2mtd with jffs2 image.

I don't. If someone wants to write some documentation, I'd gladly add it.

But I believe this should do the trick:
echo block2mtd=/dev/loop0 > /sys/modules/block2mtd/parameters/block2mtd or to explicitly set the erase size:
echo block2mtd=/dev/loop0,128KiB > /sys/modules/block2mtd/parameters/block2mtd

Jörn

Signature · 4 lines
The story so far:
In the beginning the Universe was created.  This has made a lot
of people very angry and been widely regarded as a bad move.
-- Douglas Adams
#7 lore raw
Quoted 2 lines · Dach Miroslaw
# insmod block2mtd block2mtd=/dev/loop0,640ki
                                          ^^^^^
Quoted 1 line
[ 2715.317777] block2mtd: mtd4: [d: /dev/loop0] erase_size = 640KiB [655360]
                                                               ^^^^^^

That number is likely wrong. Also you might have to pad your image with 0xff a bit.

Jörn

Signature · 2 lines
All art is but imitation of nature.
-- Lucius Annaeus Seneca