Title: jffs2 howto Subject: Use jffs2 in a simple way Author: John Stile ----------------------------------------------------------------------- What and why: #------------------------------------ # Ext2fs - optimized for 512 or 1024 block sizes, but flash varies # Ext2fs - sector erase coppies whole sector to RAM, erased, then rewritten back (flash limits to 100,000 wirtes). # Ext2fs - is not crash-proof # Ext2 - does not support wear levelling # Ext2fs - does not have particularly brilliant sector management, #------------------------------------ # JFFS - bad side-effect was boot time (5-10 minute pause) # JFFS - higher cpu usage than other file systems. #------------------------------------ # JFFS2 - Performas wareleveling via an abstraction between logical file positions and physical memory location # JFFS2 - Better performance than JFFS #------------------------------------ # MTD is broken into 2 secions User space, kernel spcace. # 1. MTD subsystem # 2. MTD_BLOCK projects the flash as a normal block device (like an IDE disk) # devices associated with MTD_BLOCK are /dev/mtdblock0, mtdblock1 (etc). # mtd block devices are normally formatted with JFFS2 or FTL, on top of emulcation device (/dev/mtdblock0). ----------------------------------------------------------------------- Kernel: I build blkmtd driver as a module, and other stuff as static. These are the relevent sections from the kernel 'make menuconfig' Device Drivers ---> Memory Technology Devices (MTD) ---> <*> Memory Technology Device (MTD) support [*] MTD partitioning support <*> NFTL (NAND Flash Translation Layer) support [*] Write support for NFTL Mapping drivers for chip access ---> [*] Support non-linear mappings of flash chips <*> PCI MTD driver Self-contained MTD device drivers ---> <*> Physical system RAM MTD emulation using block device <*> MTD using block device (rewrite) NAND Flash Device Drivers ---> <*> NAND Device Support [*] Verify NAND page writes File Systems ---> Miscellaneous filesystems ---> <*> Journalling Flash File System v2 (JFFS2) support (0) JFFS2 debugging verbosity (0 = quiet, 2 = noisy) [*] JFFS2 write-buffering support My .config now looks like this egrep 'MTD|JFFS' .config |egrep -v '^#|$#' CONFIG_MTD=y CONFIG_MTD_PARTITIONS=y CONFIG_MTD_MAP_BANK_WIDTH_1=y CONFIG_MTD_MAP_BANK_WIDTH_2=y CONFIG_MTD_MAP_BANK_WIDTH_4=y CONFIG_MTD_CFI_I1=y CONFIG_MTD_CFI_I2=y CONFIG_MTD_RAM=y CONFIG_MTD_COMPLEX_MAPPINGS=y CONFIG_MTD_PCI=y CONFIG_MTD_PHRAM=y CONFIG_MTD_BLKMTD=m CONFIG_MTD_BLOCK2MTD=y CONFIG_MTD_NAND=y CONFIG_MTD_NAND_VERIFY_WRITE=y CONFIG_MTD_NAND_IDS=y CONFIG_JFFS2_FS=y CONFIG_JFFS2_FS_DEBUG=0 CONFIG_JFFS2_FS_WRITEBUFFER=y CONFIG_JFFS2_ZLIB=y CONFIG_JFFS2_RTIME=y I'm using gentoo, so now I rebuild my kernel genkernel --menuconfig --no-clean --gensplash=gentoo all vi /boot/grub/menu.lst ----------------------------------------------------------------------- How: My compact flash card that shows up as hdc. This will put a 560Mb jffs2 image on partition hdc3 # # 1. Create 560Mb image file # mkdir jffsfile rsync -avz /bin jffsfile/ mkfs.jffs2 -r jffsfile -p -o jffs.image -e560MiB --pad # # 2. Write image file to the parition # dd if=jffs.image of=/dev/hdc3 # # 3. Mount hdc3 as jffs2 # modprobe blkmtd device=/dev/hdc3 mknod /dev/mtd0 c 90 0 mknod /dev/mtdblock0 b 31 0 mount -t jffs2 /dev/mtdblock0 /mnt/floppy cat /proc/mtd -----------------------------------------------------------------------