Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 07-14-2005, 11:38 AM   #1
Registered: Mar 2004
Distribution: CentOS 4.3/4.5
Posts: 72

Rep: Reputation: 15
JFFS2 on USB Card Reader Flash

I am developing an embedded product that has attached to it an Internal USB based Flash Card reader. This card reader works fine in RH 9 mouting it as the /dev/sda1, /dev/sdb1, /dev/sdc1, /dev/sdd1 devices. The cards that I am using are formatted (as usual) with the vfat file system and the system currently works fine using that. I would like to add increased reliability to the system by reformatting the drives with the JFFS2 file system.

I have downloaded the basic JFFS2 documents from Redhat but can anyone help me with certain details like:

Can I even use JFFS2 with a usb flash reader since it comes up as a scsi device and not a mtb device?
Do I need to get the flash card reader recognized as an mtb device somehow in order to use that file system (how do I do this if this is true)?
What files do I need to install in the RH9 install to get JFFS2 working?
Do I have to rebuild the kernel? What options do I have to set?
Are there any good instructions for doing this?
What is the last version of JFFS2 that anyone has tested reliably with RH9 (updated with the latest rpm's)?

Any documents or links that you could point me to would be greatly appreciated. The info I have found so far has been lacking in details.
Old 07-14-2005, 01:41 PM   #2
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 124Reputation: 124
I'm no expert on JFFS2, but googling turned this up, which looks like it might be helpful:


I have used jffs2 on a cf card via the blkmtd module (mtd emulation using
a block device) as a root filesystem. The read and write speeds were fast
enough (for our application). You incur a bit more cpu overhead than
normal. The only bad side-effect was boot time -- when blkmtd is inserted
at boot for a 64MB jffs2-emulating cf card, there is a 5-10 minute pause.
I don't know why, and haven't bothered looking into it. I'm hoping that
by sharing my strategy, someone else will tell me the "right" way to fix
this (or tell me that this is a stupid thing to do!).

If you didn't want the jffs2 partition as the root filesystem, you only
need to load the drivers mentioned below (and make the initial jffs2 image
with mkfs.jffs2).

Details for root fs using jffs2 on a CF card:

We wanted to change as few files from a custom install based on Red
Hat 7.1, which meant messing with initial ramdisks. In a "normal"
situation, you'd want to compile stuff into the kernel:

kernel stuff needed (xconfig section, name, symbol, module name)

1) MTD
mtd support
2) MTD
caching block device access to MTD devices
3) MTD/Self-contained MTD device drivers
emulation using block device
4) File systems
Journalling Flash File System v2 (JFFS2) support

Steps we use (you can do other stuff, of course):

On a host computer with a CF card reader:

1) partition CF card as desired. Note *exact* size of partition which
will hold the jffs2 filesystem. This should be a multiple of the cylinder
size for the CF card. Call this SIZE. If you screw this up, you can get
really weird results with strange jffs2 errors (at least if you make it
too big).

2) make your initial jffs2 filesystem image with mkfs.jffs2 (available
precompiled for some platforms from the jffs2 web page, and source is in
their cvs archive). Pad the image to SIZE (using --pad).

3) write jffs2 image onto partition using dd.

4) fix initial ramdisk image to included needed device nodes and modules:
*) run mkinitrd, including these options among others
"--preload mtdcore --preload mtdblock --preload blkmtd"
If you are compiling a kernel from scratch, don't build these mtd
items as modules; build them into the kernel instead, and you won't
need an initial ramdisk.
*) make device nodes on ramdisk image:
i) mv ramdisk.image ramdisk.image.gz
ii) gzip -d ramdisk.image.gz
iii) mount -o loop ramdisk.image /mnt/floppy
iv) create nodes for accessing CF card, such as hda or hdc
v) create nodes for mtd stuff:
for minor in `seq 0 7`; do
mknod "$initrdmnt/$devname" b 31 "$minor"
ln -s "$devname" "$initrdmnt/dev/mtdblock${minor}"
vi) umount /mnt/floppy
vii) gzip ramdisk.image
viii) mv ramdisk.image.gz ramdisk.image

5) Set up your fstab with /dev/mtdblockX as the device holding the Xth
mounted jffs2 partition (X starts at 0, of course).

6) Set up modules.conf to associate the CF card device (e.g. /dev/hda)
with the blkmtd driver. I add the following, since my root filesystem is
the second partition on the CF card.

options blkmtd device=/dev/hda2 erasesz=64
below mtdblock mtdcore
below blkmtd mtdblock
below jffs2 blkmtd

7) I should have said this before -- LILO and GRUB don't like jffs2 yet
(as far as I knew when I was doing this a few months ago), so you have to
have a "nice" partition around for the bootloader's second stage files and
kernel (i.e. /boot). Thus my fstab contains

/dev/mtdblock0 / jffs2 defaults,rw,noatime,sync 0 0
/dev/hda1 /boot ext2 defaults,rw,sync,noatime 1 1

8) Set up your boot loader in the "usual" way, with mtdblockX as the root
device and your modified initial ramdisk "ramdisk.image" (if you are using
modules). Re-read point 7) about bootloaders needing "nice" filesystems
like ext2, and place anything the bootloader needs there (including
kernel, config file(s), second stage stuff, whatever).


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
USB flash card reader in Mandrake 10.1 enrico14569 Linux - Hardware 4 10-02-2005 06:57 PM
Configuring USB flash card reader in Mandrake 10.1 enrico14569 Linux - Newbie 3 10-02-2005 12:31 PM
USB Flash card reader probs Randomcasualty Linux - Hardware 15 08-09-2005 08:20 PM
USB Compact flash card reader with XANDROS dkunjeer Linux - Newbie 1 08-03-2004 03:07 PM
Need a little help getting USB flash card reader to work Electrode Linux - Hardware 13 10-20-2003 04:04 PM > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 02:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration