配置¶
Application Configuration¶
The application’s kernel is configured using a set of configuration options that can be customized for application-specific purposes. The Zephyr build system takes a configuration option’s value from the first source in which it is specified.
The available sources are (in order):
- The application’s current configuration. (i.e. The
.config
file.) - The application’s default configuration. (i.e. The
.conf
file.) - The board configuration used by the application.
(i.e. The board’s
.defconfig
file.) - The kernel’s default configuration.
(i.e. One of the kernel’s
Kconfig
files.)
For information on available kernel configuration options, including inter-dependencies between options, see the configuration.
Default Board Configuration¶
An application’s .conf
file defines its default kernel configuration.
The settings in this file override or augment the board configuration settings.
The board configuration settings can be viewed
in $ZEPHYR_BASE/boards/ARCHITECTURE/BOARD/BOARD_defconfig
.
注解
When the default board configuration settings are sufficient for your
application, a .conf
file is not needed. Skip ahead to
Overriding Default Configuration.
Navigate to the
app
, and create theprj.conf
file. Enter:$ vim prj.conf
The default name is
prj.conf
. The filename must match theCONF_FILE
entry in the applicationMakefile
.Edit the file and add the appropriate configuration entries.
- Add each configuration entry on a new line.
- Begin each entry with
CONFIG_
. - Ensure that each entry contains no spaces (including on either side of the = sign).
- Use a # followed by a space to comment a line.
The example below shows a comment line and a board configuration override in the
prj.conf
.# Enable printk for debugging CONFIG_PRINTK=y
Save and close the file.
Overriding Default Configuration¶
Override the default board and kernel configuration to temporarily alter the application’s configuration, perhaps to test the effect of a change.
注解
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.
Run the make menuconfig rule to launch the menu-driven interface.
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
orN
in the square brackets [ ] to enable or disable a kernel configuration option.
- Type an upper case
Type a numerical value in the round brackets ( ).
Press
Tab
to navigate the command menu at the bottom of the display.注解
When a non-default entry is selected for options that are non-numerical, an asterisk
*
appears between the square brackets in the display. There is nothing added added the display when you select the option’s default.
For information about any option, select the option and tab to <Help > and press
Enter
.Press
Enter
to return to the menu.After configuring the kernel options for your application, tab to < Save > and press
Enter
.The following dialog opens with the < Ok > command selected:
Press
Enter
to save the kernel configuration options to the default file name; alternatively, type a file name and pressEnter
.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
.注解
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 inoutdir
. 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.
Press
Enter
to return to the options menu.To load any saved kernel configuration file, tab to < Load > and press
Enter
.The following dialog opens with the < Ok > command selected:
To load the last saved kernel configuration file, press < Ok >, or to load another saved configuration file, type the file name, then select < Ok >.
Press
Enter
to load the file and return to the main menu.To exit the menu configuration, tab to < Exit > and press
Enter
.The following confirmation dialog opens with the < Yes > command selected.
Press
Enter
to retire the menu display and return to the console command line.