Linux Drive porting (NAND,YAFFS2)

Source: Internet
Author: User

Original: Http://blog.sina.com.cn/s/blog_7090b8670101b0bi.htmllinux Drive transplant (NAND,YAFFS2)

After the smooth migration of Linux operating system, although the Linux kernel ran on board, but at this time Linux does not support the Board of the various hardware, such as LCD, camera, sound card, USB modules, we have to install the driver on the board, To be able to work on these hardware under the Linux operating system.

These drivers have drivers in the kernel source code, we have to do is to compile these driver source code into the kernel, of course, before compiling is necessary to the driver source to do related changes, because our hardware and the kernel of the driver is likely to be mismatched. When we compile the driver, we have to choose some of the drivers we need to discard the ones we don't need, called the clipping kernel.

First, the Linux operating system for the board must support Nandflash and mount the YAFFS2 file system, only the operating system that mounts the YAFFS2 file system can be considered a complete operating system.

Why is the driver modified in the kernel? That is because the kernel is the operating system, which is used to manage the hardware facilities.

(i) Support for Nandflash drivers:

The Linux new version of the kernel provides a driver that supports large-page NAND. This is convenient for our NAND-driven porting, so we just need to find the appropriate driver in the kernel and make some changes.

(1) Modify the partition (MTD partition) Table of NAND in the kernel

Modified: ARCH/ARM/PLAT-S3C24XX/COMMON-SMDK.C file, on line 110th:

Here we want to enable Nandflash to support 64m,256m or higher capacity at the same time.

[0] = {

. Name = "Boot", name is the name of the partition and can be arbitrarily taken.

. Offset = 0, offset is the offsets, which is the starting address of the partition.

. Size = sz_1m, which is the size of this partition

},

[1] = {

. Name = "Kernel",

. offset = sz_1m + sz_128k,

. Size = sz_4m,

},

[2] = {

. Name = "YAFFS2",

. offset = sz_1m + sz_128k + sz_4m,

. Size = sz_256m-sz_4m-sz_1m–sz_128k,}

#endif

};

The first partition is the boot partition (1M), which is the storage uboot. The second partition is the kernel partition (4M), which holds the OS kernel. The third partition is YAFFS2 (the root file system partition).

Now the concept of partitioning: partitions have two meanings of partitions, one is the kernel's MTD partition, and the other is the Uboot partition. Both are related to the partition of NAND, but they are not equal. In the kernel, there are partitions on the NAND that are called MTD partitions that can be accessed through the device files in the Linux system. So in the kernel there must be MTD on the uboot, kernel image, and file system partition information on the NAND. The Uboot partition is the real partition of the NAND, and after the system is power-on, the uboot is put into memory by the SRAM, and the bootloader, and the space address are initialized. The space address at this time is the real address of Nandflash. And the kernel does not say from the uboot to read the address, but from the kernel MTD partition address in the read address, so the kernel MTD partition and uboot partition must be the same.

(2) Modify the matching time of NAND (check chip manual)

(3) Modify the Kconfig file to select the NAND type when configured. Let the kernel choose which capacity to support Nandflash

(4) Configure the kernel, support Nandflash.

These processes are actually modifying the NAND driver source in the kernel, then modifying the compilation options and finally configuring it with make menuconfig, and finally compiling the kernel to build the image file in the Linux integrated development environment and download it to the arm Development Board. This kind of kernel supports NAND.

(ii) YAFFS2 file system porting

(1) Download YAFFS2 source code (in the CD-ROM/source package/Other software source/directory)

Unzip, enter the YAFFS2 directory:

#tar XZVF yaffs2.tar.gz

#cd cvs/yaffs2/

(2) to the kernel to the YAFFS2 file system patch, execute:

#./patch-ker.sh C/........./linux-2.6.31/? This is your kernel source directory.

At this time, the kernel source FS directory more than one YAFFS2 directory, while the makefile files and Kconfig files also added YAFFS2 configuration and compilation conditions.

(3) finally using Uboot to burn the YAFFS2 file system as well as written

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.