jffs2


  1. Create jffs2 file system.
    1. Install mtd-utils (yum install mtd-utils) before you use mkfs.jffs2 command.
      mkfs.jffs2 uses to create a jffs2 format file form a directory.
    2. mkfs.jffs2 usage
      [root@JsA8L Temp]# mkfs.jffs2 -h > mkfs_jffs2.txt
      mkfs.jffs2: Usage: mkfs.jffs2 [OPTIONS]
      Make a JFFS2 file system image from an existing directory tree

      Options:
      -p, --pad[=SIZE] Pad output to SIZE bytes with 0xFF. If SIZE is
      not specified, the output is padded to the end of
      the final erase block
      -r, -d, --root=DIR Build file system from directory DIR (default: cwd)
      -s, --pagesize=SIZE Use page size (max data node size) SIZE (default: 4KiB)
      -e, --eraseblock=SIZE Use erase block size SIZE (default: 64KiB)
      -c, --cleanmarker=SIZE Size of cleanmarker (default 12)
      -m, --compr-mode=MODE Select compression mode (default: priortiry)
      -x, --disable-compressor=COMPRESSOR_NAME
      Disable a compressor
      -X, --enable-compressor=COMPRESSOR_NAME
      Enable a compressor
      -y, --compressor-priority=PRIORITY:COMPRESSOR_NAME
      Set the priority of a compressor
      -L, --list-compressors Show the list of the avaiable compressors
      -t, --test-compression Call decompress and compare with the original (for test)
      -n, --no-cleanmarkers Don't add a cleanmarker to every eraseblock
      -o, --output=FILE Output to FILE (default: stdout)
      -l, --little-endian Create a little-endian filesystem
      -b, --big-endian Create a big-endian filesystem
      -D, --devtable=FILE Use the named FILE as a device table file
      -f, --faketime Change all file times to '0' for regression testing
      -q, --squash Squash permissions and owners making all files be owned by root
      -U, --squash-uids Squash owners making all files be owned by root
      -P, --squash-perms Squash permissions on all files
      --with-xattr stuff all xattr entries into image
      --with-selinux stuff only SELinux Labels into jffs2 image
      --with-posix-acl stuff only POSIX ACL entries into jffs2 image
      -h, --help Display this help text
      -v, --verbose Verbose operation
      -V, --version Display version information
      -i, --incremental=FILE Parse FILE and generate appendage output for it



    3. mkfs.jffs2 -l -p --eraseblock=0x04000 -d rootfs
      -o rootfs.jffs2

      .Create directory files (rootfs) into a jffs2 file(rootfs.jffs2)
  2. mount jffs2.img to loopback
    1. Load modules
      1. modprobe jffs2 : Load jffs2 module
      2. modprobe mtdblock : Load mtd block module
      3. modprobe mtdram total_size=0x800000 erase_size=0x4000 : Load mtd ram module and size is 8MB erase size 16KB.
    2. dd if=jffs2_file of=/dev/mtdblock0 : input jffs2 file and output to device mtdblock0
    3. mkdir /mnt/jffs2 : Create a folder for mount jffs2 file.
    4. mount /dev/mtdblock0 /mnt/jffs2 : mount device mtdblock0 to loopback file system /mnt/jffs2 folder.
    5. I write a shell script, you can input the jffs2 file, and it will mount to /mnt/jffs2 folder.
      You can also get the shell script from
      mount_jffs2.sh
  3. Create jffs2 file from mount jffs2 directory
    dd if=/mnt/jffs2 of=rootfs.jffs2 bs=8M: Create a 8M rootfs.jffs2 file from mount folder /mnt/jffs2
  4. K9F5608U0D & s3c2416
    1. K9F5608U0D NAND flash is a 32MB , and erase block is 16KB. The partation list below
      [root@Samsung proc]# cat mtd
      dev: size erasesize name
      mtd0: 00040000 00004000 "Bootloader"
      mtd1: 001c0000 00004000 "Kernel"
      mtd2: 00800000 00004000 "File system (jffs2)"
      mtd3: 01600000 00004000 "Extension (jffs2)"

      [root@Samsung proc]# cat partitions
      major minor #blocks name

      31 0 256 mtdblock0
      31 1 1792 mtdblock1
      31 2 8192 mtdblock2
      31 3 22528 mtdblock3










































      Start address size nand erase nand write Zero number
      Bootloader 0x0 0x40000 nand erase
      0 40000
      nand write C0000000 0 40000 4
      Kernel 0x40000 0x1C0000 nand erase
      40000 1C0000
      nand write C0000000 40000 1C0000 4
      File system 0x200000 0x800000 nand erase
      clean 200000 800000
      nand
      write.jfffs2 C0000000 200000 filesize
      5
      Extension 0xA00000 0x1600000 nand erase
      clean
      A00000
      1600000
      nand write.jfffs2 C0000000
      A00000 filesize
      5
































      New partition Start address size nand erase nand write Zero number
      Bootloader 0x0 0x40000 nand erase
      0 40000
      nand write C0000000 0 40000 4
      Kernel 0x40000 0x1C0000 nand erase
      40000 1C0000
      nand write C0000000 40000 1C0000 4
      File system 0x200000 0x1E00000 nand erase
      clean 200000
      1E00000
      nand
      write.jfffs2 C0000000 200000 filesize
      5

      I want to use jffs2 format in partition mtdblock2 and mtdblock3.Remember it need add clean when you erase flash for jffs2 partition.
      And use mkfs.jffs2 to write jffs2 file into flash.
    2. Error message
      1. nand_erase: attempt to erase a bad block at page 0x00004f00
        Erase at 0x007e0000 failed immediately: errno -5
        If you do not use nand erase clean xxx xxx to erase your nand flash
      2. Node at 0x00003e3c with length 0x0000082e would run over the end of the erase block.
        Erase block size wrong , use
        --eraseblock=xxxxx
        to correct the bug.
    3. Use dnw to erase and download images to flash. (Com port for send command, usb for transfer files.)
      1. Run the dnw application.
      2. Set the com port : Configuration | Option , set the Baud rate and com port number.
      3. Open com port : SerialPort | Connect.
      4. Power 2416 device.
      5. If you has UBoot on device, enter space to enter uboot mode before count down.
      6. erase partition : nand erase start_address size , if partition is jffs2, remember add clean option, just like nand erase clean 0 40000
      7. transfer file from pc and write to flash
        1. Enter dnw command to wait file transfer from pc
        2. The application title USB status will become OK
        3. Select USB port | Transmit | transmit to select the file to transmit to 2416 device.
        4. nand write[.jffs] C0000000 start_address file_size.
      8. reset to reboot the device.
      My Kernel boot command is
      root=/dev/mtdblock2 rootfstype=jffs2 init=/linuxrc console=ttySAC0,115200n8
    4. After login, I mount /dev/mtdblock3 to /root folder, and copy a file(/bin/busybox) to /root. Below is the message.
      [root@Samsung ~]# mount -t jffs2 /dev/mtdblock3 /root
      [root@Samsung ~]# df -h
      Filesystem Size Used Available Use% Mounted on
      /dev/mtdblock2 8.0M 7.9M 72.0k 99% /
      tmpfs 30.0M 32.0k 30.0M 0% /tmp
      /dev/mtdblock3 22.0M 1.0M 21.0M 5% /root

      [root@Samsung bin]# cp busybox /root
      Node CRC ffffffff != calculated CRC f09e7845 for node at 00a9e6a4
      [root@Samsung bin]# Header CRC failed on REF_PRISTINE node at 0x00afc074: Read 0xffffffff, calculated 0x44660075
    5. S3C2416 partition define in s3c_partition_info[]
      (arch\arm\plat-s3c24xx\common-smdk.c)
      /* ----------------S3C NAND partition information ---------------------*/
      struct mtd_partition s3c_partition_info[] = {
      {
      .name = "Bootloader",
      .offset = 0,
      .size = (256*SZ_1K),
      .mask_flags = MTD_CAP_NANDFLASH,
      },
      {
      .name = "Kernel",
      .offset = (256*SZ_1K),
      .size = (2*SZ_1M) - (256*SZ_1K),
      .mask_flags = MTD_CAP_NANDFLASH,
      },
      {
      .name = "File System",
      .offset = (2*SZ_1M),
      .size = (8*SZ_1M),
      },
      {
      .name = "Extension",
      .offset = MTDPART_OFS_APPEND,
      .size = MTDPART_SIZ_FULL,
      }
      };
  5. Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
    This causes kernel can mount correct file system. Check you partition and your file system format type.
  6. Reference
    1. JFFS2 file system-老而彌堅的檔案系統
    2. mount jffs2
    3. 建立jffs2 root file system
    4. Mounting JFFS2 Filesystem in RAM
    5. jffs2 掛載的問題
    6. jffs2
    7. 製作 JFFS2 影像並寫入 NAND Flash
    8. 制作jffs2文件系统时遇到的错误
    9. 制作jffs2文件系统时遇到的错误
    10. arm-linux学习笔记之linux-2.6.25.5移植
    11. embedded
    12. Linux 2.6.27 for ARM9/S3C2410
    13. 移植2.6.24内核到2410
    14. 对s3c2410上nand flash时序的一些问题

留言