Just found a little bit more clues, as follows:
The first concept is that the kernel will do a virtual FS before mounting the file system.
1. Uboot:
Booting from Flash
Set Bootcmd NAND read 0x30000000 0x60000 0X200000\;BOOTM 0x30000000
Set Bootargs noinitrd root=/dev/mtdblock3 INIT=/LINUXRC console=ttysac0
2.1 Kernel-mountfs
Do_mounts.c
void __init prepare_namespace (void)
{
Root_dev = name_to_dev_t (root_device_name)
if (strncmp (Root_device_name, "/dev/", 5) = = 0)
Root_device_name + = 5;
Mount_root ();//Create/dev/root nodes and mount them according to Root_dev.
}
|||
|||
|||
dev_t name_to_dev_t (char *name)
{
strcpy (S, name);//mtdblock3
part = Simple_strtoul (P, NULL, 10); 3
res = Try_name (s, part); MTDBLOCK3, 3
}
void __init mount_root (void)
{
Create_dev ("/dev/root", Root_dev);
Mount_block_root ("/dev/root", root_mountflags);
}
||
||
||
Static dev_t Try_name (char *name, int part)
{
sprintf (Path, "/sys/block/%s/dev", name);
FD = sys_open (path, 0, 0); Open Sys/block/mtdblock3/dev
if (FD < 0)
Goto fail;
# Cat Sys/block/mtdblock3/dev
31:3
SSCANF (buf, "%u:%u", &maj, &min);
res = MKDEV (maj, Min);
# Cat Sys/block/mtdblock3/range
1
sprintf (Path, "/sys/block/%s/range", name); Sys/block/mtdblock3/range
FD = sys_open (path, 0, 0);
if (FD < 0)
Goto fail;
Len = Sys_read (FD, buf, 32);
Range = Simple_strtoul (buf, &s, 10); 1
if (Part < range)
return res + part;
}
void __init Mount_block_root (char *name, int flags)
{
Char *fs_names = __getname ();
Get_fs_names (Fs_names);
Retry
for (p = fs_names; *p; p + strlen (p) +1) {
Do_mount_root (name, p, flags, root_mount_data);
Switch (ERR) {
Case 0:
Goto out;
}
}
Out
Putname (Fs_names);
}
static int __init do_mount_root (char *name, char *fs, int flags, void *data)
{
Sys_mount (name, "/root", FS, flags, data);
Sys_chdir ("/root");
Root_dev = current->fs->pwdmnt->mnt_sb->s_dev;
}
2.2 Kernel-driver
Linux/arch/arm/plat-s3c24xx/common-smdk.c
static struct Mtd_partition smdk_default_nand_part[] = {
[0] = {
. Name = "Bootloader",
. Size = 0x00040000,
. offset= 0,
},
[1] = {
. Name = "params",
. offset = Mtdpart_ofs_append,
. Size = 0x00020000,
},
[2] = {
. Name = "Kernel",
. offset = Mtdpart_ofs_append,
. Size = 0x00200000,
},
[3] = {
. Name = "Root",
. offset = Mtdpart_ofs_append,
. Size = Mtdpart_siz_full,
}
};
static struct S3c2410_nand_set smdk_nand_sets[] = {
[0] = {
. Name= "NAND",
. nr_chips= 1,
. nr_partitions= Array_size (Smdk_default_nand_part),
. partitions= Smdk_default_nand_part,
},
};
static struct S3c2410_platform_nand Smdk_nand_info = {
. tacls= 20,
. twrph0= 60,
. twrph1= 20,
. nr_sets= Array_size (smdk_nand_sets),
. sets= Smdk_nand_sets,
};
void __init smdk_machine_init (void)
{
S3c_device_nand.dev.platform_data = &smdk_nand_info; Platform Device Information
}
Mtdblock_ro.c
static struct Mtd_blktrans_ops mtdblock_tr = {
. Name= "Mtdblock",
. major=,//mtdblock main device number
. part_bits= 0,
. blksize = 512,
. readsect= Mtdblock_readsect,
. writesect= Mtdblock_writesect,
. add_mtd= MTDBLOCK_ADD_MTD,
. remove_dev= Mtdblock_remove_dev,
. owner= This_module,
};
Comb how the uboot is mounted from the Nandflash file system