Instance analysis-construct a jffs2 File System on flash

Source: Internet
Author: User
Tags bitmask

I refer to the following example during jffs2 production,
The problem is:
Root@172.16.115.7:/# cp jffs2.image/dev/mtdblock2
CP: Writing '/dev/mtdblock2': no space left on Device
How to Create mtdblock2 ??

4.7.3 instance analysis-construct a jffs2 File System on flash
Finally, I will illustrate how to construct a jffs2 File System in flash with an actual example.
Because the flash in my target system is too small, there is only 2 m, and nearly 1 m space is needed to store U-boot,
The jffs2 file system is not used as the root file system, but the process of creating a file system in Flash is introduced.
I divide the flash space of 2 MB into three partitions. The partition implementation is under the linux root directory/Drivers/MTD/maps/directory, and the tqm8xxl (tqm8xxl. c) The partition is changed. As my partition, you only need to modify the struct tqm8xxl_partitions [] in the Code:
Static struct mtd_partition tqm8xxl_partitions [] = {
{
Name: "U-boot ",
Offset: 0x0000000,
Size: 0x00020000,
},
{
Name: "kernel ",
Offset: 0x00020000,
Size: 0x000a0000,
},
{
Name: "jffs2 ",
Offset: 0x000c0000,
Size: 0x00140000,
}
}
The first line is your partition name, the second line is the offset in flash, and the third line is the size of partition. Followed by a struct:
Static struct mtd_partition tqm8xxl_fs_partitions [] {} is used in versions earlier than linux2.4.x. It is not used in linux2.4.x. I have blocked it.
There are so many changes in the source file, and then re-compile the kernel:
# Make menuconfig
Enable the kernel option:
Select <*> memory technology device (MTD) Support and remember to select "Built-in" instead of "module" (the preceding option is "*" instead of "M ")
Select <*> MTD partitioning support MTD partition support
Select <*> caching block Device Access to MTD devices to support MTD access as a block device.
Go to the [RAM/ROM/flash chip drivers-] Option and select to load the Flash Driver.
Select <*> detect flash chips by common flash interface (CFI) Probe
Automatically detect flash devices with CFI Interfaces
Select <*> support for AMD/fujistu flash chips <*> support for Rom chips in bus mapping support for Rom device bus map
If other options are not selected, they are returned to the upper level.
Choose mapping drivers for Chip access -.
Select <*> CFI flash device mapped on tqm8xxl to support tqm8xxl flash partitioning.
Other options are not selected.
Compile the kernel:
# Make Dep
# Make pimage
The kernel image file is generated in the arch/PPC/mbxboot/directory. Reboot the kernel, enter the Linux system, and run the following command:
# View more/proc/MTD
Dev: Size erasesize name
Mtd0: 00020000 00010000 "ppcboot"
Mtd1: 000a0000 00010000 "kernel"
Mtd2: 00140000 00010000 "jffs2"
The mtd0-2 shown here is the three devices simulated after the flash partition, is the memory-type device, And the mtdblock0-2 we use later is the block device for the three partitions.
In this case, the NFS file system is used. Return to the root directory and run:
# Mkfs. jffs2-D filesystem-O jffs2.image
Create a jffs2 file system. filesystem is a very small directory containing several files. The jffs2 file system file generated is jffs2.image. Create the directory jffs2 under/mnt:
# Mkdir/mnt/jffs2
Copy the jffs2 File System to flash:
# Cp jffs2.image/dev/mtdblock2
Mount the flash device to/mnt/jffs2
# Mount/dev/mtdblock2/mnt/jffs2-T jffs2
Ffs2_scan_eraseblock (): Magic bitmask 0x1985 not found at 0x001dc000: 0xe6a7 ID
Jffs2_scan_eraseblock (): Magic bitmask 0x1985 not found at 0x001dc004: 0x626f ID
Jffs2_scan_eraseblock (): Magic bitmask 0x1985 not found at 0x001dc008: 0x636d ID
Jffs2_scan_eraseblock (): Magic bitmask 0x1985 not found at 0x001dc00c: 0x626f ID
Jffs2_scan_eraseblock (): Magic bitmask 0x1985 not found at 0x001dc010: 0x6d20 ID
Jffs2_scan_eraseblock (): Magic bitmask 0x1985 not found at 0x001dc014: 0x3030 ID
Jffs2_scan_eraseblock (): Magic bitmask 0x1985 not found at 0x001dc018: 0x3000 ID
Jffs2_scan_eraseblock (): Magic bitmask 0x1985 not found at 0x001dc01c: 0x7564 ID
Jffs2_scan_eraseblock (): Magic bitmask 0x1985 not found at 0x001dc020: 0x7465 ID
Jffs2_scan_eraseblock (): Magic bitmask 0x1985 not found at 0x001dc024: 0x3932 ID
Further such events for this erase block will not be printed
Jffs2: erase block at 0x001d0000 is not formatted. It will be erased
I wonder whether the information is correct. I am querying this question.
View the jffs2 File System:
Sh-2.05a # cd/mnt/jffs2
A sh-2.05a # ls
APP bin Dev etc home lib MNT proc root sbin tmp usr VaR
Sh-2.05a #
OK! All the file systems created are in it, which is so simple. If you copy a complete file system to flash and want to use it as the root file system, you can set startup parameters when the U-BOOT is started:
# Setenv bootargs root =/dev/mtdblock2 then save the parameter and reboot the U-BOOT.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.