Книга: Embedded Linux Primer: A Practical, Real-World Approach

10.3.2. Kernel Command Line Partitioning

10.3.2. Kernel Command Line Partitioning

As detailed in Section 10.3, "MTD Partitions," the raw Flash partition information can be communicated to the kernel using other methods. Indeed, possibly the most straightforward, though perhaps not the simplest method is to manually pass the partition information directly on the kernel command line. Of course, as we have already learned, some bootloaders make that easy (for example U-Boot), whereas others do not have a facility to pass a kernel command line to the kernel upon boot. In these cases, the kernel command line must be configured at compile time and, therefore, is more difficult to change, requiring a recompile of the kernel itself each time the partitions are modified.

To enable command-line partitioning in the MTD subsystem, your kernel must be configured for this support. You can see this configuration option in Figure 10-2 under MTD partitioning support. Select the option for command-line partition table parsing, which defines the CONFIG_MTD_CMDLINE_PARTS option.

Listing 10-10 shows the format for defining a partition on the kernel command line (taken from .../drivers/mtd/cmdlinepart.c).

Listing 10-10. Kernel Command-Line MTD Partition Format

mtdparts=<mtddef>[;<mtddef]
 *<mtddef>  := <mtd-id>:<partdef>[,<partdef>]
 *<partdef> := <size>[@offset][<name>][ro]
 *<mtd-id>  := unique name used in mapping driver/device (mtd->name)
 *<size>    := std linux memsize OR "-" to denote all remaining space
 *<name>    := '(' NAME ')'
 

Each mtddef parameter passed on the kernel command line defines a separate partition. As shown is Listing 10-10, each mtddef definition contains multiple parts. You can specify a unique ID, partition size, and offset from the start of the Flash. You can also pass the partition a name and, optionally, the read-only attribute. Referring back to our Redboot partition definitions in Listing 10-5, we could statically define these on the kernel command line as follows:

mtdparts=MainFlash:384K(Redboot),4K(config),128K(FIS),-(unused)

With this definition, the kernel would instantiate four MTD partitions, with an MTD ID of MainFlash, containing the sizes and layout matching that found in Listing 10-5.

Оглавление книги


Генерация: 1.161. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз