LINUX-2.6.32 porting NAND drive and modifying partition information on the mini2440 Development Board (1)

Source: Internet
Author: User

Editor: The migration of NAND in Linux is not as complex as it is due to the use of MTD technology.

1 NAND Flash types supported by the Linux-2.6.32.2 kernelLinux2.6.32.2 has brought in most of the NAND flash drivers, and in the linux-2.6.32.2/drivers/mtd/nand/nand_ids.c file, it defines the various NAND flash types supported. 2 Modifying the NAND Flash partition tableHowever, the system default partition is not what we need, so we have to modify, in addition, NAND flash structure information needs to be added, so as to fit the system's own NAND flash drive interface, this can refer to the SMDK2440 in the NAND flash Some information about device registration. Open/ARCH/ARM/PLAT-24XX/COMMON-SMDK.C, you can see such a structure:StaticstructMtd_partition smdk_default_nand_part[] = {
[0] = {
. Name ="Boot Agent",
. Size = sz_16k,
. offset =0,
},
[1] = {
. Name ="s3c2410 Flash partition 1",
. offset =0,
. Size = sz_2m,
},
[2] = {
. Name ="s3c2410 Flash partition 2",
. offset = sz_4m,
. Size = sz_4m,
},
[3] = {
. Name ="s3c2410 Flash partition 3",
. offset = sz_8m,
. Size = sz_2m,
},
[4] = {
. Name ="s3c2410 Flash partition 4",
. offset = sz_1m *Ten,
. Size = sz_4m,
},
[5] = {
. Name ="s3c2410 Flash partition 5",
. offset = sz_1m * -,
. Size = sz_1m *Ten,
},
[6] = {
. Name ="s3c2410 Flash partition 6",
. offset = sz_1m * -,
. Size = sz_1m * -,
},
[7] = {
. Name ="s3c2410 Flash partition 7",
. offset = sz_1m * -,
. Size = sz_16m,
}
This is actually the NAND Flash partition table, in Linux-2.6.32.2, the NAND driver is registered as a platform device, which is also seen in the/arch/arm/plat-24xx/common-smdk.c file, as follows:StaticstructS3c2410_platform_nand Smdk_nand_info = {
. Tacls = -,
. Twrph0 = -,
. TWRPH1 = -,
. nr_sets = Array_size (smdk_nand_sets),
. Sets = Smdk_nand_sets,
};
/*Devices We initialise*/
StaticstructPlatform_device __initdata *smdk_devs[] = {
&s3c_device_nand,
&SMDK_LED4,
&smdk_led5,
&smdk_led6,
&smdk_led7,
};refer to the above structure information, we also in our own mach-mini2440.c to add the implementation, also need to refer to the friendly arm of the original core of the NAND partition table, as shown in:

Add header file arch/arm/mach-s3c2440/mach-mini2440.c

#include <plat/nand.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/nand_ecc.h>

#include <linux/mtd/partitions.h>

Add the following code to the MACH-MINI2440.C;StaticstructMtd_partition mini2440_default_nand_part[] = {
[0] = {
. Name ="Supervivi",//This is the partition where the bootloader is located, can be placed U-boot, Supervivi and other content, corresponding/dev/mtdblock0
. Size =0x00040000,//256k
. offset =0,
},
[1] = {
. Name ="param",//here is the Supervivi parameter area, in fact, also belongs to the bootloader part, if the u-boot is larger, can be covered out of this area, will not affect the system startup, corresponding to/dev/mtdblock1
. offset =0x00040000,
. Size =0x00020000,//128k
},
[2] = {
. Name ="Kernel",//the partition of the kernel, size 5 m, enough to put down most of their own custom-made mega-kernel, such as the kernel using a larger Linux Logo image, etc., corresponding to/dev/mtdblock2
. offset =0x00060000,
. Size =0x00500000,//5m
},
[3] = {
. Name ="Root",//file system partition, friendly arm is mainly used to store YAFFS2 file system content, corresponding to/dev/mtdblock3
. offset =0x00560000,
. Size =1024x768*1024x768*1024x768,//1g
},
[4] = {
. Name ="NAND",//This area represents the entire piece of NAND flash, mainly reserved for use, such as later can be accessed through the application to read the/DEV/MTDBLOCK4 can be implemented to backup the entire NAND flash.
. offset =0x00000000,
. Size =1024x768*1024x768*1024x768,//
}
};; Here is the NAND Flash Setup table for the development Board, because there is only one piece on the board, so there is only a single tableStaticstructS3c2410_nand_set mini2440_nand_sets[] = {
[0] = {
. Name ="NAND",
. nr_chips =1,
. nr_partitions = Array_size (Mini2440_default_nand_part),
. partitions = Mini2440_default_nand_part,
},
};; Here is the NAND flash itself some characteristics, generally need to control datasheet fill, most of the case according to the following parameters to fill inStaticstructS3c2410_platform_nand Mini2440_nand_info = {
. Tacls = -,
. Twrph0 = -,
. TWRPH1 = -,
. nr_sets = Array_size (mini2440_nand_sets),
. Sets = Mini2440_nand_sets,
. IGNORE_UNSET_ECC =1,
In addition, the NAND flash device needs to be registered with the system,StaticstructPlatform_device *mini2440_devices[] __initdata = {
&AMP;S3C_DEVICE_USB,
&AMP;S3C_DEVICE_LCD,
&AMP;S3C_DEVICE_WDT,
&AMP;S3C_DEVICE_I2C0,
&s3c_device_iis,
&s3c_device_nand, // adding NAND flash devices to the device list structure of the Development Board
};3 Viewing the partition table from the boot informationThis completes the NAND flash driver migration, at this time in the kernel root directory to execute "make Zimage", the generated zimage burned to the development Board, you can see the information at startup, they are just the Nandflash partition information we have added, and the Development Board itself NAND Flash for some information, here you can see is 256M NAND flash. PS: The above is described by the manual, said a lot of, but it is clear that the structure of the information we just declared did not have any association with S3c_device_nand, so it will certainly not work properly. Also in this file, be sure to add a sentence in the following function:Static void__init Mini2440_machine_init (void)
{
#ifDefined (lcd_width)
S3c24xx_fb_set_platdata (&mini2440_fb_info);
#endif
S3c_i2c0_set_platdata (NULL);
S3c2410_gpio_cfgpin (S3C2410_GPC (0), s3c2410_gpc0_lend);
  S3c_device_nand.dev.platform_data = &mini2440_nand_info;
S3c_device_sdi.dev.platform_data = &mini2440_mmc_cfg;
Platform_add_devices (Mini2440_devices, Array_size (mini2440_devices));
S3c_pm_init ();
This will allow this information to be linked to the device and will work properly.

LINUX-2.6.32 porting NAND drive and modifying partition information on the mini2440 Development Board (1)

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.