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

4.3.5. Custom Configuration Options

4.3.5. Custom Configuration Options

Many embedded developers add feature support to the Linux kernel to support their particular custom hardware. One of the most common examples of this is multiple versions of a given hardware platform, each of which requires some compile-time options to be configured in the kernel source tree. Instead of having a separate version of the kernel source tree for each hardware version, a developer can add configuration options to enable his custom features.

The configuration management architecture described in the previous paragraphs makes it easy to customize and add features. A quick peek into a typical Kconfig file shows the structure of the configuration script language. As an example, assume that you have two hardware platforms based on the IXP425 network processor, and that your engineering team had dubbed them Vega and Constellation. Each board has specialized hardware that must be initialized early during the kernel boot phase. Let's see how easy it is to add these configuration options to the set of choices presented to the developer during kernel configuration. Listing 4-9 is a snippet from the top-level ARM Kconfig file.

Listing 4-9. Snippet from …/arch/arm/Kconfig

source "init/Kconfig"
menu "System Type"
choice
        prompt "ARM system type"
        default ARCH_RPC
config ARCH_CLPS7500
        bool "Cirrus-CL-PS7500FE"
config ARCH_CLPS711X
        bool "CLPS711x/EP721x-based"
...
source "arch/arm/mach-ixp4xx/Kconfig

In this Kconfig snippet taken from the top-level ARM architecture Kconfig, you see the menu item System Type being defined. After the ARM System type prompt, you see a list of choices related to the ARM architecture. Later in the file, you see the inclusion of the IXP4 xx -specific Kconfig definitions. In this file, you add your custom configuration switches. Listing 4-10 reproduces a snippet of this file. Again, for readability and convenience, we've omitted irrelevant text, as indicated by the ellipsis.

Listing 4-10. File Snippet: arch/arm/mach-ixp4xx/Kconfig

menu "Intel IXP4xx Implementation Options"
comment "IXP4xx Platforms"
config ARCH_AVILA
         bool "Avila"
         help
           Say 'Y' here if you want your kernel to support...
config ARCH_ADI_COYOTE
         bool "Coyote"
         help
           Say 'Y' here if you want your kernel to support
          the ADI Engineering Coyote...
# (These are our new custom options)
config ARCH_VEGA
         bool "Vega"
         help
           Select this option for "Vega" hardware support
config ARCH_CONSTELLATION
          bool "Constellation"
          help
            Select this option for "Constellation"
            hardware support
   ...

Figure 4-4 illustrates the result of these changes as it appears when running the gconf utility (via make ARCH=arm gconfig). As a result of these simple changes, the configuration editor now includes options for our two new hardware platforms.[33] Shortly, you'll see how you can use this configuration information in the source tree to conditionally select objects that contain support for your new boards.

Figure 4-4. Custom configuration options


After the configuration editor (gconf, in these examples) is run and you select support for one of your custom hardware platforms, the .config file introduced earlier contains macros for your new options. As with all kernel-configuration options, each is preceded with CONFIG_ to identify it as a kernel-configuration option. As a result, two new configuration options have been defined, and their state has been recorded in the .config file. Listing 4-11 shows the new .config file with your new configuration options.

Listing 4-11. Customized .config File Snippet

...
#
# IXP4xx Platforms
#
# CONFIG_ARCH_AVILA is not set
# CONFIG_ARCH_ADI_COYOTE is not set
CONFIG_ARCH_VEGA=y
# CONFIG_ARCH_CONSTELLATION is not set
# CONFIG_ARCH_IXDP425 is not set
# CONFIG_ARCH_PRPMC1100 is not set
...

Notice two new configuration options related to your Vega and Constellation hardware platforms. As illustrated in Figure 4-4, you selected support for Vega; in the .config file, you can see the new CONFIG_ option representing that the Vega board is selected and set to the value ' y '. Notice also that the CONFIG_ option related to Constellation is present but not selected.

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


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