Linux kernel already provides the driver for Nand flash, we just need to modify it according to our needs.
8.1 Polish the source code
Edit file “arch/arm/plat-s3c24xx/common-smdk.c”, in line 109, there is a structure named smdk_default_nand_part[], we edit it to the structure as follows:
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = “EmbedSky_Board_uboot”,
.size = 0x00040000,
.offset = 0x00000000,
},
[1] = {
.name = “EmbedSky_Board_kernel”,
.offset = 0x00200000,
.size = 0x00200000,
},
[2] = {
.name = “EmbedSky_Board_yaffs2”,
.offset = 0x00400000,
.size = 0x03BF8000,
}
};
The next step is to modify the write/read time of Nand flash. Edit structure smdk_nand_info at around line 140 of the just modified common-smdk.c, the detail is as follows (this step can be skipped):
static struct s3c2410_platform_nand smdk_nand_info = {
.tacls = 10,
.twrph0 = 25,
.twrph1 = 10,
.nr_sets = ARRAY_SIZE(smdk_nand_sets),
.sets = smdk_nand_sets,
};
Next step is to add support for large capacity nand flash. We edit the structure smdk_default_nand_part[] in kernel file “arch/arm/plat-s3c24xx/commonsmdk.
c”, the modifed file is as follows:
/* NAND parititon from 2.4.18-swl5 */
static struct mtd_partition smdk_default_nand_part[] = {
#if defined(CONFIG_EmbedSky_64MB_NAND)
[0] = {
.name = “EmbedSky_Board_uboot”,
.offset = 0x00000000,
.size = 0x00040000,
},
[1] = {
.name = “EmbedSky_Board_kernel”,
.offset = 0x00200000,
.size = 0x00200000,
},
[2] = {
.name = “EmbedSky_Board_yaffs2”,
.offset = 0x00400000,
.size = 0x03BF8000,
}
#elif defined(CONFIG_EmbedSky_128MB_NAND)
[0] = {
.name = “EmbedSky_Board_uboot”,
.offset = 0x00000000,
.size = 0x00040000,
},
[1] = {
.name = “EmbedSky_Board_kernel”,
.offset = 0x00200000,
.size = 0x00200000,
},
[2] = {
.name = “EmbedSky_Board_yaffs2”,
.offset = 0x00400000,
.size = 0x07BA0000,
}
#elif defined(CONFIG_EmbedSky_more_than_256MB_NAND)
[0] = {
.name = “EmbedSky_Board_uboot”,
.offset = 0x00000000,
.size = 0x00040000,
},
[1] = {
.name = “EmbedSky_Board_kernel”,
.offset = 0x00200000,
.size = 0x00200000,},
[2] = {
.name = “EmbedSky_Board_yaffs2”,
.offset = 0x00400000,
.size = 0x0FB80000,
}
#endif
};
Now, we edit “drivers/mtd/nand/Kconfig” to add support for different capacities of nand flash, in line 154 or line 166:
config MTD_NAND_S3C2410
tristate “NAND Flash support for S3C2410/S3C2440 SoC”
depends on ARCH_S3C2410
help
This enables the NAND flash controller on the S3C2410 and S3C2440
SoCs
No board specific support is done by this driver, each board
must advertise a platform_device for the driver to attach.
config MTD_NAND_S3C2410_DEBUG
bool “S3C2410 NAND driver debug”
depends on MTD_NAND_S3C2410
help
Enable debugging of the S3C2410 NAND driver
config MTD_NAND_S3C2410_HWECC
bool “S3C2410 NAND Hardware ECC”
depends on MTD_NAND_S3C2410
help
Enable the use of the S3C2410’s internal ECC generator when
using NAND. Early versions of the chip have had problems with
incorrect ECC generation, and if using these, the default of
software ECC is preferable.
choice
prompt “Nand Flash Capacity select”
depends on MTD
help
EmbedSky Board Nand Flash Capacity select
config EmbedSky_64MB_NAND
boolean “64MB Nand for EmbedSky Board”
depends on MTD
help
Set 64MB Nand parts
config EmbedSky_128MB_NAND
boolean “128MB Nand for EmbedSky Board”
depends on MTD
help
Set 128MB Nand parts
config EmbedSky_more_than_256MB_NAND
boolean “256MB~1GB Nand for EmbedSky Board”
depends on MTD
help
Set 256MB~1GB Nand parts
endchoice
config MTD_NAND_NDFC
tristate “NDFC NanD Flash Controller”
depends on 4xx && !PPC_MERGE
select MTD_NAND_ECC_SMC
help
NDFC Nand Flash Controllers are integrated in IBM/AMCC’s 4xx SoCs
8.2 Add the configuration for the corresponding driver
Now we can use the just modifed config file.
Type:
#make menuconfig
The following screen will show up:
Device Drivers —>
<*> Memory Technology Device (MTD) support —>
[*] MTD partitioning support
< > RedBoot partition table parsing
[ ] Command line partition table parsing
<*> Direct char device access to MTD devices
-*- Common interface to block layer for MTD ‘translation layers
<*> Caching block device access to MTD devices
<*> NAND Device Support —>
<*> NAND Flash support for S3C2410/S3C2440 SoC
[*] S3C2410 NAND Hardware ECC
Nand Flash Capacity select (256MB~1GB Nand for EmbedSky Board) —>
Note 1: the green one can only be selected in one case: Linux 2.6.30.4 and 256MB or larger nand flash.
Note 2: The red one is chosen according to the boards, we have the following choices:
( ) 64MB Nand for EmbedSky Board
( ) 128MB Nand for EmbedSky Board
(X) 256MB~1GB Nand for EmbedSky Board
We listed the capacities of different Nand flash used on TQ2440:
K9F1208U0C is Nand Flash of 64MB.
K9F1G08U0A is Nand Flash of 128MB.
K9FXG08U0A is Nand flash of 256MB to 1GB (here X=2, 4, or 8)
After the selection, save the config.
8.3. The situation when using the nand flash driver
Compile the image and burn to TQ2440 board, the boot information is similiar to:
Leave a Reply
You must be logged in to post a comment.