Kernel Configuration

The application’s kernel is configured from a set of options that can be customized for application-specific purposes. Each configuration option is derived from the first source in which it is specified:

  1. The value specified by the application’s current configuration; that is, its .config file.
  2. The value specified by the application’s default configuration; that is, its prj.conf file.
  3. The value specified by the board configuration.
  4. The kernel’s default value for the configuration option.

Note

When the default board configuration settings are sufficient for your application, a prj.conf file is not needed. Skip ahead to Overriding the Application’s Default Kernel Configuration.

Procedures

The procedures that follow describe how to configure a prj.conf file and how to configure kernel options for microkernel and nanokernel applications. For information on how to work with kernel option inter-dependencies and board configuration-default options, see the Configuration Options Reference Guide.

Note

There are currently a number of experimental options not yet fully supported.

Defining the Application’s Default Kernel Configuration

Create a prj.conf file to define the application’s default kernel configuration. This file can contain settings that override or augment board-configuration settings.

The contents of the supported board configuration files can be viewed in ~/rootDir/boards/BOARD/BOARD_defconfig.

Before you begin

  • Confirm Zephyr environment variables are set for each console terminal using Common Procedures.

Steps

  1. Navigate to the appDir, and create the prj.conf file. Enter:
$ touch prj.conf

The default name is prj.conf. The filename must match the CONF_FILE entry in the application Makefile.

  1. Edit the file and add the appropriate configuration entries.

    1. Add each configuration entry on a new line.
    2. Begin each entry with CONFIG_.
    3. Ensure that each entry contains no spaces (including on either side of the = sign).
    4. Use a # followed by a space to comment a line.

    This example shows a comment line and a board configuration override in the prj.conf.

# Change the number of IRQs supported by the application
  CONFIG_NUM_IRQS=43
  1. Save and close the file.

Overriding the Application’s Default Kernel Configuration

Override the application’s default kernel configuration to temporarily alter the application’s configuration, perhaps to test the effect of a change.

Note

If you want to permanently alter the configuration you should revise the .conf file.

Configure the kernel options using a menu-driven interface. While you can add entries manually, using the configuration menu is a preferred method.

Before you begin

  • Review the kernel configuration options available and know which ones you want to temporarily set for your application. See the Configuration Options Reference Guide for a brief description of each option.
  • Be aware of any dependencies among the kernel configuration options.
  • Confirm an application Makefile exists for your application.
  • Confirm the Zephyr environment variable is set for each console terminal; see Common Procedures.

Steps

  1. Run the make menuconfig rule to launch the menu-driven interface.
  1. In a terminal session, navigate to the application directory (~/appDir).
  2. Enter the following command:
$ make menuconfig

A question-based menu opens that allows you to set individual configuration options.

Main Configuration Menu
  1. Set kernel configuration values using the following key commands:
  • Use the arrow keys to navigate within any menu or list.
  • Press Enter to select a menu item.
  • Type an upper case Y or N in the square brackets [ ] to enable or disable a kernel configuration option.
  • Type a numerical value in the round brackets ( ).
  • Press Tab to navigate the command menu at the bottom of the display.

Note

When a non-default entry is selected for options that are nonnumerical, an asterisk * appears between the square brackets in the display. There is nothing added added the display when you select the option’s default.

  1. For information about any option, select the option and tab to < Help > and press Enter.

    Press Enter to return to the menu.

  2. After configuring the kernel options for your application, tab to < Save > and press Enter.

    The following dialog opens with the < Ok > command selected:

Save Configuration Dialog
  1. Press Enter to save the kernel configuration options to the default file name; alternatively, type a file name and press Enter.

    Typically, you will save to the default file name unless you are experimenting with various configuration scenarios.

    An outdir directory is created in the application directory. The outdir directory contains symbolic links to files under $(ZEPHYR_BASE).

Note

At present, only a .config file can be built. If you have saved files with different file names and want to build with one of these, change the file name to .config. To keep your original .config, rename it to something other than .config.

Kernel configuration files, such as the .config file, are saved as hidden files in outdir. To list all your kernel configuration files, enter ls -a at the terminal prompt.

The following dialog opens, displaying the file name the configuration was saved to.

Saved Configuration Name Dialog
  1. Press Enter to return to the options menu.

  2. To load any saved kernel configuration file, tab to < Load > and press Enter.

    The following dialog opens with the < Ok > command selected:

Configuration File Load Dialog
  1. To load the last saved kernel configuration file, press < Ok >, or to load another saved configuration file, type the file name, then select < Ok >.

  2. Press Enter to load the file and return to the main menu.

  3. To exit the menu configuration, tab to < Exit > and press Enter.

    The following confirmation dialog opens with the < Yes > command selected.

Exit Dialog
  1. Press Enter to retire the menu display and return to the console command line.

Next Steps: For microkernel applications, go to Creating and Configuring an MDEF File for a Microkernel Application.

For nanokernel applications, go to Application Code Development.