Reputation: 2777
An example of the mtd partition table is in arch/arm/mach-omap2/board-omap3beagle.c for the beagleboard http://lxr.free-electrons.com/source/arch/arm/mach-omap2/board-omap3beagle.c
static struct mtd_partition omap3beagle_nand_partitions[] = {
/* All the partition sizes are listed in terms of NAND block size */
{
.name = "X-Loader",
.offset = 0,
.size = 4 * NAND_BLOCK_SIZE,
.mask_flags = MTD_WRITEABLE, /* force read-only */
},
{
.name = "U-Boot",
.offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
.size = 15 * NAND_BLOCK_SIZE,
.mask_flags = MTD_WRITEABLE, /* force read-only */
},
{
.name = "U-Boot Env",
.offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
.size = 1 * NAND_BLOCK_SIZE,
},
{
.name = "Kernel",
.offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
.size = 32 * NAND_BLOCK_SIZE,
},
{
.name = "File System",
.offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
.size = MTDPART_SIZ_FULL,
},
};
Another link states this:
http://landley.net/kdocs/Documentation/DocBook/xhtml-nochunks/mtdnand.html
In this link Nand flash driver board_init
function passes the mtd_partition structure
is passed to
add_mtd_partitions(board_mtd, partition_info, NUM_PARTITIONS);
function in file mtdcore.c
file.
If I am right then does the mtdcores.c
file create the mtd partitions?
Now I have two questions:
1> If I am right, then the omap3_beagle_init
function in file /board-omap3beagle.c will call the omap_nand_flash_init
function this will initialize the NAND & create /dev/mdtx nodes.
If I am not right then what creates the /dev/mtd0 nodes? Does the kernel create it or the NAND driver?
2> Also, is the omap3_beagle_init
function the first function called by the kernel? Which file in the linux kernel is it called from?
Upvotes: 1
Views: 2340
Reputation: 2304
1/ There are multiples ways the device files can be created. Usually, they are now created using devtmpfs
which is part of the kernel. When a driver or a subsystem registers a new device, devtmpfs_create_node
is called This wakes up a thread that will add the device node to the devtmpfs
filesystem.
If your kernel is not using devtmpfs
, then you have to create those device files manually, using mknod
. Also mdev
is also a tool that can create device file. Finally, udev
used to create device files but now relies on devtmpfs
.
2/ omap3_beagle_init
is definitively not the first function called by the kernel. After decompressing itself, the entry point is start_kernel
in init/main.c. This is architecture independent.
omap3_beagle_init
is called from the customize_machine
arch_initcall in arch/arm/kernel/setup.c
Upvotes: 3