- Create jffs2 file system.
- 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.
- 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
- mkfs.jffs2 -l -p --eraseblock=0x04000 -d rootfs
-o rootfs.jffs2
.Create directory files (rootfs) into a jffs2 file(rootfs.jffs2)
- Install mtd-utils (yum install mtd-utils) before you use mkfs.jffs2 command.
- mount jffs2.img to loopback
- Load modules
- modprobe jffs2 : Load jffs2 module
- modprobe mtdblock : Load mtd block module
- modprobe mtdram total_size=0x800000 erase_size=0x4000 : Load mtd ram module and size is 8MB erase size 16KB.
- modprobe jffs2 : Load jffs2 module
- dd if=jffs2_file of=/dev/mtdblock0 : input jffs2 file and output to device mtdblock0
- mkdir /mnt/jffs2 : Create a folder for mount jffs2 file.
- mount /dev/mtdblock0 /mnt/jffs2 : mount device mtdblock0 to loopback file system /mnt/jffs2 folder.
- 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
- Load modules
- 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 - K9F5608U0D & s3c2416
- 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. - Error message
- 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
- 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.
- nand_erase: attempt to erase a bad block at page 0x00004f00
- Use dnw to erase and download images to flash. (Com port for send command, usb for transfer files.)
- Run the dnw application.
- Set the com port : Configuration | Option , set the Baud rate and com port number.
- Open com port : SerialPort | Connect.
- Power 2416 device.
- If you has UBoot on device, enter space to enter uboot mode before count down.
- erase partition : nand erase start_address size , if partition is jffs2, remember add clean option, just like nand erase clean 0 40000
- transfer file from pc and write to flash
- Enter dnw command to wait file transfer from pc
- The application title USB status will become OK
- Select USB port | Transmit | transmit to select the file to transmit to 2416 device.
- nand write[.jffs] C0000000 start_address file_size.
- Enter dnw command to wait file transfer from pc
- reset to reboot the device.
root=/dev/mtdblock2 rootfstype=jffs2 init=/linuxrc console=ttySAC0,115200n8
- Run the dnw application.
- 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 - 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,
}
};
- K9F5608U0D NAND flash is a 32MB , and erase block is 16KB. The partation list below
- 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. - Reference
留言
張貼留言