Transplantation of Linux-2.6.32.2 Kernel on mini2440 (II)-transplantation of yaffs2 File System

Source: Internet
Author: User
Transplantation of Linux-2.6.32.2 Kernel on mini2440 (2) --- transplantation of yaffs2 File System


Export environment (the red bold font is the modified content, and the blue bold text is the special attention content)

2.1. transplantation of the yaffs2 File System

[1] obtain the source code of yaffs2

Currently, most development boards support the yaffs2 file system. It is a file system specially designed for embedded devices, especially the embedded devices that use NAND Flash as memory, earlier yaffs only supported NAND Flash with small pages (512 byte/page). Most of the current development boards are equipped with larger volumes of NAND Flash, generally, they are in the big page mode (2 k/page). You can use yaffs2 to support the large page NAND Flash. The following is a detailed step for porting yaffs2.
In the http://www.yaffs.net/node/346 you can download to the latest yaffs2 source code, you need to use the GIT tool (see git Version Control Software Installation and Use), in the command line input:
[Root @ localhost ~] # Cd./Linux-test
[Root @ localhost Linux-test] # git clone git: // www. aleph1.co. uk/yaffs2
Cloning into yaffs2...
Remote: counting objects: 6592, done.
Remote: compressing objects: 100% (3881/3881), done.
Remote: Total 6592 (delta 5237), reused 3396 (delta 2642)
Grouping objects: 100% (6592/6592), 3.34 MIB | 166 kib/s, done.
Resolving deltas: 100% (5237/5237), done.
[Root @ localhost Linux-test] # ls
Linux-2.6.32.2 linux-2.6.39 yaffs2
[Root @ localhost Linux-test] #
After a moment, you can see the source code directory of the latest downloaded yaffs2.

[2] patch the kernel with yaffs2

(1) Add the yaffs2 code to the kernel

This can be through the script file patch-ker.sh under the yaffs2 directory to patch the kernel, the usage is as follows:

[Root @ localhost yaffs2] #./patch-ker.sh C/root/Linux-test/linux-2.6.32.2
Usage:./patch-ker.sh C/L m/s kernelpath
If C/L is C, then copy. If l then link
If M/s is m, then use multi version code. If s then use single version code
[Root @ localhost yaffs2] #./patch-ker.sh c s/root/Linux-test/linux-2.6.32.2

* ** Warning ***
You have chosen to use the single kernel variant of the yaffs VFS glue code
That only works with the latest Linux kernel tree. If you are using an older
Version of Linux then you probably wanted to use the multi-version variant
Re-running the patch-ker.sh script using M as a second argument.
Ie./patch-ker.sh c m/root/Linux-test/linux-2.6.32.2

Updating/root/Linux-test/linux-2.6.32.2/fs/kconfig
Updating/root/Linux-test/linux-2.6.32.2/fs/makefile
[Root @ localhost yaffs2] #

Note that the second parameter is M/S. If this parameter is not specified, the execution may sometimes fail.

The preceding command completes the following three tasks:

<1> modify the Kernel File/fs/kconfig and add the following two lines (near row 177 ):

If misc_filesystems

Source "FS/ADFs/kconfig"
Source "FS/affs/kconfig"
Source "FS/ecryptfs/kconfig"
Source "FS/HFS/kconfig"
Source "FS/hfsplus/kconfig"
Source "FS/BEFS/kconfig"
Source "FS/BFS/kconfig"
Source "FS/EFS/kconfig"
Source "FS/yaffs2/kconfig"
Source "FS/jffs2/kconfig"
# Ubifs File System Configuration

<2> modify the Kernel File/fs/makefile and add the following two lines (near row 129 ):

OBJ-$ (config_gfs2_fs) + = gfs2/
OBJ-$ (config_exofs_fs) + = exofs/
OBJ-$ (config_yaffs_fs) + = yaffs2/

<3> Create the yaffs2 subdirectory under the FS directory of the kernel file and copy the following file:

Copy the makefile. Kernel File in the source code directory of yaffs2 to the kernel fs/yaffs2/MAKEFILE file.

Copy the kconfig file in the source code directory of yaffs2 to the kernel fs/yaffs2/directory.

Copy *. C and *. H files under the source code directory of yaffs2 to the FS/yaffs2/directory of the kernel.

(2) Configure kernel options

Read the FS/kconfig file of the kernel to understand the functions of each configuration option.

The following are the options used:

<1> config_yaffs_fs: supports the yaffs file system.

<2> config_yaffs_yaffs2: supports the yaffs2 file system. This option must be selected if the page size is 2 k-byte NAND Flash.

<3> config_yaffs_auto_yaffs2: automatically selects the yaffs2 file format. If you do not configure this option, you must use the word "yaffs2" to indicate the format of the yaffs2 file system. If you configure this option, then, you can use the yaffs words to unify the formats of the yaffs1 and yaffs2 file systems. The driver will automatically identify whether it is yaffs1 or yaffs2 Based on the page size of the NAND Flash.

[3] configure and compile the kernel with yaffs2 support

Run the following command in the Linux kernel source code root directory:

[Root @ localhost Linux-test] # linux-2.6.32.2 CD
[Root @ localhost linux-2.6.32.2] # Make menuconfig

Move the upper and lower buttons to find file systems,

Press enter to enter the sub-menu, and then find the "Miscellaneous filesystems" menu item,

Press enter to enter the sub-menu and find "yaffs2 file system support ",

Press the space to select it. In this way, we add support for the yaffs2 File System to the kernel and press "exit" to exit the Kernel configuration. It is best to select "yes" to save.

2.2. Compile and Test

After the modification is complete, because the module to be compiled has been added to the kernel, you must first execute:

[Root @ localhost linux-2.6.32.2] # Make clean

Otherwise, compilation errors may occur, and then Compilation:

[Root @ localhost linux-2.6.32.2] # Make zimage
After the compilation is complete, generate the zimage file, power on the Development Board, and burn zimage to the Development Board, as shown below:


Nand device: Manufacturer ID: 0xec, chip ID: 0xf1 (Samsung NAND 128mib, 3 V 8-bit)
Scanning Device for Bad blocks
Creating 5 MTD partitions on "NAND 128mib, 3 V 8-bit ":
0x0000000000000000-0x000000040000: "Boot"
Uncorrectable error:
0x000000040000-0x000000060000: "Param"
Ftl_cs: FTL header not found.
0x000000060000-0x000000560000: "kernel"
Ftl_cs: FTL header not found.
0x000000560000-0x000040560000: "root"
MTD: partition "root" extends beyond the end of device "NAND 128mib, 3 V 8-bit"
-- Size truncated to 0x7aa0000
Ftl_cs: FTL header not found.
0x0000000000000000-0x000040000000: "NAND"
MTD: partition "NAND" extends beyond the end of device "NAND 128mib, 3 V 8-bit"
-- Size truncated to 0x8000000
Uncorrectable error:
Dm9000 Ethernet driver, v1.31

"Ftl_cs: FTL header not found." is also displayed. The configuration menu should be "device drivers"> "memory technology devices (MTD ),

Press the Space key to cancel the selection, select "exit" to exit, and select "yes" to save when the "save" prompt appears. Then run the following command in the terminal:

[Root @ localhost linux-2.6.32.2] # Make clean
Note: It takes a long time to compile the kernel every time you execute make clean. Therefore, if you do not make clean every time, I will suffer a lot and wait for a long time, you can avoid it later.

Then execute

[Root @ localhost linux-2.6.32.2] # Make zimage


S3c24xx NAND driver, (c) 2004 simtec Electronics
S3c24xx-nand s3c2440-nand: tacls = 3, 29ns twrph0 = 7 69ns, twrph1 = 3 29ns
S3c24xx-nand s3c2440-nand: NAND soft ECC
Nand device: Manufacturer ID: 0xec, chip ID: 0xf1 (Samsung NAND 128mib, 3 V 8-bit)
Scanning Device for Bad blocks
Creating 5 MTD partitions on "NAND 128mib, 3 V 8-bit ":
0x0000000000000000-0x000000040000: "Boot"
0x000000040000-0x000000060000: "Param"
0x000000060000-0x000000560000: "kernel"
0x000000560000-0x000008000000: "rootfs"
0x0000000000000000-0x000008000000: "NAND"
Dm9000 Ethernet driver, v1.31

We can see that the "ftl_cs: FTL header not found." message is missing. However, the following information is still displayed:

VFS: Unable to mount root FS via NFS, trying floppy.
VFS: cannot open root device "NFS" or unknown-block (2, 0)
Please append a correct "root =" Boot option; here are the available partitions:
1f00 256 mtdblock0 (driver ?)
1f01 128 mtdblock1 (driver ?)
1f02 5120 mtdblock2 (driver ?)
1f03 125568 mtdblock3 (driver ?)
1f04 131072 mtdblock4 (driver ?)
Kernel panic-not syncing: VFS: Unable to mount root FS on unknown-block (2, 0)
This is because the kernel boot parameter settings are incorrect. Run the command in the U-boot command line.

[U-boot @ mini2440] # printenv
Bootargs = noinitrd console = ttysac0, 115200 init =/linuxrc root =/dev/mtdblock3 RW R
Ootfstype = yaffs IP = 10.1.0.129: 10.1.0.128: 10.1.0.1: 255.255.255.0: eth0: Off
Bootcmd = NAND read 0x30008000 0x80000 0x300000; bootm 0x30008000
Bootdelay = 3
Baudrate = 115200
Ethaddr = 08: 00: 3E: 26: 0a: 5b
Ipaddr = 10.1.0.129
Serverip = 10.1.0.128
Gatewayip = 10.1.0.1
Netmask = 255.255.255.0
Stdin = serial
Stdout = serial
Stderr = serial
Ethact = dm9000

Environment size: 405/131068 bytes
[U-boot @ mini2440] #

Confirm that the above blue bold text is set correctly and run the command again.

[U-boot @ mini2440] # TFTP 31000000 uimage

[U-boot @ mini2440] # bootm
......

ALSA device list:
No soundcards found.
TCP cubic registered
Net: Registered protocol family 17
Drivers/RTC/hctosys. C: Unable to open RTC device (rtc0)
IP-config: Device 'eth0' not found.
Yaffs: Dev is 32505859 name is "mtdblock3" RW
Yaffs: passed flags ""
VFS: mounted root (yaffs filesystem) on device 31: 3.
Freeing init memory: 132 k
Warning: Unable to open an initial console.
Failed to execute/linuxrc. Attempting defaults...

The yaffs file system is successfully loaded. However, we encountered "Warning: Unable to open an initial console." because the root system has not yet been set up, and the kernel cannot find the mount point of the character device. However, to reduce the number of write operations on NAND Flash, you need to test the kernel on the NFS file system.

Next, we will port the dm9000 NIC driver to the kernel.


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.